From b44d67c7c67efb1baddb12f909eb035027824566 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Sat, 23 Apr 1994 01:55:46 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'AMANCIO'. --- sys/i386/Makefile | 25 - sys/i386/boot/Makefile | 103 -- sys/i386/boot/README.386BSD | 151 --- sys/i386/boot/README.MACH | 210 --- sys/i386/boot/asm.S | 260 ---- sys/i386/boot/asm.h | 144 -- sys/i386/boot/asm.s | 270 ---- sys/i386/boot/bios.S | 329 ----- sys/i386/boot/bios.s | 326 ----- sys/i386/boot/biosboot/Makefile | 103 -- sys/i386/boot/biosboot/README.386BSD | 151 --- sys/i386/boot/biosboot/README.MACH | 210 --- sys/i386/boot/biosboot/asm.S | 260 ---- sys/i386/boot/biosboot/asm.h | 144 -- sys/i386/boot/biosboot/bios.S | 329 ----- sys/i386/boot/biosboot/boot.c | 312 ----- sys/i386/boot/biosboot/boot.h | 40 - sys/i386/boot/biosboot/boot2.S | 167 --- sys/i386/boot/biosboot/disk.c | 252 ---- sys/i386/boot/biosboot/io.c | 202 --- sys/i386/boot/biosboot/start.S | 291 ---- sys/i386/boot/biosboot/sys.c | 232 ---- sys/i386/boot/biosboot/table.c | 125 -- sys/i386/boot/boot.c | 312 ----- sys/i386/boot/boot.h | 40 - sys/i386/boot/boot.sed | 3 - sys/i386/boot/boot2.S | 167 --- sys/i386/boot/boot2.s | 73 - sys/i386/boot/disk.c | 252 ---- sys/i386/boot/io.c | 202 --- sys/i386/boot/rmaouthdr | 6 - sys/i386/boot/start.S | 291 ---- sys/i386/boot/start.s | 323 ----- sys/i386/boot/sys.c | 232 ---- sys/i386/boot/table.c | 125 -- sys/i386/conf/GENERICAH | 87 -- sys/i386/conf/GENERICBT | 87 -- sys/i386/conf/LINT | 141 -- sys/i386/conf/Makefile.i386 | 145 -- sys/i386/conf/NOTES | 141 -- sys/i386/conf/SYSCONS | 87 -- sys/i386/conf/devices.i386 | 12 - sys/i386/conf/files.i386 | 68 - sys/i386/eisa/aha1742.c | 1322 ------------------ sys/i386/i386/autoconf.c | 192 --- sys/i386/i386/conf.c | 479 ------- sys/i386/i386/cons.c | 206 --- sys/i386/i386/cons.h | 66 - sys/i386/i386/db_disasm.c | 1374 ------------------- sys/i386/i386/db_interface.c | 234 ---- sys/i386/i386/db_trace.c | 264 ---- sys/i386/i386/dkbad.c | 68 - sys/i386/i386/genassym.c | 188 --- sys/i386/i386/in_cksum.c | 173 --- sys/i386/i386/locore.s | 2152 ----------------------------- sys/i386/i386/machdep.c | 1285 ------------------ sys/i386/i386/math_emu.h | 156 --- sys/i386/i386/math_emulate.c | 1475 -------------------- sys/i386/i386/mem.c | 230 ---- sys/i386/i386/microtime.s | 136 -- sys/i386/i386/ns_cksum.c | 206 --- sys/i386/i386/pmap.c | 1722 ----------------------- sys/i386/i386/swapgeneric.c | 167 --- sys/i386/i386/symbols.raw | 84 -- sys/i386/i386/sys_machdep.c | 107 -- sys/i386/i386/trap.c | 585 -------- sys/i386/i386/tsc.c | 252 ---- sys/i386/i386/vm_machdep.c | 415 ------ sys/i386/include/_limits.h | 58 - sys/i386/include/ansi.h | 58 - sys/i386/include/console.h | 205 --- sys/i386/include/cpu.h | 103 -- sys/i386/include/cpufunc.h | 195 --- sys/i386/include/cputypes.h | 49 - sys/i386/include/db_machdep.h | 120 -- sys/i386/include/dkio.h | 49 - sys/i386/include/eflags.h | 54 - sys/i386/include/endian.h | 110 -- sys/i386/include/float.h | 68 - sys/i386/include/floatingpoint.h | 108 -- sys/i386/include/frame.h | 133 -- sys/i386/include/ioctl_pc.h | 797 ----------- sys/i386/include/limits.h | 58 - sys/i386/include/mtpr.h | 4 - sys/i386/include/npx.h | 139 -- sys/i386/include/param.h | 162 --- sys/i386/include/pc/display.h | 45 - sys/i386/include/pc/msdos.h | 65 - sys/i386/include/pcb.h | 87 -- sys/i386/include/pio.h | 44 - sys/i386/include/pmap.h | 233 ---- sys/i386/include/proc.h | 48 - sys/i386/include/psl.h | 61 - sys/i386/include/pte.h | 137 -- sys/i386/include/reg.h | 94 -- sys/i386/include/segments.h | 197 --- sys/i386/include/soundcard.h | 737 ---------- sys/i386/include/specialreg.h | 60 - sys/i386/include/stdarg.h | 54 - sys/i386/include/sysarch.h | 12 - sys/i386/include/trap.h | 97 -- sys/i386/include/tss.h | 79 -- sys/i386/include/types.h | 51 - sys/i386/include/vmparam.h | 261 ---- sys/i386/isa/aha1542.c | 1583 --------------------- sys/i386/isa/aha1742.c | 1322 ------------------ sys/i386/isa/bt742a.c | 1617 ---------------------- sys/i386/isa/clock.c | 252 ---- sys/i386/isa/fd.c | 977 ------------- sys/i386/isa/fdreg.h | 66 - sys/i386/isa/ic/i8042.h | 27 - sys/i386/isa/ic/i8237.h | 11 - sys/i386/isa/ic/i82586.h | 325 ----- sys/i386/isa/ic/nec765.h | 72 - sys/i386/isa/ic/ns16450.h | 50 - sys/i386/isa/ic/ns16550.h | 51 - sys/i386/isa/icu.h | 103 -- sys/i386/isa/icu.s | 377 ----- sys/i386/isa/if_ed.c | 2375 -------------------------------- sys/i386/isa/if_edreg.h | 903 ------------ sys/i386/isa/if_ie.c | 1799 ------------------------ sys/i386/isa/if_iereg.h | 24 - sys/i386/isa/if_is.c | 1008 -------------- sys/i386/isa/if_isreg.h | 106 -- sys/i386/isa/isa.c | 791 ----------- sys/i386/isa/isa.h | 180 --- sys/i386/isa/isa_device.h | 74 - sys/i386/isa/iso8859.font | 1230 ----------------- sys/i386/isa/kbd.h | 52 - sys/i386/isa/kbdtables.h | 858 ------------ sys/i386/isa/lpt.c | 463 ------- sys/i386/isa/lptreg.h | 33 - sys/i386/isa/mcd.c | 1260 ----------------- sys/i386/isa/mcdreg.h | 150 -- sys/i386/isa/mse.c | 493 ------- sys/i386/isa/npx.c | 554 -------- sys/i386/isa/rtc.h | 86 -- sys/i386/isa/sio.c | 1740 ------------------------ sys/i386/isa/sioreg.h | 114 -- sys/i386/isa/sound/CHANGELOG | 55 + sys/i386/isa/sound/HOWTO_MIDI | 51 - sys/i386/isa/sound/RELNOTES | 38 - sys/i386/isa/sound/RELNOTES.Linux | 191 --- sys/i386/isa/sound/gus_linearvol.h | 18 + sys/i386/isa/sound/gustest/Makefile | 16 - sys/i386/isa/sound/gustest/Readme | 67 - sys/i386/isa/sound/gustest/gmidi.h | 131 -- sys/i386/isa/sound/gustest/gmod.c | 1589 ---------------------- sys/i386/isa/sound/gustest/gpatinfo.c | 176 --- sys/i386/isa/sound/gustest/gusload.c | 350 ----- sys/i386/isa/sound/gustest/midithru.c | 325 ----- sys/i386/isa/sound/gustest/pmtest.c | 411 ------ sys/i386/isa/sound/ics2101.c | 261 ++++ sys/i386/isa/sound/midi.c | 176 --- sys/i386/isa/sound/pas.h | 249 ---- sys/i386/isa/sound/pro_midi.c | 155 --- sys/i386/isa/sound/sb16_dsp.c | 641 +++++++++ sys/i386/isa/sound/sb16_midi.c | 314 +++++ sys/i386/isa/sound/sb_midi.c | 198 +++ sys/i386/isa/sound/sb_mixer.c | 359 +++++ sys/i386/isa/sound/sb_mixer.h | 172 +++ sys/i386/isa/sound/sound_switch.c | 444 ++++++ sys/i386/isa/spkr.c | 523 ------- sys/i386/isa/syscons.c | 2415 --------------------------------- sys/i386/isa/timerreg.h | 93 -- sys/i386/isa/ultra14f.c | 1209 ----------------- sys/i386/isa/vector.s | 368 ----- sys/i386/isa/wd.c | 1341 ------------------ sys/i386/isa/wdreg.h | 144 -- sys/i386/isa/wt.c | 821 ----------- sys/i386/isa/wtreg.h | 111 -- 171 files changed, 2462 insertions(+), 57876 deletions(-) delete mode 100644 sys/i386/Makefile delete mode 100644 sys/i386/boot/Makefile delete mode 100644 sys/i386/boot/README.386BSD delete mode 100644 sys/i386/boot/README.MACH delete mode 100644 sys/i386/boot/asm.S delete mode 100644 sys/i386/boot/asm.h delete mode 100644 sys/i386/boot/asm.s delete mode 100644 sys/i386/boot/bios.S delete mode 100644 sys/i386/boot/bios.s delete mode 100644 sys/i386/boot/biosboot/Makefile delete mode 100644 sys/i386/boot/biosboot/README.386BSD delete mode 100644 sys/i386/boot/biosboot/README.MACH delete mode 100644 sys/i386/boot/biosboot/asm.S delete mode 100644 sys/i386/boot/biosboot/asm.h delete mode 100644 sys/i386/boot/biosboot/bios.S delete mode 100644 sys/i386/boot/biosboot/boot.c delete mode 100644 sys/i386/boot/biosboot/boot.h delete mode 100644 sys/i386/boot/biosboot/boot2.S delete mode 100644 sys/i386/boot/biosboot/disk.c delete mode 100644 sys/i386/boot/biosboot/io.c delete mode 100644 sys/i386/boot/biosboot/start.S delete mode 100644 sys/i386/boot/biosboot/sys.c delete mode 100644 sys/i386/boot/biosboot/table.c delete mode 100644 sys/i386/boot/boot.c delete mode 100644 sys/i386/boot/boot.h delete mode 100644 sys/i386/boot/boot.sed delete mode 100644 sys/i386/boot/boot2.S delete mode 100644 sys/i386/boot/boot2.s delete mode 100644 sys/i386/boot/disk.c delete mode 100644 sys/i386/boot/io.c delete mode 100644 sys/i386/boot/rmaouthdr delete mode 100644 sys/i386/boot/start.S delete mode 100644 sys/i386/boot/start.s delete mode 100644 sys/i386/boot/sys.c delete mode 100644 sys/i386/boot/table.c delete mode 100644 sys/i386/conf/GENERICAH delete mode 100644 sys/i386/conf/GENERICBT delete mode 100644 sys/i386/conf/LINT delete mode 100644 sys/i386/conf/Makefile.i386 delete mode 100644 sys/i386/conf/NOTES delete mode 100644 sys/i386/conf/SYSCONS delete mode 100644 sys/i386/conf/devices.i386 delete mode 100644 sys/i386/conf/files.i386 delete mode 100644 sys/i386/eisa/aha1742.c delete mode 100644 sys/i386/i386/autoconf.c delete mode 100644 sys/i386/i386/conf.c delete mode 100644 sys/i386/i386/cons.c delete mode 100644 sys/i386/i386/cons.h delete mode 100644 sys/i386/i386/db_disasm.c delete mode 100644 sys/i386/i386/db_interface.c delete mode 100644 sys/i386/i386/db_trace.c delete mode 100644 sys/i386/i386/dkbad.c delete mode 100644 sys/i386/i386/genassym.c delete mode 100644 sys/i386/i386/in_cksum.c delete mode 100644 sys/i386/i386/locore.s delete mode 100644 sys/i386/i386/machdep.c delete mode 100644 sys/i386/i386/math_emu.h delete mode 100644 sys/i386/i386/math_emulate.c delete mode 100644 sys/i386/i386/mem.c delete mode 100644 sys/i386/i386/microtime.s delete mode 100644 sys/i386/i386/ns_cksum.c delete mode 100644 sys/i386/i386/pmap.c delete mode 100644 sys/i386/i386/swapgeneric.c delete mode 100644 sys/i386/i386/symbols.raw delete mode 100644 sys/i386/i386/sys_machdep.c delete mode 100644 sys/i386/i386/trap.c delete mode 100644 sys/i386/i386/tsc.c delete mode 100644 sys/i386/i386/vm_machdep.c delete mode 100644 sys/i386/include/_limits.h delete mode 100644 sys/i386/include/ansi.h delete mode 100644 sys/i386/include/console.h delete mode 100644 sys/i386/include/cpu.h delete mode 100644 sys/i386/include/cpufunc.h delete mode 100644 sys/i386/include/cputypes.h delete mode 100644 sys/i386/include/db_machdep.h delete mode 100644 sys/i386/include/dkio.h delete mode 100644 sys/i386/include/eflags.h delete mode 100644 sys/i386/include/endian.h delete mode 100644 sys/i386/include/float.h delete mode 100644 sys/i386/include/floatingpoint.h delete mode 100644 sys/i386/include/frame.h delete mode 100644 sys/i386/include/ioctl_pc.h delete mode 100644 sys/i386/include/limits.h delete mode 100644 sys/i386/include/mtpr.h delete mode 100644 sys/i386/include/npx.h delete mode 100644 sys/i386/include/param.h delete mode 100644 sys/i386/include/pc/display.h delete mode 100644 sys/i386/include/pc/msdos.h delete mode 100644 sys/i386/include/pcb.h delete mode 100644 sys/i386/include/pio.h delete mode 100644 sys/i386/include/pmap.h delete mode 100644 sys/i386/include/proc.h delete mode 100644 sys/i386/include/psl.h delete mode 100644 sys/i386/include/pte.h delete mode 100644 sys/i386/include/reg.h delete mode 100644 sys/i386/include/segments.h delete mode 100644 sys/i386/include/soundcard.h delete mode 100644 sys/i386/include/specialreg.h delete mode 100644 sys/i386/include/stdarg.h delete mode 100644 sys/i386/include/sysarch.h delete mode 100644 sys/i386/include/trap.h delete mode 100644 sys/i386/include/tss.h delete mode 100644 sys/i386/include/types.h delete mode 100644 sys/i386/include/vmparam.h delete mode 100644 sys/i386/isa/aha1542.c delete mode 100644 sys/i386/isa/aha1742.c delete mode 100644 sys/i386/isa/bt742a.c delete mode 100644 sys/i386/isa/clock.c delete mode 100644 sys/i386/isa/fd.c delete mode 100644 sys/i386/isa/fdreg.h delete mode 100644 sys/i386/isa/ic/i8042.h delete mode 100644 sys/i386/isa/ic/i8237.h delete mode 100644 sys/i386/isa/ic/i82586.h delete mode 100644 sys/i386/isa/ic/nec765.h delete mode 100644 sys/i386/isa/ic/ns16450.h delete mode 100644 sys/i386/isa/ic/ns16550.h delete mode 100644 sys/i386/isa/icu.h delete mode 100644 sys/i386/isa/icu.s delete mode 100644 sys/i386/isa/if_ed.c delete mode 100644 sys/i386/isa/if_edreg.h delete mode 100644 sys/i386/isa/if_ie.c delete mode 100644 sys/i386/isa/if_iereg.h delete mode 100644 sys/i386/isa/if_is.c delete mode 100644 sys/i386/isa/if_isreg.h delete mode 100644 sys/i386/isa/isa.c delete mode 100644 sys/i386/isa/isa.h delete mode 100644 sys/i386/isa/isa_device.h delete mode 100644 sys/i386/isa/iso8859.font delete mode 100644 sys/i386/isa/kbd.h delete mode 100644 sys/i386/isa/kbdtables.h delete mode 100644 sys/i386/isa/lpt.c delete mode 100644 sys/i386/isa/lptreg.h delete mode 100644 sys/i386/isa/mcd.c delete mode 100644 sys/i386/isa/mcdreg.h delete mode 100644 sys/i386/isa/mse.c delete mode 100644 sys/i386/isa/npx.c delete mode 100644 sys/i386/isa/rtc.h delete mode 100644 sys/i386/isa/sio.c delete mode 100644 sys/i386/isa/sioreg.h create mode 100644 sys/i386/isa/sound/CHANGELOG delete mode 100644 sys/i386/isa/sound/HOWTO_MIDI delete mode 100644 sys/i386/isa/sound/RELNOTES delete mode 100644 sys/i386/isa/sound/RELNOTES.Linux create mode 100644 sys/i386/isa/sound/gus_linearvol.h delete mode 100644 sys/i386/isa/sound/gustest/Makefile delete mode 100644 sys/i386/isa/sound/gustest/Readme delete mode 100644 sys/i386/isa/sound/gustest/gmidi.h delete mode 100644 sys/i386/isa/sound/gustest/gmod.c delete mode 100644 sys/i386/isa/sound/gustest/gpatinfo.c delete mode 100644 sys/i386/isa/sound/gustest/gusload.c delete mode 100644 sys/i386/isa/sound/gustest/midithru.c delete mode 100644 sys/i386/isa/sound/gustest/pmtest.c create mode 100644 sys/i386/isa/sound/ics2101.c delete mode 100644 sys/i386/isa/sound/midi.c delete mode 100644 sys/i386/isa/sound/pas.h delete mode 100644 sys/i386/isa/sound/pro_midi.c create mode 100644 sys/i386/isa/sound/sb16_dsp.c create mode 100644 sys/i386/isa/sound/sb16_midi.c create mode 100644 sys/i386/isa/sound/sb_midi.c create mode 100644 sys/i386/isa/sound/sb_mixer.c create mode 100644 sys/i386/isa/sound/sb_mixer.h create mode 100644 sys/i386/isa/sound/sound_switch.c delete mode 100644 sys/i386/isa/spkr.c delete mode 100644 sys/i386/isa/syscons.c delete mode 100644 sys/i386/isa/timerreg.h delete mode 100644 sys/i386/isa/ultra14f.c delete mode 100644 sys/i386/isa/vector.s delete mode 100644 sys/i386/isa/wd.c delete mode 100644 sys/i386/isa/wdreg.h delete mode 100644 sys/i386/isa/wt.c delete mode 100644 sys/i386/isa/wtreg.h (limited to 'sys/i386') diff --git a/sys/i386/Makefile b/sys/i386/Makefile deleted file mode 100644 index 4ad5a34..0000000 --- a/sys/i386/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# from: @(#)Makefile 7.3 (Berkeley) 6/9/91 -# $Id$ - -# Makefile for i386 tags file - -all: - @echo "make tags or links only" - -TI386= ../i386/tags -SI386= ../i386/i386/*.[ch] ../i386/include/*.h ../i386/isa/*.[ch] -AI386= ../i386/i386/*.s - -# Directories in which to place i386 tags links -DI386= eisa isa mca include - -tags: - -ctags -dtf ${TI386} ${COMM} ${SI386} - egrep "^ENTRY(.*)|^ALTENTRY(.*)" ${AI386} | \ - sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \ - >> ${TI386} - sort -o ${TI386} ${TI386} - -links: - -for i in ${DI386}; do \ - cd $$i && rm -f tags; ln -s ../tags tags; done diff --git a/sys/i386/boot/Makefile b/sys/i386/boot/Makefile deleted file mode 100644 index 2e4f162..0000000 --- a/sys/i386/boot/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# -# 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 "AS IS" -# 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 Mellon -# the rights to redistribute these changes. -# -# from: Mach, Revision 2.2 92/04/04 11:33:46 rpd -# $Id$ -# - -wd0: - dd if=boot of=biosboot count=1 - dd if=boot of=bootbios skip=1 - disklabel -r -w wd0 nec5655 newboot biosboot bootbios - rm biosboot bootbios - -NOPROG= noprog -NOMAN= noman - -CFLAGS = -O -DDO_BAD144 -I${.CURDIR} -LIBS= -lc -INC= -I${.CURDIR}/../.. - -# start.o should be first -OBJS = start.o table.o boot2.o boot.o asm.o bios.o io.o disk.o sys.o - -.SUFFIXES: .S .c .o - -.c.o: - $(CC) $(CFLAGS) $(INC) -c $< - -.S.o: - $(CC) $(CFLAGS) -c $< - -boot: $(OBJS) - $(LD) -N -T 0 -o boot $(OBJS) $(LIBS) - cp boot boot.sym - @strip boot - @sh ${.CURDIR}/rmaouthdr boot boot.tmp - @mv -f boot.tmp boot - @ls -l boot - -biosboot: boot - dd if=boot of=biosboot count=1 - -bootbios: boot - dd if=boot of=bootbios skip=1 - -/usr/mdec/bootsd: bootbios - cp bootbios /usr/mdec/bootsd - -/usr/mdec/sdboot: biosboot - cp biosboot /usr/mdec/sdboot - -/usr/mdec/bootwd: /usr/mdec/bootsd - rm -f /usr/mdec/bootwd - ln /usr/mdec/bootsd /usr/mdec/bootwd - -/usr/mdec/wdboot: /usr/mdec/sdboot - rm -f /usr/mdec/wdboot - ln /usr/mdec/sdboot /usr/mdec/wdboot - -/usr/mdec/bootfd: /usr/mdec/bootsd - rm -f /usr/mdec/bootfd - ln /usr/mdec/bootsd /usr/mdec/bootfd - -/usr/mdec/fdboot: /usr/mdec/sdboot - rm -f /usr/mdec/fdboot - ln /usr/mdec/sdboot /usr/mdec/fdboot - -sd: /usr/mdec/bootsd /usr/mdec/sdboot -wd: /usr/mdec/bootwd /usr/mdec/wdboot -fd: /usr/mdec/bootfd /usr/mdec/fdboot - -all: biosboot bootbios - -fd0: - dd if=boot of=biosboot count=1 - dd if=boot of=bootbios skip=1 - disklabel -r -w fd0 floppy bootflpy biosboot bootbios - rm biosboot bootbios - -install: wd sd fd - -clean cleandir: - /bin/rm -f *.o *.d boot bootbios biosboot boot.sym - -.include diff --git a/sys/i386/boot/README.386BSD b/sys/i386/boot/README.386BSD deleted file mode 100644 index cc5cb8f..0000000 --- a/sys/i386/boot/README.386BSD +++ /dev/null @@ -1,151 +0,0 @@ -This Boot code is different from the original boot code that came with -386BSD in that it uses the BIOS to load the kernel and to provide all i/o -services. The advantage ofthis is that the same boot code exactly, can run -on any device that is supported by the BIOS. (That's most of them) -This is important for the 'generic scsi' project because it means we can -write drivers for new scsi adapters without having to develop an new -set of boot blocks for each. - -At this point you should read the first part of README.MACH... come back here -when you have done that: - -In normal operation, when co-existing with other operating systems, the -following operations occur: - -1/ the BIOS loads the first block of the disk (called the Master Boot Record -or MBR) and if it has the correct magic numbers, jumps into it: - -2/ The MBR code, looks at the Partition table that is embedded within it, -to detirmine which is the partition to boot from. If you are using the os-bs -bootblocks (highly recommended) then it will give you a menu to choose from. - -3/ The MBR will load the first record of the selected partition and -if it has (the same) magic numbers, jumps into it. In 386bsd this is the -first stage boot, (or boot1) it is represented in /usr/mdec by -wdboot, asboot and sdboot. If the disk has been set up without DOS partitioning -then this block will be at block zero, and will have been loaded directly by -the BIOS. - -4/ Boot1 will look at block0 (which might be itself if there are no DOS -partitions) and will find the 386bsd partition, and using the information -regarding the start position of that partition, will load the next 13 sectors -or so, to around 90000 (640k - 64k). and will jump into it at the appropriate -entry point. Since boot1 and boot2 were compiled together as one file -and then split later, boot1 knows the exact position within boot2 of the -entry point. - -Boot 1 also contains a compiled in DOS partition table -(in case it is at block 0), which contains a 386bsd partition starting -at 0. This ensures that the same code can work whether or not -boot1 is at block 0. - -5/ Boot2 asks the user for a boot device, partition and filename, and then -loads the MBR of the selected device. This may or may not be the device -which was originally used to boot the first MBR. The partition table -of the new MBR is searched for a 386bsd partition, and if one is found, -that is then in turn searched for the disklabel. This could all be on the -second disk at this point, if the user selected it. - -6/On finding the disklabel, boot2 can find the correct unix partition -within the 386bsd partition, and using cutdown filesystem code, -look for the file to boot (e.g. 386bsd). - -7/ Boot2 loads this file starting at the location specified by the a.out header, -(see later) and leaps into it at the location specified in he header. - -if the file does not exist or cannot be loaded, boot2 goes back to step 5. - -386bsd is now running and will hopefully start vm etc. and get to multi-user -mode. - -########################################################################## -During all these steps, all i/o is performed using the BIOS. This has a number -of side effects: - -1/ Since BIOS disk calls are specified in terms of cylinder,head and sector, -and the BIOS read the disk information from either the CMOS or from some other -location which is un-available to us, we must use the cyl,head,sec information -that is given in the MBR, rather than the start address in the MBR, because -we cannot guarentee that we can corectly calculate C,H,S from the start address. - -Therefore, the C,H,S information in the MBR must be as correct for this boot -to work as it would be for DOS to boot. For example, adaptec BIOS routines -assume a layout of 64 heads and 32 sectors giving 1MB per ficticious cylinder. -You must use these figures to calculate the correct values. Luckily, the DOS -fdisk program will do all this for you if you tell it to give you a DOS -partition, and you can change it to a 386BSD partition later. If you use -no DOS partitioning, then the compiled in table in Boot1 will do just fine. - -If you want to do it by hand remember that BIOS counts sectors starting at 1. -(cylinders and heads start at 0 (??)) - -2/ you cannot overwrite the bottom 4k of ram until you have finished ALL -bios calls, as BIOS uses this area as scratch memory. - -3/ Since BIOS runs in REAL mode, and Boot2 runs in protected mode, -Boot 2 switches back to real mode just before each BIOS call and then -back to protected mode on each return. Touch this at your peril.! - -######################################################################### -In answering the prompt from Boot2: -you can, -1/ leave it alone.. it will boot the indicated file from the first -partition of the first drive seen by the BIOS (C:) - -2/ enter only "-s" to boot the default to single user mode - -3/ enter only a filename (optionally with -s) to boot that kernel, - -4/ enter a whole line of the form shown in the prompt. This allows you to -boot some other partition, possibly on the second drive, as root. - - -########################################################################## -In the case you have two drives the same type (both scsi or bith IDE/ESDI), -wd(0,a)xxx - will boot xxx from drive 0, a partition. -wd(1,a)xxx - will boot xxx from drive 1, a partition. - -similarly for sd. - -if you have one wd drive and one scsi drive, then you MUST -use device 'hd' - -otherwise the following will happen: - -with wd0 and sd0, you specify sd1 or wd1 to indicate the 2nd drive. -it boots the kernel correctly, then tells the kernel to use sd1 as root. -you however may not have an sd1, and problems arise. - -hd is special in that the kernel is always told to use unit 0, -The correct TYPE of device will be specified too, so the kernel -will be told either sd0 or wd0. - -Whether sd or wd is specified to the kernel is read from the disklabel, -so ensure that all SCSI disks have type SCSI in their disklabel or the -boot code will assume they are ESDI or IDE. (Remember, because it is -working through the BIOS it has ho idea what kind of disk it is. - -########################################################################## -Installing: -The makefile supplied has a target install which will create the -files wdboot,bootwd ,sdboot and bootsd in /usr/mdec. -BEWARE these will overwrite the existing wdboot and bootwd. (so back -them up) - -there are also targets wd and sd which wil only do one of them - -The commented out targets wd0 and sd0 are examples of how to -load the new bootblocks, however,make sure you change the -device type and label to suit your drive if you uncomment them. -(see 'man disklabel') - -If you already have made partitions using the old bootblocks -these should install painlessly. - -Before you do this ensure you have a booting floppy with correct -disktab and bootblock files on it so that if it doesn't work, you can -re-disklabel from the floppy. - -$Id$ diff --git a/sys/i386/boot/README.MACH b/sys/i386/boot/README.MACH deleted file mode 100644 index cb62329..0000000 --- a/sys/i386/boot/README.MACH +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:33:55 rpd - * $Id$ - */ - -********NOTE: This is not all relevant to the 386BSD version********** - - AT386 Protected Mode Bootstrap Loader - ===================================== - -1. Overview of Startup - ------------------- - - After the system is rebooted, the BIOS bootstrap routine reads Sector - 1, Track 0 into memory at location 0000:7C00H. If location 0000:7DFEH - (last two bytes of that sector) contains the value AA55H, the BIOS - bootstrap routine will transfer control to 0000:7C00H. Otherwise, the - boot code in that sector is bad and the boot routine stops. - - For DOS compatibility reason, one extra stage of boot is required if - the boot device is a hard disk. The first sector of the hard disk will - contain the MOS-DOS boot code and a boot record partition table. - When this sector is loaded into 0000:7C00H, it will relocate itself - to somewhere else and then load the first sector of the active - partition into 0000:7C00H. Both UNIX and DOS use the command "fdisk" -[ 386bsd does not have an 'fdisk' (yet) ] - to install this first sector into the hard disk and to manipulate - the hard disk partitions. - - - -2. The First Stage Bootstrap Loader - -------------------------------- - - After startup, the first stage boot is loaded at 0000:7C00H. This - first stage boot will load itself and the second stage boot into - memory at location 0000:1000H. For floppy disks, the first cylinder - is reserved as the boot cylinder, and the boot code (first and second) - will be loaded from there. Currently, only double sided, high density - (15 sectors per track) floppies are supported. For hard disks, the - first 29 sectors of the active partition is reserved for boot code - which will be loaded by the first stage boot. All the disk types - recognized by BIOS are supported by this bootstrap loader. -[for 386bsd we load the second stage booter to 9000:0] - - - -3. The Second Stage Bootstrap Loader - -------------------------------- - - After the boot code is loaded, the control is passed to the second - stage bootstrap loader "boot2()". In order to be able to load the - big kernel image (bigger than 512K or 640K, depends on the memory - configuration), the second stage boot loader will run on the protected - mode. This bootstarp loader does not have any stand alone device - drivers, all the I/O's are through the BIOS calls. Since the first - stage boot code will no longer be used at this moment, the memory - location of the first stage boot code (0000:1000H to 0000:1200H) will - be used as an internal buffer for BIOS calls. Immediately after this - internal buffer is the GDT table for the second stage boot loader. - Since this boot loader needs to switch back and forth between protected - and real mode in order to use BIOS calls, the limit of the boot code - and boot data segments must not be greater than 64K. - - The boot loader loads the kernel image at memory location above 1 MB - to skip the memory hole between 521K/640K and 1MB. After the kernel - is loaded, the boot loader stores the information in the stack and - then passes control to kernel. Currently, the three information passed - fromm the boot loader to the kernel are type of the boot device, size - of the base memory and size of the extended memory. - -[ 386bsd receives: howto, bootdev] - -[ 386bsd is loaded where-ever the "MByte" bits of the load address specify, -so if you link it for FE100000 it will load to 1MB, but if you link -it for FE000000 it will load ad 0MB] - -[for machines with only 512KB normal ram the kernel will need to be linked -for 1MB and the bootblocks modified to run below 512KB. (8000:0)] - - -4. The UNIX Startup - ---------------- - - Since the boot loader loads the kernel image at memory location above - 1MB, the kernel has to start as protected mode. In addition, the - link editor description file (vuifile) has to indicate that - the text and data segments start above 1MB. Also, the boot loader - passes the infomation to the kernel through the stack. - -[MOST of what is mentionned below is NOT relevant to 386bsd] - -5. Disk Layout and Bad Block Handling - --------------------------------- - - The System V/386 Release 3.2 (AT) disk layout will be used as the disk - layout for the MACH System on the AT platform. - - This disk layout is as follows: - - * Reserve the first sector of cylinder 0 for the DOS boot record which - contains the master boot code (446 bytes) and the partition table. - (Refer to DOS Technical Reference Manual page 9-6 to 9-10). - - * Reserve the first 29 sectors of the UNIX partition for the first - and the second stage bootstrap. - - * Reserve the 30th sector of the UNIX partition for the pdinfo and - the vtoc tables. - - * Reserve the 31st to the 34th sectors of the UNIX partition for the - bad track and the bad block mapping tables. - - * Reserve up to 253 consecutive tracks when required, beginning with - the 35th sector of the UNIX partition, for alternate tracks. - - * Reserve up to 253 consecutive blocks, beginning with the first - sector after the alternate tracks area, for alternate blocks. - - SEC - 1 - ---------------------------------------------------- - | X | | CYL 0, TRK 0 - ---------------- .......... -------------------- - | .......... | - ---------------- .......... -------------------- - | .......... | - =============================================================== - ^ | BOOTSTRAP | CYL N, TRK M - | ---------------------------------------------------- - | | |30 |31 |32 |33 |34 | - ---------------------------------------------------- --- - U | .......... | ^ - N ---------------- .......... --------------------- | - I | .......... | Alternate Tracks - X ---------------- .......... --------------------- | - | .......... | V - P ---------------------------------------------------- --- - A | .......... | ^ - R ---------------- .......... --------------------- | - T | .......... | Alternate Blocks - I ---------------- .......... -------------------- | - T | .......... | V - I ---------------------------------------------------- --- - O | Unix root partition starts from here | - N ---------------- ----------------- - | | - ---------------------------------------------------- - | | - ---------------------------------------------------- - | | - | --------------------------------------------------- - | | | - | ---------------------------------------------------- - V | | - =============================================================== - | ........ | - --------------- ........ -------------- - | ........ | - ---------------------------------------------------- - - - The bad block handling mechanism is as follows: - - * Use the alternate track in the alternate tracks area if the - track containing the target sector is bad. - - * Use the alternate block in the alternate blocks area if the - target sector is bad. - - - - -6. How to make: - ----------- - - Since the kernel image is loaded above 1 MB, the kernel must start - as protected mode. This means that this bootstrap loader will work - only when the corresponding changes on the kernel startup code are done. - - The make command to generate this bootstrap loader is: - - make -f boot.mk fdboot (floppy boot loader) - make -f boot.mk hdboot (wini boot loader) -[to make 386bsd bootblocks "make sd wd" (warning: they will be installed -in /dev/mdec.. take backups)] diff --git a/sys/i386/boot/asm.S b/sys/i386/boot/asm.S deleted file mode 100644 index b291428..0000000 --- a/sys/i386/boot/asm.S +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:13 rpd - * $Id$ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "asm.s" - -#include "asm.h" - - -CR0_PE_ON = 0x1 -CR0_PE_OFF = 0xfffffffe - -.globl _ouraddr - .text - -/* -# -# real_to_prot() -# transfer from real mode to protected mode. -*/ - -ENTRY(real_to_prot) - # guarantee that interrupt is disabled when in prot mode - cli - - # load the gdtr - addr32 - data32 - lgdt EXT(Gdtr) - - # set the PE bit of CR0 - mov %cr0, %eax - - data32 - or $CR0_PE_ON, %eax - mov %eax, %cr0 - - # make intrasegment jump to flush the processor pipeline and - # reload CS register - data32 - ljmp $0x18, $xprot - -xprot: - # we are in USE32 mode now - # set up the protected mode segment registers : DS, SS, ES - mov $0x20, %eax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - - # load idtr so we can debug - lidt EXT(Idtr_prot) - - ret - -/* -# -# prot_to_real() -# transfer from protected mode to real mode -# -*/ - -ENTRY(prot_to_real) - - # set up a dummy stack frame for the second seg change. - movl _ouraddr, %eax - sarl $4, %eax - pushw %ax - movw $xreal, %ax # gas botches pushw $xreal - extra bytes 0, 0 - pushw %ax # decode to add %al, (%eax) (%al usually 0) - - # Change to use16 mode. - ljmp $0x28, $x16 - -x16: - # clear the PE bit of CR0 - mov %cr0, %eax - data32 - and $CR0_PE_OFF, %eax - mov %eax, %cr0 - - # make intersegment jmp to flush the processor pipeline - # using the fake stack frame set up earlier - # and reload CS register - lret - -xreal: - # we are in real mode now - # set up the real mode segment registers : DS, SS, ES - movw %cs, %ax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - - # load idtr so we can debug - addr32 - data32 - lidt EXT(Idtr_real) - - data32 - ret - -/* -# -# startprog(phyaddr) -# start the program on protected mode where phyaddr is the entry point -# -*/ - -ENTRY(startprog) - push %ebp - mov %esp, %ebp - - # get things we need into registers - movl 0x8(%ebp), %ecx # entry offset - movl 0x0c(%ebp), %eax # &argv - - # make a new stack at 0:0xa0000 (big segs) - mov $0x10, %ebx - movw %bx, %ss - movl $0xa0000, %ebx - movl %ebx, %esp - - # push some number of args onto the stack - pushl $0 # nominally a cyl offset in the boot. - pushl 0x8(%eax) # argv[2] = bootdev - pushl 0x4(%eax) # argv[1] = howto - pushl $0 # dummy 'return' address - - # push on our entry address - mov $0x08, %ebx # segment - pushl %ebx - pushl %ecx - - # convert over the other data segs - mov $0x10, %ebx - movw %bx, %ds - movw %bx, %es - - # convert the PC (and code seg) - lret -/* -# -# pbzero( dst, cnt) -# where src is a virtual address and dst is a physical address -*/ - -ENTRY(pbzero) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - # set %es to point at the flat segment - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %edi # destination - mov 0xc(%ebp), %ecx # count - mov $0x0, %eax # value - - rep - stosb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret -/* -# -# pcpy(src, dst, cnt) -# where src is a virtual address and dst is a physical address -# -*/ - -ENTRY(pcpy) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - # set %es to point at the flat segment - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %esi # source - mov 0xc(%ebp), %edi # destination - mov 0x10(%ebp), %ecx # count - - rep - movsb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret - diff --git a/sys/i386/boot/asm.h b/sys/i386/boot/asm.h deleted file mode 100644 index 43242bd..0000000 --- a/sys/i386/boot/asm.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.7 92/02/29 15:33:41 rpd - * $Id$ - */ - -#define S_ARG0 4(%esp) -#define S_ARG1 8(%esp) -#define S_ARG2 12(%esp) -#define S_ARG3 16(%esp) - -#define FRAME pushl %ebp; movl %esp, %ebp -#define EMARF leave - -#define B_ARG0 8(%ebp) -#define B_ARG1 12(%ebp) -#define B_ARG2 16(%ebp) -#define B_ARG3 20(%ebp) - -#ifdef wheeze - -#define ALIGN 4 -#define EXT(x) x -#define LEXT(x) x: -#define LCL(x) ./**/x - -#define LB(x,n) ./**/x -#define LBb(x,n) ./**/x -#define LBf(x,n) ./**/x - -#define SVC lcall $7,$0 - -#define String .string -#define Value .value -#define Times(a,b) [a\*b] -#define Divide(a,b) [a\\b] - -#define INB inb (%dx) -#define OUTB outb (%dx) -#define INL inl (%dx) -#define OUTL outl (%dx) - -#else wheeze -#define ALIGN -#define LCL(x) x - -#define LB(x,n) n -#ifdef __STDC__ -#define EXT(x) _ ## x -#define LEXT(x) _ ## x ## : - -#define LBb(x,n) n ## b -#define LBf(x,n) n ## f -#else __STDC__ -#define EXT(x) _/**/x -#define LEXT(x) _/**/x/**/: -#define LBb(x,n) n/**/b -#define LBf(x,n) n/**/f -#endif __STDC__ -#define SVC .byte 0x9a; .long 0; .word 0x7 - -#define String .ascii -#define Value .word -#define Times(a,b) (a*b) -#define Divide(a,b) (a/b) - -#define INB inb %dx, %al -#define OUTB outb %al, %dx -#define INL inl %dx, %eax -#define OUTL outl %eax, %dx - -#endif wheeze - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -#ifdef GPROF -#ifdef __STDC__ - -#define MCOUNT .data; LB(x, 9); .long 0; .text; lea LBb(x, 9),%edx; call mcount -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ASENTRY(x) .globl x; .align ALIGN; x ## : ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; - -#else __STDC__ - -#define MCOUNT .data; LB(x, 9): .long 0; .text; lea LBb(x, 9),%edx; call mcount -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x: ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; - -#endif __STDC__ -#else GPROF -#ifdef __STDC__ - -#define MCOUNT -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x ## : - -#else __STDC__ - -#define MCOUNT -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x: - -#endif __STDC__ -#endif GPROF - -#define Entry(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define DATA(x) .globl EXT(x); .align ALIGN; LEXT(x) diff --git a/sys/i386/boot/asm.s b/sys/i386/boot/asm.s deleted file mode 100644 index 8802b13..0000000 --- a/sys/i386/boot/asm.s +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - */ - -/* - * HISTORY - * $Log: asm.s,v $ - * Revision 2.2 92/04/04 11:34:13 rpd - * Fix Intel Copyright as per B. Davies authorization. - * [92/04/03 rvb] - * From 2.5 boot: pruned inb(), outb(), and pzero(). - * [92/03/30 rvb] - * - * Revision 2.2 91/04/02 14:35:10 mbj - * Added _sp() => where is the stack at. [kupfer] - * Add Intel copyright - * [90/02/09 rvb] - * - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "asm.s" - -#include "asm.h" - - -CR0_PE_ON = 0x1 -CR0_PE_OFF = 0xfffffffe - -.globl _ouraddr - .text - -/* -# -# real_to_prot() -# transfer from real mode to protected mode. -*/ - -ENTRY(real_to_prot) - # guarantee that interrupt is disabled when in prot mode - cli - - # load the gdtr - addr16 - data32 - lgdt EXT(Gdtr) - - # set the PE bit of CR0 - mov %cr0, %eax - - data32 - or $CR0_PE_ON, %eax - mov %eax, %cr0 - - # make intrasegment jump to flush the processor pipeline and - # reload CS register - data32 - ljmp $0x18, $xprot - -xprot: - # we are in USE32 mode now - # set up the protective mode segment registers : DS, SS, ES - mov $0x20, %eax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - - ret - -/* -# -# prot_to_real() -# transfer from protected mode to real mode -# -*/ - -ENTRY(prot_to_real) - - # set up a dummy stack frame for the second seg change. - movl _ouraddr, %eax - sarl $4, %eax - pushw %ax - pushw $xreal - - # Change to use16 mode. - ljmp $0x28, $x16 - -x16: - # clear the PE bit of CR0 - mov %cr0, %eax - data32 - and $CR0_PE_OFF, %eax - mov %eax, %cr0 - - - # make intersegment jmp to flush the processor pipeline - # using the fake stack frame set up earlier - # and reload CS register - lret - - -xreal: - # we are in real mode now - # set up the real mode segment registers : DS, SS, ES - movw %cs, %ax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - - data32 - ret - -/* -# -# startprog(phyaddr) -# start the program on protected mode where phyaddr is the entry point -# -*/ - -ENTRY(startprog) - push %ebp - mov %esp, %ebp - - - - # get things we need into registers - movl 0x8(%ebp), %ecx # entry offset - movl 0x0c(%ebp), %eax # &argv - - # make a new stack at 0:0xa0000 (big segs) - mov $0x10, %ebx - movw %bx, %ss - movl $0xa0000,%ebx - movl %ebx,%esp - - - # push some number of args onto the stack - pushl $0 # nominally a cyl offset in the boot. - pushl 0x8(%eax) # argv[2] = bootdev - pushl 0x4(%eax) # argv[1] = howto - pushl $0 # dummy 'return' address - - # push on our entry address - mov $0x08, %ebx # segment - pushl %ebx - pushl %ecx - - # convert over the other data segs - mov $0x10, %ebx - movw %bx, %ds - movw %bx, %es - - # convert the PC (and code seg) - lret -/* -# -# pbzero( dst, cnt) -# where src is a virtual address and dst is a physical address -*/ - -ENTRY(pbzero) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - # set %es to point at the flat segment - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %edi # destination - mov 0xc(%ebp), %ecx # count - mov $0x0,%eax # value - - rep - stosb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret -/* -# -# pcpy(src, dst, cnt) -# where src is a virtual address and dst is a physical address -# -*/ - -ENTRY(pcpy) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - # set %es to point at the flat segment - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %esi # source - mov 0xc(%ebp), %edi # destination - mov 0x10(%ebp), %ecx # count - - rep - movsb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret - diff --git a/sys/i386/boot/bios.S b/sys/i386/boot/bios.S deleted file mode 100644 index 687ca18..0000000 --- a/sys/i386/boot/bios.S +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id$ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "bios.s" - -#include "asm.h" - .text - -/* -# biosread(dev, cyl, head, sec, nsec, offset) -# Read "nsec" sectors from disk to offset "offset" in boot segment -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -ENTRY(biosread) - push %ebp - mov %esp, %ebp - - push %ebx - push %ecx - push %edx - push %es - - movb 0x10(%ebp), %dh - movw 0x0c(%ebp), %cx - xchgb %ch, %cl # cylinder; the highest 2 bits of cyl is in %cl - rorb $2, %cl - movb 0x14(%ebp), %al - orb %al, %cl - incb %cl # sector; sec starts from 1, not 0 - movb 0x8(%ebp), %dl # device - movl 0x1c(%ebp), %ebx # offset - # prot_to_real will set %es to BOOTSEG - - call EXT(prot_to_real) # enter real mode - movb $0x2, %ah # subfunction - addr32 - movb 0x18(%ebp), %al # number of sectors - - sti - int $0x13 - cli - - mov %eax, %ebx # save return value (actually movw %ax, %bx) - - data32 - call EXT(real_to_prot) # back to protected mode - - xor %eax, %eax - movb %bh, %al # return value in %ax - - pop %es - pop %edx - pop %ecx - pop %ebx - pop %ebp - - ret - - -/* -# putc(ch) -# BIOS call "INT 10H Function 0Eh" to write character to console -# Call with %ah = 0x0e -# %al = character -# %bh = page -# %bl = foreground color ( graphics modes) -*/ - - -ENTRY(putc) - push %ebp - mov %esp, %ebp - push %ebx - push %ecx - - movb 0x8(%ebp), %cl - - call EXT(prot_to_real) - - data32 - mov $0x1, %ebx # %bh=0, %bl=1 (blue) - movb $0xe, %ah - movb %cl, %al - sti - int $0x10 # display a byte - cli - - data32 - call EXT(real_to_prot) - - pop %ecx - pop %ebx - pop %ebp - ret - - -/* -# getc() -# BIOS call "INT 16H Function 00H" to read character from keyboard -# Call with %ah = 0x0 -# Return: %ah = keyboard scan code -# %al = ASCII character -*/ - -ENTRY(getc) - push %ebp - mov %esp, %ebp - push %ebx # save %ebx - - call EXT(prot_to_real) - - movb $0x0, %ah - sti - int $0x16 - cli - - movb %al, %bl # real_to_prot uses %eax - - data32 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret -/* -# ischar() -# if there is a character pending, return it; otherwise return 0 -# BIOS call "INT 16H Function 01H" to check whether a character is pending -# Call with %ah = 0x1 -# Return: -# If key waiting to be input: -# %ah = keyboard scan code -# %al = ASCII character -# Zero flag = clear -# else -# Zero flag = set -*/ -ENTRY(ischar) - push %ebp - mov %esp, %ebp - push %ebx - - call EXT(prot_to_real) # enter real mode - - xor %ebx, %ebx - movb $0x1, %ah - sti - int $0x16 - cli - data32 - jz nochar - movb %al, %bl - -nochar: - data32 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret - -/* -# -# get_diskinfo(): return a word that represents the -# max number of sectors and heads and drives for this device -# -*/ - -ENTRY(get_diskinfo) - push %ebp - mov %esp, %ebp - push %es - push %ebx - push %ecx - push %edx - - movb 0x8(%ebp), %dl # diskinfo(drive #) - call EXT(prot_to_real) # enter real mode - - movb $0x8, %ah # ask for disk info - - sti - int $0x13 - cli - - jnc ok - /* - * Urk. Call failed. It is not supported for floppies by old BIOS's. - * Guess it's a 15-sector floppy. Initialize all the registers for - * documentation, although we only need head and sector counts. - */ - subb %ah, %ah # %ax = 0 - movb %al, %al - movb %ah, %bh # %bh = 0 - movb $2, %bl # %bl bits 0-3 = drive type, 2 = 1.2M - movb $79, %ch # max track - movb $15, %cl # max sector - movb $1, %dh # max head - movb $1, %dl # # floppy drives installed - # es:di = parameter table - # carry = 0 -ok: - - data32 - call EXT(real_to_prot) # back to protected mode - - xor %eax, %eax - - /*form a longword representing all this gunk*/ - movb %dh, %ah # max head - andb $0x3f, %cl # mask of cylinder gunk - movb %cl, %al # max sector (and # sectors) - - pop %edx - pop %ecx - pop %ebx - pop %es - pop %ebp - ret - -/* -# -# memsize(i) : return the memory size in KB. i == 0 for conventional memory, -# i == 1 for extended memory -# BIOS call "INT 12H" to get conventional memory size -# BIOS call "INT 15H, AH=88H" to get extended memory size -# Both have the return value in AX. -# -*/ - -ENTRY(memsize) - push %ebp - mov %esp, %ebp - push %ebx - - mov 8(%ebp), %ebx - - call EXT(prot_to_real) # enter real mode - - cmpb $0x1, %bl - data32 - je xext - - sti - int $0x12 - cli - data32 - jmp xdone - -xext: movb $0x88, %ah - sti - int $0x15 - cli - -xdone: - mov %eax, %ebx - - data32 - call EXT(real_to_prot) - - mov %ebx, %eax - pop %ebx - pop %ebp - ret diff --git a/sys/i386/boot/bios.s b/sys/i386/boot/bios.s deleted file mode 100644 index d1673a5..0000000 --- a/sys/i386/boot/bios.s +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - */ - -/* - * HISTORY - * $Log: bios.s,v $ - * Revision 2.2 92/04/04 11:34:26 rpd - * Fix Intel Copyright as per B. Davies authorization. - * [92/04/03 rvb] - * From 2.5 version - * [92/03/30 mg32] - * - * Revision 2.2 91/04/02 14:35:21 mbj - * Add Intel copyright - * [90/02/09 rvb] - * - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "bios.s" - -#include "asm.h" - .text - -/* -# biosread(dev, cyl, head, sec) -# Read one sector from disk into the internal buffer "intbuf" which -# is the first 512 bytes of the boot loader. -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -ENTRY(biosread) - push %ebp - mov %esp, %ebp - - push %ebx - push %ecx - push %edx - push %es - - movb 0x10(%ebp), %dh - movw 0x0c(%ebp), %cx - xchgb %ch, %cl # cylinder; the highest 2 bits of cyl is in %cl - rorb $2, %cl - movb 0x14(%ebp), %al - orb %al, %cl - incb %cl # sector; sec starts from 1, not 0 - movb 0x8(%ebp), %dl # device - xor %ebx, %ebx # offset -- 0 - # prot_to_real will set %es to BOOTSEG - - call EXT(prot_to_real) # enter real mode - movb $0x2, %ah # subfunction - movb $0x1, %al # number of sectors -- one - - sti - int $0x13 - cli - - mov %eax, %ebx # save return value - - data16 - call EXT(real_to_prot) # back to protected mode - - xor %eax, %eax - movb %bh, %al # return value in %ax - - pop %es - pop %edx - pop %ecx - pop %ebx - pop %ebp - - ret - - -/* -# putc(ch) -# BIOS call "INT 10H Function 0Eh" to write character to console -# Call with %ah = 0x0e -# %al = character -# %bh = page -# %bl = foreground color ( graphics modes) -*/ - - -ENTRY(putc) - push %ebp - mov %esp, %ebp - push %ebx - push %ecx - - movb 0x8(%ebp), %cl - - call EXT(prot_to_real) - - data16 - mov $0x1, %ebx # %bh=0, %bl=1 (blue) - movb $0xe, %ah - movb %cl, %al - sti - int $0x10 # display a byte - cli - - data16 - call EXT(real_to_prot) - - pop %ecx - pop %ebx - pop %ebp - ret - - -/* -# getc() -# BIOS call "INT 16H Function 00H" to read character from keyboard -# Call with %ah = 0x0 -# Return: %ah = keyboard scan code -# %al = ASCII character -*/ - -ENTRY(getc) - push %ebp - mov %esp, %ebp - push %ebx # save %ebx - - call EXT(prot_to_real) - - movb $0x0, %ah - sti - int $0x16 - cli - - movb %al, %bl # real_to_prot uses %eax - - data16 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret -/* -# ischar() -# if there is a character pending, return it; otherwise return 0 -# BIOS call "INT 16H Function 01H" to check whether a character is pending -# Call with %ah = 0x1 -# Return: -# If key waiting to be input: -# %ah = keyboard scan code -# %al = ASCII character -# Zero flag = clear -# else -# Zero flag = set -*/ -ENTRY(ischar) - push %ebp - mov %esp, %ebp - push %ebx - - call EXT(prot_to_real) # enter real mode - - xor %ebx, %ebx - movb $0x1, %ah - sti - int $0x16 - cli - data16 - jz nochar - movb %al, %bl - -nochar: - data16 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret - -/* -# -# get_diskinfo(): return a word that represents the -# max number of sectors and heads and drives for this device -# -*/ - -ENTRY(get_diskinfo) - push %ebp - mov %esp, %ebp - push %es - push %ebx - push %ecx - push %edx - - movb 0x8(%ebp), %dl # diskinfo(drive #) - call EXT(prot_to_real) # enter real mode - - movb $0x8, %ah # ask for disk info - - sti - int $0x13 - cli - - data16 - call EXT(real_to_prot) # back to protected mode - - xor %eax, %eax - - /*form a longword representing all this gunk*/ - movb %dh, %ah # # heads - andb $0x3f, %cl # mask of cylinder gunk - movb %cl, %al # # sectors - - pop %edx - pop %ecx - pop %ebx - pop %es - pop %ebp - ret - -/* -# -# memsize(i) : return the memory size in KB. i == 0 for conventional memory, -# i == 1 for extended memory -# BIOS call "INT 12H" to get conventional memory size -# BIOS call "INT 15H, AH=88H" to get extended memory size -# Both have the return value in AX. -# -*/ - -ENTRY(memsize) - push %ebp - mov %esp, %ebp - push %ebx - - mov 8(%ebp), %ebx - - call EXT(prot_to_real) # enter real mode - - cmpb $0x1, %bl - data16 - je xext - - sti - int $0x12 - cli - data16 - jmp xdone - -xext: movb $0x88, %ah - sti - int $0x15 - cli - -xdone: - mov %eax, %ebx - - data16 - call EXT(real_to_prot) - - mov %ebx, %eax - pop %ebx - pop %ebp - ret diff --git a/sys/i386/boot/biosboot/Makefile b/sys/i386/boot/biosboot/Makefile deleted file mode 100644 index 2e4f162..0000000 --- a/sys/i386/boot/biosboot/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# -# 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 "AS IS" -# 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 Mellon -# the rights to redistribute these changes. -# -# from: Mach, Revision 2.2 92/04/04 11:33:46 rpd -# $Id$ -# - -wd0: - dd if=boot of=biosboot count=1 - dd if=boot of=bootbios skip=1 - disklabel -r -w wd0 nec5655 newboot biosboot bootbios - rm biosboot bootbios - -NOPROG= noprog -NOMAN= noman - -CFLAGS = -O -DDO_BAD144 -I${.CURDIR} -LIBS= -lc -INC= -I${.CURDIR}/../.. - -# start.o should be first -OBJS = start.o table.o boot2.o boot.o asm.o bios.o io.o disk.o sys.o - -.SUFFIXES: .S .c .o - -.c.o: - $(CC) $(CFLAGS) $(INC) -c $< - -.S.o: - $(CC) $(CFLAGS) -c $< - -boot: $(OBJS) - $(LD) -N -T 0 -o boot $(OBJS) $(LIBS) - cp boot boot.sym - @strip boot - @sh ${.CURDIR}/rmaouthdr boot boot.tmp - @mv -f boot.tmp boot - @ls -l boot - -biosboot: boot - dd if=boot of=biosboot count=1 - -bootbios: boot - dd if=boot of=bootbios skip=1 - -/usr/mdec/bootsd: bootbios - cp bootbios /usr/mdec/bootsd - -/usr/mdec/sdboot: biosboot - cp biosboot /usr/mdec/sdboot - -/usr/mdec/bootwd: /usr/mdec/bootsd - rm -f /usr/mdec/bootwd - ln /usr/mdec/bootsd /usr/mdec/bootwd - -/usr/mdec/wdboot: /usr/mdec/sdboot - rm -f /usr/mdec/wdboot - ln /usr/mdec/sdboot /usr/mdec/wdboot - -/usr/mdec/bootfd: /usr/mdec/bootsd - rm -f /usr/mdec/bootfd - ln /usr/mdec/bootsd /usr/mdec/bootfd - -/usr/mdec/fdboot: /usr/mdec/sdboot - rm -f /usr/mdec/fdboot - ln /usr/mdec/sdboot /usr/mdec/fdboot - -sd: /usr/mdec/bootsd /usr/mdec/sdboot -wd: /usr/mdec/bootwd /usr/mdec/wdboot -fd: /usr/mdec/bootfd /usr/mdec/fdboot - -all: biosboot bootbios - -fd0: - dd if=boot of=biosboot count=1 - dd if=boot of=bootbios skip=1 - disklabel -r -w fd0 floppy bootflpy biosboot bootbios - rm biosboot bootbios - -install: wd sd fd - -clean cleandir: - /bin/rm -f *.o *.d boot bootbios biosboot boot.sym - -.include diff --git a/sys/i386/boot/biosboot/README.386BSD b/sys/i386/boot/biosboot/README.386BSD deleted file mode 100644 index cc5cb8f..0000000 --- a/sys/i386/boot/biosboot/README.386BSD +++ /dev/null @@ -1,151 +0,0 @@ -This Boot code is different from the original boot code that came with -386BSD in that it uses the BIOS to load the kernel and to provide all i/o -services. The advantage ofthis is that the same boot code exactly, can run -on any device that is supported by the BIOS. (That's most of them) -This is important for the 'generic scsi' project because it means we can -write drivers for new scsi adapters without having to develop an new -set of boot blocks for each. - -At this point you should read the first part of README.MACH... come back here -when you have done that: - -In normal operation, when co-existing with other operating systems, the -following operations occur: - -1/ the BIOS loads the first block of the disk (called the Master Boot Record -or MBR) and if it has the correct magic numbers, jumps into it: - -2/ The MBR code, looks at the Partition table that is embedded within it, -to detirmine which is the partition to boot from. If you are using the os-bs -bootblocks (highly recommended) then it will give you a menu to choose from. - -3/ The MBR will load the first record of the selected partition and -if it has (the same) magic numbers, jumps into it. In 386bsd this is the -first stage boot, (or boot1) it is represented in /usr/mdec by -wdboot, asboot and sdboot. If the disk has been set up without DOS partitioning -then this block will be at block zero, and will have been loaded directly by -the BIOS. - -4/ Boot1 will look at block0 (which might be itself if there are no DOS -partitions) and will find the 386bsd partition, and using the information -regarding the start position of that partition, will load the next 13 sectors -or so, to around 90000 (640k - 64k). and will jump into it at the appropriate -entry point. Since boot1 and boot2 were compiled together as one file -and then split later, boot1 knows the exact position within boot2 of the -entry point. - -Boot 1 also contains a compiled in DOS partition table -(in case it is at block 0), which contains a 386bsd partition starting -at 0. This ensures that the same code can work whether or not -boot1 is at block 0. - -5/ Boot2 asks the user for a boot device, partition and filename, and then -loads the MBR of the selected device. This may or may not be the device -which was originally used to boot the first MBR. The partition table -of the new MBR is searched for a 386bsd partition, and if one is found, -that is then in turn searched for the disklabel. This could all be on the -second disk at this point, if the user selected it. - -6/On finding the disklabel, boot2 can find the correct unix partition -within the 386bsd partition, and using cutdown filesystem code, -look for the file to boot (e.g. 386bsd). - -7/ Boot2 loads this file starting at the location specified by the a.out header, -(see later) and leaps into it at the location specified in he header. - -if the file does not exist or cannot be loaded, boot2 goes back to step 5. - -386bsd is now running and will hopefully start vm etc. and get to multi-user -mode. - -########################################################################## -During all these steps, all i/o is performed using the BIOS. This has a number -of side effects: - -1/ Since BIOS disk calls are specified in terms of cylinder,head and sector, -and the BIOS read the disk information from either the CMOS or from some other -location which is un-available to us, we must use the cyl,head,sec information -that is given in the MBR, rather than the start address in the MBR, because -we cannot guarentee that we can corectly calculate C,H,S from the start address. - -Therefore, the C,H,S information in the MBR must be as correct for this boot -to work as it would be for DOS to boot. For example, adaptec BIOS routines -assume a layout of 64 heads and 32 sectors giving 1MB per ficticious cylinder. -You must use these figures to calculate the correct values. Luckily, the DOS -fdisk program will do all this for you if you tell it to give you a DOS -partition, and you can change it to a 386BSD partition later. If you use -no DOS partitioning, then the compiled in table in Boot1 will do just fine. - -If you want to do it by hand remember that BIOS counts sectors starting at 1. -(cylinders and heads start at 0 (??)) - -2/ you cannot overwrite the bottom 4k of ram until you have finished ALL -bios calls, as BIOS uses this area as scratch memory. - -3/ Since BIOS runs in REAL mode, and Boot2 runs in protected mode, -Boot 2 switches back to real mode just before each BIOS call and then -back to protected mode on each return. Touch this at your peril.! - -######################################################################### -In answering the prompt from Boot2: -you can, -1/ leave it alone.. it will boot the indicated file from the first -partition of the first drive seen by the BIOS (C:) - -2/ enter only "-s" to boot the default to single user mode - -3/ enter only a filename (optionally with -s) to boot that kernel, - -4/ enter a whole line of the form shown in the prompt. This allows you to -boot some other partition, possibly on the second drive, as root. - - -########################################################################## -In the case you have two drives the same type (both scsi or bith IDE/ESDI), -wd(0,a)xxx - will boot xxx from drive 0, a partition. -wd(1,a)xxx - will boot xxx from drive 1, a partition. - -similarly for sd. - -if you have one wd drive and one scsi drive, then you MUST -use device 'hd' - -otherwise the following will happen: - -with wd0 and sd0, you specify sd1 or wd1 to indicate the 2nd drive. -it boots the kernel correctly, then tells the kernel to use sd1 as root. -you however may not have an sd1, and problems arise. - -hd is special in that the kernel is always told to use unit 0, -The correct TYPE of device will be specified too, so the kernel -will be told either sd0 or wd0. - -Whether sd or wd is specified to the kernel is read from the disklabel, -so ensure that all SCSI disks have type SCSI in their disklabel or the -boot code will assume they are ESDI or IDE. (Remember, because it is -working through the BIOS it has ho idea what kind of disk it is. - -########################################################################## -Installing: -The makefile supplied has a target install which will create the -files wdboot,bootwd ,sdboot and bootsd in /usr/mdec. -BEWARE these will overwrite the existing wdboot and bootwd. (so back -them up) - -there are also targets wd and sd which wil only do one of them - -The commented out targets wd0 and sd0 are examples of how to -load the new bootblocks, however,make sure you change the -device type and label to suit your drive if you uncomment them. -(see 'man disklabel') - -If you already have made partitions using the old bootblocks -these should install painlessly. - -Before you do this ensure you have a booting floppy with correct -disktab and bootblock files on it so that if it doesn't work, you can -re-disklabel from the floppy. - -$Id$ diff --git a/sys/i386/boot/biosboot/README.MACH b/sys/i386/boot/biosboot/README.MACH deleted file mode 100644 index cb62329..0000000 --- a/sys/i386/boot/biosboot/README.MACH +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:33:55 rpd - * $Id$ - */ - -********NOTE: This is not all relevant to the 386BSD version********** - - AT386 Protected Mode Bootstrap Loader - ===================================== - -1. Overview of Startup - ------------------- - - After the system is rebooted, the BIOS bootstrap routine reads Sector - 1, Track 0 into memory at location 0000:7C00H. If location 0000:7DFEH - (last two bytes of that sector) contains the value AA55H, the BIOS - bootstrap routine will transfer control to 0000:7C00H. Otherwise, the - boot code in that sector is bad and the boot routine stops. - - For DOS compatibility reason, one extra stage of boot is required if - the boot device is a hard disk. The first sector of the hard disk will - contain the MOS-DOS boot code and a boot record partition table. - When this sector is loaded into 0000:7C00H, it will relocate itself - to somewhere else and then load the first sector of the active - partition into 0000:7C00H. Both UNIX and DOS use the command "fdisk" -[ 386bsd does not have an 'fdisk' (yet) ] - to install this first sector into the hard disk and to manipulate - the hard disk partitions. - - - -2. The First Stage Bootstrap Loader - -------------------------------- - - After startup, the first stage boot is loaded at 0000:7C00H. This - first stage boot will load itself and the second stage boot into - memory at location 0000:1000H. For floppy disks, the first cylinder - is reserved as the boot cylinder, and the boot code (first and second) - will be loaded from there. Currently, only double sided, high density - (15 sectors per track) floppies are supported. For hard disks, the - first 29 sectors of the active partition is reserved for boot code - which will be loaded by the first stage boot. All the disk types - recognized by BIOS are supported by this bootstrap loader. -[for 386bsd we load the second stage booter to 9000:0] - - - -3. The Second Stage Bootstrap Loader - -------------------------------- - - After the boot code is loaded, the control is passed to the second - stage bootstrap loader "boot2()". In order to be able to load the - big kernel image (bigger than 512K or 640K, depends on the memory - configuration), the second stage boot loader will run on the protected - mode. This bootstarp loader does not have any stand alone device - drivers, all the I/O's are through the BIOS calls. Since the first - stage boot code will no longer be used at this moment, the memory - location of the first stage boot code (0000:1000H to 0000:1200H) will - be used as an internal buffer for BIOS calls. Immediately after this - internal buffer is the GDT table for the second stage boot loader. - Since this boot loader needs to switch back and forth between protected - and real mode in order to use BIOS calls, the limit of the boot code - and boot data segments must not be greater than 64K. - - The boot loader loads the kernel image at memory location above 1 MB - to skip the memory hole between 521K/640K and 1MB. After the kernel - is loaded, the boot loader stores the information in the stack and - then passes control to kernel. Currently, the three information passed - fromm the boot loader to the kernel are type of the boot device, size - of the base memory and size of the extended memory. - -[ 386bsd receives: howto, bootdev] - -[ 386bsd is loaded where-ever the "MByte" bits of the load address specify, -so if you link it for FE100000 it will load to 1MB, but if you link -it for FE000000 it will load ad 0MB] - -[for machines with only 512KB normal ram the kernel will need to be linked -for 1MB and the bootblocks modified to run below 512KB. (8000:0)] - - -4. The UNIX Startup - ---------------- - - Since the boot loader loads the kernel image at memory location above - 1MB, the kernel has to start as protected mode. In addition, the - link editor description file (vuifile) has to indicate that - the text and data segments start above 1MB. Also, the boot loader - passes the infomation to the kernel through the stack. - -[MOST of what is mentionned below is NOT relevant to 386bsd] - -5. Disk Layout and Bad Block Handling - --------------------------------- - - The System V/386 Release 3.2 (AT) disk layout will be used as the disk - layout for the MACH System on the AT platform. - - This disk layout is as follows: - - * Reserve the first sector of cylinder 0 for the DOS boot record which - contains the master boot code (446 bytes) and the partition table. - (Refer to DOS Technical Reference Manual page 9-6 to 9-10). - - * Reserve the first 29 sectors of the UNIX partition for the first - and the second stage bootstrap. - - * Reserve the 30th sector of the UNIX partition for the pdinfo and - the vtoc tables. - - * Reserve the 31st to the 34th sectors of the UNIX partition for the - bad track and the bad block mapping tables. - - * Reserve up to 253 consecutive tracks when required, beginning with - the 35th sector of the UNIX partition, for alternate tracks. - - * Reserve up to 253 consecutive blocks, beginning with the first - sector after the alternate tracks area, for alternate blocks. - - SEC - 1 - ---------------------------------------------------- - | X | | CYL 0, TRK 0 - ---------------- .......... -------------------- - | .......... | - ---------------- .......... -------------------- - | .......... | - =============================================================== - ^ | BOOTSTRAP | CYL N, TRK M - | ---------------------------------------------------- - | | |30 |31 |32 |33 |34 | - ---------------------------------------------------- --- - U | .......... | ^ - N ---------------- .......... --------------------- | - I | .......... | Alternate Tracks - X ---------------- .......... --------------------- | - | .......... | V - P ---------------------------------------------------- --- - A | .......... | ^ - R ---------------- .......... --------------------- | - T | .......... | Alternate Blocks - I ---------------- .......... -------------------- | - T | .......... | V - I ---------------------------------------------------- --- - O | Unix root partition starts from here | - N ---------------- ----------------- - | | - ---------------------------------------------------- - | | - ---------------------------------------------------- - | | - | --------------------------------------------------- - | | | - | ---------------------------------------------------- - V | | - =============================================================== - | ........ | - --------------- ........ -------------- - | ........ | - ---------------------------------------------------- - - - The bad block handling mechanism is as follows: - - * Use the alternate track in the alternate tracks area if the - track containing the target sector is bad. - - * Use the alternate block in the alternate blocks area if the - target sector is bad. - - - - -6. How to make: - ----------- - - Since the kernel image is loaded above 1 MB, the kernel must start - as protected mode. This means that this bootstrap loader will work - only when the corresponding changes on the kernel startup code are done. - - The make command to generate this bootstrap loader is: - - make -f boot.mk fdboot (floppy boot loader) - make -f boot.mk hdboot (wini boot loader) -[to make 386bsd bootblocks "make sd wd" (warning: they will be installed -in /dev/mdec.. take backups)] diff --git a/sys/i386/boot/biosboot/asm.S b/sys/i386/boot/biosboot/asm.S deleted file mode 100644 index b291428..0000000 --- a/sys/i386/boot/biosboot/asm.S +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:13 rpd - * $Id$ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "asm.s" - -#include "asm.h" - - -CR0_PE_ON = 0x1 -CR0_PE_OFF = 0xfffffffe - -.globl _ouraddr - .text - -/* -# -# real_to_prot() -# transfer from real mode to protected mode. -*/ - -ENTRY(real_to_prot) - # guarantee that interrupt is disabled when in prot mode - cli - - # load the gdtr - addr32 - data32 - lgdt EXT(Gdtr) - - # set the PE bit of CR0 - mov %cr0, %eax - - data32 - or $CR0_PE_ON, %eax - mov %eax, %cr0 - - # make intrasegment jump to flush the processor pipeline and - # reload CS register - data32 - ljmp $0x18, $xprot - -xprot: - # we are in USE32 mode now - # set up the protected mode segment registers : DS, SS, ES - mov $0x20, %eax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - - # load idtr so we can debug - lidt EXT(Idtr_prot) - - ret - -/* -# -# prot_to_real() -# transfer from protected mode to real mode -# -*/ - -ENTRY(prot_to_real) - - # set up a dummy stack frame for the second seg change. - movl _ouraddr, %eax - sarl $4, %eax - pushw %ax - movw $xreal, %ax # gas botches pushw $xreal - extra bytes 0, 0 - pushw %ax # decode to add %al, (%eax) (%al usually 0) - - # Change to use16 mode. - ljmp $0x28, $x16 - -x16: - # clear the PE bit of CR0 - mov %cr0, %eax - data32 - and $CR0_PE_OFF, %eax - mov %eax, %cr0 - - # make intersegment jmp to flush the processor pipeline - # using the fake stack frame set up earlier - # and reload CS register - lret - -xreal: - # we are in real mode now - # set up the real mode segment registers : DS, SS, ES - movw %cs, %ax - movw %ax, %ds - movw %ax, %ss - movw %ax, %es - - # load idtr so we can debug - addr32 - data32 - lidt EXT(Idtr_real) - - data32 - ret - -/* -# -# startprog(phyaddr) -# start the program on protected mode where phyaddr is the entry point -# -*/ - -ENTRY(startprog) - push %ebp - mov %esp, %ebp - - # get things we need into registers - movl 0x8(%ebp), %ecx # entry offset - movl 0x0c(%ebp), %eax # &argv - - # make a new stack at 0:0xa0000 (big segs) - mov $0x10, %ebx - movw %bx, %ss - movl $0xa0000, %ebx - movl %ebx, %esp - - # push some number of args onto the stack - pushl $0 # nominally a cyl offset in the boot. - pushl 0x8(%eax) # argv[2] = bootdev - pushl 0x4(%eax) # argv[1] = howto - pushl $0 # dummy 'return' address - - # push on our entry address - mov $0x08, %ebx # segment - pushl %ebx - pushl %ecx - - # convert over the other data segs - mov $0x10, %ebx - movw %bx, %ds - movw %bx, %es - - # convert the PC (and code seg) - lret -/* -# -# pbzero( dst, cnt) -# where src is a virtual address and dst is a physical address -*/ - -ENTRY(pbzero) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - # set %es to point at the flat segment - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %edi # destination - mov 0xc(%ebp), %ecx # count - mov $0x0, %eax # value - - rep - stosb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret -/* -# -# pcpy(src, dst, cnt) -# where src is a virtual address and dst is a physical address -# -*/ - -ENTRY(pcpy) - push %ebp - mov %esp, %ebp - push %es - push %esi - push %edi - push %ecx - - cld - - # set %es to point at the flat segment - mov $0x10, %eax - movw %ax, %es - - mov 0x8(%ebp), %esi # source - mov 0xc(%ebp), %edi # destination - mov 0x10(%ebp), %ecx # count - - rep - movsb - - pop %ecx - pop %edi - pop %esi - pop %es - pop %ebp - - ret - diff --git a/sys/i386/boot/biosboot/asm.h b/sys/i386/boot/biosboot/asm.h deleted file mode 100644 index 43242bd..0000000 --- a/sys/i386/boot/biosboot/asm.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.7 92/02/29 15:33:41 rpd - * $Id$ - */ - -#define S_ARG0 4(%esp) -#define S_ARG1 8(%esp) -#define S_ARG2 12(%esp) -#define S_ARG3 16(%esp) - -#define FRAME pushl %ebp; movl %esp, %ebp -#define EMARF leave - -#define B_ARG0 8(%ebp) -#define B_ARG1 12(%ebp) -#define B_ARG2 16(%ebp) -#define B_ARG3 20(%ebp) - -#ifdef wheeze - -#define ALIGN 4 -#define EXT(x) x -#define LEXT(x) x: -#define LCL(x) ./**/x - -#define LB(x,n) ./**/x -#define LBb(x,n) ./**/x -#define LBf(x,n) ./**/x - -#define SVC lcall $7,$0 - -#define String .string -#define Value .value -#define Times(a,b) [a\*b] -#define Divide(a,b) [a\\b] - -#define INB inb (%dx) -#define OUTB outb (%dx) -#define INL inl (%dx) -#define OUTL outl (%dx) - -#else wheeze -#define ALIGN -#define LCL(x) x - -#define LB(x,n) n -#ifdef __STDC__ -#define EXT(x) _ ## x -#define LEXT(x) _ ## x ## : - -#define LBb(x,n) n ## b -#define LBf(x,n) n ## f -#else __STDC__ -#define EXT(x) _/**/x -#define LEXT(x) _/**/x/**/: -#define LBb(x,n) n/**/b -#define LBf(x,n) n/**/f -#endif __STDC__ -#define SVC .byte 0x9a; .long 0; .word 0x7 - -#define String .ascii -#define Value .word -#define Times(a,b) (a*b) -#define Divide(a,b) (a/b) - -#define INB inb %dx, %al -#define OUTB outb %al, %dx -#define INL inl %dx, %eax -#define OUTL outl %eax, %dx - -#endif wheeze - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -#ifdef GPROF -#ifdef __STDC__ - -#define MCOUNT .data; LB(x, 9); .long 0; .text; lea LBb(x, 9),%edx; call mcount -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ASENTRY(x) .globl x; .align ALIGN; x ## : ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; - -#else __STDC__ - -#define MCOUNT .data; LB(x, 9): .long 0; .text; lea LBb(x, 9),%edx; call mcount -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x: ; \ - pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp; - -#endif __STDC__ -#else GPROF -#ifdef __STDC__ - -#define MCOUNT -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x ## : - -#else __STDC__ - -#define MCOUNT -#define ENTRY(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \ - .align ALIGN; LEXT(x) LEXT(y) -#define ASENTRY(x) .globl x; .align ALIGN; x: - -#endif __STDC__ -#endif GPROF - -#define Entry(x) .globl EXT(x); .align ALIGN; LEXT(x) -#define DATA(x) .globl EXT(x); .align ALIGN; LEXT(x) diff --git a/sys/i386/boot/biosboot/bios.S b/sys/i386/boot/biosboot/bios.S deleted file mode 100644 index 687ca18..0000000 --- a/sys/i386/boot/biosboot/bios.S +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id$ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - - .file "bios.s" - -#include "asm.h" - .text - -/* -# biosread(dev, cyl, head, sec, nsec, offset) -# Read "nsec" sectors from disk to offset "offset" in boot segment -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -ENTRY(biosread) - push %ebp - mov %esp, %ebp - - push %ebx - push %ecx - push %edx - push %es - - movb 0x10(%ebp), %dh - movw 0x0c(%ebp), %cx - xchgb %ch, %cl # cylinder; the highest 2 bits of cyl is in %cl - rorb $2, %cl - movb 0x14(%ebp), %al - orb %al, %cl - incb %cl # sector; sec starts from 1, not 0 - movb 0x8(%ebp), %dl # device - movl 0x1c(%ebp), %ebx # offset - # prot_to_real will set %es to BOOTSEG - - call EXT(prot_to_real) # enter real mode - movb $0x2, %ah # subfunction - addr32 - movb 0x18(%ebp), %al # number of sectors - - sti - int $0x13 - cli - - mov %eax, %ebx # save return value (actually movw %ax, %bx) - - data32 - call EXT(real_to_prot) # back to protected mode - - xor %eax, %eax - movb %bh, %al # return value in %ax - - pop %es - pop %edx - pop %ecx - pop %ebx - pop %ebp - - ret - - -/* -# putc(ch) -# BIOS call "INT 10H Function 0Eh" to write character to console -# Call with %ah = 0x0e -# %al = character -# %bh = page -# %bl = foreground color ( graphics modes) -*/ - - -ENTRY(putc) - push %ebp - mov %esp, %ebp - push %ebx - push %ecx - - movb 0x8(%ebp), %cl - - call EXT(prot_to_real) - - data32 - mov $0x1, %ebx # %bh=0, %bl=1 (blue) - movb $0xe, %ah - movb %cl, %al - sti - int $0x10 # display a byte - cli - - data32 - call EXT(real_to_prot) - - pop %ecx - pop %ebx - pop %ebp - ret - - -/* -# getc() -# BIOS call "INT 16H Function 00H" to read character from keyboard -# Call with %ah = 0x0 -# Return: %ah = keyboard scan code -# %al = ASCII character -*/ - -ENTRY(getc) - push %ebp - mov %esp, %ebp - push %ebx # save %ebx - - call EXT(prot_to_real) - - movb $0x0, %ah - sti - int $0x16 - cli - - movb %al, %bl # real_to_prot uses %eax - - data32 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret -/* -# ischar() -# if there is a character pending, return it; otherwise return 0 -# BIOS call "INT 16H Function 01H" to check whether a character is pending -# Call with %ah = 0x1 -# Return: -# If key waiting to be input: -# %ah = keyboard scan code -# %al = ASCII character -# Zero flag = clear -# else -# Zero flag = set -*/ -ENTRY(ischar) - push %ebp - mov %esp, %ebp - push %ebx - - call EXT(prot_to_real) # enter real mode - - xor %ebx, %ebx - movb $0x1, %ah - sti - int $0x16 - cli - data32 - jz nochar - movb %al, %bl - -nochar: - data32 - call EXT(real_to_prot) - - xor %eax, %eax - movb %bl, %al - - pop %ebx - pop %ebp - ret - -/* -# -# get_diskinfo(): return a word that represents the -# max number of sectors and heads and drives for this device -# -*/ - -ENTRY(get_diskinfo) - push %ebp - mov %esp, %ebp - push %es - push %ebx - push %ecx - push %edx - - movb 0x8(%ebp), %dl # diskinfo(drive #) - call EXT(prot_to_real) # enter real mode - - movb $0x8, %ah # ask for disk info - - sti - int $0x13 - cli - - jnc ok - /* - * Urk. Call failed. It is not supported for floppies by old BIOS's. - * Guess it's a 15-sector floppy. Initialize all the registers for - * documentation, although we only need head and sector counts. - */ - subb %ah, %ah # %ax = 0 - movb %al, %al - movb %ah, %bh # %bh = 0 - movb $2, %bl # %bl bits 0-3 = drive type, 2 = 1.2M - movb $79, %ch # max track - movb $15, %cl # max sector - movb $1, %dh # max head - movb $1, %dl # # floppy drives installed - # es:di = parameter table - # carry = 0 -ok: - - data32 - call EXT(real_to_prot) # back to protected mode - - xor %eax, %eax - - /*form a longword representing all this gunk*/ - movb %dh, %ah # max head - andb $0x3f, %cl # mask of cylinder gunk - movb %cl, %al # max sector (and # sectors) - - pop %edx - pop %ecx - pop %ebx - pop %es - pop %ebp - ret - -/* -# -# memsize(i) : return the memory size in KB. i == 0 for conventional memory, -# i == 1 for extended memory -# BIOS call "INT 12H" to get conventional memory size -# BIOS call "INT 15H, AH=88H" to get extended memory size -# Both have the return value in AX. -# -*/ - -ENTRY(memsize) - push %ebp - mov %esp, %ebp - push %ebx - - mov 8(%ebp), %ebx - - call EXT(prot_to_real) # enter real mode - - cmpb $0x1, %bl - data32 - je xext - - sti - int $0x12 - cli - data32 - jmp xdone - -xext: movb $0x88, %ah - sti - int $0x15 - cli - -xdone: - mov %eax, %ebx - - data32 - call EXT(real_to_prot) - - mov %ebx, %eax - pop %ebx - pop %ebp - ret diff --git a/sys/i386/boot/biosboot/boot.c b/sys/i386/boot/biosboot/boot.c deleted file mode 100644 index 1e15ab7..0000000 --- a/sys/i386/boot/biosboot/boot.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, [92/04/03 16:51:14 rvb] - * $Id: boot.c,v 1.7 1993/10/15 12:33:03 rgrimes Exp $ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include -#include "boot.h" -#include -#include - -struct exec head; -int argv[10], esym; -char *name; -char *names[] = { - "/386bsd", "/o386bsd", "/386bsd.old", - "/vmunix", "/ovmunix", "/vmunix.old" -}; -#define NUMNAMES (sizeof(names)/sizeof(char *)) - -extern int end; -boot(drive) -int drive; -{ - int loadflags, currname = 0; - char *t; - - printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory [%s]\n", - ouraddr, - argv[7] = memsize(0), - argv[8] = memsize(1), - "$Revision: 1.7 $"); - printf("use hd(1,a)/386bsd to boot sd0 when wd0 is also installed\n"); - gateA20(); -loadstart: - /***************************************************************\ - * As a default set it to the first partition of the first * - * floppy or hard drive * - \***************************************************************/ - part = unit = 0; - maj = (drive&0x80 ? 0 : 2); /* a good first bet */ - name = names[currname++]; - - loadflags = 0; - if (currname == NUMNAMES) - currname = 0; - getbootdev(&loadflags); - if (openrd()) { - printf("Can't find %s\n", name); - goto loadstart; - } -/* if (inode.i_mode&IEXEC) - loadflags |= RB_KDB; -*/ - loadprog(loadflags); - goto loadstart; -} - -loadprog(howto) - int howto; -{ - long int startaddr; - long int addr; /* physical address.. not directly useable */ - long int addr0; - int i; - static int (*x_entry)() = 0; - unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ - - argv[3] = 0; - argv[4] = 0; - read(&head, sizeof(head)); - if ( N_BADMAG(head)) { - printf("Invalid format!\n"); - return; - } - - poff = N_TXTOFF(head); - /*if(poff==0) - poff = 32;*/ - - startaddr = (int)head.a_entry; - addr = (startaddr & 0x00ffffff); /* some MEG boundary */ - addr0 = addr; - printf("Booting %s(%d,%c)%s @ 0x%x\n" - , devs[maj] - , unit - , 'a'+part - , name - , addr); - if(addr < ouraddr) - { - if((addr + head.a_text + head.a_data) > ouraddr) - { - printf("kernel will not fit below loader\n"); - return; - } - if((addr + head.a_text + head.a_data + head.a_bss) > 0xa0000) - { - printf("kernel too big, won't fit in 640K with bss\n"); - printf("Only hope is to link the kernel for > 1MB\n"); - return; - } - } - printf("text=0x%x ", head.a_text); - /********************************************************/ - /* LOAD THE TEXT SEGMENT */ - /* don't clobber the first 4k yet (BIOS NEEDS IT) */ - /********************************************************/ - read(tmpbuf,4096); - addr += 4096; - xread(addr, head.a_text - 4096); - addr += head.a_text - 4096; - - /********************************************************/ - /* Load the Initialised data after the text */ - /********************************************************/ - while (addr & CLOFSET) - *(char *)addr++ = 0; - - printf("data=0x%x ", head.a_data); - xread(addr, head.a_data); - addr += head.a_data; - - /********************************************************/ - /* Skip over the uninitialised data */ - /* (but clear it) */ - /********************************************************/ - printf("bss=0x%x ", head.a_bss); - if( (addr < ouraddr) && ((addr + head.a_bss) > ouraddr)) - { - pbzero(addr,ouraddr - (int)addr); - } - else - { - pbzero(addr,head.a_bss); - } - argv[3] = (addr += head.a_bss); - -#ifdef LOADSYMS /* not yet, haven't worked this out yet */ - if (addr > 0x100000) - { - /********************************************************/ - /*copy in the symbol header */ - /********************************************************/ - pcpy(&head.a_syms, addr, sizeof(head.a_syms)); - addr += sizeof(head.a_syms); - - /********************************************************/ - /* READ in the symbol table */ - /********************************************************/ - printf("symbols=[+0x%x", head.a_syms); - xread(addr, head.a_syms); - addr += head.a_syms; - - /********************************************************/ - /* Followed by the next integer (another header) */ - /* more debug symbols? */ - /********************************************************/ - read(&i, sizeof(int)); - pcpy(&i, addr, sizeof(int)); - i -= sizeof(int); - addr += sizeof(int); - - - /********************************************************/ - /* and that many bytes of (debug symbols?) */ - /********************************************************/ - printf("+0x%x] ", i); - xread(addr, i); - addr += i; - } -#endif LOADSYMS - /********************************************************/ - /* and note the end address of all this */ - /********************************************************/ - - argv[4] = ((addr+sizeof(int)-1))&~(sizeof(int)-1); - printf("total=0x%x ",argv[4]); - - - /* - * We now pass the various bootstrap parameters to the loaded - * image via the argument list - * (THIS IS A BIT OF HISTORY FROM MACH.. LEAVE FOR NOW) - * arg1 = boot flags - * arg2 = boot device - * arg3 = start of symbol table (0 if not loaded) - * arg4 = end of symbol table (0 if not loaded) - * arg5 = transfer address from image - * arg6 = transfer address for next image pointer - */ - switch(maj) - { - case 2: - printf("\n\nInsert file system floppy in drive A or B\n"); - printf("Press 'A', 'B' or any other key for the default "); - printf("%c: ", unit+'A'); - i = getchar(); - switch (i) { - case '0': case 'A': case 'a': - unit = 0; - break; - case '1': case 'B': case 'b': - unit = 1; - break; - } - printf("\n"); - break; - case 4: - break; - } - argv[1] = howto; - argv[2] = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ; - argv[5] = (head.a_entry &= 0xfffffff); - argv[6] = (int) &x_entry; - argv[0] = 8; - /****************************************************************/ - /* copy that first page and overwrite any BIOS variables */ - /****************************************************************/ - printf("entry point=0x%x\n" ,((int)startaddr) & 0xffffff); - /* Under no circumstances overwrite precious BIOS variables! */ - pcpy(tmpbuf, addr0, 0x400); - pcpy(tmpbuf + 0x500, addr0 + 0x500, 4096 - 0x500); - startprog(((int)startaddr & 0xffffff),argv); -} - -char namebuf[100]; -getbootdev(howto) - int *howto; -{ - char c, *ptr = namebuf; - printf("Boot: [[[%s(%d,%c)]%s][-s][-a][-d]] :- " - , devs[maj] - , unit - , 'a'+part - , name); - if (gets(namebuf)) { - while (c=*ptr) { - while (c==' ') - c = *++ptr; - if (!c) - return; - if (c=='-') - while ((c = *++ptr) && c!=' ') - switch (c) { - case 'a': - *howto |= RB_ASKNAME; continue; - case 's': - *howto |= RB_SINGLE; continue; - case 'd': - *howto |= RB_KDB; continue; - case 'b': - *howto |= RB_HALT; continue; - } - else { - name = ptr; - while ((c = *++ptr) && c!=' '); - if (c) - *ptr++ = 0; - } - } - } else - printf("\n"); -} - diff --git a/sys/i386/boot/biosboot/boot.h b/sys/i386/boot/biosboot/boot.h deleted file mode 100644 index f77f882..0000000 --- a/sys/i386/boot/biosboot/boot.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:03 rpd - * $Id$ - */ - -#include -#include -#include -#include -#include - -extern char *devs[], *name, *iodest; -extern struct fs *fs; -extern struct inode inode; -extern int dosdev, unit, part, maj, boff, poff, bnum, cnt; -extern long int ouraddr; diff --git a/sys/i386/boot/biosboot/boot2.S b/sys/i386/boot/biosboot/boot2.S deleted file mode 100644 index 2569dd2..0000000 --- a/sys/i386/boot/biosboot/boot2.S +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:26 rpd - * $Id$ - */ - -#include "asm.h" - -/* Conventional GDT indexes. */ -#define BOOT_CS_INDEX 3 -#define BOOT_CS16_INDEX 5 -#define BOOT_DS_INDEX 4 -#define DB_CS_INDEX 14 -#define DB_CS16_INDEX 15 -#define DB_DS_INDEX 16 -#define GDT_INDEX 17 - -/* Vector numbers. */ -#define BREAKPOINT_VECTOR 3 -#define DEBUG_VECTOR 1 - -/* - * boot2() -- second stage boot - */ - -.globl EXT(ouraddr) - -ENTRY(boot2) - data32 - subl %eax, %eax - mov %cs, %ax - mov %ax, %ds - mov %ax, %es - data32 - shll $4, %eax - addr32 - data32 - movl %eax, EXT(ouraddr) - - /* fix up GDT entries for bootstrap */ -#define FIXUP(gdt_index) \ - addr32; \ - movl %eax, EXT(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \ - addr32; \ - movb %bl, EXT(Gdt)+(8*gdt_index)+4 - - data32 - shld $16, %eax, %ebx - FIXUP(BOOT_CS_INDEX) - FIXUP(BOOT_CS16_INDEX) - FIXUP(BOOT_DS_INDEX) - - /* fix up GDT entry for GDT, and GDT and IDT pointers */ - data32 - movl %eax, %ecx - data32 - addl $ EXT(Gdt), %eax - data32 - shld $16, %eax, %ebx - FIXUP(GDT_INDEX) - addr32 - data32 - movl %eax, EXT(Gdtr)+2 - data32 - addl $ EXT(Idt), %ecx - addr32 - data32 - movl %ecx, EXT(Idtr_prot)+2 - - /* %es = vector table segment for a while */ - push %es - data32 - subl %eax, %eax - mov %ax, %es - - /* fix up GDT entries for bdb */ - data32 - movl $4*DEBUG_VECTOR, %esi - addr32 - movl %es: 2(%esi), %eax /* actually movw to %ax */ - data32 - shll $4, %eax - data32 - shld $16, %eax, %ebx - FIXUP(DB_CS_INDEX) - FIXUP(DB_CS16_INDEX) - FIXUP(DB_DS_INDEX) - - /* Fetch entry points of bdb's protected mode trap handlers. These - * are stored at 2 before the corresponding entry points for real mode. - */ - data32 - subl %ebx, %ebx - addr32 - movl %es: (%esi), %ebx /* actually movw to %bx */ - data32 - subl %ecx, %ecx - addr32 - movl %es: 4*(BREAKPOINT_VECTOR-DEBUG_VECTOR)(%esi), %ecx - /* actually movw to %cx */ - - /* %es = bdb segment for a while */ - data32 - shrl $4, %eax - mov %ax, %es - - /* fix up IDT entries for bdb */ - movl %es: -2(%ebx), %eax /* actually movw to %ax */ - addr32 - movl %eax, EXT(Idt)+8*DEBUG_VECTOR /* actually movw %ax */ - movl %es: -2(%ecx), %eax /* actually movw to %ax */ - addr32 - movl %eax, EXT(Idt)+8*BREAKPOINT_VECTOR /* actually movw %ax */ - - /* finished with groping in real mode segments */ - pop %es - - /* change to protected mode */ - data32 - call EXT(real_to_prot) - - /* clear the bss */ - movl $ EXT(edata), %edi /* no EXT(_edata) - krufty ld */ - movl $ EXT(end), %ecx /* or EXT(_end) */ - subl %edi, %ecx - subb %al, %al - rep - stosb - - movzbl %dl, %edx /* discard head (%dh) and random high bits */ - pushl %edx - call EXT(boot) -oops: - hlt - jmp oops - - .data - .align 2 -#if 0 /* XXX this would give losing "_ouraddr :". Better declared in C */ -EXT(ouraddr): -#else -_ouraddr: -#endif - .long 0 diff --git a/sys/i386/boot/biosboot/disk.c b/sys/i386/boot/biosboot/disk.c deleted file mode 100644 index a8d1602..0000000 --- a/sys/i386/boot/biosboot/disk.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd - * $Id$ - */ - -#include "boot.h" -#ifdef DO_BAD144 -#include -#endif DO_BAD144 -#include - -#define BIOS_DEV_FLOPPY 0x0 -#define BIOS_DEV_WIN 0x80 - -#define BPS 512 -#define SPT(di) ((di)&0xff) -#define HEADS(di) ((((di)>>8)&0xff)+1) - -char *devs[] = {"wd", "hd", "fd", "wt", "sd", 0}; - -#ifdef DO_BAD144 -struct dkbad dkb; -int do_bad144; -int bsize; -#endif DO_BAD144 - -int spt, spc; - -char *iodest; -struct fs *fs; -struct inode inode; -int dosdev, unit, part, maj, boff, poff, bnum, cnt; - -/*#define EMBEDDED_DISKLABEL 1*/ -extern struct disklabel disklabel; -/*struct disklabel disklabel;*/ - -devopen() -{ - struct dos_partition *dptr; - struct disklabel *dl; - int dosdev = inode.i_dev; - int i, sector, di; - - di = get_diskinfo(dosdev); - spc = (spt = SPT(di)) * HEADS(di); - if (dosdev == 2) - { - boff = 0; - part = (spt == 15 ? 3 : 1); - } - else - { -#ifdef EMBEDDED_DISKLABEL - dl = &disklabel; -#else EMBEDDED_DISKLABEL - Bread(dosdev, 0); - dptr = (struct dos_partition *)(((char *)0)+DOSPARTOFF); - for (i = 0; i < NDOSPART; i++, dptr++) - if (dptr->dp_typ == DOSPTYP_386BSD) - break; - sector = dptr->dp_start + LABELSECTOR; - Bread(dosdev, sector++); - dl=((struct disklabel *)0); - disklabel = *dl; /* structure copy (maybe useful later)*/ -#endif EMBEDDED_DISKLABEL - if (dl->d_magic != DISKMAGIC) { - printf("bad disklabel"); - return 1; - } - if( (maj == 4) || (maj == 0) || (maj == 1)) - { - if (dl->d_type == DTYPE_SCSI) - { - maj = 4; /* use scsi as boot dev */ - } - else - { - maj = 0; /* must be ESDI/IDE */ - } - } - boff = dl->d_partitions[part].p_offset; -#ifdef DO_BAD144 - bsize = dl->d_partitions[part].p_size; - do_bad144 = 0; - if (dl->d_flags & D_BADSECT) { - /* this disk uses bad144 */ - int i; - int dkbbnum; - struct dkbad *dkbptr; - - /* find the first readable bad144 sector */ - /* some of this code is copied from ufs/disk_subr.c */ - /* read a bad sector table */ - dkbbnum = dl->d_secperunit - dl->d_nsectors; - if (dl->d_secsize > DEV_BSIZE) - dkbbnum *= dl->d_secsize / DEV_BSIZE; - else - dkbbnum /= DEV_BSIZE / dl->d_secsize; - i = 0; - do_bad144 = 0; - do { - /* XXX: what if the "DOS sector" < 512 bytes ??? */ - Bread(dosdev, dkbbnum + i); - dkbptr = (struct dkbad *) 0; -/* XXX why is this not in ??? */ -#define DKBAD_MAGIC 0x4321 - if (dkbptr->bt_mbz == 0 && - dkbptr->bt_flag == DKBAD_MAGIC) { - dkb = *dkbptr; /* structure copy */ - do_bad144 = 1; - break; - } - i += 2; - } while (i < 10 && i < dl->d_nsectors); - if (!do_bad144) - printf("Bad badsect table\n"); - else - printf("Using bad144 bad sector at %d\n", dkbbnum+i); - } -#endif DO_BAD144 - } - return 0; -} - -devread() -{ - int offset, sector = bnum; - int dosdev = inode.i_dev; - for (offset = 0; offset < cnt; offset += BPS) - { - Bread(dosdev, badsect(dosdev, sector++)); - bcopy(0, iodest+offset, BPS); - } -} - -#define I_ADDR ((void *) 0) /* XXX where all reads go */ - -/* Read ahead buffer large enough for one track on a 1440K floppy. For - * reading from floppies, the bootstrap has to be loaded on a 64K boundary - * to ensure that this buffer doesn't cross a 64K DMA boundary. - */ -#define RA_SECTORS 18 -static char ra_buf[RA_SECTORS * BPS]; -static int ra_end; -static int ra_first; - -Bread(dosdev,sector) - int dosdev,sector; -{ - if (sector < ra_first || sector >= ra_end) - { - int cyl, head, sec, nsec; - - cyl = sector/spc; - head = (sector % spc) / spt; - sec = sector % spt; - nsec = spt - sec; - if (nsec > RA_SECTORS) - nsec = RA_SECTORS; - twiddle(); - if (biosread(dosdev, cyl, head, sec, nsec, ra_buf) != 0) - { - nsec = 1; - twiddle(); - while (biosread(dosdev, cyl, head, sec, nsec, ra_buf) != 0) { - printf("Error: C:%d H:%d S:%d\n", cyl, head, sec); - twiddle(); - } - } - ra_first = sector; - ra_end = sector + nsec; - } - bcopy(ra_buf + (sector - ra_first) * BPS, I_ADDR, BPS); -} - -badsect(dosdev, sector) - int dosdev, sector; -{ - int i; -#ifdef DO_BAD144 - if (do_bad144) { - u_short cyl; - u_short head; - u_short sec; - int newsec; - struct disklabel *dl = &disklabel; - - /* XXX */ - /* from wd.c */ - /* bt_cyl = cylinder number in sorted order */ - /* bt_trksec is actually (head << 8) + sec */ - - /* only remap sectors in the partition */ - if (sector < boff || sector >= boff + bsize) { - goto no_remap; - } - - cyl = sector / dl->d_secpercyl; - head = (sector % dl->d_secpercyl) / dl->d_nsectors; - sec = sector % dl->d_nsectors; - sec = (head<<8) + sec; - - /* now, look in the table for a possible bad sector */ - for (i=0; i<126; i++) { - if (dkb.bt_bad[i].bt_cyl == cyl) { - /* found same cylinder */ - if (dkb.bt_bad[i].bt_trksec == sec) { - /* FOUND! */ - break; - } - } else if (dkb.bt_bad[i].bt_cyl > cyl) { - i = 126; - break; - } - } - if (i == 126) { - /* didn't find bad sector */ - goto no_remap; - } - /* otherwise find replacement sector */ - newsec = dl->d_secperunit - dl->d_nsectors - i -1; - return newsec; - } -#endif DO_BAD144 - no_remap: - return sector; -} diff --git a/sys/i386/boot/biosboot/io.c b/sys/i386/boot/biosboot/io.c deleted file mode 100644 index 6a5a58a..0000000 --- a/sys/i386/boot/biosboot/io.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:57 rpd - * $Id$ - */ - -#include - -#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */ -#define K_STATUS 0x64 /* keyboard status */ -#define K_CMD 0x64 /* keybd ctlr command (write-only) */ - -#define K_OBUF_FUL 0x01 /* output buffer full */ -#define K_IBUF_FUL 0x02 /* input buffer full */ - -#define KC_CMD_WIN 0xd0 /* read output port */ -#define KC_CMD_WOUT 0xd1 /* write output port */ -#define KB_A20 0x9f /* enable A20, - enable output buffer full interrupt - enable data line - disable clock line */ - -/* - * Gate A20 for high memory - */ -unsigned char x_20 = KB_A20; -gateA20() -{ -#ifdef IBM_L40 - outb(0x92, 0x2); -#else IBM_L40 - while (inb(K_STATUS) & K_IBUF_FUL); - while (inb(K_STATUS) & K_OBUF_FUL) - (void)inb(K_RDWR); - - outb(K_CMD, KC_CMD_WOUT); - while (inb(K_STATUS) & K_IBUF_FUL); - outb(K_RDWR, x_20); - while (inb(K_STATUS) & K_IBUF_FUL); -#endif IBM_L40 -} - -/* printf - only handles %d as decimal, %c as char, %s as string */ - -printf(format,data) - char *format; - int data; -{ - int *dataptr = &data; - char c; - - reset_twiddle(); - while (c = *format++) - if (c != '%') - putchar(c); - else - switch (c = *format++) { - case 'd': { - int num = *dataptr++; - char buf[10], *ptr = buf; - if (num<0) { - num = -num; - putchar('-'); - } - do - *ptr++ = '0'+num%10; - while (num /= 10); - do - putchar(*--ptr); - while (ptr != buf); - break; - } - case 'x': { - int num = *dataptr++, dig; - char buf[8], *ptr = buf; - do - *ptr++ = (dig=(num&0xf)) > 9? - 'a' + dig - 10 : - '0' + dig; - while (num >>= 4); - do - putchar(*--ptr); - while (ptr != buf); - break; - } - case 'c': putchar((*dataptr++)&0xff); break; - case 's': { - char *ptr = (char *)*dataptr++; - while (c = *ptr++) - putchar(c); - break; - } - } -} - -putchar(c) -{ - if (c == '\n') - putc('\r'); - putc(c); -} - -getchar() -{ - int c; - - if ((c=getc()) == '\r') - c = '\n'; - if (c == '\b') { - putchar('\b'); - putchar(' '); - } - putchar(c); - return(c); -} - -gets(buf) -char *buf; -{ - int i; - char *ptr=buf; - - for (i = 240000; i>0; i--) - if (ischar()) - for (;;) - switch(*ptr = getchar() & 0xff) { - case '\n': - case '\r': - *ptr = '\0'; - return 1; - case '\b': - if (ptr > buf) ptr--; - continue; - default: - ptr++; - } - return 0; -} - -strcmp(s1, s2) -char *s1, *s2; -{ - while (*s1 == *s2) { - if (!*s1++) - return 0; - s2++; - } - return 1; -} - -bcopy(from, to, len) -char *from, *to; -int len; -{ - while (len-- > 0) - *to++ = *from++; -} - -static int tw_on; -static int tw_pos; -static char tw_chars[] = "|/-\\"; - -reset_twiddle() -{ - if (tw_on) - putchar('\b'); - tw_on = 0; - tw_pos = 0; -} - -twiddle() -{ - if (tw_on) - putchar('\b'); - else - tw_on = 1; - putchar(tw_chars[tw_pos++]); - tw_pos %= (sizeof(tw_chars) - 1); -} diff --git a/sys/i386/boot/biosboot/start.S b/sys/i386/boot/biosboot/start.S deleted file mode 100644 index 62b93ac..0000000 --- a/sys/i386/boot/biosboot/start.S +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:29 rpd - * $Id$ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -#include "asm.h" - - .file "start.s" - -BOOTSEG = 0x9000 # boot will be loaded here (below 640K) -BOOTSTACK = 0xe000 # boot stack -SIGNATURE = 0xaa55 -LOADSZ = 15 # size of unix boot -PARTSTART = 0x1be # starting address of partition table -NUMPART = 4 # number of partitions in partition table -PARTSZ = 16 # each partition table entry is 16 bytes -BSDPART = 0xA5 # value of boot_ind, means bootable partition -BOOTABLE = 0x80 # value of boot_ind, means bootable partition - - .text - -ENTRY(boot1) - # start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 - # ljmp to the next instruction to adjust %cs - data32 - ljmp $0x7c0, $start - -start: - # set up %ds - mov %cs, %ax - mov %ax, %ds - - # set up %ss and %esp - data32 - mov $BOOTSEG, %eax - mov %ax, %ss - data32 - mov $BOOTSTACK, %esp - - /*** set up %es, (where we will load boot2 to) ***/ - mov %ax, %es - -#ifdef DEBUG - data32 - mov $one, %esi - data32 - call message -#endif - - # bootstrap passes us drive number in %dl - cmpb $0x80, %dl - data32 - jae hd - -fd: -# reset the disk system -#ifdef DEBUG - data32 - mov $two, %esi - data32 - call message -#endif - movb $0x0, %ah - int $0x13 - data32 - mov $0x0001, %ecx # cyl 0, sector 1 - movb $0, %dh # head -#ifdef DEBUG - data32 - mov $three, %esi - data32 - call message -#endif - data32 - jmp load - -hd: /**** load sector 0 into the BOOTSEG ****/ -#ifdef DEBUG - data32 - mov $four, %esi - data32 - call message -#endif - data32 - mov $0x0201, %eax - xor %ebx, %ebx # %bx = 0 - data32 - mov $0x0001, %ecx -#ifdef DEBUG - data32 - mov $five, %esi - data32 - call message -#endif - data32 - andl $0xff, %edx - /*mov $0x0080, %edx*/ - int $0x13 - data32 - jb read_error - - /***# find the first 386BSD partition *****/ - data32 - mov $PARTSTART, %ebx - data32 - mov $NUMPART, %ecx -again: - addr32 - movb %es:4(%ebx), %al - cmpb $BSDPART, %al - data32 - je found - data32 - add $PARTSZ, %ebx - data32 - loop again - data32 - mov $enoboot, %esi - data32 - jmp err_stop - - -/* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -found: - addr32 - movb %es:1(%ebx), %dh /* head */ - addr32 - movl %es:2(%ebx), %ecx /*sect, cyl (+ 2 bytes junk in top word) */ - -load: - movb $0x2, %ah /* function 2 */ - movb $LOADSZ, %al /* number of blocks */ - xor %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */ - int $0x13 - data32 - jb read_error - - # ljmp to the second stage boot loader (boot2). - # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - # as an internal buffer "intbuf". - -#ifdef DEBUG - data32 - mov $six, %esi - data32 - call message -#endif - data32 - ljmp $BOOTSEG, $ EXT(boot2) - -# -# read_error -# - -read_error: - data32 - mov $eread, %esi -err_stop: - data32 - call message - data32 - jmp stop - -# -# message: write the error message in %ds:%esi to console -# - -message: -/* - # Use BIOS "int 10H Function 0Eh" to write character in teletype mode - # %ah = 0xe %al = character - # %bh = page %bl = foreground color (graphics modes) -*/ - - data32 - push %eax - data32 - push %ebx - data32 - mov $0x0001, %ebx - cld - -nextb: - lodsb # load a byte into %al - cmpb $0x0, %al - data32 - je done - movb $0xe, %ah - int $0x10 # display a byte - data32 - jmp nextb -done: - data32 - pop %ebx - data32 - pop %eax - data32 - ret - -stop: hlt - data32 - jmp stop # halt doesnt actually halt forever - -/* error messages */ - -#ifdef DEBUG -one: String "1\r\n\0" -two: String "2\r\n\0" -three: String "3\r\n\0" -four: String "4\r\n\0" -five: String "5\r\n\0" -six: String "6\r\n\0" -seven: String "7\r\n\0" -#endif DEBUG -eread: String "Read error\r\n\0" -enoboot: String "No bootable partition\r\n\0" -endofcode: -/* throw in a partition in case we are block0 as well */ -/* flag, head, sec, cyl, typ, ehead, esect, ecyl, start, len */ - . = EXT(boot1) + PARTSTART - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte BOOTABLE,0,1,0,BSDPART,255,255,255 - .long 0,50000 -/* the last 2 bytes in the sector 0 contain the signature */ - . = EXT(boot1) + 0x1fe - .value SIGNATURE -ENTRY(disklabel) - . = EXT(boot1) + 0x400 diff --git a/sys/i386/boot/biosboot/sys.c b/sys/i386/boot/biosboot/sys.c deleted file mode 100644 index 4ffe171..0000000 --- a/sys/i386/boot/biosboot/sys.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:34 rpd - * $Id$ - */ - -#include "boot.h" -#include -#include - -/* #define BUFSIZE 4096 */ -#define BUFSIZE MAXBSIZE - -char buf[BUFSIZE], fsbuf[SBSIZE], iobuf[MAXBSIZE]; - -int xread(addr, size) - char * addr; - int size; -{ - int count = BUFSIZE; - while (size > 0) { - if (BUFSIZE > size) - count = size; - read(buf, count); - pcpy(buf, addr, count); - size -= count; - addr += count; - } -} - -read(buffer, count) - int count; - char *buffer; -{ - int logno, off, size; - int cnt2, bnum2; - - while (count) { - off = blkoff(fs, poff); - logno = lblkno(fs, poff); - cnt2 = size = blksize(fs, &inode, logno); - bnum2 = fsbtodb(fs, block_map(logno)) + boff; - cnt = cnt2; - bnum = bnum2; - if ( (!off) && (size <= count)) - { - iodest = buffer; - devread(); - } - else - { - iodest = iobuf; - size -= off; - if (size > count) - size = count; - devread(); - bcopy(iodest+off,buffer,size); - } - buffer += size; - count -= size; - poff += size; - } -} - -find(path) - char *path; -{ - char *rest, ch; - int block, off, loc, ino = ROOTINO; - struct direct *dp; -loop: iodest = iobuf; - cnt = fs->fs_bsize; - bnum = fsbtodb(fs,itod(fs,ino)) + boff; - devread(); - bcopy(&((struct dinode *)iodest)[ino % fs->fs_inopb], - &inode.i_din, - sizeof (struct dinode)); - if (!*path) - return 1; - while (*path == '/') - path++; - if (!inode.i_size || ((inode.i_mode&IFMT) != IFDIR)) - return 0; - for (rest = path; (ch = *rest) && ch != '/'; rest++) ; - *rest = 0; - loc = 0; - do { - if (loc >= inode.i_size) - return 0; - if (!(off = blkoff(fs, loc))) { - block = lblkno(fs, loc); - cnt = blksize(fs, &inode, block); - bnum = fsbtodb(fs, block_map(block)) + boff; - iodest = iobuf; - devread(); - } - dp = (struct direct *)(iodest + off); - loc += dp->d_reclen; - } while (!dp->d_ino || strcmp(path, dp->d_name)); - ino = dp->d_ino; - *(path = rest) = ch; - goto loop; -} - -char mapbuf[MAXBSIZE]; -int mapblock = 0; - -block_map(file_block) - int file_block; -{ - if (file_block < NDADDR) - return(inode.i_db[file_block]); - if ((bnum=fsbtodb(fs, inode.i_ib[0])+boff) != mapblock) { - iodest = mapbuf; - cnt = fs->fs_bsize; - devread(); - mapblock = bnum; - } - return (((int *)mapbuf)[(file_block - NDADDR) % NINDIR(fs)]); -} - -openrd() -{ - char **devp, *cp = name; - /*******************************************************\ - * If bracket given look for preceding device name * - \*******************************************************/ - while (*cp && *cp!='(') - cp++; - if (!*cp) - { - cp = name; - } - else - { - if (cp++ != name) - { - for (devp = devs; *devp; devp++) - if (name[0] == (*devp)[0] && - name[1] == (*devp)[1]) - break; - if (!*devp) - { - printf("Unknown device\n"); - return 1; - } - maj = devp-devs; - } - /*******************************************************\ - * Look inside brackets for unit number, and partition * - \*******************************************************/ - if (*cp >= '0' && *cp <= '9') - if ((unit = *cp++ - '0') > 1) - { - printf("Bad unit\n"); - return 1; - } - if (!*cp || (*cp == ',' && !*++cp)) - return 1; - if (*cp >= 'a' && *cp <= 'p') - part = *cp++ - 'a'; - while (*cp && *cp++!=')') ; - if (!*cp) - return 1; - } - switch(maj) - { - case 1: - dosdev = unit | 0x80; - unit = 0; - break; - case 0: - case 4: - dosdev = unit | 0x80; - break; - case 2: - dosdev = unit; - break; - case 3: - printf("Wangtek unsupported\n"); - return 1; - break; - } - inode.i_dev = dosdev; - /***********************************************\ - * Now we know the disk unit and part, * - * Load disk info, (open the device) * - \***********************************************/ - if (devopen()) - return 1; - - /***********************************************\ - * Load Filesystem info (mount the device) * - \***********************************************/ - iodest = (char *)(fs = (struct fs *)fsbuf); - cnt = SBSIZE; - bnum = SBLOCK + boff; - devread(); - /***********************************************\ - * Find the actual FILE on the mounted device * - \***********************************************/ - if (!find(cp)) - { - return 1; - } - poff = 0; - name = cp; - return 0; -} diff --git a/sys/i386/boot/biosboot/table.c b/sys/i386/boot/biosboot/table.c deleted file mode 100644 index c53173d..0000000 --- a/sys/i386/boot/biosboot/table.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:43 rpd - * $Id$ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -/* Segment Descriptor - * - * 31 24 19 16 7 0 - * ------------------------------------------------------------ - * | | |B| |A| | | |1|0|E|W|A| | - * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 | - * | | |D| |L| 19..16| | |1|1|C|R|A| | - * ------------------------------------------------------------ - * | | | - * | BASE 15..0 | LIMIT 15..0 | - * | | | - * ------------------------------------------------------------ - */ - -struct seg_desc { - unsigned short limit_15_0; - unsigned short base_15_0; - unsigned char base_23_16; - unsigned char p_dpl_type; - unsigned char g_b_a_limit; - unsigned char base_31_24; - }; - -#define RUN 0 /* not really 0, but filled in at boot time */ - -struct seg_desc Gdt[] = { - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* 0x0 : null */ - {0xFFFF, 0x0, 0x0, 0x9F, 0xCF, 0x0}, /* 0x08 : kernel code */ - /* 0x9E? */ - {0xFFFF, 0x0, 0x0, 0x93, 0xCF, 0x0}, /* 0x10 : kernel data */ - /* 0x92? */ - {0xFFFF, RUN, RUN, 0x9E, 0x40, 0x0}, /* 0x18 : boot code */ - {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* 0x20 : boot data */ - {0xFFFF, RUN, RUN, 0x9E, 0x0, 0x0}, /* 0x28 : boot code, 16 bits */ - /* More for bdb. */ - {}, /* BIOS_CS_INDEX = 6 : null */ - {}, /* BIOS_TMP_INDEX = 7 : null */ - {}, /* TSS_INDEX = 8 : null */ - {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* DS_286_INDEX = 9 */ - {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* ES_286_INDEX = 10 */ - {}, /* Unused = 11 : null */ - {0x7FFF, 0x8000, 0xB, 0xB2, 0x40, 0x0}, /* COLOR_INDEX = 12 */ - {0x7FFF, 0x0, 0xB, 0xB2, 0x40, 0x0}, /* MONO_INDEX = 13 */ - {0xFFFF, RUN, RUN, 0x9A, 0x40, 0x0}, /* DB_CS_INDEX = 14 */ - {0xFFFF, RUN, RUN, 0x9A, 0x0, 0x0}, /* DB_CS16_INDEX = 15 */ - {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* DB_DS_INDEX = 16 */ - {8*18-1, RUN, RUN, 0x92, 0x40, 0x0}, /* GDT_INDEX = 17 */ -}; - -struct idt_desc { - unsigned short entry_15_0; - unsigned short selector; - unsigned char padding; - unsigned char p_dpl_type; - unsigned short entry_31_16; -}; - -struct idt_desc Idt[] = { - {}, /* Null (int 0) */ - {RUN, 0x70, 0, 0x8E, 0}, /* DEBUG_VECTOR = 1 */ - {}, /* Null (int 2) */ - {RUN, 0x70, 0, 0xEE, 0}, /* BREAKPOINT_VECTOR = 3 */ -}; - -struct pseudo_desc { - unsigned short limit; - unsigned short base_low; - unsigned short base_high; - }; - -struct pseudo_desc Gdtr = { sizeof Gdt - 1, RUN, RUN }; -struct pseudo_desc Idtr_prot = { sizeof Idt - 1, RUN, RUN }; -struct pseudo_desc Idtr_real = { 0x400 - 1, 0x0, 0x0 }; diff --git a/sys/i386/boot/boot.c b/sys/i386/boot/boot.c deleted file mode 100644 index 1e15ab7..0000000 --- a/sys/i386/boot/boot.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, [92/04/03 16:51:14 rvb] - * $Id: boot.c,v 1.7 1993/10/15 12:33:03 rgrimes Exp $ - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include -#include "boot.h" -#include -#include - -struct exec head; -int argv[10], esym; -char *name; -char *names[] = { - "/386bsd", "/o386bsd", "/386bsd.old", - "/vmunix", "/ovmunix", "/vmunix.old" -}; -#define NUMNAMES (sizeof(names)/sizeof(char *)) - -extern int end; -boot(drive) -int drive; -{ - int loadflags, currname = 0; - char *t; - - printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory [%s]\n", - ouraddr, - argv[7] = memsize(0), - argv[8] = memsize(1), - "$Revision: 1.7 $"); - printf("use hd(1,a)/386bsd to boot sd0 when wd0 is also installed\n"); - gateA20(); -loadstart: - /***************************************************************\ - * As a default set it to the first partition of the first * - * floppy or hard drive * - \***************************************************************/ - part = unit = 0; - maj = (drive&0x80 ? 0 : 2); /* a good first bet */ - name = names[currname++]; - - loadflags = 0; - if (currname == NUMNAMES) - currname = 0; - getbootdev(&loadflags); - if (openrd()) { - printf("Can't find %s\n", name); - goto loadstart; - } -/* if (inode.i_mode&IEXEC) - loadflags |= RB_KDB; -*/ - loadprog(loadflags); - goto loadstart; -} - -loadprog(howto) - int howto; -{ - long int startaddr; - long int addr; /* physical address.. not directly useable */ - long int addr0; - int i; - static int (*x_entry)() = 0; - unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ - - argv[3] = 0; - argv[4] = 0; - read(&head, sizeof(head)); - if ( N_BADMAG(head)) { - printf("Invalid format!\n"); - return; - } - - poff = N_TXTOFF(head); - /*if(poff==0) - poff = 32;*/ - - startaddr = (int)head.a_entry; - addr = (startaddr & 0x00ffffff); /* some MEG boundary */ - addr0 = addr; - printf("Booting %s(%d,%c)%s @ 0x%x\n" - , devs[maj] - , unit - , 'a'+part - , name - , addr); - if(addr < ouraddr) - { - if((addr + head.a_text + head.a_data) > ouraddr) - { - printf("kernel will not fit below loader\n"); - return; - } - if((addr + head.a_text + head.a_data + head.a_bss) > 0xa0000) - { - printf("kernel too big, won't fit in 640K with bss\n"); - printf("Only hope is to link the kernel for > 1MB\n"); - return; - } - } - printf("text=0x%x ", head.a_text); - /********************************************************/ - /* LOAD THE TEXT SEGMENT */ - /* don't clobber the first 4k yet (BIOS NEEDS IT) */ - /********************************************************/ - read(tmpbuf,4096); - addr += 4096; - xread(addr, head.a_text - 4096); - addr += head.a_text - 4096; - - /********************************************************/ - /* Load the Initialised data after the text */ - /********************************************************/ - while (addr & CLOFSET) - *(char *)addr++ = 0; - - printf("data=0x%x ", head.a_data); - xread(addr, head.a_data); - addr += head.a_data; - - /********************************************************/ - /* Skip over the uninitialised data */ - /* (but clear it) */ - /********************************************************/ - printf("bss=0x%x ", head.a_bss); - if( (addr < ouraddr) && ((addr + head.a_bss) > ouraddr)) - { - pbzero(addr,ouraddr - (int)addr); - } - else - { - pbzero(addr,head.a_bss); - } - argv[3] = (addr += head.a_bss); - -#ifdef LOADSYMS /* not yet, haven't worked this out yet */ - if (addr > 0x100000) - { - /********************************************************/ - /*copy in the symbol header */ - /********************************************************/ - pcpy(&head.a_syms, addr, sizeof(head.a_syms)); - addr += sizeof(head.a_syms); - - /********************************************************/ - /* READ in the symbol table */ - /********************************************************/ - printf("symbols=[+0x%x", head.a_syms); - xread(addr, head.a_syms); - addr += head.a_syms; - - /********************************************************/ - /* Followed by the next integer (another header) */ - /* more debug symbols? */ - /********************************************************/ - read(&i, sizeof(int)); - pcpy(&i, addr, sizeof(int)); - i -= sizeof(int); - addr += sizeof(int); - - - /********************************************************/ - /* and that many bytes of (debug symbols?) */ - /********************************************************/ - printf("+0x%x] ", i); - xread(addr, i); - addr += i; - } -#endif LOADSYMS - /********************************************************/ - /* and note the end address of all this */ - /********************************************************/ - - argv[4] = ((addr+sizeof(int)-1))&~(sizeof(int)-1); - printf("total=0x%x ",argv[4]); - - - /* - * We now pass the various bootstrap parameters to the loaded - * image via the argument list - * (THIS IS A BIT OF HISTORY FROM MACH.. LEAVE FOR NOW) - * arg1 = boot flags - * arg2 = boot device - * arg3 = start of symbol table (0 if not loaded) - * arg4 = end of symbol table (0 if not loaded) - * arg5 = transfer address from image - * arg6 = transfer address for next image pointer - */ - switch(maj) - { - case 2: - printf("\n\nInsert file system floppy in drive A or B\n"); - printf("Press 'A', 'B' or any other key for the default "); - printf("%c: ", unit+'A'); - i = getchar(); - switch (i) { - case '0': case 'A': case 'a': - unit = 0; - break; - case '1': case 'B': case 'b': - unit = 1; - break; - } - printf("\n"); - break; - case 4: - break; - } - argv[1] = howto; - argv[2] = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ; - argv[5] = (head.a_entry &= 0xfffffff); - argv[6] = (int) &x_entry; - argv[0] = 8; - /****************************************************************/ - /* copy that first page and overwrite any BIOS variables */ - /****************************************************************/ - printf("entry point=0x%x\n" ,((int)startaddr) & 0xffffff); - /* Under no circumstances overwrite precious BIOS variables! */ - pcpy(tmpbuf, addr0, 0x400); - pcpy(tmpbuf + 0x500, addr0 + 0x500, 4096 - 0x500); - startprog(((int)startaddr & 0xffffff),argv); -} - -char namebuf[100]; -getbootdev(howto) - int *howto; -{ - char c, *ptr = namebuf; - printf("Boot: [[[%s(%d,%c)]%s][-s][-a][-d]] :- " - , devs[maj] - , unit - , 'a'+part - , name); - if (gets(namebuf)) { - while (c=*ptr) { - while (c==' ') - c = *++ptr; - if (!c) - return; - if (c=='-') - while ((c = *++ptr) && c!=' ') - switch (c) { - case 'a': - *howto |= RB_ASKNAME; continue; - case 's': - *howto |= RB_SINGLE; continue; - case 'd': - *howto |= RB_KDB; continue; - case 'b': - *howto |= RB_HALT; continue; - } - else { - name = ptr; - while ((c = *++ptr) && c!=' '); - if (c) - *ptr++ = 0; - } - } - } else - printf("\n"); -} - diff --git a/sys/i386/boot/boot.h b/sys/i386/boot/boot.h deleted file mode 100644 index f77f882..0000000 --- a/sys/i386/boot/boot.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:03 rpd - * $Id$ - */ - -#include -#include -#include -#include -#include - -extern char *devs[], *name, *iodest; -extern struct fs *fs; -extern struct inode inode; -extern int dosdev, unit, part, maj, boff, poff, bnum, cnt; -extern long int ouraddr; diff --git a/sys/i386/boot/boot.sed b/sys/i386/boot/boot.sed deleted file mode 100644 index c6b38ea..0000000 --- a/sys/i386/boot/boot.sed +++ /dev/null @@ -1,3 +0,0 @@ -/^[ ]*.data/c\ - .text -/^[ ]*.ident/d diff --git a/sys/i386/boot/boot2.S b/sys/i386/boot/boot2.S deleted file mode 100644 index 2569dd2..0000000 --- a/sys/i386/boot/boot2.S +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:26 rpd - * $Id$ - */ - -#include "asm.h" - -/* Conventional GDT indexes. */ -#define BOOT_CS_INDEX 3 -#define BOOT_CS16_INDEX 5 -#define BOOT_DS_INDEX 4 -#define DB_CS_INDEX 14 -#define DB_CS16_INDEX 15 -#define DB_DS_INDEX 16 -#define GDT_INDEX 17 - -/* Vector numbers. */ -#define BREAKPOINT_VECTOR 3 -#define DEBUG_VECTOR 1 - -/* - * boot2() -- second stage boot - */ - -.globl EXT(ouraddr) - -ENTRY(boot2) - data32 - subl %eax, %eax - mov %cs, %ax - mov %ax, %ds - mov %ax, %es - data32 - shll $4, %eax - addr32 - data32 - movl %eax, EXT(ouraddr) - - /* fix up GDT entries for bootstrap */ -#define FIXUP(gdt_index) \ - addr32; \ - movl %eax, EXT(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \ - addr32; \ - movb %bl, EXT(Gdt)+(8*gdt_index)+4 - - data32 - shld $16, %eax, %ebx - FIXUP(BOOT_CS_INDEX) - FIXUP(BOOT_CS16_INDEX) - FIXUP(BOOT_DS_INDEX) - - /* fix up GDT entry for GDT, and GDT and IDT pointers */ - data32 - movl %eax, %ecx - data32 - addl $ EXT(Gdt), %eax - data32 - shld $16, %eax, %ebx - FIXUP(GDT_INDEX) - addr32 - data32 - movl %eax, EXT(Gdtr)+2 - data32 - addl $ EXT(Idt), %ecx - addr32 - data32 - movl %ecx, EXT(Idtr_prot)+2 - - /* %es = vector table segment for a while */ - push %es - data32 - subl %eax, %eax - mov %ax, %es - - /* fix up GDT entries for bdb */ - data32 - movl $4*DEBUG_VECTOR, %esi - addr32 - movl %es: 2(%esi), %eax /* actually movw to %ax */ - data32 - shll $4, %eax - data32 - shld $16, %eax, %ebx - FIXUP(DB_CS_INDEX) - FIXUP(DB_CS16_INDEX) - FIXUP(DB_DS_INDEX) - - /* Fetch entry points of bdb's protected mode trap handlers. These - * are stored at 2 before the corresponding entry points for real mode. - */ - data32 - subl %ebx, %ebx - addr32 - movl %es: (%esi), %ebx /* actually movw to %bx */ - data32 - subl %ecx, %ecx - addr32 - movl %es: 4*(BREAKPOINT_VECTOR-DEBUG_VECTOR)(%esi), %ecx - /* actually movw to %cx */ - - /* %es = bdb segment for a while */ - data32 - shrl $4, %eax - mov %ax, %es - - /* fix up IDT entries for bdb */ - movl %es: -2(%ebx), %eax /* actually movw to %ax */ - addr32 - movl %eax, EXT(Idt)+8*DEBUG_VECTOR /* actually movw %ax */ - movl %es: -2(%ecx), %eax /* actually movw to %ax */ - addr32 - movl %eax, EXT(Idt)+8*BREAKPOINT_VECTOR /* actually movw %ax */ - - /* finished with groping in real mode segments */ - pop %es - - /* change to protected mode */ - data32 - call EXT(real_to_prot) - - /* clear the bss */ - movl $ EXT(edata), %edi /* no EXT(_edata) - krufty ld */ - movl $ EXT(end), %ecx /* or EXT(_end) */ - subl %edi, %ecx - subb %al, %al - rep - stosb - - movzbl %dl, %edx /* discard head (%dh) and random high bits */ - pushl %edx - call EXT(boot) -oops: - hlt - jmp oops - - .data - .align 2 -#if 0 /* XXX this would give losing "_ouraddr :". Better declared in C */ -EXT(ouraddr): -#else -_ouraddr: -#endif - .long 0 diff --git a/sys/i386/boot/boot2.s b/sys/i386/boot/boot2.s deleted file mode 100644 index d319edf..0000000 --- a/sys/i386/boot/boot2.s +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - */ - -/* - * HISTORY - * $Log: boot2.s,v $ - * Revision 2.2 92/04/04 11:35:26 rpd - * From 2.5 - * [92/03/30 rvb] - * - * Revision 2.2 91/04/02 14:39:21 mbj - * Put into rcs tree - * [90/02/09 rvb] - * - */ - -#include "asm.h" -#define LOADMSG 1 -/* - * boot2() -- second stage boot - */ - -.globl _ouraddr - -ENTRY(boot2) - movl %cs, %ax - movl %ax, %ds - movl %ax, %es - data32 - sall $4, %eax - data32 - movl %eax, _ouraddr - /* save the drive type and ID */ - data32 - pushl %edx - /* change to protected mode */ - data32 - call _real_to_prot - - call _boot - ret - - .data - .align 2 -_ouraddr: - .long 0 - - diff --git a/sys/i386/boot/disk.c b/sys/i386/boot/disk.c deleted file mode 100644 index a8d1602..0000000 --- a/sys/i386/boot/disk.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd - * $Id$ - */ - -#include "boot.h" -#ifdef DO_BAD144 -#include -#endif DO_BAD144 -#include - -#define BIOS_DEV_FLOPPY 0x0 -#define BIOS_DEV_WIN 0x80 - -#define BPS 512 -#define SPT(di) ((di)&0xff) -#define HEADS(di) ((((di)>>8)&0xff)+1) - -char *devs[] = {"wd", "hd", "fd", "wt", "sd", 0}; - -#ifdef DO_BAD144 -struct dkbad dkb; -int do_bad144; -int bsize; -#endif DO_BAD144 - -int spt, spc; - -char *iodest; -struct fs *fs; -struct inode inode; -int dosdev, unit, part, maj, boff, poff, bnum, cnt; - -/*#define EMBEDDED_DISKLABEL 1*/ -extern struct disklabel disklabel; -/*struct disklabel disklabel;*/ - -devopen() -{ - struct dos_partition *dptr; - struct disklabel *dl; - int dosdev = inode.i_dev; - int i, sector, di; - - di = get_diskinfo(dosdev); - spc = (spt = SPT(di)) * HEADS(di); - if (dosdev == 2) - { - boff = 0; - part = (spt == 15 ? 3 : 1); - } - else - { -#ifdef EMBEDDED_DISKLABEL - dl = &disklabel; -#else EMBEDDED_DISKLABEL - Bread(dosdev, 0); - dptr = (struct dos_partition *)(((char *)0)+DOSPARTOFF); - for (i = 0; i < NDOSPART; i++, dptr++) - if (dptr->dp_typ == DOSPTYP_386BSD) - break; - sector = dptr->dp_start + LABELSECTOR; - Bread(dosdev, sector++); - dl=((struct disklabel *)0); - disklabel = *dl; /* structure copy (maybe useful later)*/ -#endif EMBEDDED_DISKLABEL - if (dl->d_magic != DISKMAGIC) { - printf("bad disklabel"); - return 1; - } - if( (maj == 4) || (maj == 0) || (maj == 1)) - { - if (dl->d_type == DTYPE_SCSI) - { - maj = 4; /* use scsi as boot dev */ - } - else - { - maj = 0; /* must be ESDI/IDE */ - } - } - boff = dl->d_partitions[part].p_offset; -#ifdef DO_BAD144 - bsize = dl->d_partitions[part].p_size; - do_bad144 = 0; - if (dl->d_flags & D_BADSECT) { - /* this disk uses bad144 */ - int i; - int dkbbnum; - struct dkbad *dkbptr; - - /* find the first readable bad144 sector */ - /* some of this code is copied from ufs/disk_subr.c */ - /* read a bad sector table */ - dkbbnum = dl->d_secperunit - dl->d_nsectors; - if (dl->d_secsize > DEV_BSIZE) - dkbbnum *= dl->d_secsize / DEV_BSIZE; - else - dkbbnum /= DEV_BSIZE / dl->d_secsize; - i = 0; - do_bad144 = 0; - do { - /* XXX: what if the "DOS sector" < 512 bytes ??? */ - Bread(dosdev, dkbbnum + i); - dkbptr = (struct dkbad *) 0; -/* XXX why is this not in ??? */ -#define DKBAD_MAGIC 0x4321 - if (dkbptr->bt_mbz == 0 && - dkbptr->bt_flag == DKBAD_MAGIC) { - dkb = *dkbptr; /* structure copy */ - do_bad144 = 1; - break; - } - i += 2; - } while (i < 10 && i < dl->d_nsectors); - if (!do_bad144) - printf("Bad badsect table\n"); - else - printf("Using bad144 bad sector at %d\n", dkbbnum+i); - } -#endif DO_BAD144 - } - return 0; -} - -devread() -{ - int offset, sector = bnum; - int dosdev = inode.i_dev; - for (offset = 0; offset < cnt; offset += BPS) - { - Bread(dosdev, badsect(dosdev, sector++)); - bcopy(0, iodest+offset, BPS); - } -} - -#define I_ADDR ((void *) 0) /* XXX where all reads go */ - -/* Read ahead buffer large enough for one track on a 1440K floppy. For - * reading from floppies, the bootstrap has to be loaded on a 64K boundary - * to ensure that this buffer doesn't cross a 64K DMA boundary. - */ -#define RA_SECTORS 18 -static char ra_buf[RA_SECTORS * BPS]; -static int ra_end; -static int ra_first; - -Bread(dosdev,sector) - int dosdev,sector; -{ - if (sector < ra_first || sector >= ra_end) - { - int cyl, head, sec, nsec; - - cyl = sector/spc; - head = (sector % spc) / spt; - sec = sector % spt; - nsec = spt - sec; - if (nsec > RA_SECTORS) - nsec = RA_SECTORS; - twiddle(); - if (biosread(dosdev, cyl, head, sec, nsec, ra_buf) != 0) - { - nsec = 1; - twiddle(); - while (biosread(dosdev, cyl, head, sec, nsec, ra_buf) != 0) { - printf("Error: C:%d H:%d S:%d\n", cyl, head, sec); - twiddle(); - } - } - ra_first = sector; - ra_end = sector + nsec; - } - bcopy(ra_buf + (sector - ra_first) * BPS, I_ADDR, BPS); -} - -badsect(dosdev, sector) - int dosdev, sector; -{ - int i; -#ifdef DO_BAD144 - if (do_bad144) { - u_short cyl; - u_short head; - u_short sec; - int newsec; - struct disklabel *dl = &disklabel; - - /* XXX */ - /* from wd.c */ - /* bt_cyl = cylinder number in sorted order */ - /* bt_trksec is actually (head << 8) + sec */ - - /* only remap sectors in the partition */ - if (sector < boff || sector >= boff + bsize) { - goto no_remap; - } - - cyl = sector / dl->d_secpercyl; - head = (sector % dl->d_secpercyl) / dl->d_nsectors; - sec = sector % dl->d_nsectors; - sec = (head<<8) + sec; - - /* now, look in the table for a possible bad sector */ - for (i=0; i<126; i++) { - if (dkb.bt_bad[i].bt_cyl == cyl) { - /* found same cylinder */ - if (dkb.bt_bad[i].bt_trksec == sec) { - /* FOUND! */ - break; - } - } else if (dkb.bt_bad[i].bt_cyl > cyl) { - i = 126; - break; - } - } - if (i == 126) { - /* didn't find bad sector */ - goto no_remap; - } - /* otherwise find replacement sector */ - newsec = dl->d_secperunit - dl->d_nsectors - i -1; - return newsec; - } -#endif DO_BAD144 - no_remap: - return sector; -} diff --git a/sys/i386/boot/io.c b/sys/i386/boot/io.c deleted file mode 100644 index 6a5a58a..0000000 --- a/sys/i386/boot/io.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:57 rpd - * $Id$ - */ - -#include - -#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */ -#define K_STATUS 0x64 /* keyboard status */ -#define K_CMD 0x64 /* keybd ctlr command (write-only) */ - -#define K_OBUF_FUL 0x01 /* output buffer full */ -#define K_IBUF_FUL 0x02 /* input buffer full */ - -#define KC_CMD_WIN 0xd0 /* read output port */ -#define KC_CMD_WOUT 0xd1 /* write output port */ -#define KB_A20 0x9f /* enable A20, - enable output buffer full interrupt - enable data line - disable clock line */ - -/* - * Gate A20 for high memory - */ -unsigned char x_20 = KB_A20; -gateA20() -{ -#ifdef IBM_L40 - outb(0x92, 0x2); -#else IBM_L40 - while (inb(K_STATUS) & K_IBUF_FUL); - while (inb(K_STATUS) & K_OBUF_FUL) - (void)inb(K_RDWR); - - outb(K_CMD, KC_CMD_WOUT); - while (inb(K_STATUS) & K_IBUF_FUL); - outb(K_RDWR, x_20); - while (inb(K_STATUS) & K_IBUF_FUL); -#endif IBM_L40 -} - -/* printf - only handles %d as decimal, %c as char, %s as string */ - -printf(format,data) - char *format; - int data; -{ - int *dataptr = &data; - char c; - - reset_twiddle(); - while (c = *format++) - if (c != '%') - putchar(c); - else - switch (c = *format++) { - case 'd': { - int num = *dataptr++; - char buf[10], *ptr = buf; - if (num<0) { - num = -num; - putchar('-'); - } - do - *ptr++ = '0'+num%10; - while (num /= 10); - do - putchar(*--ptr); - while (ptr != buf); - break; - } - case 'x': { - int num = *dataptr++, dig; - char buf[8], *ptr = buf; - do - *ptr++ = (dig=(num&0xf)) > 9? - 'a' + dig - 10 : - '0' + dig; - while (num >>= 4); - do - putchar(*--ptr); - while (ptr != buf); - break; - } - case 'c': putchar((*dataptr++)&0xff); break; - case 's': { - char *ptr = (char *)*dataptr++; - while (c = *ptr++) - putchar(c); - break; - } - } -} - -putchar(c) -{ - if (c == '\n') - putc('\r'); - putc(c); -} - -getchar() -{ - int c; - - if ((c=getc()) == '\r') - c = '\n'; - if (c == '\b') { - putchar('\b'); - putchar(' '); - } - putchar(c); - return(c); -} - -gets(buf) -char *buf; -{ - int i; - char *ptr=buf; - - for (i = 240000; i>0; i--) - if (ischar()) - for (;;) - switch(*ptr = getchar() & 0xff) { - case '\n': - case '\r': - *ptr = '\0'; - return 1; - case '\b': - if (ptr > buf) ptr--; - continue; - default: - ptr++; - } - return 0; -} - -strcmp(s1, s2) -char *s1, *s2; -{ - while (*s1 == *s2) { - if (!*s1++) - return 0; - s2++; - } - return 1; -} - -bcopy(from, to, len) -char *from, *to; -int len; -{ - while (len-- > 0) - *to++ = *from++; -} - -static int tw_on; -static int tw_pos; -static char tw_chars[] = "|/-\\"; - -reset_twiddle() -{ - if (tw_on) - putchar('\b'); - tw_on = 0; - tw_pos = 0; -} - -twiddle() -{ - if (tw_on) - putchar('\b'); - else - tw_on = 1; - putchar(tw_chars[tw_pos++]); - tw_pos %= (sizeof(tw_chars) - 1); -} diff --git a/sys/i386/boot/rmaouthdr b/sys/i386/boot/rmaouthdr deleted file mode 100644 index 4bb9c84..0000000 --- a/sys/i386/boot/rmaouthdr +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/csh -f -# -# from: Mach, Revision 2.2 92/04/04 11:36:01 rpd -# $Id$ -# -dd if=$1 of=$2 ibs=32 skip=1 obs=1024b diff --git a/sys/i386/boot/start.S b/sys/i386/boot/start.S deleted file mode 100644 index 62b93ac..0000000 --- a/sys/i386/boot/start.S +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:29 rpd - * $Id$ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -#include "asm.h" - - .file "start.s" - -BOOTSEG = 0x9000 # boot will be loaded here (below 640K) -BOOTSTACK = 0xe000 # boot stack -SIGNATURE = 0xaa55 -LOADSZ = 15 # size of unix boot -PARTSTART = 0x1be # starting address of partition table -NUMPART = 4 # number of partitions in partition table -PARTSZ = 16 # each partition table entry is 16 bytes -BSDPART = 0xA5 # value of boot_ind, means bootable partition -BOOTABLE = 0x80 # value of boot_ind, means bootable partition - - .text - -ENTRY(boot1) - # start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 - # ljmp to the next instruction to adjust %cs - data32 - ljmp $0x7c0, $start - -start: - # set up %ds - mov %cs, %ax - mov %ax, %ds - - # set up %ss and %esp - data32 - mov $BOOTSEG, %eax - mov %ax, %ss - data32 - mov $BOOTSTACK, %esp - - /*** set up %es, (where we will load boot2 to) ***/ - mov %ax, %es - -#ifdef DEBUG - data32 - mov $one, %esi - data32 - call message -#endif - - # bootstrap passes us drive number in %dl - cmpb $0x80, %dl - data32 - jae hd - -fd: -# reset the disk system -#ifdef DEBUG - data32 - mov $two, %esi - data32 - call message -#endif - movb $0x0, %ah - int $0x13 - data32 - mov $0x0001, %ecx # cyl 0, sector 1 - movb $0, %dh # head -#ifdef DEBUG - data32 - mov $three, %esi - data32 - call message -#endif - data32 - jmp load - -hd: /**** load sector 0 into the BOOTSEG ****/ -#ifdef DEBUG - data32 - mov $four, %esi - data32 - call message -#endif - data32 - mov $0x0201, %eax - xor %ebx, %ebx # %bx = 0 - data32 - mov $0x0001, %ecx -#ifdef DEBUG - data32 - mov $five, %esi - data32 - call message -#endif - data32 - andl $0xff, %edx - /*mov $0x0080, %edx*/ - int $0x13 - data32 - jb read_error - - /***# find the first 386BSD partition *****/ - data32 - mov $PARTSTART, %ebx - data32 - mov $NUMPART, %ecx -again: - addr32 - movb %es:4(%ebx), %al - cmpb $BSDPART, %al - data32 - je found - data32 - add $PARTSZ, %ebx - data32 - loop again - data32 - mov $enoboot, %esi - data32 - jmp err_stop - - -/* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -found: - addr32 - movb %es:1(%ebx), %dh /* head */ - addr32 - movl %es:2(%ebx), %ecx /*sect, cyl (+ 2 bytes junk in top word) */ - -load: - movb $0x2, %ah /* function 2 */ - movb $LOADSZ, %al /* number of blocks */ - xor %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */ - int $0x13 - data32 - jb read_error - - # ljmp to the second stage boot loader (boot2). - # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - # as an internal buffer "intbuf". - -#ifdef DEBUG - data32 - mov $six, %esi - data32 - call message -#endif - data32 - ljmp $BOOTSEG, $ EXT(boot2) - -# -# read_error -# - -read_error: - data32 - mov $eread, %esi -err_stop: - data32 - call message - data32 - jmp stop - -# -# message: write the error message in %ds:%esi to console -# - -message: -/* - # Use BIOS "int 10H Function 0Eh" to write character in teletype mode - # %ah = 0xe %al = character - # %bh = page %bl = foreground color (graphics modes) -*/ - - data32 - push %eax - data32 - push %ebx - data32 - mov $0x0001, %ebx - cld - -nextb: - lodsb # load a byte into %al - cmpb $0x0, %al - data32 - je done - movb $0xe, %ah - int $0x10 # display a byte - data32 - jmp nextb -done: - data32 - pop %ebx - data32 - pop %eax - data32 - ret - -stop: hlt - data32 - jmp stop # halt doesnt actually halt forever - -/* error messages */ - -#ifdef DEBUG -one: String "1\r\n\0" -two: String "2\r\n\0" -three: String "3\r\n\0" -four: String "4\r\n\0" -five: String "5\r\n\0" -six: String "6\r\n\0" -seven: String "7\r\n\0" -#endif DEBUG -eread: String "Read error\r\n\0" -enoboot: String "No bootable partition\r\n\0" -endofcode: -/* throw in a partition in case we are block0 as well */ -/* flag, head, sec, cyl, typ, ehead, esect, ecyl, start, len */ - . = EXT(boot1) + PARTSTART - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte BOOTABLE,0,1,0,BSDPART,255,255,255 - .long 0,50000 -/* the last 2 bytes in the sector 0 contain the signature */ - . = EXT(boot1) + 0x1fe - .value SIGNATURE -ENTRY(disklabel) - . = EXT(boot1) + 0x400 diff --git a/sys/i386/boot/start.s b/sys/i386/boot/start.s deleted file mode 100644 index f6f4bf0..0000000 --- a/sys/i386/boot/start.s +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - */ - -/* - * HISTORY - * $Log: start.s,v $ - * Revision 2.2 92/04/04 11:36:29 rpd - * Fix Intel Copyright as per B. Davies authorization. - * [92/04/03 rvb] - * Need to zero dh on hd path; at least for an adaptec card. - * [92/01/14 rvb] - * - * From 2.5 boot: - * Flush digit printing. - * Fuse floppy and hd boot by using Int 21 to tell - * boot type (slightly dubious since Int 21 is DOS - * not BIOS) - * [92/03/30 mg32] - * - * Revision 2.2 91/04/02 14:42:04 mbj - * Fix the BIG boot bug. We had missed a necessary data - * before a xor that was clearing a register used later - * as an index register. - * [91/03/01 rvb] - * Remember floppy type for swapgeneric - * Add Intel copyright - * [90/02/09 rvb] - * - */ - - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -#include "asm.h" - - .file "start.s" - -BOOTSEG = 0x9000 # boot will be loaded at 640k-64k -BOOTSTACK = 0xe000 # boot stack -SIGNATURE = 0xaa55 -LOADSZ = 14 # size of unix boot -PARTSTART = 0x1be # starting address of partition table -NUMPART = 4 # number of partitions in partition table -PARTSZ = 16 # each partition table entry is 16 bytes -BSDPART = 0xA5 # value of boot_ind, means bootable partition -BOOTABLE = 0x80 # value of boot_ind, means bootable partition - - .text - -ENTRY(boot1) - - # boot1 is loaded at 0x0:0x7c00 - # ljmp to the next instruction to set up %cs - data32 - ljmp $0x7c0, $start - -start: - # set up %ds - mov %cs, %ax - mov %ax, %ds - - - # set up %ss and %esp - data32 - mov $BOOTSEG, %eax - mov %ax, %ss - data32 - mov $BOOTSTACK, %esp - - /*** set up %es, (where we will load boot2 to) ***/ - mov %ax, %es - -#ifdef DEBUG - data32 - mov $one, %esi - data32 - call message -#endif - # get the boot drive id - movb $0x33, %ah - movb $0x05, %al - int $0x21 - - cmpb $0x80, %dl - data32 - jge hd - -fd: -# reset the disk system -#ifdef DEBUG - data32 - mov $two, %esi - data32 - call message -#endif - movb $0x0, %ah - int $0x13 - data32 - mov $0x0001, %ecx # cyl 0, sector 1 - data32 -#ifdef DEBUG - data32 - mov $three, %esi - data32 - call message -#endif - jmp load - -hd: /**** load sector 0 into the BOOTSEG ****/ -#ifdef DEBUG - data32 - mov $four, %esi - data32 - call message -#endif - data32 - mov $0x0201, %eax - xor %ebx, %ebx # %bx = 0 - data32 - mov $0x0001, %ecx -#ifdef DEBUG - data32 - mov $five, %esi - data32 - call message -#endif - data32 - andl $0xff, %edx - /*mov $0x0080, %edx*/ - int $0x13 - data32 - jb read_error - - /***# find the bootable partition *****/ - data32 - mov $PARTSTART, %ebx - data32 - mov $NUMPART, %ecx -again: - addr16 - movb %es:4(%ebx), %al - cmpb $BSDPART, %al - data32 - je found - data32 - add $PARTSZ, %ebx - data32 - loop again - data32 - mov $enoboot, %esi - data32 - jmp err_stop - - -/* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -found: - addr16 - movb %es:1(%ebx), %dh /* head */ - addr16 - xor %ecx, %ecx - addr16 - movw %es:2(%ebx), %ecx /*sect,cyl (+ 2 bytes junk in top word )*/ - -load: - movb $0x2, %ah /* function 2 */ - movb $LOADSZ, %al /* number of blocks */ - xor %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */ - int $0x13 - data32 - jb read_error - - # ljmp to the second stage boot loader (boot2). - # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - # as an internal buffer "intbuf". - -#ifdef DEBUG - data32 - mov $six, %esi - data32 - call message -#endif - data32 - ljmp $BOOTSEG, $EXT(boot2) - -# -# read_error -# - -read_error: - - data32 - mov $eread, %esi -err_stop: - data32 - call message - data32 - jmp stop - -# -# message: write the error message in %ds:%esi to console -# - -message: - # Use BIOS "int 10H Function 0Eh" to write character in teletype mode - # %ah = 0xe %al = character - # %bh = page %bl = foreground color (graphics modes) - - data32 - push %eax - data32 - push %ebx - data32 - mov $0x0001, %ebx - cld - -nextb: - lodsb # load a byte into %al - cmpb $0x0, %al - data32 - je done - movb $0xe, %ah - int $0x10 # display a byte - data32 - jmp nextb -done: - data32 - pop %ebx - data32 - pop %eax - data32 - ret - -stop: hlt - data32 - jmp stop # halt doesnt actually halt forever - -/* error messages */ - -#ifdef DEBUG -one: String "1\r\n\0" -two: String "2\r\n\0" -three: String "3\r\n\0" -four: String "4\r\n\0" -five: String "5\r\n\0" -six: String "6\r\n\0" -seven: String "7\r\n\0" -#endif DEBUG -eread: String "Read error\r\n\0" -enoboot: String "No bootable partition\r\n\0" -endofcode: -/* throw in a partition in case we are block0 as well */ -/* flag,head,sec,cyl,typ,ehead,esect,ecyl,start,len */ - . = EXT(boot1) + PARTSTART - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte BOOTABLE,0,1,0,BSDPART,255,255,255 - .long 0,50000 -/* the last 2 bytes in the sector 0 contain the signature */ - . = EXT(boot1) + 0x1fe - .value SIGNATURE -ENTRY(disklabel) - . = EXT(boot1) + 0x400 diff --git a/sys/i386/boot/sys.c b/sys/i386/boot/sys.c deleted file mode 100644 index 4ffe171..0000000 --- a/sys/i386/boot/sys.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:34 rpd - * $Id$ - */ - -#include "boot.h" -#include -#include - -/* #define BUFSIZE 4096 */ -#define BUFSIZE MAXBSIZE - -char buf[BUFSIZE], fsbuf[SBSIZE], iobuf[MAXBSIZE]; - -int xread(addr, size) - char * addr; - int size; -{ - int count = BUFSIZE; - while (size > 0) { - if (BUFSIZE > size) - count = size; - read(buf, count); - pcpy(buf, addr, count); - size -= count; - addr += count; - } -} - -read(buffer, count) - int count; - char *buffer; -{ - int logno, off, size; - int cnt2, bnum2; - - while (count) { - off = blkoff(fs, poff); - logno = lblkno(fs, poff); - cnt2 = size = blksize(fs, &inode, logno); - bnum2 = fsbtodb(fs, block_map(logno)) + boff; - cnt = cnt2; - bnum = bnum2; - if ( (!off) && (size <= count)) - { - iodest = buffer; - devread(); - } - else - { - iodest = iobuf; - size -= off; - if (size > count) - size = count; - devread(); - bcopy(iodest+off,buffer,size); - } - buffer += size; - count -= size; - poff += size; - } -} - -find(path) - char *path; -{ - char *rest, ch; - int block, off, loc, ino = ROOTINO; - struct direct *dp; -loop: iodest = iobuf; - cnt = fs->fs_bsize; - bnum = fsbtodb(fs,itod(fs,ino)) + boff; - devread(); - bcopy(&((struct dinode *)iodest)[ino % fs->fs_inopb], - &inode.i_din, - sizeof (struct dinode)); - if (!*path) - return 1; - while (*path == '/') - path++; - if (!inode.i_size || ((inode.i_mode&IFMT) != IFDIR)) - return 0; - for (rest = path; (ch = *rest) && ch != '/'; rest++) ; - *rest = 0; - loc = 0; - do { - if (loc >= inode.i_size) - return 0; - if (!(off = blkoff(fs, loc))) { - block = lblkno(fs, loc); - cnt = blksize(fs, &inode, block); - bnum = fsbtodb(fs, block_map(block)) + boff; - iodest = iobuf; - devread(); - } - dp = (struct direct *)(iodest + off); - loc += dp->d_reclen; - } while (!dp->d_ino || strcmp(path, dp->d_name)); - ino = dp->d_ino; - *(path = rest) = ch; - goto loop; -} - -char mapbuf[MAXBSIZE]; -int mapblock = 0; - -block_map(file_block) - int file_block; -{ - if (file_block < NDADDR) - return(inode.i_db[file_block]); - if ((bnum=fsbtodb(fs, inode.i_ib[0])+boff) != mapblock) { - iodest = mapbuf; - cnt = fs->fs_bsize; - devread(); - mapblock = bnum; - } - return (((int *)mapbuf)[(file_block - NDADDR) % NINDIR(fs)]); -} - -openrd() -{ - char **devp, *cp = name; - /*******************************************************\ - * If bracket given look for preceding device name * - \*******************************************************/ - while (*cp && *cp!='(') - cp++; - if (!*cp) - { - cp = name; - } - else - { - if (cp++ != name) - { - for (devp = devs; *devp; devp++) - if (name[0] == (*devp)[0] && - name[1] == (*devp)[1]) - break; - if (!*devp) - { - printf("Unknown device\n"); - return 1; - } - maj = devp-devs; - } - /*******************************************************\ - * Look inside brackets for unit number, and partition * - \*******************************************************/ - if (*cp >= '0' && *cp <= '9') - if ((unit = *cp++ - '0') > 1) - { - printf("Bad unit\n"); - return 1; - } - if (!*cp || (*cp == ',' && !*++cp)) - return 1; - if (*cp >= 'a' && *cp <= 'p') - part = *cp++ - 'a'; - while (*cp && *cp++!=')') ; - if (!*cp) - return 1; - } - switch(maj) - { - case 1: - dosdev = unit | 0x80; - unit = 0; - break; - case 0: - case 4: - dosdev = unit | 0x80; - break; - case 2: - dosdev = unit; - break; - case 3: - printf("Wangtek unsupported\n"); - return 1; - break; - } - inode.i_dev = dosdev; - /***********************************************\ - * Now we know the disk unit and part, * - * Load disk info, (open the device) * - \***********************************************/ - if (devopen()) - return 1; - - /***********************************************\ - * Load Filesystem info (mount the device) * - \***********************************************/ - iodest = (char *)(fs = (struct fs *)fsbuf); - cnt = SBSIZE; - bnum = SBLOCK + boff; - devread(); - /***********************************************\ - * Find the actual FILE on the mounted device * - \***********************************************/ - if (!find(cp)) - { - return 1; - } - poff = 0; - name = cp; - return 0; -} diff --git a/sys/i386/boot/table.c b/sys/i386/boot/table.c deleted file mode 100644 index c53173d..0000000 --- a/sys/i386/boot/table.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:36:43 rpd - * $Id$ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -/* Segment Descriptor - * - * 31 24 19 16 7 0 - * ------------------------------------------------------------ - * | | |B| |A| | | |1|0|E|W|A| | - * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 | - * | | |D| |L| 19..16| | |1|1|C|R|A| | - * ------------------------------------------------------------ - * | | | - * | BASE 15..0 | LIMIT 15..0 | - * | | | - * ------------------------------------------------------------ - */ - -struct seg_desc { - unsigned short limit_15_0; - unsigned short base_15_0; - unsigned char base_23_16; - unsigned char p_dpl_type; - unsigned char g_b_a_limit; - unsigned char base_31_24; - }; - -#define RUN 0 /* not really 0, but filled in at boot time */ - -struct seg_desc Gdt[] = { - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* 0x0 : null */ - {0xFFFF, 0x0, 0x0, 0x9F, 0xCF, 0x0}, /* 0x08 : kernel code */ - /* 0x9E? */ - {0xFFFF, 0x0, 0x0, 0x93, 0xCF, 0x0}, /* 0x10 : kernel data */ - /* 0x92? */ - {0xFFFF, RUN, RUN, 0x9E, 0x40, 0x0}, /* 0x18 : boot code */ - {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* 0x20 : boot data */ - {0xFFFF, RUN, RUN, 0x9E, 0x0, 0x0}, /* 0x28 : boot code, 16 bits */ - /* More for bdb. */ - {}, /* BIOS_CS_INDEX = 6 : null */ - {}, /* BIOS_TMP_INDEX = 7 : null */ - {}, /* TSS_INDEX = 8 : null */ - {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* DS_286_INDEX = 9 */ - {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0}, /* ES_286_INDEX = 10 */ - {}, /* Unused = 11 : null */ - {0x7FFF, 0x8000, 0xB, 0xB2, 0x40, 0x0}, /* COLOR_INDEX = 12 */ - {0x7FFF, 0x0, 0xB, 0xB2, 0x40, 0x0}, /* MONO_INDEX = 13 */ - {0xFFFF, RUN, RUN, 0x9A, 0x40, 0x0}, /* DB_CS_INDEX = 14 */ - {0xFFFF, RUN, RUN, 0x9A, 0x0, 0x0}, /* DB_CS16_INDEX = 15 */ - {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0}, /* DB_DS_INDEX = 16 */ - {8*18-1, RUN, RUN, 0x92, 0x40, 0x0}, /* GDT_INDEX = 17 */ -}; - -struct idt_desc { - unsigned short entry_15_0; - unsigned short selector; - unsigned char padding; - unsigned char p_dpl_type; - unsigned short entry_31_16; -}; - -struct idt_desc Idt[] = { - {}, /* Null (int 0) */ - {RUN, 0x70, 0, 0x8E, 0}, /* DEBUG_VECTOR = 1 */ - {}, /* Null (int 2) */ - {RUN, 0x70, 0, 0xEE, 0}, /* BREAKPOINT_VECTOR = 3 */ -}; - -struct pseudo_desc { - unsigned short limit; - unsigned short base_low; - unsigned short base_high; - }; - -struct pseudo_desc Gdtr = { sizeof Gdt - 1, RUN, RUN }; -struct pseudo_desc Idtr_prot = { sizeof Idt - 1, RUN, RUN }; -struct pseudo_desc Idtr_real = { 0x400 - 1, 0x0, 0x0 }; diff --git a/sys/i386/conf/GENERICAH b/sys/i386/conf/GENERICAH deleted file mode 100644 index b30211f..0000000 --- a/sys/i386/conf/GENERICAH +++ /dev/null @@ -1,87 +0,0 @@ -# -# GENERICAH -- Generic machine with WD/AHx family disks -# -# $Id: GENERICAH,v 1.15 1993/10/16 12:28:32 rgrimes Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident GENERICAH -timezone 8 dst -maxusers 10 -maxfdescs 2048 #Max file descriptors per process -options MATH_EMULATE #Support for x87 emulation -options INET #InterNETworking -options ISOFS #ISO File System -options NFS #Network File System -options PCFS #MSDOS File System -options "COMPAT_43" #Compatible with BSD 4.3 -options "TCP_COMPAT_42" #TCP/IP compatible with 4.2 -options XSERVER #Xserver -options UCONSOLE #X Console support -#options GATEWAY #Host is a Gateway (forwards packets) - -config "386bsd" root on wd0 swap on wd0 and sd0 - -controller isa0 - -controller fd0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fd0 drive 0 -disk fd1 at fd0 drive 1 - -controller wd0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wd0 drive 0 -disk wd1 at wd0 drive 1 - -controller ahb0 at isa? bio irq 11 vector ahbintr -controller aha0 at isa? port "IO_AHA0" bio irq 11 drq 5 vector ahaintr -controller scbus0 - -device sd0 -device sd1 -device sd2 -device sd3 - -device st0 -device st1 - -device cd0 #Only need one of these, the code dynamically grows - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr - -device pc0 at isa? port "IO_KBD" tty irq 1 vector pcrint -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -#The old drivers are rarely needed anymore... -#device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -#device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -#device com2 at isa? port "IO_COM3" tty irq 5 vector comintr -#device com3 at isa? port "IO_COM4" tty irq 9 vector comintr - -#For high speed serial lines. -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr - -device lpt0 at isa? port "IO_LPT3" tty irq 7 vector lptintr -device lpa0 at isa? port "IO_LPT1" tty -device lpa1 at isa? port "IO_LPT2" tty - -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ed1 at isa? port 0x300 net irq 5 iomem 0xd8000 vector edintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr - -pseudo-device loop -pseudo-device ether -pseudo-device log -pseudo-device sl 2 -pseudo-device pty 12 -pseudo-device speaker - -pseudo-device swappager -pseudo-device vnodepager -pseudo-device devpager diff --git a/sys/i386/conf/GENERICBT b/sys/i386/conf/GENERICBT deleted file mode 100644 index 7c91d1d..0000000 --- a/sys/i386/conf/GENERICBT +++ /dev/null @@ -1,87 +0,0 @@ -# -# GENERICBT -- Generic machine with WD/BTx family disks -# -# $Id: GENERICBT,v 1.14 1993/10/16 12:28:33 rgrimes Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident GENERICBT -timezone 8 dst -maxusers 10 -maxfdescs 2048 #Max file descriptors per process -options MATH_EMULATE #Support for x87 emulation -options INET #InterNETworking -options ISOFS #ISO File System -options NFS #Network File System -options PCFS #MSDOS File System -options "COMPAT_43" #Compatible with BSD 4.3 -options "TCP_COMPAT_42" #TCP/IP compatible with 4.2 -options XSERVER #Xserver -options UCONSOLE #X Console support -#options GATEWAY #Host is a Gateway (forwards packets) - -config "386bsd" root on wd0 swap on wd0 and sd0 - -controller isa0 - -controller fd0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fd0 drive 0 -disk fd1 at fd0 drive 1 - -controller wd0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wd0 drive 0 -disk wd1 at wd0 drive 1 - -controller bt0 at isa? port "IO_BT0" bio irq 12 vector btintr -controller uha0 at isa? port "IO_UHA0" bio irq 14 drq 5 vector uhaintr -controller scbus0 - -device sd0 -device sd1 -device sd2 -device sd3 - -device st0 -device st1 - -device cd0 #Only need one of these, the code dynamically grows - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr - -device pc0 at isa? port "IO_KBD" tty irq 1 vector pcrint -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -#The old drivers are rarely needed anymore... -#device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -#device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -#device com2 at isa? port "IO_COM3" tty irq 5 vector comintr -#device com3 at isa? port "IO_COM4" tty irq 9 vector comintr - -#For high speed serial lines. -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr - -device lpt0 at isa? port "IO_LPT3" tty irq 7 vector lptintr -device lpa0 at isa? port "IO_LPT1" tty -device lpa1 at isa? port "IO_LPT2" tty - -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ed1 at isa? port 0x300 net irq 5 iomem 0xd8000 vector edintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr - -pseudo-device loop -pseudo-device ether -pseudo-device log -pseudo-device sl 2 -pseudo-device pty 12 -pseudo-device speaker - -pseudo-device swappager -pseudo-device vnodepager -pseudo-device devpager diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT deleted file mode 100644 index 60dfc97..0000000 --- a/sys/i386/conf/LINT +++ /dev/null @@ -1,141 +0,0 @@ -# -# LINT -- config file for checking all the sources, tries to pull in -# as much of the source tree as it can. -# -# This kernel is NOT MEANT to be runnable! -# -# $Id: LINT,v 1.17 1993/10/19 19:49:24 nate Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident LINT -timezone 8 dst -maxusers 10 -maxfdescs 2048 #Max file descriptors per process -options MATH_EMULATE #Support for x87 emulation - -config "386bsd" at 0xFE100000 root on wd0 swap on wd0 and sd0 - -# -# options that appear as inline #ifdef's -# -options "COM_BIDIR" #Bidirectional support in sys/isa/sio.c -options "COM_MULTIPORT" #Multiport support in sys/isa/sio.c -options "COMPAT_43" #compatible with BSD 4.3 -options "SYMTAB_SPACE=89000" #This kernel needs LOTS of symtable -options GATEWAY #internetwork gateway -options KTRACE #kernel tracing -options "NCONS=8" #number of syscons virtual consoles -options "TCP_COMPAT_42" #tcp/ip compatible with 4.2 -options UCONSOLE #x console support -options XSERVER #xserver - -# -# options that are in sys/conf/files -# -pseudo-device bpfilter 4 #berkeley packet filter -options CCITT -device cd0 #Only need one of these, the code dynamically grows -device ch0 -pseudo-device ddb -pseudo-device devpager -options EON -pseudo-device ether -options FIFO -#pseudo-device imp -options INET #Internet communications protocols -options ISO -options ISOFS #ISO 9660 File System -pseudo-device loop -options MFS #Memroy File System -options NFS #Network File System -options NS #Xerox NS communications protocols -options PCFS #PC (MSDOS) File System -pseudo-device ppp 2 -pseudo-device pty 4 -options QUOTA #enable disk quotas -controller scbus0 -device sd0 -device sd1 -device sd2 -device sd3 -pseudo-device sl 2 -device st0 -device st1 -pseudo-device swappager -options SYSVSHM -options "SHMMAXPGS=64" # 256Kb of sharable memory -#pseudo-device tb #tablet line discipline. -pseudo-device tpip -#pseudo-device tun -pseudo-device vnodepager - -# -# options that are in sys/i386/conf/files.i386 -# -#This is needed here so the isa? below will work -controller isa0 - -controller aha0 at isa? port "IO_AHA0" bio irq 11 drq 5 vector ahaintr -controller ahb0 at isa? bio irq 11 vector ahbintr -controller bt0 at isa? port "IO_BT0" bio irq 12 vector btintr -device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -device com2 at isa? port "IO_COM3" tty irq 5 vector comintr -device com3 at isa? port "IO_COM4" tty irq 9 vector comintr -#dcfclk device-driver -controller fd0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fd0 drive 0 -disk fd1 at fd0 drive 1 -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr -#device ix0 at isa? port 0x320 net irq 10 iomem 0xd0000 iosiz 32768 vector ixintr -#special cased above: -#controller isa0 -device lpa0 at isa? port "IO_LPT1" tty -device lpa1 at isa? port "IO_LPT2" tty -device lpt0 at isa? port "IO_LPT3" tty irq 7 vector lptintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr -device mse0 at isa? port 0x23c tty irq 5 vector mseintr -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr -device pc0 at isa? port "IO_KBD" tty irq 1 vector pcrint -#only one of pc0 or sc0 allowed -#device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr -pseudo-device speaker -#tw device-driver -controller uha0 at isa? port "IO_UHA0" bio irq 14 drq 5 vector uhaintr -controller wd0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wd0 drive 0 -disk wd1 at wd0 drive 1 -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr - -# To enable sound card support, uncomment one or more of the following lines. -# Unit numbers are: -# 1 for Yamaha FM synth -# 2 for SB/SB Pro DSP -# 3 for PAS PCM and Midi -# 4 for GUS -# 5 for MPU-401 -# -# If you have ProAudioSpectrum, uncomment units 3, 2 and 1 -# If you have SoundBlaster, uncomment 2 and 1. -# If you have GravisUltrasound, uncomment 4 -# If you have MPU-401, uncomment 5 -# -#device snd5 at isa? port 0x330 irq 6 drq 0 vector mpuintr -#device snd4 at isa? port 0x220 irq 15 drq 6 vector gusintr -#device snd3 at isa? port 0x388 irq 12 drq 3 vector pasintr -#device snd2 at isa? port 0x220 irq 7 drq 1 vector sbintr -#device snd1 at isa? port 0x388 irq 0 drq 0 vector sbintr -# -# -# options that have not been resolved yet -# -pseudo-device log diff --git a/sys/i386/conf/Makefile.i386 b/sys/i386/conf/Makefile.i386 deleted file mode 100644 index 3b649d4..0000000 --- a/sys/i386/conf/Makefile.i386 +++ /dev/null @@ -1,145 +0,0 @@ -# Copyright 1990 W. Jolitz -# from: @(#)Makefile.i386 7.1 5/10/91 -# $Id: Makefile.i386,v 1.9 1993/10/23 06:46:24 nate Exp $ -# -# Makefile for FreeBSD -# -# This makefile is constructed from a machine description: -# config machineid -# Most changes should be made in the machine description -# /sys/i386/conf/``machineid'' -# after which you should do -# config machineid -# Generic makefile changes should be made in -# /sys/i386/conf/Makefile.i386 -# after which config should be rerun for all machines. -# -# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE -# IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING -# -# -DTRACE compile in kernel tracing hooks -# -DQUOTA compile in file system quotas -# -TOUCH= touch -f -c -LD= /usr/bin/ld -CC= cc -CPP= cpp -STRIP= strip -DBSYM= /usr/sbin/dbsym - -S= ../.. -I386= ../../i386 - -INCLUDES= -I. -I$S -I$S/sys -COPTS= ${INCLUDES} ${IDENT} -DKERNEL -Di386 -DNPX -ASFLAGS= -CFLAGS= -O ${DEBUG} ${COPTS} -LOAD_ADDRESS?= FE000000 - -NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $< -NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $< -NORMAL_S= ${CPP} -I. -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o -DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $< -DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $< -SYSTEM_OBJS=locore.o ${OBJS} param.o ioconf.o conf.o machdep.o -SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS} -SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ -SYSTEM_LD= @${LD} -z -T ${LOAD_ADDRESS} -o $@ -X vers.o ${SYSTEM_OBJS} -SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \ - ${DBSYM} -fT ${LOAD_ADDRESS} $@; ${STRIP} -x $@; size $@; chmod 755 $@ - -# (XXX) ok, this is weird. but we've got a working ed, and a broken ex, and -# the script is identical for either... -- cgd -# -GPROF.EX= /usr/src/lib/csu.i386/gprof.ex -PROFILE_C= ${CC} -S -c ${CFLAGS} $< ; \ - ed - $*.s < ${GPROF.EX} ; \ - ${AS} -o $@ $*.s ; \ - rm -f $*.s - -%OBJS - -%CFILES - -%LOAD - -clean: - rm -f eddep *386bsd tags *.o locore.i [a-uw-z]*.s \ - errs linterrs makelinks genassym - -lint: /tmp param.c - @lint -hbxn -I. -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \ - ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \ - grep -v 'struct/union .* never defined' | \ - grep -v 'possible pointer alignment problem' - -symbols.sort: ${I386}/i386/symbols.raw - grep -v '^#' ${I386}/i386/symbols.raw \ - | sed 's/^ //' | sort -u > symbols.sort - -locore.o: assym.s ${I386}/i386/locore.s machine/trap.h machine/psl.h \ - machine/pte.h ${I386}/isa/vector.s ${I386}/isa/icu.s \ - $S/sys/errno.h machine/specialreg.h ${I386}/isa/debug.h \ - ${I386}/isa/icu.h ${I386}/isa/isa.h vector.h $S/net/netisr.h - ${CPP} -I. -DLOCORE ${COPTS} ${I386}/i386/locore.s | \ - ${AS} ${ASFLAGS} -o locore.o - -machdep.o: ${I386}/i386/machdep.c Makefile - ${CC} -c ${CFLAGS} -DLOAD_ADDRESS=0x${LOAD_ADDRESS} ${PROF} $< - -# the following is necessary because autoconf.o depends on #if GENERIC -autoconf.o: Makefile - -# depend on network configuration -af.o uipc_proto.o locore.o: Makefile - -# depend on maxusers -assym.s: Makefile - -# depends on KDB (cons.o also depends on GENERIC) -trap.o cons.o: Makefile - -assym.s: genassym - ./genassym >assym.s - -genassym: - ${CC} ${INCLUDES} -DKERNEL ${IDENT} ${PARAM} \ - ${I386}/i386/genassym.c -o genassym - -depend: assym.s param.c - sh /usr/bin/mkdep -DLOAD_ADDRESS=0x${LOAD_ADDRESS} ${COPTS} ${CFILES} ioconf.c param.c ${I386}/i386/conf.c - sh /usr/bin/mkdep -a -p ${INCLUDES} ${IDENT} ${PARAM} ${I386}/i386/genassym.c - -links: - egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ - sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink - echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ - sort -u | comm -23 - dontlink | \ - sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks - sh makelinks && rm -f dontlink - -tags: - @echo "see $S/kern/Makefile for tags" - -ioconf.o: ioconf.c $S/sys/param.h machine/pte.h $S/sys/buf.h \ - ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h - ${CC} -c ${CFLAGS} ioconf.c - -conf.o: ${I386}/i386/conf.c - ${CC} -traditional -c ${CFLAGS} ${I386}/i386/conf.c - -param.c: $S/conf/param.c - -rm -f param.c - cp $S/conf/param.c . - -param.o: param.c Makefile - ${CC} -c ${CFLAGS} ${PARAM} param.c - -vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} - sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} - ${CC} ${CFLAGS} -c vers.c - -%RULES - -# DO NOT DELETE THIS LINE -- make depend uses it - diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES deleted file mode 100644 index 60dfc97..0000000 --- a/sys/i386/conf/NOTES +++ /dev/null @@ -1,141 +0,0 @@ -# -# LINT -- config file for checking all the sources, tries to pull in -# as much of the source tree as it can. -# -# This kernel is NOT MEANT to be runnable! -# -# $Id: LINT,v 1.17 1993/10/19 19:49:24 nate Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident LINT -timezone 8 dst -maxusers 10 -maxfdescs 2048 #Max file descriptors per process -options MATH_EMULATE #Support for x87 emulation - -config "386bsd" at 0xFE100000 root on wd0 swap on wd0 and sd0 - -# -# options that appear as inline #ifdef's -# -options "COM_BIDIR" #Bidirectional support in sys/isa/sio.c -options "COM_MULTIPORT" #Multiport support in sys/isa/sio.c -options "COMPAT_43" #compatible with BSD 4.3 -options "SYMTAB_SPACE=89000" #This kernel needs LOTS of symtable -options GATEWAY #internetwork gateway -options KTRACE #kernel tracing -options "NCONS=8" #number of syscons virtual consoles -options "TCP_COMPAT_42" #tcp/ip compatible with 4.2 -options UCONSOLE #x console support -options XSERVER #xserver - -# -# options that are in sys/conf/files -# -pseudo-device bpfilter 4 #berkeley packet filter -options CCITT -device cd0 #Only need one of these, the code dynamically grows -device ch0 -pseudo-device ddb -pseudo-device devpager -options EON -pseudo-device ether -options FIFO -#pseudo-device imp -options INET #Internet communications protocols -options ISO -options ISOFS #ISO 9660 File System -pseudo-device loop -options MFS #Memroy File System -options NFS #Network File System -options NS #Xerox NS communications protocols -options PCFS #PC (MSDOS) File System -pseudo-device ppp 2 -pseudo-device pty 4 -options QUOTA #enable disk quotas -controller scbus0 -device sd0 -device sd1 -device sd2 -device sd3 -pseudo-device sl 2 -device st0 -device st1 -pseudo-device swappager -options SYSVSHM -options "SHMMAXPGS=64" # 256Kb of sharable memory -#pseudo-device tb #tablet line discipline. -pseudo-device tpip -#pseudo-device tun -pseudo-device vnodepager - -# -# options that are in sys/i386/conf/files.i386 -# -#This is needed here so the isa? below will work -controller isa0 - -controller aha0 at isa? port "IO_AHA0" bio irq 11 drq 5 vector ahaintr -controller ahb0 at isa? bio irq 11 vector ahbintr -controller bt0 at isa? port "IO_BT0" bio irq 12 vector btintr -device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -device com2 at isa? port "IO_COM3" tty irq 5 vector comintr -device com3 at isa? port "IO_COM4" tty irq 9 vector comintr -#dcfclk device-driver -controller fd0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fd0 drive 0 -disk fd1 at fd0 drive 1 -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr -#device ix0 at isa? port 0x320 net irq 10 iomem 0xd0000 iosiz 32768 vector ixintr -#special cased above: -#controller isa0 -device lpa0 at isa? port "IO_LPT1" tty -device lpa1 at isa? port "IO_LPT2" tty -device lpt0 at isa? port "IO_LPT3" tty irq 7 vector lptintr -device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr -device mse0 at isa? port 0x23c tty irq 5 vector mseintr -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr -device pc0 at isa? port "IO_KBD" tty irq 1 vector pcrint -#only one of pc0 or sc0 allowed -#device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr -pseudo-device speaker -#tw device-driver -controller uha0 at isa? port "IO_UHA0" bio irq 14 drq 5 vector uhaintr -controller wd0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wd0 drive 0 -disk wd1 at wd0 drive 1 -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr - -# To enable sound card support, uncomment one or more of the following lines. -# Unit numbers are: -# 1 for Yamaha FM synth -# 2 for SB/SB Pro DSP -# 3 for PAS PCM and Midi -# 4 for GUS -# 5 for MPU-401 -# -# If you have ProAudioSpectrum, uncomment units 3, 2 and 1 -# If you have SoundBlaster, uncomment 2 and 1. -# If you have GravisUltrasound, uncomment 4 -# If you have MPU-401, uncomment 5 -# -#device snd5 at isa? port 0x330 irq 6 drq 0 vector mpuintr -#device snd4 at isa? port 0x220 irq 15 drq 6 vector gusintr -#device snd3 at isa? port 0x388 irq 12 drq 3 vector pasintr -#device snd2 at isa? port 0x220 irq 7 drq 1 vector sbintr -#device snd1 at isa? port 0x388 irq 0 drq 0 vector sbintr -# -# -# options that have not been resolved yet -# -pseudo-device log diff --git a/sys/i386/conf/SYSCONS b/sys/i386/conf/SYSCONS deleted file mode 100644 index 0b5055c..0000000 --- a/sys/i386/conf/SYSCONS +++ /dev/null @@ -1,87 +0,0 @@ -# -# SYSCONS -- Generic machine with WD/AHx family disks and syscons -# -# $Id: SYSCONS,v 1.11 1993/10/16 12:28:35 rgrimes Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident SYSCONS -timezone 8 dst -maxusers 10 -maxfdescs 2048 #Max file descriptors per process -options MATH_EMULATE #Support for x87 emulation -options INET #InterNETworking -options ISOFS #ISO File System -options NFS #Network File System -options PCFS #MSDOS File System -options "COMPAT_43" #Compatible with BSD 4.3 -options "TCP_COMPAT_42" #TCP/IP compatible with 4.2 -options XSERVER #Xserver -options UCONSOLE #X Console support -options "NCONS=8" #8 virtual consoles -#options GATEWAY #Host is a Gateway (forwards packets) - -config "386bsd" root on wd0 swap on wd0 and sd0 - -controller isa0 - -controller fd0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fd0 drive 0 -disk fd1 at fd0 drive 1 - -controller wd0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wd0 drive 0 -disk wd1 at wd0 drive 1 - -controller ahb0 at isa? bio irq 11 vector ahbintr -controller aha0 at isa? port "IO_AHA0" bio irq 11 drq 5 vector ahaintr -controller scbus0 - -device sd0 -device sd1 -device sd2 -device sd3 - -device st0 -device st1 - -device cd0 #Only need one of these, the code dynamically grows - -device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr - -#The old drivers are rarely needed anymore... -#device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -#device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -#device com2 at isa? port "IO_COM3" tty irq 5 vector comintr -#device com3 at isa? port "IO_COM4" tty irq 9 vector comintr - -#For high speed serial lines. -device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr -device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr -device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr -device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr - -device lpt0 at isa? port "IO_LPT3" tty irq 7 vector lptintr -device lpa0 at isa? port "IO_LPT1" tty -device lpa1 at isa? port "IO_LPT2" tty - -device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr -device ed1 at isa? port 0x300 net irq 5 iomem 0xd8000 vector edintr -device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr -device is0 at isa? port 0x280 net irq 10 drq 7 vector isintr - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr - -pseudo-device loop -pseudo-device ether -pseudo-device log -pseudo-device sl 2 -pseudo-device pty 4 -pseudo-device speaker - -pseudo-device swappager -pseudo-device vnodepager -pseudo-device devpager diff --git a/sys/i386/conf/devices.i386 b/sys/i386/conf/devices.i386 deleted file mode 100644 index b69698c..0000000 --- a/sys/i386/conf/devices.i386 +++ /dev/null @@ -1,12 +0,0 @@ -# This file tells what major numbers the various possible swap devices have. -# -# $Id: devices.i386,v 1.2 1993/08/21 22:20:50 rgrimes Exp $ -# -wd 0 -dk 1 -fd 2 -wt 3 -sd 4 -st 5 -cd 6 -mcd 7 diff --git a/sys/i386/conf/files.i386 b/sys/i386/conf/files.i386 deleted file mode 100644 index 118fe75..0000000 --- a/sys/i386/conf/files.i386 +++ /dev/null @@ -1,68 +0,0 @@ -# This file tells config what files go into building a kernel, -# files marked standard are always included. -# -# $Id: files.i386,v 1.16 1993/10/14 17:09:55 rgrimes Exp $ -# -i386/i386/autoconf.c standard device-driver -i386/i386/cons.c standard -i386/i386/db_disasm.c optional ddb -i386/i386/db_interface.c optional ddb -i386/i386/db_trace.c optional ddb -i386/i386/in_cksum.c optional inet -i386/i386/math_emulate.c optional math_emulate -i386/i386/mem.c standard -i386/i386/microtime.s standard -i386/i386/ns_cksum.c optional ns -i386/i386/pmap.c standard -i386/i386/sys_machdep.c standard -i386/i386/trap.c standard -i386/i386/vm_machdep.c standard -i386/isa/aha1542.c optional aha device-driver -i386/isa/aha1742.c optional ahb device-driver -i386/isa/bt742a.c optional bt device-driver -i386/isa/clock.c standard -i386/isa/com.c optional com device-driver -i386/isa/dcfclk.c optional dcfclk device-driver -i386/isa/fd.c optional fd device-driver -i386/isa/if_ed.c optional ed device-driver -i386/isa/if_ie.c optional ie device-driver -i386/isa/if_is.c optional is device-driver -i386/isa/if_ix.c optional ix device-driver -i386/isa/isa.c optional isa device-driver -i386/isa/lpa.c optional lpa device-driver -i386/isa/lpt.c optional lpt device-driver -i386/isa/mcd.c optional mcd device-driver -i386/isa/mse.c optional mse device-driver -i386/isa/npx.c optional npx device-driver -i386/isa/syscons.c optional sc device-driver -i386/isa/pccons.c optional pc device-driver -i386/isa/sb.c optional sb device-driver -i386/isa/sio.c optional sio device-driver -i386/isa/spkr.c optional speaker -i386/isa/tw.c optional tw device-driver -i386/isa/ultra14f.c optional uha device-driver -i386/isa/wd.c optional wd device-driver -i386/isa/wt.c optional wt device-driver -i386/isa/sound/soundcard.c optional snd device-driver -i386/isa/sound/dev_table.c optional snd device-driver -i386/isa/sound/adlib_card.c optional snd device-driver -i386/isa/sound/audio.c optional snd device-driver -i386/isa/sound/dmabuf.c optional snd device-driver -i386/isa/sound/dsp.c optional snd device-driver -i386/isa/sound/gus_card.c optional snd device-driver -i386/isa/sound/gus_wave.c optional snd device-driver -i386/isa/sound/gus_midi.c optional snd device-driver -i386/isa/sound/gus_vol.c optional snd device-driver -i386/isa/sound/midibuf.c optional snd device-driver -i386/isa/sound/mpu401.c optional snd device-driver -i386/isa/sound/opl3.c optional snd device-driver -i386/isa/sound/pas2_card.c optional snd device-driver -i386/isa/sound/pas2_midi.c optional snd device-driver -i386/isa/sound/pas2_mixer.c optional snd device-driver -i386/isa/sound/pas2_pcm.c optional snd device-driver -i386/isa/sound/pro_midi.c optional snd device-driver -i386/isa/sound/sb_card.c optional snd device-driver -i386/isa/sound/sb_dsp.c optional snd device-driver -i386/isa/sound/sequencer.c optional snd device-driver -i386/isa/sound/midi.c optional snd device-driver -i386/isa/sound/patmgr.c optional snd device-driver diff --git a/sys/i386/eisa/aha1742.c b/sys/i386/eisa/aha1742.c deleted file mode 100644 index 1e3e154..0000000 --- a/sys/i386/eisa/aha1742.c +++ /dev/null @@ -1,1322 +0,0 @@ -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * commenced: Sun Sep 27 18:14:01 PDT 1992 - * - * $Id: aha1742.c,v 1.9 1993/08/28 03:07:40 rgrimes Exp $ - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef MACH /* EITHER CMU OR OSF */ -#include -#include -#include - -#ifdef OSF /* OSF ONLY */ -#include -#include -#include -#include - -#else OSF /* CMU ONLY */ -#include -#include -#endif OSF -#endif MACH /* end of MACH specific */ - -#ifdef __386BSD__ /* 386BSD specific */ -#define isa_dev isa_device -#define dev_unit id_unit -#define dev_addr id_iobase - -#include -#include -#include -#include -#endif __386BSD__ - -/* */ - -#ifdef __386BSD__ -#include "ddb.h" -#if NDDB > 0 -int Debugger(); -#else NDDB -#define Debugger() panic("should call debugger here (adaptec.c)") -#endif NDDB -#endif __386BSD__ - -#ifdef MACH -int Debugger(); -#endif MACH - -typedef unsigned long int physaddr; -extern int hz; - -#ifdef MACH -extern physaddr kvtophys(); -#define PHYSTOKV(x) phystokv(x) -#define KVTOPHYS(x) kvtophys(x) -#endif MACH - -#ifdef __386BSD__ -#define KVTOPHYS(x) vtophys(x) -#endif __386BSD__ - -extern int delaycount; /* from clock setup code */ -#define NUM_CONCURRENT 16 /* number of concurrent ops per board */ -#define AHB_NSEG 33 /* number of dma segments supported */ -#define FUDGE(X) (X>>1) /* our loops are slower than spinwait() */ -/* */ -/***********************************************************************\ -* AHA1740 standard EISA Host ID regs (Offset from slot base) * -\***********************************************************************/ -#define HID0 0xC80 /* 0,1: msb of ID2, 3-7: ID1 */ -#define HID1 0xC81 /* 0-4: ID3, 4-7: LSB ID2 */ -#define HID2 0xC82 /* product, 0=174[20] 1 = 1744 */ -#define HID3 0xC83 /* firmware revision */ - -#define CHAR1(B1,B2) (((B1>>2) & 0x1F) | '@') -#define CHAR2(B1,B2) (((B1<<3) & 0x18) | ((B2>>5) & 0x7)|'@') -#define CHAR3(B1,B2) ((B2 & 0x1F) | '@') - -/* AHA1740 EISA board control registers (Offset from slot base) */ -#define EBCTRL 0xC84 -#define CDEN 0x01 -/***********************************************************************\ -* AHA1740 EISA board mode registers (Offset from slot base) * -\***********************************************************************/ -#define PORTADDR 0xCC0 -#define PORTADDR_ENHANCED 0x80 -#define BIOSADDR 0xCC1 -#define INTDEF 0xCC2 -#define SCSIDEF 0xCC3 -#define BUSDEF 0xCC4 -#define RESV0 0xCC5 -#define RESV1 0xCC6 -#define RESV2 0xCC7 -/**** bit definitions for INTDEF ****/ -#define INT9 0x00 -#define INT10 0x01 -#define INT11 0x02 -#define INT12 0x03 -#define INT14 0x05 -#define INT15 0x06 -#define INTHIGH 0x08 /* int high=ACTIVE (else edge) */ -#define INTEN 0x10 -/**** bit definitions for SCSIDEF ****/ -#define HSCSIID 0x0F /* our SCSI ID */ -#define RSTPWR 0x10 /* reset scsi bus on power up or reset */ -/**** bit definitions for BUSDEF ****/ -#define B0uS 0x00 /* give up bus immediatly */ -#define B4uS 0x01 /* delay 4uSec. */ -#define B8uS 0x02 -/***********************************************************************\ -* AHA1740 ENHANCED mode mailbox control regs (Offset from slot base) * -\***********************************************************************/ -#define MBOXOUT0 0xCD0 -#define MBOXOUT1 0xCD1 -#define MBOXOUT2 0xCD2 -#define MBOXOUT3 0xCD3 - -#define ATTN 0xCD4 -#define G2CNTRL 0xCD5 -#define G2INTST 0xCD6 -#define G2STAT 0xCD7 - -#define MBOXIN0 0xCD8 -#define MBOXIN1 0xCD9 -#define MBOXIN2 0xCDA -#define MBOXIN3 0xCDB - -#define G2STAT2 0xCDC - -/*******************************************************\ -* Bit definitions for the 5 control/status registers * -\*******************************************************/ -#define ATTN_TARGET 0x0F -#define ATTN_OPCODE 0xF0 -#define OP_IMMED 0x10 -#define AHB_TARG_RESET 0x80 -#define OP_START_ECB 0x40 -#define OP_ABORT_ECB 0x50 - -#define G2CNTRL_SET_HOST_READY 0x20 -#define G2CNTRL_CLEAR_EISA_INT 0x40 -#define G2CNTRL_HARD_RESET 0x80 - -#define G2INTST_TARGET 0x0F -#define G2INTST_INT_STAT 0xF0 -#define AHB_ECB_OK 0x10 -#define AHB_ECB_RECOVERED 0x50 -#define AHB_HW_ERR 0x70 -#define AHB_IMMED_OK 0xA0 -#define AHB_ECB_ERR 0xC0 -#define AHB_ASN 0xD0 /* for target mode */ -#define AHB_IMMED_ERR 0xE0 - -#define G2STAT_BUSY 0x01 -#define G2STAT_INT_PEND 0x02 -#define G2STAT_MBOX_EMPTY 0x04 - -#define G2STAT2_HOST_READY 0x01 -/* */ - -struct ahb_dma_seg -{ - physaddr addr; - long len; -}; - -struct ahb_ecb_status -{ - u_short status; -# define ST_DON 0x0001 -# define ST_DU 0x0002 -# define ST_QF 0x0008 -# define ST_SC 0x0010 -# define ST_DO 0x0020 -# define ST_CH 0x0040 -# define ST_INT 0x0080 -# define ST_ASA 0x0100 -# define ST_SNS 0x0200 -# define ST_INI 0x0800 -# define ST_ME 0x1000 -# define ST_ECA 0x4000 - u_char ha_status; -# define HS_OK 0x00 -# define HS_CMD_ABORTED_HOST 0x04 -# define HS_CMD_ABORTED_ADAPTER 0x05 -# define HS_TIMED_OUT 0x11 -# define HS_HARDWARE_ERR 0x20 -# define HS_SCSI_RESET_ADAPTER 0x22 -# define HS_SCSI_RESET_INCOMING 0x23 - u_char targ_status; -# define TS_OK 0x00 -# define TS_CHECK_CONDITION 0x02 -# define TS_BUSY 0x08 - u_long resid_count; - u_long resid_addr; - u_short addit_status; - u_char sense_len; - u_char unused[9]; - u_char cdb[6]; -}; - -/* */ - -struct ecb -{ - u_char opcode; -# define ECB_SCSI_OP 0x01 - u_char :4; - u_char options:3; - u_char :1; - short opt1; -# define ECB_CNE 0x0001 -# define ECB_DI 0x0080 -# define ECB_SES 0x0400 -# define ECB_S_G 0x1000 -# define ECB_DSB 0x4000 -# define ECB_ARS 0x8000 - short opt2; -# define ECB_LUN 0x0007 -# define ECB_TAG 0x0008 -# define ECB_TT 0x0030 -# define ECB_ND 0x0040 -# define ECB_DAT 0x0100 -# define ECB_DIR 0x0200 -# define ECB_ST 0x0400 -# define ECB_CHK 0x0800 -# define ECB_REC 0x4000 -# define ECB_NRB 0x8000 - u_short unused1; - physaddr data; - u_long datalen; - physaddr status; - physaddr chain; - short unused2; - short unused3; - physaddr sense; - u_char senselen; - u_char cdblen; - short cksum; - u_char cdb[12]; - /*-----------------end of hardware supported fields----------------*/ - struct ecb *next; /* in free list */ - struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ - int flags; -#define ECB_FREE 0 -#define ECB_ACTIVE 1 -#define ECB_ABORTED 2 -#define ECB_IMMED 4 -#define ECB_IMMED_FAIL 8 - struct ahb_dma_seg ahb_dma[AHB_NSEG]; - struct ahb_ecb_status ecb_status; - struct scsi_sense_data ecb_sense; -}; - -/* */ - -struct ahb_data -{ - int flags; -#define AHB_INIT 0x01; - int baseport; - struct ecb ecbs[NUM_CONCURRENT]; - struct ecb *free_ecb; - int our_id; /* our scsi id */ - int vect; - struct ecb *immed_ecb; /* an outstanding immediete command */ -} ahb_data[NAHB]; - -int ahbprobe(); -int ahb_attach(); -int ahbintr(); -int ahb_scsi_cmd(); -int ahb_timeout(); -struct ecb *cheat; -void ahbminphys(); -long int ahb_adapter_info(); - -#ifdef MACH -struct isa_driver ahbdriver = { ahbprobe, 0, ahb_attach, "ahb", 0, 0, 0}; -int (*ahbintrs[])() = {ahbintr, 0}; -#endif MACH - -#ifdef __386BSD__ -struct isa_driver ahbdriver = { ahbprobe, ahb_attach, "ahb"}; -#endif __386BSD__ - -#define MAX_SLOTS 8 -static ahb_slot = 0; /* slot last board was found in */ -static ahb_unit = 0; -int ahb_debug = 0; -#define AHB_SHOWECBS 0x01 -#define AHB_SHOWINTS 0x02 -#define AHB_SHOWCMDS 0x04 -#define AHB_SHOWMISC 0x08 -#define FAIL 1 -#define SUCCESS 0 -#define PAGESIZ 4096 - -struct scsi_switch ahb_switch = -{ - ahb_scsi_cmd, - ahbminphys, - 0, - 0, - ahb_adapter_info, - "ahb", - 0,0 -}; - -/* */ -/***********************************************************************\ -* Function to send a command out through a mailbox * -\***********************************************************************/ -ahb_send_mbox( int unit - ,int opcode - ,int target - ,struct ecb *ecb) -{ - int port = ahb_data[unit].baseport; - int spincount = FUDGE(delaycount) * 1; /* 1ms should be enough */ - int s = splbio(); - int stport = port + G2STAT; - - while( ((inb(stport) & (G2STAT_BUSY | G2STAT_MBOX_EMPTY)) - != (G2STAT_MBOX_EMPTY)) - && (spincount--)); - if(spincount == -1) - { - printf("ahb%d: board not responding\n",unit); - Debugger(); - } - - outl(port + MBOXOUT0,KVTOPHYS(ecb)); /* don't know this will work */ - outb(port + ATTN, opcode|target); - - splx(s); -} - -/***********************************************************************\ -* Function to poll for command completion when in poll mode * -\***********************************************************************/ -ahb_poll(int unit ,int wait) /* in msec */ -{ - int port = ahb_data[unit].baseport; - int spincount = FUDGE(delaycount) * wait; /* in msec */ - int stport = port + G2STAT; -int start = spincount; - -retry: - while( (spincount--) && (!(inb(stport) & G2STAT_INT_PEND))); - if(spincount == -1) - { - printf("ahb%d: board not responding\n",unit); - return(EIO); - } -if ((int)cheat != PHYSTOKV(inl(port + MBOXIN0))) -{ - printf("discarding %x ",inl(port + MBOXIN0)); - outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT); - spinwait(50); - goto retry; -}/* don't know this will work */ - ahbintr(unit); - return(0); -} -/***********************************************************************\ -* Function to send an immediate type command to the adapter * -\***********************************************************************/ -ahb_send_immed( int unit - ,int target - ,u_long cmd) -{ - int port = ahb_data[unit].baseport; - int spincount = FUDGE(delaycount) * 1; /* 1ms should be enough */ - int s = splbio(); - int stport = port + G2STAT; - - while( ((inb(stport) & (G2STAT_BUSY | G2STAT_MBOX_EMPTY)) - != (G2STAT_MBOX_EMPTY)) - && (spincount--)); - if(spincount == -1) - { - printf("ahb%d: board not responding\n",unit); - Debugger(); - } - - outl(port + MBOXOUT0,cmd); /* don't know this will work */ - outb(port + G2CNTRL, G2CNTRL_SET_HOST_READY); - outb(port + ATTN, OP_IMMED | target); - splx(s); -} - -/* */ - -/*******************************************************\ -* Check the slots looking for a board we recognise * -* If we find one, note it's address (slot) and call * -* the actual probe routine to check it out. * -\*******************************************************/ -ahbprobe(dev) -struct isa_dev *dev; -{ - int port; - u_char byte1,byte2,byte3; - ahb_slot++; - while (ahb_slot<8) - { - port = 0x1000 * ahb_slot; - byte1 = inb(port + HID0); - byte2 = inb(port + HID1); - byte3 = inb(port + HID2); - if(byte1 == 0xff) - { - ahb_slot++; - continue; - } - if ((CHAR1(byte1,byte2) == 'A') - && (CHAR2(byte1,byte2) == 'D') - && (CHAR3(byte1,byte2) == 'P') - && ((byte3 == 0 ) || (byte3 == 1))) - { - dev->dev_addr = port; - return(ahbprobe1(dev)); - } - ahb_slot++; - } - return(0); -} -/*******************************************************\ -* Check if the device can be found at the port given * -* and if so, set it up ready for further work * -* as an argument, takes the isa_dev structure from * -* autoconf.c * -\*******************************************************/ -ahbprobe1(dev) -struct isa_dev *dev; -{ - /***********************************************\ - * find unit and check we have that many defined * - \***********************************************/ - int unit = ahb_unit; -#if defined(OSF) - static ihandler_t ahb_handler[NAHB]; - static ihandler_id_t *ahb_handler_id[NAHB]; - register ihandler_t *chp = &ahb_handler[unit];; -#endif /* defined(OSF) */ - - dev->dev_unit = unit; - ahb_data[unit].baseport = dev->dev_addr; - if(unit >= NAHB) - { - printf("ahb: unit number (%d) too high\n",unit); - return(0); - } - /***********************************************\ - * Try initialise a unit at this location * - * sets up dma and bus speed, loads ahb_data[unit].vect* - \***********************************************/ - if (ahb_init(unit) != 0) - { - return(0); - } - - /***********************************************\ - * If it's there, put in it's interrupt vectors * - \***********************************************/ -#ifdef MACH - dev->dev_pic = ahb_data[unit].vect; -#if defined(OSF) /* OSF */ - chp->ih_level = dev->dev_pic; - chp->ih_handler = dev->dev_intr[0]; - chp->ih_resolver = i386_resolver; - chp->ih_rdev = dev; - chp->ih_stats.intr_type = INTR_DEVICE; - chp->ih_stats.intr_cnt = 0; - chp->ih_hparam[0].intparam = unit; - if ((ahb_handler_id[unit] = handler_add(chp)) != NULL) - handler_enable(ahb_handler_id[unit]); - else - panic("Unable to add ahb interrupt handler"); -#else /* CMU */ - take_dev_irq(dev); -#endif /* !defined(OSF) */ - printf("port=%x spl=%d\n", dev->dev_addr, dev->dev_spl); -#endif MACH -#ifdef __386BSD__ /* 386BSD */ - dev->id_irq = (1 << ahb_data[unit].vect); - dev->id_drq = -1; /* use EISA dma */ -#endif __386BSD__ - - ahb_unit++; - return(1); -} - -/***********************************************\ -* Attach all the sub-devices we can find * -\***********************************************/ -ahb_attach(dev) -struct isa_dev *dev; -{ - int unit = dev->dev_unit; - - /***********************************************\ - * ask the adapter what subunits are present * - \***********************************************/ - scsi_attachdevs( unit, ahb_data[unit].our_id, &ahb_switch); -#if defined(OSF) - ahb_attached[unit]=1; -#endif /* defined(OSF) */ - return; -} - -/***********************************************\ -* Return some information to the caller about * -* the adapter and it's capabilities * -\***********************************************/ -long int ahb_adapter_info(unit) -int unit; -{ - return(2); /* 2 outstanding requests at a time per device */ -} - -/***********************************************\ -* Catch an interrupt from the adaptor * -\***********************************************/ -ahbintr(unit) -{ - struct ecb *ecb; - unsigned char stat; - register i; - u_char ahbstat; - int target; - long int mboxval; - - int port = ahb_data[unit].baseport; - -#ifdef AHBDEBUG - if(scsi_debug & PRINTROUTINES) - printf("ahbintr "); -#endif /*AHBDEBUG*/ - -#if defined(OSF) - if (!ahb_attached[unit]) - { - return(1); - } -#endif /* defined(OSF) */ - while(inb(port + G2STAT) & G2STAT_INT_PEND) - { - /***********************************************\ - * First get all the information and then * - * acknowlege the interrupt * - \***********************************************/ - ahbstat = inb(port + G2INTST); - target = ahbstat & G2INTST_TARGET; - stat = ahbstat & G2INTST_INT_STAT; - mboxval = inl(port + MBOXIN0);/* don't know this will work */ - outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT); -#ifdef AHBDEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("status = 0x%x ",stat); -#endif /*AHBDEBUG*/ - /***********************************************\ - * Process the completed operation * - \***********************************************/ - - if(stat == AHB_ECB_OK) /* common case is fast */ - { - ecb = (struct ecb *)PHYSTOKV(mboxval); - } - else - { - switch(stat) - { - case AHB_IMMED_OK: - ecb = ahb_data[unit].immed_ecb; - ahb_data[unit].immed_ecb = 0; - break; - case AHB_IMMED_ERR: - ecb = ahb_data[unit].immed_ecb; - ecb->flags |= ECB_IMMED_FAIL; - ahb_data[unit].immed_ecb = 0; - break; - case AHB_ASN: /* for target mode */ - printf("ahb%d: Unexpected ASN interrupt(%x)\n", - unit, mboxval); - ecb = 0; - break; - case AHB_HW_ERR: - printf("ahb%d: Hardware error interrupt(%x)\n", - unit, mboxval); - ecb = 0; - break; - case AHB_ECB_RECOVERED: - ecb = (struct ecb *)PHYSTOKV(mboxval); - break; - case AHB_ECB_ERR: - ecb = (struct ecb *)PHYSTOKV(mboxval); - break; - default: - printf(" Unknown return from ahb%d(%x)\n",unit,ahbstat); - ecb=0; - } - } - if(ecb) - { -#ifdef AHBDEBUG - if(ahb_debug & AHB_SHOWCMDS ) - { - ahb_show_scsi_cmd(ecb->xs); - } - if((ahb_debug & AHB_SHOWECBS) && ecb) - printf("",ecb); -#endif /*AHBDEBUG*/ - untimeout(ahb_timeout,ecb); - ahb_done(unit,ecb,((stat == AHB_ECB_OK)?SUCCESS:FAIL)); - } - } - return(1); -} - -/***********************************************\ -* We have a ecb which has been processed by the * -* adaptor, now we look to see how the operation * -* went. * -\***********************************************/ -ahb_done(unit,ecb,state) -int unit,state; -struct ecb *ecb; -{ - struct ahb_ecb_status *stat = &ecb->ecb_status; - struct scsi_sense_data *s1,*s2; - struct scsi_xfer *xs = ecb->xs; - -#ifdef AHBDEBUG - if(scsi_debug & (PRINTROUTINES | TRACEINTERRUPTS)) - printf("ahb_done "); -#endif /*AHBDEBUG*/ - /***********************************************\ - * Otherwise, put the results of the operation * - * into the xfer and call whoever started it * - \***********************************************/ - if(ecb->flags & ECB_IMMED) - { - if(ecb->flags & ECB_IMMED_FAIL) - { - xs->error = XS_DRIVER_STUFFUP; - } - goto done; - } - if ( (state == SUCCESS) || (xs->flags & SCSI_ERR_OK)) - { /* All went correctly OR errors expected */ - xs->resid = 0; - xs->error = 0; - } - else - { - - s1 = &(ecb->ecb_sense); - s2 = &(xs->sense); - - if(stat->ha_status) - { - switch(stat->ha_status) - { - case HS_SCSI_RESET_ADAPTER: - break; - case HS_SCSI_RESET_INCOMING: - break; - case HS_CMD_ABORTED_HOST: /* No response */ - case HS_CMD_ABORTED_ADAPTER: /* No response */ - break; - case HS_TIMED_OUT: /* No response */ -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) - { - printf("timeout reported back\n"); - } -#endif /*AHBDEBUG*/ - xs->error = XS_TIMEOUT; - break; - default: /* Other scsi protocol messes */ - xs->error = XS_DRIVER_STUFFUP; -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) - { - printf("unexpected ha_status: %x\n", - stat->ha_status); - } -#endif /*AHBDEBUG*/ - } - - } - else - { - switch(stat->targ_status) - { - case TS_CHECK_CONDITION: - /* structure copy!!!!!*/ - *s2=*s1; - xs->error = XS_SENSE; - break; - case TS_BUSY: - xs->error = XS_BUSY; - break; - default: -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) - { - printf("unexpected targ_status: %x\n", - stat->targ_status); - } -#endif /*AHBDEBUG*/ - xs->error = XS_DRIVER_STUFFUP; - } - } - } -done: xs->flags |= ITSDONE; - ahb_free_ecb(unit,ecb, xs->flags); - if(xs->when_done) - (*(xs->when_done))(xs->done_arg,xs->done_arg2); -} - -/***********************************************\ -* A ecb (and hence a mbx-out is put onto the * -* free list. * -\***********************************************/ -ahb_free_ecb(unit,ecb, flags) -struct ecb *ecb; -{ - unsigned int opri; - -#ifdef AHBDEBUG - if(scsi_debug & PRINTROUTINES) - printf("ecb%d(0x%x)> ",unit,flags); -#endif /*AHBDEBUG*/ - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - - ecb->next = ahb_data[unit].free_ecb; - ahb_data[unit].free_ecb = ecb; - ecb->flags = ECB_FREE; - /***********************************************\ - * If there were none, wake abybody waiting for * - * one to come free, starting with queued entries* - \***********************************************/ - if (!ecb->next) { - wakeup(&ahb_data[unit].free_ecb); - } - if (!(flags & SCSI_NOMASK)) - splx(opri); -} - -/***********************************************\ -* Get a free ecb (and hence mbox-out entry) * -\***********************************************/ -struct ecb * -ahb_get_ecb(unit,flags) -{ - unsigned opri; - struct ecb *rc; - -#ifdef AHBDEBUG - if(scsi_debug & PRINTROUTINES) - printf("next; - rc->flags = ECB_ACTIVE; - } - if (!(flags & SCSI_NOMASK)) - splx(opri); - return(rc); -} - - - -/***********************************************\ -* Start the board, ready for normal operation * -\***********************************************/ -ahb_init(unit) -int unit; -{ - int port = ahb_data[unit].baseport; - int intdef; - int spincount = FUDGE(delaycount) * 1000; /* 1 sec enough? */ - int i; - int stport = port + G2STAT; -#define NO_NO 1 -#ifdef NO_NO - /***********************************************\ - * reset board, If it doesn't respond, assume * - * that it's not there.. good for the probe * - \***********************************************/ - outb(port + EBCTRL,CDEN); /* enable full card */ - outb(port + PORTADDR,PORTADDR_ENHANCED); - - outb(port + G2CNTRL,G2CNTRL_HARD_RESET); - spinwait(1); - outb(port + G2CNTRL,0); - spinwait(10); - while( ((inb(stport) & G2STAT_BUSY )) - && (spincount--)); - if(spincount == -1) - { -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) - printf("ahb_init: No answer from bt742a board\n"); -#endif /*AHBDEBUG*/ - return(ENXIO); - } - i = inb(port + MBOXIN0) & 0xff; - if(i) - { - printf("self test failed, val = 0x%x\n",i); - return(EIO); - } -#endif - while( inb(stport) & G2STAT_INT_PEND) - { - printf("."); - outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT); - spinwait(10); - } - outb(port + EBCTRL,CDEN); /* enable full card */ - outb(port + PORTADDR,PORTADDR_ENHANCED); - /***********************************************\ - * Assume we have a board at this stage * - * setup dma channel from jumpers and save int * - * level * - \***********************************************/ -#ifdef __386BSD__ - printf("ahb%d: reading board settings, ",unit); -#else __386BSD__ - printf("ahb%d:",unit); -#endif __386BSD__ - - intdef = inb(port + INTDEF); - switch(intdef & 0x07) - { - case INT9: - ahb_data[unit].vect = 9; - break; - case INT10: - ahb_data[unit].vect = 10; - break; - case INT11: - ahb_data[unit].vect = 11; - break; - case INT12: - ahb_data[unit].vect = 12; - break; - case INT14: - ahb_data[unit].vect = 14; - break; - case INT15: - ahb_data[unit].vect = 15; - break; - default: - printf("illegal int setting\n"); - return(EIO); - } -#ifdef __386BSD__ - printf("int=%d\n",ahb_data[unit].vect); -#else __386BSD__ - printf("int=%d ",ahb_data[unit].vect); -#endif __386BSD__ - - outb(port + INTDEF ,(intdef | INTEN)); /* make sure we can interrupt */ - /* who are we on the scsi bus */ - ahb_data[unit].our_id = (inb(port + SCSIDEF) & HSCSIID); - - /***********************************************\ - * link up all our ECBs into a free list * - \***********************************************/ - for (i=0; i < NUM_CONCURRENT; i++) - { - ahb_data[unit].ecbs[i].next = ahb_data[unit].free_ecb; - ahb_data[unit].free_ecb = &ahb_data[unit].ecbs[i]; - ahb_data[unit].free_ecb->flags = ECB_FREE; - } - - /***********************************************\ - * Note that we are going and return (to probe) * - \***********************************************/ - ahb_data[unit].flags |= AHB_INIT; - return( 0 ); -} - - -#ifndef min -#define min(x,y) (x < y ? x : y) -#endif min - - -void ahbminphys(bp) -struct buf *bp; -{ -#ifdef MACH -#if !defined(OSF) - bp->b_flags |= B_NPAGES; /* can support scat/gather */ -#endif /* defined(OSF) */ -#endif MACH - if(bp->b_bcount > ((AHB_NSEG-1) * PAGESIZ)) - { - bp->b_bcount = ((AHB_NSEG-1) * PAGESIZ); - } -} - -/***********************************************\ -* start a scsi operation given the command and * -* the data address. Also needs the unit, target * -* and lu * -\***********************************************/ -int ahb_scsi_cmd(xs) -struct scsi_xfer *xs; -{ - struct scsi_sense_data *s1,*s2; - struct ecb *ecb; - struct ahb_dma_seg *sg; - int seg; /* scatter gather seg being worked on */ - int i = 0; - int rc = 0; - int thiskv; - physaddr thisphys,nextphys; - int unit =xs->adapter; - int bytes_this_seg,bytes_this_page,datalen,flags; - struct iovec *iovp; - int s; -#ifdef AHBDEBUG - if(scsi_debug & PRINTROUTINES) - printf("ahb_scsi_cmd "); -#endif /*AHBDEBUG*/ - /***********************************************\ - * get a ecb (mbox-out) to use. If the transfer * - * is from a buf (possibly from interrupt time) * - * then we can't allow it to sleep * - \***********************************************/ - flags = xs->flags; - if(xs->bp) flags |= (SCSI_NOSLEEP); /* just to be sure */ - if(flags & ITSDONE) - { - printf("ahb%d: Already done?",unit); - xs->flags &= ~ITSDONE; - } - if(!(flags & INUSE)) - { - printf("ahb%d: Not in use?",unit); - xs->flags |= INUSE; - } - if (!(ecb = ahb_get_ecb(unit,flags))) - { - xs->error = XS_DRIVER_STUFFUP; - return(TRY_AGAIN_LATER); - } - -cheat = ecb; -#ifdef AHBDEBUG - if(ahb_debug & AHB_SHOWECBS) - printf("",ecb); - if(scsi_debug & SHOWCOMMANDS) - { - ahb_show_scsi_cmd(xs); - } -#endif /*AHBDEBUG*/ - ecb->xs = xs; - /***********************************************\ - * If it's a reset, we need to do an 'immediate' * - * command, and store it's ccb for later * - * if there is already an immediate waiting, * - * then WE must wait * - \***********************************************/ - if(flags & SCSI_RESET) - { - ecb->flags |= ECB_IMMED; - if(ahb_data[unit].immed_ecb) - { - return(TRY_AGAIN_LATER); - } - ahb_data[unit].immed_ecb = ecb; - if (!(flags & SCSI_NOMASK)) - { - s = splbio(); - ahb_send_immed(unit,xs->targ,AHB_TARG_RESET); - timeout(ahb_timeout,ecb,(xs->timeout * hz)/1000); - splx(s); - return(SUCCESSFULLY_QUEUED); - } - else - { - ahb_send_immed(unit,xs->targ,AHB_TARG_RESET); - /***********************************************\ - * If we can't use interrupts, poll on completion* - \***********************************************/ -#ifdef AHBDEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("wait "); -#endif /*AHBDEBUG*/ - if( ahb_poll(unit,xs->timeout)) - { - ahb_free_ecb(unit,ecb,flags); - xs->error = XS_TIMEOUT; - return(HAD_ERROR); - } - return(COMPLETE); - } - } - /***********************************************\ - * Put all the arguments for the xfer in the ecb * - \***********************************************/ - ecb->opcode = ECB_SCSI_OP; - ecb->opt1 = ECB_SES|ECB_DSB|ECB_ARS; - if(xs->datalen) - { - ecb->opt1 |= ECB_S_G; - } - ecb->opt2 = xs->lu | ECB_NRB; - ecb->cdblen = xs->cmdlen; - ecb->sense = KVTOPHYS(&(ecb->ecb_sense)); - ecb->senselen = sizeof(ecb->ecb_sense); - ecb->status = KVTOPHYS(&(ecb->ecb_status)); - - if(xs->datalen) - { /* should use S/G only if not zero length */ - ecb->data = KVTOPHYS(ecb->ahb_dma); - sg = ecb->ahb_dma ; - seg = 0; - if(flags & SCSI_DATA_UIO) - { - iovp = ((struct uio *)xs->data)->uio_iov; - datalen = ((struct uio *)xs->data)->uio_iovcnt; - xs->datalen = 0; - while ((datalen) && (seg < AHB_NSEG)) - { - sg->addr = (physaddr)iovp->iov_base; - xs->datalen += sg->len = iovp->iov_len; -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x@0x%x)" - ,iovp->iov_len - ,iovp->iov_base); -#endif /*AHBDEBUG*/ - sg++; - iovp++; - seg++; - datalen--; - } - } - else - { - /***********************************************\ - * Set up the scatter gather block * - \***********************************************/ - -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("%d @0x%x:- ",xs->datalen,xs->data); -#endif /*AHBDEBUG*/ - datalen = xs->datalen; - thiskv = (int)xs->data; - thisphys = KVTOPHYS(thiskv); - - while ((datalen) && (seg < AHB_NSEG)) - { - bytes_this_seg = 0; - - /* put in the base address */ - sg->addr = thisphys; - -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("0x%x",thisphys); -#endif /*AHBDEBUG*/ - - /* do it at least once */ - nextphys = thisphys; - while ((datalen) && (thisphys == nextphys)) - /*********************************************\ - * This page is contiguous (physically) with * - * the the last, just extend the length * - \*********************************************/ - { - /* how far to the end of the page */ - nextphys= (thisphys & (~(PAGESIZ - 1))) - + PAGESIZ; - bytes_this_page = nextphys - thisphys; - /**** or the data ****/ - bytes_this_page = min(bytes_this_page - ,datalen); - bytes_this_seg += bytes_this_page; - datalen -= bytes_this_page; - - /* get more ready for the next page */ - thiskv = (thiskv & (~(PAGESIZ - 1))) - + PAGESIZ; - if(datalen) - thisphys = KVTOPHYS(thiskv); - } - /********************************************\ - * next page isn't contiguous, finish the seg * - \********************************************/ -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x)",bytes_this_seg); -#endif /*AHBDEBUG*/ - sg->len = bytes_this_seg; - sg++; - seg++; - } - } /*end of iov/kv decision */ - ecb->datalen = seg * sizeof(struct ahb_dma_seg); -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("\n"); -#endif /*AHBDEBUG*/ - if (datalen) - { /* there's still data, must have run out of segs! */ - printf("ahb_scsi_cmd%d: more than %d DMA segs\n", - unit,AHB_NSEG); - xs->error = XS_DRIVER_STUFFUP; - ahb_free_ecb(unit,ecb,flags); - return(HAD_ERROR); - } - - } - else - { /* No data xfer, use non S/G values */ - ecb->data = (physaddr)0; - ecb->datalen = 0; - } - ecb->chain = (physaddr)0; - /***********************************************\ - * Put the scsi command in the ecb and start it * - \***********************************************/ - bcopy(xs->cmd, ecb->cdb, xs->cmdlen); - /***********************************************\ - * Usually return SUCCESSFULLY QUEUED * - \***********************************************/ - if (!(flags & SCSI_NOMASK)) - { - s = splbio(); - ahb_send_mbox(unit,OP_START_ECB,xs->targ,ecb); - timeout(ahb_timeout,ecb,(xs->timeout * hz)/1000); - splx(s); -#ifdef AHBDEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("cmd_sent "); -#endif /*AHBDEBUG*/ - return(SUCCESSFULLY_QUEUED); - } - /***********************************************\ - * If we can't use interrupts, poll on completion* - \***********************************************/ - ahb_send_mbox(unit,OP_START_ECB,xs->targ,ecb); -#ifdef AHBDEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("cmd_wait "); -#endif /*AHBDEBUG*/ - do - { - if(ahb_poll(unit,xs->timeout)) - { - if (!(xs->flags & SCSI_SILENT)) printf("cmd fail\n"); - ahb_send_mbox(unit,OP_ABORT_ECB,xs->targ,ecb); - if(ahb_poll(unit,2000)) - { - printf("abort failed in wait\n"); - ahb_free_ecb(unit,ecb,flags); - } - xs->error = XS_DRIVER_STUFFUP; - return(HAD_ERROR); - } - } while (!(xs->flags & ITSDONE));/* something (?) else finished */ - if(xs->error) - { - return(HAD_ERROR); - } - return(COMPLETE); -} - - -ahb_timeout(struct ecb *ecb) -{ - int unit; - int s = splbio(); - - unit = ecb->xs->adapter; - printf("ahb%d:%d device timed out\n",unit - ,ecb->xs->targ); -#ifdef AHBDEBUG - if(ahb_debug & AHB_SHOWECBS) - ahb_print_active_ecb(unit); -#endif /*AHBDEBUG*/ - - /***************************************\ - * If it's immediate, don't try abort it * - \***************************************/ - if(ecb->flags & ECB_IMMED) - { - ecb->xs->retries = 0; /* I MEAN IT ! */ - ecb->flags |= ECB_IMMED_FAIL; - ahb_done(unit,ecb,FAIL); - splx(s); - return; - } - /***************************************\ - * If it has been through before, then * - * a previous abort has failed, don't * - * try abort again * - \***************************************/ - if(ecb->flags == ECB_ABORTED) /* abort timed out */ - { - printf("AGAIN"); - ecb->xs->retries = 0; /* I MEAN IT ! */ - ecb->ecb_status.ha_status = HS_CMD_ABORTED_HOST; - ahb_done(unit,ecb,FAIL); - } - else /* abort the operation that has timed out */ - { - printf("\n"); - ahb_send_mbox(unit,OP_ABORT_ECB,ecb->xs->targ,ecb); - /* 2 secs for the abort */ - timeout(ahb_timeout,ecb,2 * hz); - ecb->flags = ECB_ABORTED; - } - splx(s); -} - -#ifdef AHBDEBUG -ahb_show_scsi_cmd(struct scsi_xfer *xs) -{ - u_char *b = (u_char *)xs->cmd; - int i = 0; - if(!(xs->flags & SCSI_RESET)) - { - printf("ahb%d:%d:%d-" - ,xs->adapter - ,xs->targ - ,xs->lu); - while(i < xs->cmdlen ) - { - if(i) printf(","); - printf("%x",b[i++]); - } - printf("-\n"); - } - else - { - printf("ahb%d:%d:%d-RESET-\n" - ,xs->adapter - ,xs->targ - ,xs->lu - ); - } -} -ahb_print_ecb(ecb) -struct ecb *ecb; -{ - printf("ecb:%x op:%x cmdlen:%d senlen:%d\n" - ,ecb - ,ecb->opcode - ,ecb->cdblen - ,ecb->senselen); - printf(" datlen:%d hstat:%x tstat:%x flags:%x\n" - ,ecb->datalen - ,ecb->ecb_status.ha_status - ,ecb->ecb_status.targ_status - ,ecb->flags); - ahb_show_scsi_cmd(ecb->xs); -} - -ahb_print_active_ecb(int unit) -{ - struct ecb *ecb = ahb_data[unit].ecbs; - int i = NUM_CONCURRENT; - - while(i--) - { - if(ecb->flags != ECB_FREE) - { - ahb_print_ecb(ecb); - } - ecb++; - } -} -#endif /*AHBDEBUG */ diff --git a/sys/i386/i386/autoconf.c b/sys/i386/i386/autoconf.c deleted file mode 100644 index 9f06f75..0000000 --- a/sys/i386/i386/autoconf.c +++ /dev/null @@ -1,192 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * Setup the system to run on the current machine. - * - * Configure() is called at boot time and initializes the vba - * device tables and the memory controller monitoring. Available - * devices are determined (from possibilities mentioned in ioconf.c), - * and the drivers are initialized. - */ -#include "param.h" -#include "systm.h" -#include "buf.h" -#include "dkstat.h" -#include "conf.h" -#include "dmap.h" -#include "reboot.h" - -#include "machine/pte.h" - -/* - * The following several variables are related to - * the configuration process, and are used in initializing - * the machine. - */ -int dkn; /* number of iostat dk numbers assigned so far */ -extern int cold; /* cold start flag initialized in locore.s */ - -/* - * Determine i/o configuration for a machine. - */ -configure() -{ - -#include "isa.h" -#if NISA > 0 - isa_configure(); -#endif - -#if GENERICxxx - if ((boothowto & RB_ASKNAME) == 0) - setroot(); - setconf(); -#else - setroot(); -#endif - /* - * Configure swap area and related system - * parameter based on device(s) used. - */ - swapconf(); - cold = 0; -} - -/* - * Configure swap space and related parameters. - */ -swapconf() -{ - register struct swdevt *swp; - register int nblks; -extern int Maxmem; - - for (swp = swdevt; swp->sw_dev > 0; swp++) - { - unsigned d = major(swp->sw_dev); - - if (d > nblkdev) break; - if (bdevsw[d].d_psize) { - nblks = (*bdevsw[d].d_psize)(swp->sw_dev); - if (nblks > 0 && - (swp->sw_nblks == 0 || swp->sw_nblks > nblks)) - swp->sw_nblks = nblks; - else - swp->sw_nblks = 0; - } - swp->sw_nblks = ctod(dtoc(swp->sw_nblks)); - } - if (dumplo == 0 && bdevsw[major(dumpdev)].d_psize) - /*dumplo = (*bdevsw[major(dumpdev)].d_psize)(dumpdev) - physmem;*/ - dumplo = (*bdevsw[major(dumpdev)].d_psize)(dumpdev) - - Maxmem*NBPG/512; - if (dumplo < 0) - dumplo = 0; -} - -#define DOSWAP /* change swdevt and dumpdev */ -u_long bootdev = 0; /* should be dev_t, but not until 32 bits */ - -static char devname[][2] = { - 'w','d', /* 0 = wd */ - 's','w', /* 1 = sw */ - 'f','d', /* 2 = fd */ - 'w','t', /* 3 = wt */ - 's','d', /* 4 = sd -- new SCSI system */ -}; - -#define PARTITIONMASK 0x7 -#define PARTITIONSHIFT 3 - -/* - * Attempt to find the device from which we were booted. - * If we can do so, and not instructed not to do so, - * change rootdev to correspond to the load device. - */ -setroot() -{ - int majdev, mindev, unit, part, adaptor; - dev_t temp, orootdev; - struct swdevt *swp; - -/*printf("howto %x bootdev %x ", boothowto, bootdev);*/ - if (boothowto & RB_DFLTROOT || - (bootdev & B_MAGICMASK) != (u_long)B_DEVMAGIC) - return; - majdev = (bootdev >> B_TYPESHIFT) & B_TYPEMASK; - if (majdev > sizeof(devname) / sizeof(devname[0])) - return; - adaptor = (bootdev >> B_ADAPTORSHIFT) & B_ADAPTORMASK; - part = (bootdev >> B_PARTITIONSHIFT) & B_PARTITIONMASK; - unit = (bootdev >> B_UNITSHIFT) & B_UNITMASK; - mindev = (unit << PARTITIONSHIFT) + part; - orootdev = rootdev; - rootdev = makedev(majdev, mindev); - /* - * If the original rootdev is the same as the one - * just calculated, don't need to adjust the swap configuration. - */ - if (rootdev == orootdev) - return; - printf("changing root device to %c%c%d%c\n", - devname[majdev][0], devname[majdev][1], - mindev >> PARTITIONSHIFT, part + 'a'); -#ifdef DOSWAP - mindev &= ~PARTITIONMASK; - for (swp = swdevt; swp->sw_dev; swp++) { - if (majdev == major(swp->sw_dev) && - mindev == (minor(swp->sw_dev) & ~PARTITIONMASK)) { - - temp = swdevt[0].sw_dev; - swdevt[0].sw_dev = swp->sw_dev; - swp->sw_dev = temp; - break; - } - } - if (swp->sw_dev == 0) - return; - /* - * If dumpdev was the same as the old primary swap - * device, move it to the new primary swap device. - */ - if (temp == dumpdev) - dumpdev = swdevt[0].sw_dev; -#endif -} diff --git a/sys/i386/i386/conf.c b/sys/i386/i386/conf.c deleted file mode 100644 index 9aec75d..0000000 --- a/sys/i386/i386/conf.c +++ /dev/null @@ -1,479 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)conf.c 5.8 (Berkeley) 5/12/91 - * $Id: conf.c,v 1.10 1993/10/11 07:39:13 rgrimes Exp $ - */ - -#include "param.h" -#include "systm.h" -#include "buf.h" -#include "ioctl.h" -#include "tty.h" -#include "conf.h" - -int nullop(), enxio(), enodev(), rawread(), rawwrite(), swstrategy(); -int rawread(), rawwrite(), swstrategy(); - -#include "wd.h" -#if NWD > 0 -int wdopen(),wdclose(),wdstrategy(),wdioctl(); -int wddump(),wdsize(); -#else -#define wdopen enxio -#define wdclose enxio -#define wdstrategy enxio -#define wdioctl enxio -#define wddump enxio -#define wdsize NULL -#endif - -#include "sd.h" -#if NSD > 0 -int sdopen(),sdclose(),sdstrategy(),sdioctl(); -int sddump(),sdsize(); -#else -#define sdopen enxio -#define sdclose enxio -#define sdstrategy enxio -#define sdioctl enxio -#define sddump enxio -#define sdsize NULL -#endif - -#include "st.h" -#if NST > 0 -int stopen(),stclose(),ststrategy(),stioctl(); -/*int stdump(),stsize();*/ -#define stdump enxio -#define stsize NULL -#else -#define stopen enxio -#define stclose enxio -#define ststrategy enxio -#define stioctl enxio -#define stdump enxio -#define stsize NULL -#endif - -#include "cd.h" -#if NCD > 0 -int cdopen(),cdclose(),cdstrategy(),cdioctl(); -int /*cddump(),*/cdsize(); -#define cddump enxio -#else -#define cdopen enxio -#define cdclose enxio -#define cdstrategy enxio -#define cdioctl enxio -#define cddump enxio -#define cdsize NULL -#endif - -#include "mcd.h" -#if NMCD > 0 -int mcdopen(),mcdclose(),mcdstrategy(),mcdioctl(); -int /*mcddump(),*/mcdsize(); -#define mcddump enxio -#else -#define mcdopen enxio -#define mcdclose enxio -#define mcdstrategy enxio -#define mcdioctl enxio -#define mcddump enxio -#define mcdsize NULL -#endif - -#include "ch.h" -#if NCH > 0 -int chopen(),chclose(),chioctl(); -#else -#define chopen enxio -#define chclose enxio -#define chioctl enxio -#endif - -#include "sg.h" -#if NSG > 0 -int sgopen(),sgclose(),sgioctl(),sgstrategy(); -#define sgdump enxio -#define sgsize NULL -#else -#define sgopen enxio -#define sgclose enxio -#define sgstrategy enxio -#define sgioctl enxio -#define sgdump enxio -#define sgsize NULL -#endif - -#include "wt.h" -#if NWT > 0 -int wtopen(),wtclose(),wtstrategy(),wtioctl(); -int wtdump(),wtsize(); -#else -#define wtopen enxio -#define wtclose enxio -#define wtstrategy enxio -#define wtioctl enxio -#define wtdump enxio -#define wtsize NULL -#endif - -#include "fd.h" -#if NFD > 0 -int Fdopen(),fdclose(),fdstrategy(),fdioctl(); -#define fddump enxio -#define fdsize NULL -#else -#define Fdopen enxio -#define fdclose enxio -#define fdstrategy enxio -#define fdioctl enxio -#define fddump enxio -#define fdsize NULL -#endif - -int swstrategy(),swread(),swwrite(); - -struct bdevsw bdevsw[] = -{ - { wdopen, wdclose, wdstrategy, wdioctl, /*0*/ - wddump, wdsize, NULL }, - { enodev, enodev, swstrategy, enodev, /*1*/ - enodev, enodev, NULL }, - { Fdopen, fdclose, fdstrategy, fdioctl, /*2*/ - fddump, fdsize, NULL }, - { wtopen, wtclose, wtstrategy, wtioctl, /*3*/ - wtdump, wtsize, B_TAPE }, - { sdopen, sdclose, sdstrategy, sdioctl, /*4*/ - sddump, sdsize, NULL }, - { stopen, stclose, ststrategy, stioctl, /*5*/ - stdump, stsize, NULL }, - { cdopen, cdclose, cdstrategy, cdioctl, /*6*/ - cddump, cdsize, NULL }, - { mcdopen, mcdclose, mcdstrategy, mcdioctl, /*7*/ - mcddump, mcdsize, NULL }, -/* - * If you need a bdev major number, please contact the 386bsd patchkit - * coordinator by sending mail to "patches@cs.montana.edu". - * If you assign one yourself it may conflict with someone else. - */ -}; -int nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]); - -int cnopen(),cnclose(),cnread(),cnwrite(),cnioctl(),cnselect(); - -int pcopen(),pcclose(),pcread(),pcwrite(),pcioctl(),pcmmap(); -extern struct tty pccons; - -int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect(); - -int mmopen(), mmclose(), mmrw(); -#define mmselect seltrue - -#include "pty.h" -#if NPTY > 0 -int ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop(); -int ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect(); -int ptyioctl(); -struct tty pt_tty[]; -#else -#define ptsopen enxio -#define ptsclose enxio -#define ptsread enxio -#define ptswrite enxio -#define ptcopen enxio -#define ptcclose enxio -#define ptcread enxio -#define ptcwrite enxio -#define ptyioctl enxio -#define pt_tty NULL -#define ptcselect enxio -#define ptsstop nullop -#endif - -#include "com.h" -#if NCOM > 0 -int comopen(),comclose(),comread(),comwrite(),comioctl(),comselect(); -#define comreset enxio -extern struct tty com_tty[]; -#else -#define comopen enxio -#define comclose enxio -#define comread enxio -#define comwrite enxio -#define comioctl enxio -#define comreset enxio -#define comselect enxio -#define com_tty NULL -#endif - -int logopen(),logclose(),logread(),logioctl(),logselect(); - -int ttselect(), seltrue(); - -#include "lpt.h" -#if NLPT > 0 -int lptopen(),lptclose(),lptwrite(),lptioctl(); -#else -#define lptopen enxio -#define lptclose enxio -#define lptwrite enxio -#define lptioctl enxio -#endif - -#include "tw.h" -#if NTW > 0 -int twopen(),twclose(),twread(),twwrite(),twselect(); -#else -#define twopen enxio -#define twclose enxio -#define twread enxio -#define twwrite enxio -#define twselect enxio -#endif - -#include "sb.h" /* Sound Blaster */ -#if NSB > 0 -int sbopen(), sbclose(), sbioctl(), sbread(), sbwrite(); -int sbselect(); -#else -#define sbopen enxio -#define sbclose enxio -#define sbioctl enxio -#define sbread enxio -#define sbwrite enxio -#define sbselect seltrue -#endif - -#include "snd.h" /* General Sound Driver */ -#if NSND > 0 -int sndopen(), sndclose(), sndioctl(), sndread(), sndwrite(); -int sndselect(); -#else -#define sndopen enxio -#define sndclose enxio -#define sndioctl enxio -#define sndread enxio -#define sndwrite enxio -#define sndselect seltrue -#endif - -int fdopen(); - -#include "bpfilter.h" -#if NBPFILTER > 0 -int bpfopen(),bpfclose(),bpfread(),bpfwrite(),bpfselect(),bpfioctl(); -#else -#define bpfopen enxio -#define bpfclose enxio -#define bpfread enxio -#define bpfwrite enxio -#define bpfselect enxio -#define bpfioctl enxio -#endif - -#include "dcfclk.h" -#if NDCFCLK > 0 -int dcfclkopen(),dcfclkclose(),dcfclkread(),dcfclkioctl(),dcfclkselect(); -#else -#define dcfclkopen enxio -#define dcfclkclose enxio -#define dcfclkread enxio -#define dcfclkioctl enxio -#define dcfclkselect enxio -#endif - -#include "lpa.h" -#if NLPA > 0 -int lpaopen(),lpaclose(),lpawrite(),lpaioctl(); -#else -#define lpaopen enxio -#define lpaclose enxio -#define lpawrite enxio -#define lpaioctl enxio -#endif - -#include "speaker.h" -#if NSPEAKER > 0 -int spkropen(),spkrclose(),spkrwrite(),spkrioctl(); -#else -#define spkropen enxio -#define spkrclose enxio -#define spkrwrite enxio -#define spkrioctl enxio -#endif - -#include "mse.h" -#if NMSE > 0 -int mseopen(),mseclose(),mseread(),mseselect(); -#else -#define mseopen enxio -#define mseclose enxio -#define mseread enxio -#define mseselect enxio -#endif - -#include "sio.h" -#if NSIO > 0 -int sioopen(),sioclose(),sioread(),siowrite(),sioioctl(),sioselect(), - siostop(); -#define sioreset enxio -extern struct tty sio_tty[]; -#else -#define sioopen enxio -#define sioclose enxio -#define sioread enxio -#define siowrite enxio -#define sioioctl enxio -#define siostop enxio -#define sioreset enxio -#define sioselect enxio -#define sio_tty NULL -#endif - -struct cdevsw cdevsw[] = -{ - { cnopen, cnclose, cnread, cnwrite, /*0*/ - cnioctl, nullop, nullop, NULL, /* console */ - cnselect, enodev, NULL }, - { cttyopen, nullop, cttyread, cttywrite, /*1*/ - cttyioctl, nullop, nullop, NULL, /* tty */ - cttyselect, enodev, NULL }, - { mmopen, mmclose, mmrw, mmrw, /*2*/ - enodev, nullop, nullop, NULL, /* memory */ - mmselect, enodev, NULL }, - { wdopen, wdclose, rawread, rawwrite, /*3*/ - wdioctl, enodev, nullop, NULL, /* wd */ - seltrue, enodev, wdstrategy }, - { nullop, nullop, rawread, rawwrite, /*4*/ - enodev, enodev, nullop, NULL, /* swap */ - enodev, enodev, swstrategy }, - { ptsopen, ptsclose, ptsread, ptswrite, /*5*/ - ptyioctl, ptsstop, nullop, pt_tty, /* ttyp */ - ttselect, enodev, NULL }, - { ptcopen, ptcclose, ptcread, ptcwrite, /*6*/ - ptyioctl, nullop, nullop, pt_tty, /* ptyp */ - ptcselect, enodev, NULL }, - { logopen, logclose, logread, enodev, /*7*/ - logioctl, enodev, nullop, NULL, /* klog */ - logselect, enodev, NULL }, - { comopen, comclose, comread, comwrite, /*8*/ - comioctl, enodev, comreset, com_tty, /* com */ - comselect, enodev, NULL }, - { Fdopen, fdclose, rawread, rawwrite, /*9*/ - fdioctl, enodev, nullop, NULL, /* Fd (!=fd) */ - seltrue, enodev, fdstrategy }, - { wtopen, wtclose, rawread, rawwrite, /*10*/ - wtioctl, enodev, nullop, NULL, /* wt */ - seltrue, enodev, wtstrategy }, - { enodev, enodev, enodev, enodev, /*11*/ - enodev, enodev, nullop, NULL, - seltrue, enodev, enodev }, - { pcopen, pcclose, pcread, pcwrite, /*12*/ - pcioctl, nullop, nullop, &pccons, /* pc */ - ttselect, pcmmap, NULL }, - { sdopen, sdclose, rawread, rawwrite, /*13*/ - sdioctl, enodev, nullop, NULL, /* sd */ - seltrue, enodev, sdstrategy }, - { stopen, stclose, rawread, rawwrite, /*14*/ - stioctl, enodev, nullop, NULL, /* st */ - seltrue, enodev, ststrategy }, - { cdopen, cdclose, rawread, enodev, /*15*/ - cdioctl, enodev, nullop, NULL, /* cd */ - seltrue, enodev, cdstrategy }, - { lptopen, lptclose, nullop, lptwrite, /*16*/ - lptioctl, nullop, nullop, NULL, /* lpt */ - seltrue, enodev, enodev}, - { chopen, chclose, enxio, enxio, /*17*/ - chioctl, enxio, enxio, NULL, /* ch */ - enxio, enxio, enxio }, - { sgopen, sgclose, enodev, enodev, /*18*/ - sgioctl, enodev, nullop, NULL, /* scsi 'generic' */ - seltrue, enodev, sgstrategy }, - { twopen, twclose, twread, twwrite, /*19*/ - enodev, nullop, nullop, NULL, /* tw */ - twselect, enodev, enodev }, - { sbopen, sbclose, sbread, sbwrite, /*20*/ - sbioctl, enodev, enodev, NULL, /* soundblaster*/ - sbselect, enodev, NULL }, - { sndopen, sndclose, sndread, sndwrite, /*21*/ - sndioctl, enodev, enodev, NULL, /* sound driver */ - sndselect, enodev, NULL }, - { fdopen, enxio, enxio, enxio, /*22*/ - enxio, enxio, enxio, NULL, /* fd (!=Fd) */ - enxio, enxio, enxio }, - { bpfopen, bpfclose, bpfread, bpfwrite, /*23*/ - bpfioctl, enodev, nullop, NULL, /* bpf */ - bpfselect, enodev, NULL }, - { dcfclkopen, dcfclkclose, dcfclkread, enodev, /*24*/ - dcfclkioctl, enodev, nullop, NULL, /* dcfclk */ - dcfclkselect, enodev, NULL }, - { lpaopen, lpaclose, nullop, lpawrite, /*25*/ - lpaioctl, nullop, nullop, NULL, /* lpa */ - seltrue, enodev, enodev}, - { spkropen, spkrclose, enxio, spkrwrite, /*26*/ - spkrioctl, enxio, enxio, NULL, /* spkr */ - enxio, enxio, enxio }, - { mseopen, mseclose, mseread, nullop, /*27*/ - nullop, enodev, nullop, NULL, /* mse */ - mseselect, enodev, NULL }, - { sioopen, sioclose, sioread, siowrite, /*28*/ - sioioctl, siostop, sioreset, sio_tty, /* sio */ - sioselect, enodev, NULL }, - { mcdopen, mcdclose, rawread, enodev, /*29*/ - mcdioctl, enodev, nullop, NULL, /* mitsumi cd */ - seltrue, enodev, mcdstrategy }, -/* - * If you need a cdev major number, please contact the 386bsd patchkit - * coordinator by sending mail to "patches@cs.montana.edu". - * If you assign one yourself it may then conflict with someone else. - */ -}; -int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]); - -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(1, 0); diff --git a/sys/i386/i386/cons.c b/sys/i386/i386/cons.c deleted file mode 100644 index 2e92a9c..0000000 --- a/sys/i386/i386/cons.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)cons.c 7.2 (Berkeley) 5/9/91 - * $Id: cons.c,v 1.3 1993/10/16 14:14:49 rgrimes Exp $ - */ - - -#include "sys/param.h" -#include "sys/proc.h" -#include "sys/user.h" -#include "sys/systm.h" -#include "sys/buf.h" -#include "sys/ioctl.h" -#include "sys/tty.h" -#include "sys/file.h" -#include "sys/conf.h" - -#include "cons.h" - -/* XXX - all this could be autoconfig()ed */ -int pccnprobe(), pccninit(), pccngetc(), pccnputc(); -#include "com.h" -#if NCOM > 0 -int comcnprobe(), comcninit(), comcngetc(), comcnputc(); -#endif - -struct consdev constab[] = { - { pccnprobe, pccninit, pccngetc, pccnputc }, -#if NCOM > 0 - { comcnprobe, comcninit, comcngetc, comcnputc }, -#endif - { 0 }, -}; -/* end XXX */ - -struct tty *constty = 0; /* virtual console output device */ -struct consdev *cn_tab; /* physical console device info */ -struct tty *cn_tty; /* XXX: console tty struct for tprintf */ - -cninit() -{ - register struct consdev *cp; - - /* - * Collect information about all possible consoles - * and find the one with highest priority - */ - for (cp = constab; cp->cn_probe; cp++) { - (*cp->cn_probe)(cp); - if (cp->cn_pri > CN_DEAD && - (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri)) - cn_tab = cp; - } - /* - * No console, we can handle it - */ - if ((cp = cn_tab) == NULL) - return; - /* - * Turn on console - */ - cn_tty = cp->cn_tp; - (*cp->cn_init)(cp); -} - -cnopen(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - if (cn_tab == NULL) - return (0); - dev = cn_tab->cn_dev; - return ((*cdevsw[major(dev)].d_open)(dev, flag, mode, p)); -} - -cnclose(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - if (cn_tab == NULL) - return (0); - dev = cn_tab->cn_dev; - return ((*cdevsw[major(dev)].d_close)(dev, flag, mode, p)); -} - -cnread(dev, uio, flag) - dev_t dev; - struct uio *uio; -{ - if (cn_tab == NULL) - return (0); - dev = cn_tab->cn_dev; - return ((*cdevsw[major(dev)].d_read)(dev, uio, flag)); -} - -cnwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; -{ - if (cn_tab == NULL) - return (0); - if (constty) /* 16 Aug 92*/ - dev = constty->t_dev; - else - dev = cn_tab->cn_dev; - return ((*cdevsw[major(dev)].d_write)(dev, uio, flag)); -} - -cnioctl(dev, cmd, data, flag, p) - dev_t dev; - caddr_t data; - struct proc *p; -{ - int error; - - if (cn_tab == NULL) - return (0); - /* - * Superuser can always use this to wrest control of console - * output from the "virtual" console. - */ - if (cmd == TIOCCONS && constty) { - error = suser(p->p_ucred, (u_short *) NULL); - if (error) - return (error); - constty = NULL; - return (0); - } - dev = cn_tab->cn_dev; - return ((*cdevsw[major(dev)].d_ioctl)(dev, cmd, data, flag, p)); -} - -/*ARGSUSED*/ -cnselect(dev, rw, p) - dev_t dev; - int rw; - struct proc *p; -{ - if (cn_tab == NULL) - return (1); - return (ttselect(cn_tab->cn_dev, rw, p)); -} - -cngetc() -{ - if (cn_tab == NULL) - return (0); - return ((*cn_tab->cn_getc)(cn_tab->cn_dev)); -} - -cnputc(c) - register int c; -{ - if (cn_tab == NULL) - return; - if (c) { - (*cn_tab->cn_putc)(cn_tab->cn_dev, c); - if (c == '\n') - (*cn_tab->cn_putc)(cn_tab->cn_dev, '\r'); - } -} - -pg(p,q,r,s,t,u,v,w,x,y,z) char *p; { - printf(p,q,r,s,t,u,v,w,x,y,z); - printf("\n>"); - return(cngetc()); -} - - diff --git a/sys/i386/i386/cons.h b/sys/i386/i386/cons.h deleted file mode 100644 index e8a9812..0000000 --- a/sys/i386/i386/cons.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)cons.h 7.2 (Berkeley) 5/9/91 - * $Id$ - */ - - -struct consdev { - int (*cn_probe)(); /* probe hardware and fill in consdev info */ - int (*cn_init)(); /* turn on as console */ - int (*cn_getc)(); /* kernel getchar interface */ - int (*cn_putc)(); /* kernel putchar interface */ - struct tty *cn_tp; /* tty structure for console device */ - dev_t cn_dev; /* major/minor of device */ - short cn_pri; /* pecking order; the higher the better */ -}; - -/* values for cn_pri - reflect our policy for console selection */ -#define CN_DEAD 0 /* device doesn't exist */ -#define CN_NORMAL 1 /* device exists but is nothing special */ -#define CN_INTERNAL 2 /* "internal" bit-mapped display */ -#define CN_REMOTE 3 /* serial interface with remote bit set */ - -/* XXX */ -#define CONSMAJOR 0 - -#ifdef KERNEL -extern struct consdev constab[]; -extern struct consdev *cn_tab; -extern struct tty *cn_tty; -#endif diff --git a/sys/i386/i386/db_disasm.c b/sys/i386/i386/db_disasm.c deleted file mode 100644 index a8b98da..0000000 --- a/sys/i386/i386/db_disasm.c +++ /dev/null @@ -1,1374 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990 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. - * - * $Id$ - */ - -/* - * Instruction disassembler. - */ -#include "param.h" -#include "proc.h" -#include - -#include -#include - -/* - * Size attributes - */ -#define BYTE 0 -#define WORD 1 -#define LONG 2 -#define QUAD 3 -#define SNGL 4 -#define DBLR 5 -#define EXTR 6 -#define SDEP 7 -#define NONE 8 - -/* - * Addressing modes - */ -#define E 1 /* general effective address */ -#define Eind 2 /* indirect address (jump, call) */ -#define Ew 3 /* address, word size */ -#define Eb 4 /* address, byte size */ -#define R 5 /* register, in 'reg' field */ -#define Rw 6 /* word register, in 'reg' field */ -#define Ri 7 /* register in instruction */ -#define S 8 /* segment reg, in 'reg' field */ -#define Si 9 /* segment reg, in instruction */ -#define A 10 /* accumulator */ -#define BX 11 /* (bx) */ -#define CL 12 /* cl, for shifts */ -#define DX 13 /* dx, for IO */ -#define SI 14 /* si */ -#define DI 15 /* di */ -#define CR 16 /* control register */ -#define DR 17 /* debug register */ -#define TR 18 /* test register */ -#define I 19 /* immediate, unsigned */ -#define Is 20 /* immediate, signed */ -#define Ib 21 /* byte immediate, unsigned */ -#define Ibs 22 /* byte immediate, signed */ -#define Iw 23 /* word immediate, unsigned */ -#define Il 24 /* long immediate */ -#define O 25 /* direct address */ -#define Db 26 /* byte displacement from EIP */ -#define Dl 27 /* long displacement from EIP */ -#define o1 28 /* constant 1 */ -#define o3 29 /* constant 3 */ -#define OS 30 /* immediate offset/segment */ -#define ST 31 /* FP stack top */ -#define STI 32 /* FP stack */ -#define X 33 /* extended FP op */ -#define XA 34 /* for 'fstcw %ax' */ - -struct inst { - char * i_name; /* name */ - short i_has_modrm; /* has regmodrm byte */ - short i_size; /* operand size */ - int i_mode; /* addressing modes */ - char * i_extra; /* pointer to extra opcode table */ -}; - -#define op1(x) (x) -#define op2(x,y) ((x)|((y)<<8)) -#define op3(x,y,z) ((x)|((y)<<8)|((z)<<16)) - -struct finst { - char * f_name; /* name for memory instruction */ - int f_size; /* size for memory instruction */ - int f_rrmode; /* mode for rr instruction */ - char * f_rrname; /* name for rr instruction - (or pointer to table) */ -}; - -char * db_Grp6[] = { - "sldt", - "str", - "lldt", - "ltr", - "verr", - "verw", - "", - "" -}; - -char * db_Grp7[] = { - "sgdt", - "sidt", - "lgdt", - "lidt", - "smsw", - "", - "lmsw", - "invlpg" -}; - -char * db_Grp8[] = { - "", - "", - "", - "", - "bt", - "bts", - "btr", - "btc" -}; - -struct inst db_inst_0f0x[] = { -/*00*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp6 }, -/*01*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp7 }, -/*02*/ { "lar", TRUE, LONG, op2(E,R), 0 }, -/*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 }, -/*04*/ { "", FALSE, NONE, 0, 0 }, -/*05*/ { "", FALSE, NONE, 0, 0 }, -/*06*/ { "clts", FALSE, NONE, 0, 0 }, -/*07*/ { "", FALSE, NONE, 0, 0 }, - -/*08*/ { "invd", FALSE, NONE, 0, 0 }, -/*09*/ { "wbinvd",FALSE, NONE, 0, 0 }, -/*0a*/ { "", FALSE, NONE, 0, 0 }, -/*0b*/ { "", FALSE, NONE, 0, 0 }, -/*0c*/ { "", FALSE, NONE, 0, 0 }, -/*0d*/ { "", FALSE, NONE, 0, 0 }, -/*0e*/ { "", FALSE, NONE, 0, 0 }, -/*0f*/ { "", FALSE, NONE, 0, 0 }, -}; - -struct inst db_inst_0f2x[] = { -/*20*/ { "mov", TRUE, LONG, op2(CR,E), 0 }, /* use E for reg */ -/*21*/ { "mov", TRUE, LONG, op2(DR,E), 0 }, /* since mod == 11 */ -/*22*/ { "mov", TRUE, LONG, op2(E,CR), 0 }, -/*23*/ { "mov", TRUE, LONG, op2(E,DR), 0 }, -/*24*/ { "mov", TRUE, LONG, op2(TR,E), 0 }, -/*25*/ { "", FALSE, NONE, 0, 0 }, -/*26*/ { "mov", TRUE, LONG, op2(E,TR), 0 }, -/*27*/ { "", FALSE, NONE, 0, 0 }, - -/*28*/ { "", FALSE, NONE, 0, 0 }, -/*29*/ { "", FALSE, NONE, 0, 0 }, -/*2a*/ { "", FALSE, NONE, 0, 0 }, -/*2b*/ { "", FALSE, NONE, 0, 0 }, -/*2c*/ { "", FALSE, NONE, 0, 0 }, -/*2d*/ { "", FALSE, NONE, 0, 0 }, -/*2e*/ { "", FALSE, NONE, 0, 0 }, -/*2f*/ { "", FALSE, NONE, 0, 0 }, -}; - -struct inst db_inst_0f8x[] = { -/*80*/ { "jo", FALSE, NONE, op1(Dl), 0 }, -/*81*/ { "jno", FALSE, NONE, op1(Dl), 0 }, -/*82*/ { "jb", FALSE, NONE, op1(Dl), 0 }, -/*83*/ { "jnb", FALSE, NONE, op1(Dl), 0 }, -/*84*/ { "jz", FALSE, NONE, op1(Dl), 0 }, -/*85*/ { "jnz", FALSE, NONE, op1(Dl), 0 }, -/*86*/ { "jbe", FALSE, NONE, op1(Dl), 0 }, -/*87*/ { "jnbe", FALSE, NONE, op1(Dl), 0 }, - -/*88*/ { "js", FALSE, NONE, op1(Dl), 0 }, -/*89*/ { "jns", FALSE, NONE, op1(Dl), 0 }, -/*8a*/ { "jp", FALSE, NONE, op1(Dl), 0 }, -/*8b*/ { "jnp", FALSE, NONE, op1(Dl), 0 }, -/*8c*/ { "jl", FALSE, NONE, op1(Dl), 0 }, -/*8d*/ { "jnl", FALSE, NONE, op1(Dl), 0 }, -/*8e*/ { "jle", FALSE, NONE, op1(Dl), 0 }, -/*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 }, -}; - -struct inst db_inst_0f9x[] = { -/*90*/ { "seto", TRUE, NONE, op1(Eb), 0 }, -/*91*/ { "setno", TRUE, NONE, op1(Eb), 0 }, -/*92*/ { "setb", TRUE, NONE, op1(Eb), 0 }, -/*93*/ { "setnb", TRUE, NONE, op1(Eb), 0 }, -/*94*/ { "setz", TRUE, NONE, op1(Eb), 0 }, -/*95*/ { "setnz", TRUE, NONE, op1(Eb), 0 }, -/*96*/ { "setbe", TRUE, NONE, op1(Eb), 0 }, -/*97*/ { "setnbe",TRUE, NONE, op1(Eb), 0 }, - -/*98*/ { "sets", TRUE, NONE, op1(Eb), 0 }, -/*99*/ { "setns", TRUE, NONE, op1(Eb), 0 }, -/*9a*/ { "setp", TRUE, NONE, op1(Eb), 0 }, -/*9b*/ { "setnp", TRUE, NONE, op1(Eb), 0 }, -/*9c*/ { "setl", TRUE, NONE, op1(Eb), 0 }, -/*9d*/ { "setnl", TRUE, NONE, op1(Eb), 0 }, -/*9e*/ { "setle", TRUE, NONE, op1(Eb), 0 }, -/*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 }, -}; - -struct inst db_inst_0fax[] = { -/*a0*/ { "push", FALSE, NONE, op1(Si), 0 }, -/*a1*/ { "pop", FALSE, NONE, op1(Si), 0 }, -/*a2*/ { "", FALSE, NONE, 0, 0 }, -/*a3*/ { "bt", TRUE, LONG, op2(E,R), 0 }, -/*a4*/ { "shld", TRUE, LONG, op3(Ib,E,R), 0 }, -/*a5*/ { "shld", TRUE, LONG, op3(CL,E,R), 0 }, -/*a6*/ { "", FALSE, NONE, 0, 0 }, -/*a7*/ { "", FALSE, NONE, 0, 0 }, - -/*a8*/ { "push", FALSE, NONE, op1(Si), 0 }, -/*a9*/ { "pop", FALSE, NONE, op1(Si), 0 }, -/*aa*/ { "", FALSE, NONE, 0, 0 }, -/*ab*/ { "bts", TRUE, LONG, op2(E,R), 0 }, -/*ac*/ { "shrd", TRUE, LONG, op3(Ib,E,R), 0 }, -/*ad*/ { "shrd", TRUE, LONG, op3(CL,E,R), 0 }, -/*a6*/ { "", FALSE, NONE, 0, 0 }, -/*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 }, -}; - -struct inst db_inst_0fbx[] = { -/*b0*/ { "", FALSE, NONE, 0, 0 }, -/*b1*/ { "", FALSE, NONE, 0, 0 }, -/*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 }, -/*b3*/ { "bts", TRUE, LONG, op2(R, E), 0 }, -/*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 }, -/*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 }, -/*b6*/ { "movzb", TRUE, LONG, op2(E, R), 0 }, -/*b7*/ { "movzw", TRUE, LONG, op2(E, R), 0 }, - -/*b8*/ { "", FALSE, NONE, 0, 0 }, -/*b9*/ { "", FALSE, NONE, 0, 0 }, -/*ba*/ { "", TRUE, LONG, op2(Is, E), (char *)db_Grp8 }, -/*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 }, -/*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 }, -/*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 }, -/*be*/ { "movsb", TRUE, LONG, op2(E, R), 0 }, -/*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 }, -}; - -struct inst db_inst_0fcx[] = { -/*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 }, -/*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 }, -/*c2*/ { "", FALSE, NONE, 0, 0 }, -/*c3*/ { "", FALSE, NONE, 0, 0 }, -/*c4*/ { "", FALSE, NONE, 0, 0 }, -/*c5*/ { "", FALSE, NONE, 0, 0 }, -/*c6*/ { "", FALSE, NONE, 0, 0 }, -/*c7*/ { "", FALSE, NONE, 0, 0 }, -/*c8*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*c9*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*ca*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*cb*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*cc*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*cd*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*ce*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -}; - -struct inst db_inst_0fdx[] = { -/*c0*/ { "cmpxchg",TRUE, BYTE, op2(R, E), 0 }, -/*c1*/ { "cmpxchg",TRUE, LONG, op2(R, E), 0 }, -/*c2*/ { "", FALSE, NONE, 0, 0 }, -/*c3*/ { "", FALSE, NONE, 0, 0 }, -/*c4*/ { "", FALSE, NONE, 0, 0 }, -/*c5*/ { "", FALSE, NONE, 0, 0 }, -/*c6*/ { "", FALSE, NONE, 0, 0 }, -/*c7*/ { "", FALSE, NONE, 0, 0 }, -/*c8*/ { "", FALSE, NONE, 0, 0 }, -/*c9*/ { "", FALSE, NONE, 0, 0 }, -/*ca*/ { "", FALSE, NONE, 0, 0 }, -/*cb*/ { "", FALSE, NONE, 0, 0 }, -/*cc*/ { "", FALSE, NONE, 0, 0 }, -/*cd*/ { "", FALSE, NONE, 0, 0 }, -/*ce*/ { "", FALSE, NONE, 0, 0 }, -/*cf*/ { "", FALSE, NONE, 0, 0 }, -}; - -struct inst *db_inst_0f[] = { - db_inst_0f0x, - 0, - db_inst_0f2x, - 0, - 0, - 0, - 0, - 0, - db_inst_0f8x, - db_inst_0f9x, - db_inst_0fax, - db_inst_0fbx, - db_inst_0fcx, - db_inst_0fdx, - 0, - 0 -}; - -char * db_Esc92[] = { - "fnop", "", "", "", "", "", "", "" -}; -char * db_Esc93[] = { - "", "", "", "", "", "", "", "" -}; -char * db_Esc94[] = { - "fchs", "fabs", "", "", "ftst", "fxam", "", "" -}; -char * db_Esc95[] = { - "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","" -}; -char * db_Esc96[] = { - "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp", - "fincstp" -}; -char * db_Esc97[] = { - "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos" -}; - -char * db_Esca4[] = { - "", "fucompp","", "", "", "", "", "" -}; - -char * db_Escb4[] = { - "", "", "fnclex","fninit","", "", "", "" -}; - -char * db_Esce3[] = { - "", "fcompp","", "", "", "", "", "" -}; - -char * db_Escf4[] = { - "fnstsw","", "", "", "", "", "", "" -}; - -struct finst db_Esc8[] = { -/*0*/ { "fadd", SNGL, op2(STI,ST), 0 }, -/*1*/ { "fmul", SNGL, op2(STI,ST), 0 }, -/*2*/ { "fcom", SNGL, op2(STI,ST), 0 }, -/*3*/ { "fcomp", SNGL, op2(STI,ST), 0 }, -/*4*/ { "fsub", SNGL, op2(STI,ST), 0 }, -/*5*/ { "fsubr", SNGL, op2(STI,ST), 0 }, -/*6*/ { "fdiv", SNGL, op2(STI,ST), 0 }, -/*7*/ { "fdivr", SNGL, op2(STI,ST), 0 }, -}; - -struct finst db_Esc9[] = { -/*0*/ { "fld", SNGL, op1(STI), 0 }, -/*1*/ { "", NONE, op1(STI), "fxch" }, -/*2*/ { "fst", SNGL, op1(X), (char *)db_Esc92 }, -/*3*/ { "fstp", SNGL, op1(X), (char *)db_Esc93 }, -/*4*/ { "fldenv", NONE, op1(X), (char *)db_Esc94 }, -/*5*/ { "fldcw", NONE, op1(X), (char *)db_Esc95 }, -/*6*/ { "fnstenv",NONE, op1(X), (char *)db_Esc96 }, -/*7*/ { "fnstcw", NONE, op1(X), (char *)db_Esc97 }, -}; - -struct finst db_Esca[] = { -/*0*/ { "fiadd", WORD, 0, 0 }, -/*1*/ { "fimul", WORD, 0, 0 }, -/*2*/ { "ficom", WORD, 0, 0 }, -/*3*/ { "ficomp", WORD, 0, 0 }, -/*4*/ { "fisub", WORD, op1(X), (char *)db_Esca4 }, -/*5*/ { "fisubr", WORD, 0, 0 }, -/*6*/ { "fidiv", WORD, 0, 0 }, -/*7*/ { "fidivr", WORD, 0, 0 } -}; - -struct finst db_Escb[] = { -/*0*/ { "fild", WORD, 0, 0 }, -/*1*/ { "", NONE, 0, 0 }, -/*2*/ { "fist", WORD, 0, 0 }, -/*3*/ { "fistp", WORD, 0, 0 }, -/*4*/ { "", WORD, op1(X), (char *)db_Escb4 }, -/*5*/ { "fld", EXTR, 0, 0 }, -/*6*/ { "", WORD, 0, 0 }, -/*7*/ { "fstp", EXTR, 0, 0 }, -}; - -struct finst db_Escc[] = { -/*0*/ { "fadd", DBLR, op2(ST,STI), 0 }, -/*1*/ { "fmul", DBLR, op2(ST,STI), 0 }, -/*2*/ { "fcom", DBLR, op2(ST,STI), 0 }, -/*3*/ { "fcomp", DBLR, op2(ST,STI), 0 }, -/*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" }, -/*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" }, -/*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" }, -/*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" }, -}; - -struct finst db_Escd[] = { -/*0*/ { "fld", DBLR, op1(STI), "ffree" }, -/*1*/ { "", NONE, 0, 0 }, -/*2*/ { "fst", DBLR, op1(STI), 0 }, -/*3*/ { "fstp", DBLR, op1(STI), 0 }, -/*4*/ { "frstor", NONE, op1(STI), "fucom" }, -/*5*/ { "", NONE, op1(STI), "fucomp" }, -/*6*/ { "fnsave", NONE, 0, 0 }, -/*7*/ { "fnstsw", NONE, 0, 0 }, -}; - -struct finst db_Esce[] = { -/*0*/ { "fiadd", LONG, op2(ST,STI), "faddp" }, -/*1*/ { "fimul", LONG, op2(ST,STI), "fmulp" }, -/*2*/ { "ficom", LONG, 0, 0 }, -/*3*/ { "ficomp", LONG, op1(X), (char *)db_Esce3 }, -/*4*/ { "fisub", LONG, op2(ST,STI), "fsubrp" }, -/*5*/ { "fisubr", LONG, op2(ST,STI), "fsubp" }, -/*6*/ { "fidiv", LONG, op2(ST,STI), "fdivrp" }, -/*7*/ { "fidivr", LONG, op2(ST,STI), "fdivp" }, -}; - -struct finst db_Escf[] = { -/*0*/ { "fild", LONG, 0, 0 }, -/*1*/ { "", LONG, 0, 0 }, -/*2*/ { "fist", LONG, 0, 0 }, -/*3*/ { "fistp", LONG, 0, 0 }, -/*4*/ { "fbld", NONE, op1(XA), (char *)db_Escf4 }, -/*5*/ { "fld", QUAD, 0, 0 }, -/*6*/ { "fbstp", NONE, 0, 0 }, -/*7*/ { "fstp", QUAD, 0, 0 }, -}; - -struct finst *db_Esc_inst[] = { - db_Esc8, db_Esc9, db_Esca, db_Escb, - db_Escc, db_Escd, db_Esce, db_Escf -}; - -char * db_Grp1[] = { - "add", - "or", - "adc", - "sbb", - "and", - "sub", - "xor", - "cmp" -}; - -char * db_Grp2[] = { - "rol", - "ror", - "rcl", - "rcr", - "shl", - "shr", - "shl", - "sar" -}; - -struct inst db_Grp3[] = { - { "test", TRUE, NONE, op2(I,E), 0 }, - { "test", TRUE, NONE, op2(I,E), 0 }, - { "not", TRUE, NONE, op1(E), 0 }, - { "neg", TRUE, NONE, op1(E), 0 }, - { "mul", TRUE, NONE, op2(E,A), 0 }, - { "imul", TRUE, NONE, op2(E,A), 0 }, - { "div", TRUE, NONE, op2(E,A), 0 }, - { "idiv", TRUE, NONE, op2(E,A), 0 }, -}; - -struct inst db_Grp4[] = { - { "inc", TRUE, BYTE, op1(E), 0 }, - { "dec", TRUE, BYTE, op1(E), 0 }, - { "", TRUE, NONE, 0, 0 }, - { "", TRUE, NONE, 0, 0 }, - { "", TRUE, NONE, 0, 0 }, - { "", TRUE, NONE, 0, 0 }, - { "", TRUE, NONE, 0, 0 }, - { "", TRUE, NONE, 0, 0 } -}; - -struct inst db_Grp5[] = { - { "inc", TRUE, LONG, op1(E), 0 }, - { "dec", TRUE, LONG, op1(E), 0 }, - { "call", TRUE, NONE, op1(Eind),0 }, - { "lcall", TRUE, NONE, op1(Eind),0 }, - { "jmp", TRUE, NONE, op1(Eind),0 }, - { "ljmp", TRUE, NONE, op1(Eind),0 }, - { "push", TRUE, LONG, op1(E), 0 }, - { "", TRUE, NONE, 0, 0 } -}; - -struct inst db_inst_table[256] = { -/*00*/ { "add", TRUE, BYTE, op2(R, E), 0 }, -/*01*/ { "add", TRUE, LONG, op2(R, E), 0 }, -/*02*/ { "add", TRUE, BYTE, op2(E, R), 0 }, -/*03*/ { "add", TRUE, LONG, op2(E, R), 0 }, -/*04*/ { "add", FALSE, BYTE, op2(Is, A), 0 }, -/*05*/ { "add", FALSE, LONG, op2(Is, A), 0 }, -/*06*/ { "push", FALSE, NONE, op1(Si), 0 }, -/*07*/ { "pop", FALSE, NONE, op1(Si), 0 }, - -/*08*/ { "or", TRUE, BYTE, op2(R, E), 0 }, -/*09*/ { "or", TRUE, LONG, op2(R, E), 0 }, -/*0a*/ { "or", TRUE, BYTE, op2(E, R), 0 }, -/*0b*/ { "or", TRUE, LONG, op2(E, R), 0 }, -/*0c*/ { "or", FALSE, BYTE, op2(I, A), 0 }, -/*0d*/ { "or", FALSE, LONG, op2(I, A), 0 }, -/*0e*/ { "push", FALSE, NONE, op1(Si), 0 }, -/*0f*/ { "", FALSE, NONE, 0, 0 }, - -/*10*/ { "adc", TRUE, BYTE, op2(R, E), 0 }, -/*11*/ { "adc", TRUE, LONG, op2(R, E), 0 }, -/*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 }, -/*13*/ { "adc", TRUE, LONG, op2(E, R), 0 }, -/*14*/ { "adc", FALSE, BYTE, op2(Is, A), 0 }, -/*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 }, -/*16*/ { "push", FALSE, NONE, op1(Si), 0 }, -/*17*/ { "pop", FALSE, NONE, op1(Si), 0 }, - -/*18*/ { "sbb", TRUE, BYTE, op2(R, E), 0 }, -/*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 }, -/*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 }, -/*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 }, -/*1c*/ { "sbb", FALSE, BYTE, op2(Is, A), 0 }, -/*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 }, -/*1e*/ { "push", FALSE, NONE, op1(Si), 0 }, -/*1f*/ { "pop", FALSE, NONE, op1(Si), 0 }, - -/*20*/ { "and", TRUE, BYTE, op2(R, E), 0 }, -/*21*/ { "and", TRUE, LONG, op2(R, E), 0 }, -/*22*/ { "and", TRUE, BYTE, op2(E, R), 0 }, -/*23*/ { "and", TRUE, LONG, op2(E, R), 0 }, -/*24*/ { "and", FALSE, BYTE, op2(I, A), 0 }, -/*25*/ { "and", FALSE, LONG, op2(I, A), 0 }, -/*26*/ { "", FALSE, NONE, 0, 0 }, -/*27*/ { "aaa", FALSE, NONE, 0, 0 }, - -/*28*/ { "sub", TRUE, BYTE, op2(R, E), 0 }, -/*29*/ { "sub", TRUE, LONG, op2(R, E), 0 }, -/*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 }, -/*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 }, -/*2c*/ { "sub", FALSE, BYTE, op2(Is, A), 0 }, -/*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 }, -/*2e*/ { "", FALSE, NONE, 0, 0 }, -/*2f*/ { "das", FALSE, NONE, 0, 0 }, - -/*30*/ { "xor", TRUE, BYTE, op2(R, E), 0 }, -/*31*/ { "xor", TRUE, LONG, op2(R, E), 0 }, -/*32*/ { "xor", TRUE, BYTE, op2(E, R), 0 }, -/*33*/ { "xor", TRUE, LONG, op2(E, R), 0 }, -/*34*/ { "xor", FALSE, BYTE, op2(I, A), 0 }, -/*35*/ { "xor", FALSE, LONG, op2(I, A), 0 }, -/*36*/ { "", FALSE, NONE, 0, 0 }, -/*37*/ { "daa", FALSE, NONE, 0, 0 }, - -/*38*/ { "cmp", TRUE, BYTE, op2(R, E), 0 }, -/*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 }, -/*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 }, -/*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 }, -/*3c*/ { "cmp", FALSE, BYTE, op2(Is, A), 0 }, -/*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 }, -/*3e*/ { "", FALSE, NONE, 0, 0 }, -/*3f*/ { "aas", FALSE, NONE, 0, 0 }, - -/*40*/ { "inc", FALSE, LONG, op1(Ri), 0 }, -/*41*/ { "inc", FALSE, LONG, op1(Ri), 0 }, -/*42*/ { "inc", FALSE, LONG, op1(Ri), 0 }, -/*43*/ { "inc", FALSE, LONG, op1(Ri), 0 }, -/*44*/ { "inc", FALSE, LONG, op1(Ri), 0 }, -/*45*/ { "inc", FALSE, LONG, op1(Ri), 0 }, -/*46*/ { "inc", FALSE, LONG, op1(Ri), 0 }, -/*47*/ { "inc", FALSE, LONG, op1(Ri), 0 }, - -/*48*/ { "dec", FALSE, LONG, op1(Ri), 0 }, -/*49*/ { "dec", FALSE, LONG, op1(Ri), 0 }, -/*4a*/ { "dec", FALSE, LONG, op1(Ri), 0 }, -/*4b*/ { "dec", FALSE, LONG, op1(Ri), 0 }, -/*4c*/ { "dec", FALSE, LONG, op1(Ri), 0 }, -/*4d*/ { "dec", FALSE, LONG, op1(Ri), 0 }, -/*4e*/ { "dec", FALSE, LONG, op1(Ri), 0 }, -/*4f*/ { "dec", FALSE, LONG, op1(Ri), 0 }, - -/*50*/ { "push", FALSE, LONG, op1(Ri), 0 }, -/*51*/ { "push", FALSE, LONG, op1(Ri), 0 }, -/*52*/ { "push", FALSE, LONG, op1(Ri), 0 }, -/*53*/ { "push", FALSE, LONG, op1(Ri), 0 }, -/*54*/ { "push", FALSE, LONG, op1(Ri), 0 }, -/*55*/ { "push", FALSE, LONG, op1(Ri), 0 }, -/*56*/ { "push", FALSE, LONG, op1(Ri), 0 }, -/*57*/ { "push", FALSE, LONG, op1(Ri), 0 }, - -/*58*/ { "pop", FALSE, LONG, op1(Ri), 0 }, -/*59*/ { "pop", FALSE, LONG, op1(Ri), 0 }, -/*5a*/ { "pop", FALSE, LONG, op1(Ri), 0 }, -/*5b*/ { "pop", FALSE, LONG, op1(Ri), 0 }, -/*5c*/ { "pop", FALSE, LONG, op1(Ri), 0 }, -/*5d*/ { "pop", FALSE, LONG, op1(Ri), 0 }, -/*5e*/ { "pop", FALSE, LONG, op1(Ri), 0 }, -/*5f*/ { "pop", FALSE, LONG, op1(Ri), 0 }, - -/*60*/ { "pusha", FALSE, LONG, 0, 0 }, -/*61*/ { "popa", FALSE, LONG, 0, 0 }, -/*62*/ { "bound", TRUE, LONG, op2(E, R), 0 }, -/*63*/ { "arpl", TRUE, NONE, op2(Ew,Rw), 0 }, - -/*64*/ { "", FALSE, NONE, 0, 0 }, -/*65*/ { "", FALSE, NONE, 0, 0 }, -/*66*/ { "", FALSE, NONE, 0, 0 }, -/*67*/ { "", FALSE, NONE, 0, 0 }, - -/*68*/ { "push", FALSE, LONG, op1(I), 0 }, -/*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 }, -/*6a*/ { "push", FALSE, LONG, op1(Ib), 0 }, -/*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 }, -/*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 }, -/*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 }, -/*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 }, -/*6f*/ { "outs", FALSE, LONG, op2(SI, DX), 0 }, - -/*70*/ { "jo", FALSE, NONE, op1(Db), 0 }, -/*71*/ { "jno", FALSE, NONE, op1(Db), 0 }, -/*72*/ { "jb", FALSE, NONE, op1(Db), 0 }, -/*73*/ { "jnb", FALSE, NONE, op1(Db), 0 }, -/*74*/ { "jz", FALSE, NONE, op1(Db), 0 }, -/*75*/ { "jnz", FALSE, NONE, op1(Db), 0 }, -/*76*/ { "jbe", FALSE, NONE, op1(Db), 0 }, -/*77*/ { "jnbe", FALSE, NONE, op1(Db), 0 }, - -/*78*/ { "js", FALSE, NONE, op1(Db), 0 }, -/*79*/ { "jns", FALSE, NONE, op1(Db), 0 }, -/*7a*/ { "jp", FALSE, NONE, op1(Db), 0 }, -/*7b*/ { "jnp", FALSE, NONE, op1(Db), 0 }, -/*7c*/ { "jl", FALSE, NONE, op1(Db), 0 }, -/*7d*/ { "jnl", FALSE, NONE, op1(Db), 0 }, -/*7e*/ { "jle", FALSE, NONE, op1(Db), 0 }, -/*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 }, - -/*80*/ { "", TRUE, BYTE, op2(I, E), (char *)db_Grp1 }, -/*81*/ { "", TRUE, LONG, op2(I, E), (char *)db_Grp1 }, -/*82*/ { "", TRUE, BYTE, op2(Is,E), (char *)db_Grp1 }, -/*83*/ { "", TRUE, LONG, op2(Ibs,E), (char *)db_Grp1 }, -/*84*/ { "test", TRUE, BYTE, op2(R, E), 0 }, -/*85*/ { "test", TRUE, LONG, op2(R, E), 0 }, -/*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 }, -/*87*/ { "xchg", TRUE, LONG, op2(R, E), 0 }, - -/*88*/ { "mov", TRUE, BYTE, op2(R, E), 0 }, -/*89*/ { "mov", TRUE, LONG, op2(R, E), 0 }, -/*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 }, -/*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 }, -/*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 }, -/*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 }, -/*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 }, -/*8f*/ { "pop", TRUE, LONG, op1(E), 0 }, - -/*90*/ { "nop", FALSE, NONE, 0, 0 }, -/*91*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, -/*92*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, -/*93*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, -/*94*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, -/*95*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, -/*96*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, -/*97*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, - -/*98*/ { "cbw", FALSE, SDEP, 0, "cwde" }, /* cbw/cwde */ -/*99*/ { "cwd", FALSE, SDEP, 0, "cdq" }, /* cwd/cdq */ -/*9a*/ { "lcall", FALSE, NONE, op1(OS), 0 }, -/*9b*/ { "wait", FALSE, NONE, 0, 0 }, -/*9c*/ { "pushf", FALSE, LONG, 0, 0 }, -/*9d*/ { "popf", FALSE, LONG, 0, 0 }, -/*9e*/ { "sahf", FALSE, NONE, 0, 0 }, -/*9f*/ { "lahf", FALSE, NONE, 0, 0 }, - -/*a0*/ { "mov", FALSE, BYTE, op2(O, A), 0 }, -/*a1*/ { "mov", FALSE, LONG, op2(O, A), 0 }, -/*a2*/ { "mov", FALSE, BYTE, op2(A, O), 0 }, -/*a3*/ { "mov", FALSE, LONG, op2(A, O), 0 }, -/*a4*/ { "movs", FALSE, BYTE, op2(SI,DI), 0 }, -/*a5*/ { "movs", FALSE, LONG, op2(SI,DI), 0 }, -/*a6*/ { "cmps", FALSE, BYTE, op2(SI,DI), 0 }, -/*a7*/ { "cmps", FALSE, LONG, op2(SI,DI), 0 }, - -/*a8*/ { "test", FALSE, BYTE, op2(I, A), 0 }, -/*a9*/ { "test", FALSE, LONG, op2(I, A), 0 }, -/*aa*/ { "stos", FALSE, BYTE, op1(DI), 0 }, -/*ab*/ { "stos", FALSE, LONG, op1(DI), 0 }, -/*ac*/ { "lods", FALSE, BYTE, op1(SI), 0 }, -/*ad*/ { "lods", FALSE, LONG, op1(SI), 0 }, -/*ae*/ { "scas", FALSE, BYTE, op1(SI), 0 }, -/*af*/ { "scas", FALSE, LONG, op1(SI), 0 }, - -/*b0*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, -/*b1*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, -/*b2*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, -/*b3*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, -/*b4*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, -/*b5*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, -/*b6*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, -/*b7*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, - -/*b8*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, -/*b9*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, -/*ba*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, -/*bb*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, -/*bc*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, -/*bd*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, -/*be*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, -/*bf*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, - -/*c0*/ { "", TRUE, BYTE, op2(Ib, E), (char *)db_Grp2 }, -/*c1*/ { "", TRUE, LONG, op2(Ib, E), (char *)db_Grp2 }, -/*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 }, -/*c3*/ { "ret", FALSE, NONE, 0, 0 }, -/*c4*/ { "les", TRUE, LONG, op2(E, R), 0 }, -/*c5*/ { "lds", TRUE, LONG, op2(E, R), 0 }, -/*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 }, -/*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 }, - -/*c8*/ { "enter", FALSE, NONE, op2(Ib, Iw), 0 }, -/*c9*/ { "leave", FALSE, NONE, 0, 0 }, -/*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 }, -/*cb*/ { "lret", FALSE, NONE, 0, 0 }, -/*cc*/ { "int", FALSE, NONE, op1(o3), 0 }, -/*cd*/ { "int", FALSE, NONE, op1(Ib), 0 }, -/*ce*/ { "into", FALSE, NONE, 0, 0 }, -/*cf*/ { "iret", FALSE, NONE, 0, 0 }, - -/*d0*/ { "", TRUE, BYTE, op2(o1, E), (char *)db_Grp2 }, -/*d1*/ { "", TRUE, LONG, op2(o1, E), (char *)db_Grp2 }, -/*d2*/ { "", TRUE, BYTE, op2(CL, E), (char *)db_Grp2 }, -/*d3*/ { "", TRUE, LONG, op2(CL, E), (char *)db_Grp2 }, -/*d4*/ { "aam", TRUE, NONE, 0, 0 }, -/*d5*/ { "aad", TRUE, NONE, 0, 0 }, -/*d6*/ { "", FALSE, NONE, 0, 0 }, -/*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 }, - -/*d8*/ { "", TRUE, NONE, 0, (char *)db_Esc8 }, -/*d9*/ { "", TRUE, NONE, 0, (char *)db_Esc9 }, -/*da*/ { "", TRUE, NONE, 0, (char *)db_Esca }, -/*db*/ { "", TRUE, NONE, 0, (char *)db_Escb }, -/*dc*/ { "", TRUE, NONE, 0, (char *)db_Escc }, -/*dd*/ { "", TRUE, NONE, 0, (char *)db_Escd }, -/*de*/ { "", TRUE, NONE, 0, (char *)db_Esce }, -/*df*/ { "", TRUE, NONE, 0, (char *)db_Escf }, - -/*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 }, -/*e1*/ { "loope", FALSE, NONE, op1(Db), 0 }, -/*e2*/ { "loop", FALSE, NONE, op1(Db), 0 }, -/*e3*/ { "jcxz", FALSE, SDEP, op1(Db), "jecxz" }, -/*e4*/ { "in", FALSE, BYTE, op2(Ib, A), 0 }, -/*e5*/ { "in", FALSE, LONG, op2(Ib, A) , 0 }, -/*e6*/ { "out", FALSE, BYTE, op2(A, Ib), 0 }, -/*e7*/ { "out", FALSE, LONG, op2(A, Ib) , 0 }, - -/*e8*/ { "call", FALSE, NONE, op1(Dl), 0 }, -/*e9*/ { "jmp", FALSE, NONE, op1(Dl), 0 }, -/*ea*/ { "ljmp", FALSE, NONE, op1(OS), 0 }, -/*eb*/ { "jmp", FALSE, NONE, op1(Db), 0 }, -/*ec*/ { "in", FALSE, BYTE, op2(DX, A), 0 }, -/*ed*/ { "in", FALSE, LONG, op2(DX, A) , 0 }, -/*ee*/ { "out", FALSE, BYTE, op2(A, DX), 0 }, -/*ef*/ { "out", FALSE, LONG, op2(A, DX) , 0 }, - -/*f0*/ { "", FALSE, NONE, 0, 0 }, -/*f1*/ { "", FALSE, NONE, 0, 0 }, -/*f2*/ { "", FALSE, NONE, 0, 0 }, -/*f3*/ { "", FALSE, NONE, 0, 0 }, -/*f4*/ { "hlt", FALSE, NONE, 0, 0 }, -/*f5*/ { "cmc", FALSE, NONE, 0, 0 }, -/*f6*/ { "", TRUE, BYTE, 0, (char *)db_Grp3 }, -/*f7*/ { "", TRUE, LONG, 0, (char *)db_Grp3 }, - -/*f8*/ { "clc", FALSE, NONE, 0, 0 }, -/*f9*/ { "stc", FALSE, NONE, 0, 0 }, -/*fa*/ { "cli", FALSE, NONE, 0, 0 }, -/*fb*/ { "sti", FALSE, NONE, 0, 0 }, -/*fc*/ { "cld", FALSE, NONE, 0, 0 }, -/*fd*/ { "std", FALSE, NONE, 0, 0 }, -/*fe*/ { "", TRUE, NONE, 0, (char *)db_Grp4 }, -/*ff*/ { "", TRUE, NONE, 0, (char *)db_Grp5 }, -}; - -struct inst db_bad_inst = - { "???", FALSE, NONE, 0, 0 } -; - -#define f_mod(byte) ((byte)>>6) -#define f_reg(byte) (((byte)>>3)&0x7) -#define f_rm(byte) ((byte)&0x7) - -#define sib_ss(byte) ((byte)>>6) -#define sib_index(byte) (((byte)>>3)&0x7) -#define sib_base(byte) ((byte)&0x7) - -struct i_addr { - int is_reg; /* if reg, reg number is in 'disp' */ - int disp; - char * base; - char * index; - int ss; -}; - -char * db_index_reg_16[8] = { - "%bx,%si", - "%bx,%di", - "%bp,%si", - "%bp,%di", - "%si", - "%di", - "%bp", - "%bx" -}; - -char * db_reg[3][8] = { - "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh", - "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di", - "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" -}; - -char * db_seg_reg[8] = { - "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", "" -}; - -/* - * lengths for size attributes - */ -int db_lengths[] = { - 1, /* BYTE */ - 2, /* WORD */ - 4, /* LONG */ - 8, /* QUAD */ - 4, /* SNGL */ - 8, /* DBLR */ - 10, /* EXTR */ -}; - -#define get_value_inc(result, loc, size, is_signed) \ - result = db_get_value((loc), (size), (is_signed)); \ - (loc) += (size); - -/* - * Read address at location and return updated location. - */ -db_addr_t -db_read_address(loc, short_addr, regmodrm, addrp) - db_addr_t loc; - int short_addr; - int regmodrm; - struct i_addr *addrp; /* out */ -{ - int mod, rm, sib, index, ss, disp; - - mod = f_mod(regmodrm); - rm = f_rm(regmodrm); - - if (mod == 3) { - addrp->is_reg = TRUE; - addrp->disp = rm; - return (loc); - } - addrp->is_reg = FALSE; - addrp->index = 0; - - if (short_addr) { - addrp->index = 0; - addrp->ss = 0; - switch (mod) { - case 0: - if (rm == 6) { - get_value_inc(disp, loc, 2, TRUE); - addrp->disp = disp; - addrp->base = 0; - } - else { - addrp->disp = 0; - addrp->base = db_index_reg_16[rm]; - } - break; - case 1: - get_value_inc(disp, loc, 1, TRUE); - addrp->disp = disp; - addrp->base = db_index_reg_16[rm]; - break; - case 2: - get_value_inc(disp, loc, 2, TRUE); - addrp->disp = disp; - addrp->base = db_index_reg_16[rm]; - break; - } - } - else { - if (mod != 3 && rm == 4) { - get_value_inc(sib, loc, 1, FALSE); - rm = sib_base(sib); - index = sib_index(sib); - if (index != 4) - addrp->index = db_reg[LONG][index]; - addrp->ss = sib_ss(sib); - } - - switch (mod) { - case 0: - if (rm == 5) { - get_value_inc(addrp->disp, loc, 4, FALSE); - addrp->base = 0; - } - else { - addrp->disp = 0; - addrp->base = db_reg[LONG][rm]; - } - break; - - case 1: - get_value_inc(disp, loc, 1, TRUE); - addrp->disp = disp; - addrp->base = db_reg[LONG][rm]; - break; - - case 2: - get_value_inc(disp, loc, 4, FALSE); - addrp->disp = disp; - addrp->base = db_reg[LONG][rm]; - break; - } - } - return (loc); -} - -void -db_print_address(seg, size, addrp) - char * seg; - int size; - struct i_addr *addrp; -{ - if (addrp->is_reg) { - db_printf("%s", db_reg[size][addrp->disp]); - return; - } - - if (seg) { - db_printf("%s:", seg); - } - - db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY); - if (addrp->base != 0 || addrp->index != 0) { - db_printf("("); - if (addrp->base) - db_printf("%s", addrp->base); - if (addrp->index) - db_printf(",%s,%d", addrp->index, 1<ss); - db_printf(")"); - } -} - -/* - * Disassemble floating-point ("escape") instruction - * and return updated location. - */ -db_addr_t -db_disasm_esc(loc, inst, short_addr, size, seg) - db_addr_t loc; - int inst; - int short_addr; - int size; - char * seg; -{ - int regmodrm; - struct finst *fp; - int mod; - struct i_addr address; - char * name; - - get_value_inc(regmodrm, loc, 1, FALSE); - fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)]; - mod = f_mod(regmodrm); - if (mod != 3) { - /* - * Normal address modes. - */ - loc = db_read_address(loc, short_addr, regmodrm, &address); - db_printf(fp->f_name); - switch(fp->f_size) { - case SNGL: - db_printf("s"); - break; - case DBLR: - db_printf("l"); - break; - case EXTR: - db_printf("t"); - break; - case WORD: - db_printf("s"); - break; - case LONG: - db_printf("l"); - break; - case QUAD: - db_printf("q"); - break; - default: - break; - } - db_printf("\t"); - db_print_address(seg, BYTE, &address); - } - else { - /* - * 'reg-reg' - special formats - */ - switch (fp->f_rrmode) { - case op2(ST,STI): - name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; - db_printf("%s\t%%st,%%st(%d)",name,f_rm(regmodrm)); - break; - case op2(STI,ST): - name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; - db_printf("%s\t%%st(%d),%%st",name, f_rm(regmodrm)); - break; - case op1(STI): - name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; - db_printf("%s\t%%st(%d)",name, f_rm(regmodrm)); - break; - case op1(X): - db_printf("%s", ((char **)fp->f_rrname)[f_rm(regmodrm)]); - break; - case op1(XA): - db_printf("%s\t%%ax", - ((char **)fp->f_rrname)[f_rm(regmodrm)]); - break; - default: - db_printf(""); - break; - } - } - - return (loc); -} - -/* - * Disassemble instruction at 'loc'. 'altfmt' specifies an - * (optional) alternate format. Return address of start of - * next instruction. - */ -db_addr_t -db_disasm(loc, altfmt) - db_addr_t loc; - boolean_t altfmt; -{ - int inst; - int size; - int short_addr; - char * seg; - struct inst * ip; - char * i_name; - int i_size; - int i_mode; - int regmodrm; - boolean_t first; - int displ; - int prefix; - int imm; - int imm2; - int len; - struct i_addr address; - - get_value_inc(inst, loc, 1, FALSE); - short_addr = FALSE; - size = LONG; - seg = 0; - - /* - * Get prefixes - */ - prefix = TRUE; - do { - switch (inst) { - case 0x66: /* data16 */ - size = WORD; - break; - case 0x67: - short_addr = TRUE; - break; - case 0x26: - seg = "%es"; - break; - case 0x36: - seg = "%ss"; - break; - case 0x2e: - seg = "%cs"; - break; - case 0x3e: - seg = "%ds"; - break; - case 0x64: - seg = "%fs"; - break; - case 0x65: - seg = "%gs"; - break; - case 0xf0: - db_printf("lock "); - break; - case 0xf2: - db_printf("repne "); - break; - case 0xf3: - db_printf("repe "); /* XXX repe VS rep */ - break; - default: - prefix = FALSE; - break; - } - if (prefix) { - get_value_inc(inst, loc, 1, FALSE); - } - } while (prefix); - - if (inst >= 0xd8 && inst <= 0xdf) { - loc = db_disasm_esc(loc, inst, short_addr, size, seg); - db_printf("\n"); - return (loc); - } - - if (inst == 0x0f) { - get_value_inc(inst, loc, 1, FALSE); - ip = db_inst_0f[inst>>4]; - if (ip == 0) { - ip = &db_bad_inst; - } - else { - ip = &ip[inst&0xf]; - } - } - else - ip = &db_inst_table[inst]; - - if (ip->i_has_modrm) { - get_value_inc(regmodrm, loc, 1, FALSE); - loc = db_read_address(loc, short_addr, regmodrm, &address); - } - - i_name = ip->i_name; - i_size = ip->i_size; - i_mode = ip->i_mode; - - if (ip->i_extra == (char *)db_Grp1 || - ip->i_extra == (char *)db_Grp2 || - ip->i_extra == (char *)db_Grp6 || - ip->i_extra == (char *)db_Grp7 || - ip->i_extra == (char *)db_Grp8) { - i_name = ((char **)ip->i_extra)[f_reg(regmodrm)]; - } - else if (ip->i_extra == (char *)db_Grp3) { - ip = (struct inst *)ip->i_extra; - ip = &ip[f_reg(regmodrm)]; - i_name = ip->i_name; - i_mode = ip->i_mode; - } - else if (ip->i_extra == (char *)db_Grp4 || - ip->i_extra == (char *)db_Grp5) { - ip = (struct inst *)ip->i_extra; - ip = &ip[f_reg(regmodrm)]; - i_name = ip->i_name; - i_mode = ip->i_mode; - i_size = ip->i_size; - } - - if (i_size == SDEP) { - if (size == WORD) - db_printf(i_name); - else - db_printf(ip->i_extra); - } - else { - db_printf(i_name); - if (i_size != NONE) { - if (i_size == BYTE) { - db_printf("b"); - size = BYTE; - } - else if (i_size == WORD) { - db_printf("w"); - size = WORD; - } - else if (size == WORD) - db_printf("w"); - else - db_printf("l"); - } - } - db_printf("\t"); - for (first = TRUE; - i_mode != 0; - i_mode >>= 8, first = FALSE) - { - if (!first) - db_printf(","); - - switch (i_mode & 0xFF) { - - case E: - db_print_address(seg, size, &address); - break; - - case Eind: - db_printf("*"); - db_print_address(seg, size, &address); - break; - - case Ew: - db_print_address(seg, WORD, &address); - break; - - case Eb: - db_print_address(seg, BYTE, &address); - break; - - case R: - db_printf("%s", db_reg[size][f_reg(regmodrm)]); - break; - - case Rw: - db_printf("%s", db_reg[WORD][f_reg(regmodrm)]); - break; - - case Ri: - db_printf("%s", db_reg[size][f_rm(inst)]); - break; - - case S: - db_printf("%s", db_seg_reg[f_reg(regmodrm)]); - break; - - case Si: - db_printf("%s", db_seg_reg[f_reg(inst)]); - break; - - case A: - db_printf("%s", db_reg[size][0]); /* acc */ - break; - - case BX: - if (seg) - db_printf("%s:", seg); - db_printf("(%s)", short_addr ? "%bx" : "%ebx"); - break; - - case CL: - db_printf("%%cl"); - break; - - case DX: - db_printf("%%dx"); - break; - - case SI: - if (seg) - db_printf("%s:", seg); - db_printf("(%s)", short_addr ? "%si" : "%esi"); - break; - - case DI: - db_printf("%%es:(%s)", short_addr ? "%di" : "%edi"); - break; - - case CR: - db_printf("%%cr%d", f_reg(regmodrm)); - break; - - case DR: - db_printf("%%dr%d", f_reg(regmodrm)); - break; - - case TR: - db_printf("%%tr%d", f_reg(regmodrm)); - break; - - case I: - len = db_lengths[size]; - get_value_inc(imm, loc, len, FALSE);/* unsigned */ - db_printf("$%#n", imm); - break; - - case Is: - len = db_lengths[size]; - get_value_inc(imm, loc, len, TRUE); /* signed */ - db_printf("$%#r", imm); - break; - - case Ib: - get_value_inc(imm, loc, 1, FALSE); /* unsigned */ - db_printf("$%#n", imm); - break; - - case Ibs: - get_value_inc(imm, loc, 1, TRUE); /* signed */ - db_printf("$%#r", imm); - break; - - case Iw: - get_value_inc(imm, loc, 2, FALSE); /* unsigned */ - db_printf("$%#n", imm); - break; - - case Il: - get_value_inc(imm, loc, 4, FALSE); - db_printf("$%#n", imm); - break; - - case O: - if (short_addr) { - get_value_inc(displ, loc, 2, TRUE); - } - else { - get_value_inc(displ, loc, 4, TRUE); - } - if (seg) - db_printf("%s:%#r",seg, displ); - else - db_printsym((db_addr_t)displ, DB_STGY_ANY); - break; - - case Db: - get_value_inc(displ, loc, 1, TRUE); - db_printsym((db_addr_t)(displ + loc), DB_STGY_XTRN); - break; - - case Dl: - get_value_inc(displ, loc, 4, TRUE); - db_printsym((db_addr_t)(displ + loc), DB_STGY_XTRN); - break; - - case o1: - db_printf("$1"); - break; - - case o3: - db_printf("$3"); - break; - - case OS: - get_value_inc(imm, loc, 4, FALSE); /* offset */ - get_value_inc(imm2, loc, 2, FALSE); /* segment */ - db_printf("$%#n,%#n", imm2, imm); - break; - } - } - - if (altfmt == 0) { - if (inst == 0xe9 || inst == 0xeb) { - /* - * GAS pads to longword boundary after unconditional jumps. - */ - loc = (loc + (4-1)) & ~(4-1); - } - } - db_printf("\n"); - return (loc); -} - diff --git a/sys/i386/i386/db_interface.c b/sys/i386/i386/db_interface.c deleted file mode 100644 index 74c09dc..0000000 --- a/sys/i386/i386/db_interface.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990 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. - * - * $Id$ - */ - -/* - * Interface to new debugger. - */ -#include "param.h" -#include "proc.h" -#include - -#include -#include -#include - -#include -#include /* just for boothowto --eichin */ -int db_active = 0; - -/* - * Received keyboard interrupt sequence. - */ -kdb_kbd_trap(regs) - struct i386_saved_state *regs; -{ - if (db_active == 0 && (boothowto & RB_KDB)) { - printf("\n\nkernel: keyboard interrupt\n"); - kdb_trap(-1, 0, regs); - } -} - -/* - * kdb_trap - field a TRACE or BPT trap - */ - -static jmp_buf *db_nofault = 0; - -kdb_trap(type, code, regs) - int type, code; - register struct i386_saved_state *regs; -{ -#if 0 - if ((boothowto&RB_KDB) == 0) - return(0); -#endif - - switch (type) { - case T_BPTFLT /* T_INT3 */: /* breakpoint */ - case T_KDBTRAP /* T_WATCHPOINT */: /* watchpoint */ - case T_PRIVINFLT /* T_DEBUG */: /* single_step */ - - case -1: /* keyboard interrupt */ - break; - - default: - kdbprinttrap(type, code); - - if (db_nofault) { - jmp_buf *no_fault = db_nofault; - db_nofault = 0; - longjmp(*no_fault, 1); - } - } - - /* Should switch to kdb`s own stack here. */ - - ddb_regs = *regs; - - if ((regs->tf_cs & 0x3) == 0) { - /* - * Kernel mode - esp and ss not saved - */ - ddb_regs.tf_esp = (int)®s->tf_esp; /* kernel stack pointer */ -#if 0 - ddb_regs.ss = KERNEL_DS; -#endif - asm(" movw %%ss,%%ax; movl %%eax,%0 " - : "=g" (ddb_regs.tf_ss) - : - : "ax"); - } - - db_active++; - cnpollc(TRUE); - db_trap(type, code); - cnpollc(FALSE); - db_active--; - - regs->tf_eip = ddb_regs.tf_eip; - regs->tf_eflags = ddb_regs.tf_eflags; - regs->tf_eax = ddb_regs.tf_eax; - regs->tf_ecx = ddb_regs.tf_ecx; - regs->tf_edx = ddb_regs.tf_edx; - regs->tf_ebx = ddb_regs.tf_ebx; - if (regs->tf_cs & 0x3) { - /* - * user mode - saved esp and ss valid - */ - regs->tf_esp = ddb_regs.tf_esp; /* user stack pointer */ - regs->tf_ss = ddb_regs.tf_ss & 0xffff; /* user stack segment */ - } - regs->tf_ebp = ddb_regs.tf_ebp; - regs->tf_esi = ddb_regs.tf_esi; - regs->tf_edi = ddb_regs.tf_edi; - regs->tf_es = ddb_regs.tf_es & 0xffff; - regs->tf_cs = ddb_regs.tf_cs & 0xffff; - regs->tf_ds = ddb_regs.tf_ds & 0xffff; -#if 0 - regs->tf_fs = ddb_regs.tf_fs & 0xffff; - regs->tf_gs = ddb_regs.tf_gs & 0xffff; -#endif - - return (1); -} - -/* - * Print trap reason. - */ -kdbprinttrap(type, code) - int type, code; -{ - printf("kernel: "); - printf("type %d", type); - printf(" trap, code=%x\n", code); -} - -/* - * Read bytes from kernel address space for debugger. - */ - -extern jmp_buf db_jmpbuf; - -void -db_read_bytes(addr, size, data) - vm_offset_t addr; - register int size; - register char *data; -{ - register char *src; - - db_nofault = &db_jmpbuf; - - src = (char *)addr; - while (--size >= 0) - *data++ = *src++; - - db_nofault = 0; -} - -struct pte *pmap_pte(pmap_t, vm_offset_t); - -/* - * Write bytes to kernel address space for debugger. - */ -void -db_write_bytes(addr, size, data) - vm_offset_t addr; - register int size; - register char *data; -{ - register char *dst; - - register pt_entry_t *ptep0 = 0; - pt_entry_t oldmap0 = { 0 }; - vm_offset_t addr1; - register pt_entry_t *ptep1 = 0; - pt_entry_t oldmap1 = { 0 }; - extern char etext; - - db_nofault = &db_jmpbuf; - - if (addr >= VM_MIN_KERNEL_ADDRESS && - addr <= (vm_offset_t)&etext) - { - ptep0 = pmap_pte(kernel_pmap, addr); - oldmap0 = *ptep0; - *(int *)ptep0 |= /* INTEL_PTE_WRITE */ PG_RW; - - addr1 = i386_trunc_page(addr + size - 1); - if (i386_trunc_page(addr) != addr1) { - /* data crosses a page boundary */ - - ptep1 = pmap_pte(kernel_pmap, addr1); - oldmap1 = *ptep1; - *(int *)ptep1 |= /* INTEL_PTE_WRITE */ PG_RW; - } - tlbflush(); - } - - dst = (char *)addr; - - while (--size >= 0) - *dst++ = *data++; - - db_nofault = 0; - - if (ptep0) { - *ptep0 = oldmap0; - if (ptep1) { - *ptep1 = oldmap1; - } - tlbflush(); - } -} - -Debugger (msg) -char *msg; -{ - asm ("int $3"); -} diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c deleted file mode 100644 index ffed283..0000000 --- a/sys/i386/i386/db_trace.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990 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. - * - * $Id$ - */ - -#include "param.h" -#include "proc.h" -#include - -#include -#include -#include - -/* - * Machine register set. - */ -struct db_variable db_regs[] = { - "cs", (int *)&ddb_regs.tf_cs, FCN_NULL, - "ds", (int *)&ddb_regs.tf_ds, FCN_NULL, - "es", (int *)&ddb_regs.tf_es, FCN_NULL, -#if 0 - "fs", (int *)&ddb_regs.tf_fs, FCN_NULL, - "gs", (int *)&ddb_regs.tf_gs, FCN_NULL, -#endif - "ss", (int *)&ddb_regs.tf_ss, FCN_NULL, - "eax", (int *)&ddb_regs.tf_eax, FCN_NULL, - "ecx", (int *)&ddb_regs.tf_ecx, FCN_NULL, - "edx", (int *)&ddb_regs.tf_edx, FCN_NULL, - "ebx", (int *)&ddb_regs.tf_ebx, FCN_NULL, - "esp", (int *)&ddb_regs.tf_esp,FCN_NULL, - "ebp", (int *)&ddb_regs.tf_ebp, FCN_NULL, - "esi", (int *)&ddb_regs.tf_esi, FCN_NULL, - "edi", (int *)&ddb_regs.tf_edi, FCN_NULL, - "eip", (int *)&ddb_regs.tf_eip, FCN_NULL, - "efl", (int *)&ddb_regs.tf_eflags, FCN_NULL, -}; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); - -/* - * Stack trace. - */ -#define INKERNEL(va) (((vm_offset_t)(va)) >= VM_MIN_KERNEL_ADDRESS) - -struct i386_frame { - struct i386_frame *f_frame; - int f_retaddr; - int f_arg0; -}; - -#define TRAP 1 -#define INTERRUPT 2 - -db_addr_t db_trap_symbol_value = 0; -db_addr_t db_kdintr_symbol_value = 0; -boolean_t db_trace_symbols_found = FALSE; - -void -db_find_trace_symbols() -{ - db_expr_t value; - if (db_value_of_name("_trap", &value)) - db_trap_symbol_value = (db_addr_t) value; - if (db_value_of_name("_kdintr", &value)) - db_kdintr_symbol_value = (db_addr_t) value; - db_trace_symbols_found = TRUE; -} - -/* - * Figure out how many arguments were passed into the frame at "fp". - */ -int -db_numargs(fp) - struct i386_frame *fp; -{ - int *argp; - int inst; - int args; - extern char etext[]; - - argp = (int *)db_get_value((int)&fp->f_retaddr, 4, FALSE); - if (argp < (int *)VM_MIN_KERNEL_ADDRESS || argp > (int *)etext) - args = 5; - else { - inst = db_get_value((int)argp, 4, FALSE); - if ((inst & 0xff) == 0x59) /* popl %ecx */ - args = 1; - else if ((inst & 0xffff) == 0xc483) /* addl %n, %esp */ - args = ((inst >> 16) & 0xff) / 4; - else - args = 5; - } - return (args); -} - -/* - * Figure out the next frame up in the call stack. - * For trap(), we print the address of the faulting instruction and - * proceed with the calling frame. We return the ip that faulted. - * If the trap was caused by jumping through a bogus pointer, then - * the next line in the backtrace will list some random function as - * being called. It should get the argument list correct, though. - * It might be possible to dig out from the next frame up the name - * of the function that faulted, but that could get hairy. - */ -void -db_nextframe(fp, ip, argp, is_trap) - struct i386_frame **fp; /* in/out */ - db_addr_t *ip; /* out */ - int *argp; /* in */ - int is_trap; /* in */ -{ - struct i386_saved_state *saved_regs; - - if (is_trap == 0) { - *ip = (db_addr_t) - db_get_value((int) &(*fp)->f_retaddr, 4, FALSE); - *fp = (struct i386_frame *) - db_get_value((int) &(*fp)->f_frame, 4, FALSE); - } else { - /* - * We know that trap() has 1 argument and we know that - * it is an (int *). - */ - saved_regs = (struct i386_saved_state *) - db_get_value((int)argp, 4, FALSE); - db_printf("--- trap (number %d) ---\n", - saved_regs->tf_trapno & 0xffff); - db_printsym(saved_regs->tf_eip, DB_STGY_XTRN); - db_printf(":\n"); - *fp = (struct i386_frame *)saved_regs->tf_ebp; - *ip = (db_addr_t)saved_regs->tf_eip; - } - -} - -void -db_stack_trace_cmd(addr, have_addr, count, modif) - db_expr_t addr; - boolean_t have_addr; - db_expr_t count; - char *modif; -{ - struct i386_frame *frame, *lastframe; - int *argp; - db_addr_t callpc; - int is_trap; - boolean_t kernel_only = TRUE; - boolean_t trace_thread = FALSE; - - if (!db_trace_symbols_found) - db_find_trace_symbols(); - - { - register char *cp = modif; - register char c; - - while ((c = *cp++) != 0) { - if (c == 't') - trace_thread = TRUE; - if (c == 'u') - kernel_only = FALSE; - } - } - - if (count == -1) - count = 65535; - - if (!have_addr) { - frame = (struct i386_frame *)ddb_regs.tf_ebp; - callpc = (db_addr_t)ddb_regs.tf_eip; - } - else if (trace_thread) { - printf ("db_trace.c: can't trace thread\n"); - } - else { - frame = (struct i386_frame *)addr; - callpc = (db_addr_t)db_get_value((int)&frame->f_retaddr, 4, FALSE); - } - - lastframe = 0; - while (count-- && frame != 0) { - register int narg; - char * name; - db_expr_t offset; - - if (INKERNEL((int)frame) && callpc == db_trap_symbol_value) { - narg = 1; - is_trap = TRAP; - } - else - if (INKERNEL((int)frame) && callpc == db_kdintr_symbol_value) { - is_trap = INTERRUPT; - narg = 0; - } - else { - is_trap = 0; - narg = db_numargs(frame); - } - - db_find_sym_and_offset(callpc, &name, &offset); - db_printf("%s(", name); - - argp = &frame->f_arg0; - while (narg) { - db_printf("%x", db_get_value((int)argp, 4, FALSE)); - argp++; - if (--narg != 0) - db_printf(","); - } - db_printf(") at "); - db_printsym(callpc, DB_STGY_XTRN); - db_printf("\n"); - - lastframe = frame; - db_nextframe(&frame, &callpc, &frame->f_arg0, is_trap); - - if (frame == 0) { - /* end of chain */ - break; - } - if (INKERNEL((int)frame)) { - /* staying in kernel */ - if (frame <= lastframe) { - db_printf("Bad frame pointer: 0x%x\n", frame); - break; - } - } - else if (INKERNEL((int)lastframe)) { - /* switch from user to kernel */ - if (kernel_only) - break; /* kernel stack only */ - } - else { - /* in user */ - if (frame <= lastframe) { - db_printf("Bad frame pointer: 0x%x\n", frame); - break; - } - } - } -} diff --git a/sys/i386/i386/dkbad.c b/sys/i386/i386/dkbad.c deleted file mode 100644 index 0e9aca3..0000000 --- a/sys/i386/i386/dkbad.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)dkbad.c 5.4 (Berkeley) 1/19/91 - * $Id$ - */ - - -#ifndef NOBADSECT -#include "sys/param.h" -#include "sys/buf.h" -#include "sys/dkbad.h" - -/* - * Search the bad sector table looking for - * the specified sector. Return index if found. - * Return -1 if not found. - */ - -isbad(bt, cyl, trk, sec) - register struct dkbad *bt; -{ - register int i; - register long blk, bblk; - - blk = ((long)cyl << 16) + (trk << 8) + sec; - for (i = 0; i < 126; i++) { - bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec; - if (blk == bblk) - return (i); - if (blk < bblk || bblk < 0) - break; - } - return (-1); -} -#endif diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c deleted file mode 100644 index 381f3df..0000000 --- a/sys/i386/i386/genassym.c +++ /dev/null @@ -1,188 +0,0 @@ -/*- - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 - * $Id: genassym.c,v 1.4 1993/10/12 15:33:18 rgrimes Exp $ - */ - -#include "sys/param.h" -#include "sys/buf.h" -#include "sys/vmmeter.h" -#include "sys/proc.h" -#include "sys/user.h" -#include "sys/mbuf.h" -#include "sys/msgbuf.h" -#include "sys/resourcevar.h" -#include "machine/cpu.h" -#include "machine/trap.h" -#include "machine/psl.h" -#include "sys/syscall.h" -#include "vm/vm_param.h" -#include "vm/vm_map.h" -#include "machine/pmap.h" - -main() -{ - struct proc *p = (struct proc *)0; - struct vmmeter *vm = (struct vmmeter *)0; - struct user *up = (struct user *)0; - struct rusage *rup = (struct rusage *)0; - struct uprof *uprof = (struct uprof *)0; - struct vmspace *vms = (struct vmspace *)0; - vm_map_t map = (vm_map_t)0; - pmap_t pmap = (pmap_t)0; - struct pcb *pcb = (struct pcb *)0; - struct trapframe *tf = (struct trapframe *)0; - struct sigframe *sigf = (struct sigframe *)0; - register unsigned i; - - printf("#define\tI386_CR3PAT %d\n", I386_CR3PAT); - printf("#define\tUDOT_SZ %d\n", sizeof(struct user)); - printf("#define\tP_LINK %d\n", &p->p_link); - printf("#define\tP_RLINK %d\n", &p->p_rlink); - printf("#define\tP_VMSPACE %d\n", &p->p_vmspace); - printf("#define\tVM_PMAP %d\n", &vms->vm_pmap); - printf("#define\tP_ADDR %d\n", &p->p_addr); - printf("#define\tP_PRI %d\n", &p->p_pri); - printf("#define\tP_STAT %d\n", &p->p_stat); - printf("#define\tP_WCHAN %d\n", &p->p_wchan); - printf("#define\tP_FLAG %d\n", &p->p_flag); - printf("#define\tP_PID %d\n", &p->p_pid); - printf("#define\tSSLEEP %d\n", SSLEEP); - printf("#define\tSRUN %d\n", SRUN); - printf("#define\tV_SWTCH %d\n", &vm->v_swtch); - printf("#define\tV_TRAP %d\n", &vm->v_trap); - printf("#define\tV_SYSCALL %d\n", &vm->v_syscall); - printf("#define\tV_INTR %d\n", &vm->v_intr); - printf("#define\tV_SOFT %d\n", &vm->v_soft); - printf("#define\tV_PDMA %d\n", &vm->v_pdma); - printf("#define\tV_FAULTS %d\n", &vm->v_faults); - printf("#define\tV_PGREC %d\n", &vm->v_pgrec); - printf("#define\tV_FASTPGREC %d\n", &vm->v_fastpgrec); - printf("#define\tUPAGES %d\n", UPAGES); - printf("#define\tHIGHPAGES %d\n", HIGHPAGES); - printf("#define\tCLSIZE %d\n", CLSIZE); - printf("#define\tNBPG %d\n", NBPG); - printf("#define\tNPTEPG %d\n", NPTEPG); - printf("#define\tNKPDE %d\n", NKPDE); - printf("#define\tKPTDI %d\n", KPTDI); - printf("#define\tPTDPTDI %d\n", PTDPTDI); - printf("#define\tAPTDPTDI %d\n", APTDPTDI); - printf("#define\tPGSHIFT %d\n", PGSHIFT); - printf("#define\tPDRSHIFT %d\n", PDRSHIFT); - printf("#define\tSYSPTSIZE %d\n", SYSPTSIZE); - printf("#define\tUSRPTSIZE %d\n", USRPTSIZE); - printf("#define\tUSRIOSIZE %d\n", USRIOSIZE); -#ifdef SYSVSHM - printf("#define\tSHMMAXPGS %d\n", SHMMAXPGS); -#endif - printf("#define\tUSRSTACK %d\n", USRSTACK); - printf("#define\tKERNBASE %d\n", KERNBASE); - printf("#define\tKERNSIZE %d\n", KERNSIZE); - printf("#define\tMSGBUFPTECNT %d\n", btoc(sizeof (struct msgbuf))); - printf("#define\tNMBCLUSTERS %d\n", NMBCLUSTERS); - printf("#define\tMCLBYTES %d\n", MCLBYTES); - printf("#define\tPCB_LINK %d\n", &pcb->pcb_tss.tss_link); - printf("#define\tPCB_ESP0 %d\n", &pcb->pcb_tss.tss_esp0); - printf("#define\tPCB_SS0 %d\n", &pcb->pcb_tss.tss_ss0); - printf("#define\tPCB_ESP1 %d\n", &pcb->pcb_tss.tss_esp1); - printf("#define\tPCB_SS1 %d\n", &pcb->pcb_tss.tss_ss1); - printf("#define\tPCB_ESP2 %d\n", &pcb->pcb_tss.tss_esp2); - printf("#define\tPCB_SS2 %d\n", &pcb->pcb_tss.tss_ss2); - printf("#define\tPCB_CR3 %d\n", &pcb->pcb_tss.tss_cr3); - printf("#define\tPCB_EIP %d\n", &pcb->pcb_tss.tss_eip); - printf("#define\tPCB_EFLAGS %d\n", &pcb->pcb_tss.tss_eflags); - printf("#define\tPCB_EAX %d\n", &pcb->pcb_tss.tss_eax); - printf("#define\tPCB_ECX %d\n", &pcb->pcb_tss.tss_ecx); - printf("#define\tPCB_EDX %d\n", &pcb->pcb_tss.tss_edx); - printf("#define\tPCB_EBX %d\n", &pcb->pcb_tss.tss_ebx); - printf("#define\tPCB_ESP %d\n", &pcb->pcb_tss.tss_esp); - printf("#define\tPCB_EBP %d\n", &pcb->pcb_tss.tss_ebp); - printf("#define\tPCB_ESI %d\n", &pcb->pcb_tss.tss_esi); - printf("#define\tPCB_EDI %d\n", &pcb->pcb_tss.tss_edi); - printf("#define\tPCB_ES %d\n", &pcb->pcb_tss.tss_es); - printf("#define\tPCB_CS %d\n", &pcb->pcb_tss.tss_cs); - printf("#define\tPCB_SS %d\n", &pcb->pcb_tss.tss_ss); - printf("#define\tPCB_DS %d\n", &pcb->pcb_tss.tss_ds); - printf("#define\tPCB_FS %d\n", &pcb->pcb_tss.tss_fs); - printf("#define\tPCB_GS %d\n", &pcb->pcb_tss.tss_gs); - printf("#define\tPCB_LDT %d\n", &pcb->pcb_tss.tss_ldt); - printf("#define\tPCB_USERLDT %d\n", &pcb->pcb_ldt); - printf("#define\tPCB_IOOPT %d\n", &pcb->pcb_tss.tss_ioopt); - printf("#define\tU_PROF %d\n", &up->u_stats.p_prof); - printf("#define\tU_PROFSCALE %d\n", &up->u_stats.p_prof.pr_scale); - printf("#define\tPR_BASE %d\n", &uprof->pr_base); - printf("#define\tPR_SIZE %d\n", &uprof->pr_size); - printf("#define\tPR_OFF %d\n", &uprof->pr_off); - printf("#define\tPR_SCALE %d\n", &uprof->pr_scale); - printf("#define\tRU_MINFLT %d\n", &rup->ru_minflt); - printf("#define\tPCB_FLAGS %d\n", &pcb->pcb_flags); - printf("#define\tPCB_SAVEFPU %d\n", &pcb->pcb_savefpu); - printf("#define\tFP_USESEMC %d\n", FP_USESEMC); - printf("#define\tPCB_SAVEEMC %d\n", &pcb->pcb_saveemc); - printf("#define\tPCB_CMAP2 %d\n", &pcb->pcb_cmap2); - printf("#define\tPCB_IML %d\n", &pcb->pcb_iml); - printf("#define\tPCB_ONFAULT %d\n", &pcb->pcb_onfault); - - printf("#define\tTF_ES %d\n", &tf->tf_es); - printf("#define\tTF_DS %d\n", &tf->tf_ds); - printf("#define\tTF_EDI %d\n", &tf->tf_edi); - printf("#define\tTF_ESI %d\n", &tf->tf_esi); - printf("#define\tTF_EBP %d\n", &tf->tf_ebp); - printf("#define\tTF_ISP %d\n", &tf->tf_isp); - printf("#define\tTF_EBX %d\n", &tf->tf_ebx); - printf("#define\tTF_EDX %d\n", &tf->tf_edx); - printf("#define\tTF_ECX %d\n", &tf->tf_ecx); - printf("#define\tTF_EAX %d\n", &tf->tf_eax); - printf("#define\tTF_TRAPNO %d\n", &tf->tf_trapno); - printf("#define\tTF_ERR %d\n", &tf->tf_err); - printf("#define\tTF_EIP %d\n", &tf->tf_eip); - printf("#define\tTF_CS %d\n", &tf->tf_cs); - printf("#define\tTF_EFLAGS %d\n", &tf->tf_eflags); - printf("#define\tTF_ESP %d\n", &tf->tf_esp); - printf("#define\tTF_SS %d\n", &tf->tf_ss); - - printf("#define\tSIGF_SIGNUM %d\n", &sigf->sf_signum); - printf("#define\tSIGF_CODE %d\n", &sigf->sf_code); - printf("#define\tSIGF_SCP %d\n", &sigf->sf_scp); - printf("#define\tSIGF_HANDLER %d\n", &sigf->sf_handler); - printf("#define\tSIGF_SC %d\n", &sigf->sf_sc); - - printf("#define\tB_READ %d\n", B_READ); - printf("#define\tENOENT %d\n", ENOENT); - printf("#define\tEFAULT %d\n", EFAULT); - printf("#define\tENAMETOOLONG %d\n", ENAMETOOLONG); - exit(0); -} diff --git a/sys/i386/i386/in_cksum.c b/sys/i386/i386/in_cksum.c deleted file mode 100644 index 3bea1c1..0000000 --- a/sys/i386/i386/in_cksum.c +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from tahoe: in_cksum.c 1.2 86/01/05 - * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 - * $Id$ - */ - -#include "param.h" -#include "sys/mbuf.h" - -/* - * Checksum routine for Internet Protocol family headers. - * - * This routine is very heavily used in the network - * code and should be modified for each CPU to be as fast as possible. - * - * This implementation is 386 version. - */ - -#undef ADDCARRY -#define ADDCARRY(x) if ((x) > 0xffff) (x) -= 0xffff -#define REDUCE {sum = (sum & 0xffff) + (sum >> 16); ADDCARRY(sum);} - -/* - * Thanks to gcc we don't have to guess - * which registers contain sum & w. - */ -#define CLC asm("clc") -#define ADD(n) asm("adcl " #n "(%2), %0": "=r"(sum): "0"(sum), "r"(w)) -#define MOP asm("adcl $0, %0": "=r"(sum): "0"(sum)) - -in_cksum(m, len) - register struct mbuf *m; - register int len; -{ - register u_short *w; - register unsigned sum = 0; - register int mlen = 0; - int byte_swapped = 0; - union { char c[2]; u_short s; } su; - - for (;m && len; m = m->m_next) { - if (m->m_len == 0) - continue; - w = mtod(m, u_short *); - if (mlen == -1) { - /* - * The first byte of this mbuf is the continuation - * of a word spanning between this mbuf and the - * last mbuf. - */ - - /* su.c[0] is already saved when scanning previous - * mbuf. sum was REDUCEd when we found mlen == -1 - */ - su.c[1] = *(u_char *)w; - sum += su.s; - w = (u_short *)((char *)w + 1); - mlen = m->m_len - 1; - len--; - } else - mlen = m->m_len; - if (len < mlen) - mlen = len; - len -= mlen; - /* - * Force to long boundary so we do longword aligned - * memory operations - */ - if (3 & (int) w) { - REDUCE; - if ((1 & (int) w) && (mlen > 0)) { - sum <<= 8; - su.c[0] = *(char *)w; - w = (u_short *)((char *)w + 1); - mlen--; - byte_swapped = 1; - } - if ((2 & (int) w) && (mlen >= 2)) { - sum += *w++; - mlen -= 2; - } - } - /* - * Do as much of the checksum as possible 32 bits at at time. - * In fact, this loop is unrolled to make overhead from - * branches &c small. - */ - while ((mlen -= 32) >= 0) { - /* - * Clear the carry flag, add with carry 16 words - * and fold-in last carry by adding a 0 with carry. - */ - CLC; - ADD(0); ADD(4); ADD(8); ADD(12); - ADD(16); ADD(20); ADD(24); ADD(28); - MOP; w += 16; - } - mlen += 32; - while ((mlen -= 8) >= 0) { - CLC; - ADD(0); ADD(4); - MOP; - w += 4; - } - mlen += 8; - if (mlen == 0 && byte_swapped == 0) - continue; /* worth 1% maybe ?? */ - REDUCE; - while ((mlen -= 2) >= 0) { - sum += *w++; - } - if (byte_swapped) { - sum <<= 8; - byte_swapped = 0; - if (mlen == -1) { - su.c[1] = *(char *)w; - sum += su.s; - mlen = 0; - } else - mlen = -1; - } else if (mlen == -1) - /* - * This mbuf has odd number of bytes. - * There could be a word split betwen - * this mbuf and the next mbuf. - * Save the last byte (to prepend to next mbuf). - */ - su.c[0] = *(char *)w; - } - - if (len) - printf("cksum: out of data\n"); - if (mlen == -1) { - /* The last mbuf has odd # of bytes. Follow the - standard (the odd byte is shifted left by 8 bits) */ - su.c[1] = 0; - sum += su.s; - } - REDUCE; - return (~sum & 0xffff); -} - diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s deleted file mode 100644 index 3781885..0000000 --- a/sys/i386/i386/locore.s +++ /dev/null @@ -1,2152 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $Id: locore.s,v 1.7 1993/10/13 07:11:11 rgrimes Exp $ - */ - - -/* - * locore.s: 4BSD machine support for the Intel 386 - * Preliminary version - * Written by William F. Jolitz, 386BSD Project - */ - -#include "npx.h" - -#include "assym.s" -#include "machine/psl.h" -#include "machine/pte.h" - -#include "errno.h" - -#include "machine/trap.h" - -#include "machine/specialreg.h" -#include "i386/isa/debug.h" -#include "machine/cputypes.h" - -#define KDSEL 0x10 -#define SEL_RPL_MASK 0x0003 -#define TRAPF_CS_OFF (13 * 4) - -/* - * Note: This version greatly munged to avoid various assembler errors - * that may be fixed in newer versions of gas. Perhaps newer versions - * will have more pleasant appearance. - */ - - .set IDXSHIFT,10 - -#define ALIGN_DATA .align 2 -#define ALIGN_TEXT .align 2,0x90 /* 4-byte boundaries, NOP-filled */ -#define SUPERALIGN_TEXT .align 4,0x90 /* 16-byte boundaries better for 486 */ - -#define GEN_ENTRY(name) ALIGN_TEXT; .globl name; name: -#define NON_GPROF_ENTRY(name) GEN_ENTRY(_/**/name) - -#ifdef GPROF -/* - * ALTENTRY() must be before a corresponding ENTRY() so that it can jump - * over the mcounting. - */ -#define ALTENTRY(name) GEN_ENTRY(_/**/name); MCOUNT; jmp 2f -#define ENTRY(name) GEN_ENTRY(_/**/name); MCOUNT; 2: -/* - * The call to mcount supports the usual (bad) conventions. We allocate - * some data and pass a pointer to it although the 386BSD doesn't use - * the data. We set up a frame before calling mcount because that is - * the standard convention although it makes work for both mcount and - * callers. - */ -#define MCOUNT .data; ALIGN_DATA; 1:; .long 0; .text; \ - pushl %ebp; movl %esp,%ebp; \ - movl $1b,%eax; call mcount; popl %ebp -#else -/* - * ALTENTRY() has to align because it is before a corresponding ENTRY(). - * ENTRY() has to align to because there may be no ALTENTRY() before it. - * If there is a previous ALTENTRY() then the alignment code is empty. - */ -#define ALTENTRY(name) GEN_ENTRY(_/**/name) -#define ENTRY(name) GEN_ENTRY(_/**/name) -#endif - -/* NB: NOP now preserves registers so NOPs can be inserted anywhere */ -/* XXX: NOP and FASTER_NOP are misleadingly named */ -#ifdef DUMMY_NOPS /* this will break some older machines */ -#define FASTER_NOP -#define NOP -#else -#define FASTER_NOP pushl %eax ; inb $0x84,%al ; popl %eax -#define NOP pushl %eax ; inb $0x84,%al ; inb $0x84,%al ; popl %eax -#endif - -/* - * PTmap is recursive pagemap at top of virtual address space. - * Within PTmap, the page directory can be found (third indirection). - */ - .globl _PTmap,_PTD,_PTDpde,_Sysmap - .set _PTmap,PTDPTDI << PDRSHIFT - .set _PTD,_PTmap + (PTDPTDI * NBPG) - .set _PTDpde,_PTD + (PTDPTDI * 4) /* XXX 4=sizeof pde */ - - .set _Sysmap,_PTmap + (KPTDI * NBPG) - -/* - * APTmap, APTD is the alternate recursive pagemap. - * It's used when modifying another process's page tables. - */ - .globl _APTmap,_APTD,_APTDpde - .set _APTmap,APTDPTDI << PDRSHIFT - .set _APTD,_APTmap + (APTDPTDI * NBPG) - .set _APTDpde,_PTD + (APTDPTDI * 4) /* XXX 4=sizeof pde */ - -/* - * Access to each processes kernel stack is via a region of - * per-process address space (at the beginning), immediatly above - * the user process stack. - */ - .set _kstack,USRSTACK - .globl _kstack - .set PPDROFF,0x3F6 - .set PPTEOFF,0x400-UPAGES /* 0x3FE */ - - -/* - * Globals - */ - .data - .globl _esym -_esym: .long 0 /* ptr to end of syms */ - - .globl _boothowto,_bootdev,_curpcb - - .globl _cpu,_cold,_atdevbase -_cpu: .long 0 /* are we 386, 386sx, or 486 */ -_cold: .long 1 /* cold till we are not */ -_atdevbase: .long 0 /* location of start of iomem in virtual */ -_atdevphys: .long 0 /* location of device mapping ptes (phys) */ - - .globl _IdlePTD,_KPTphys -_IdlePTD: .long 0 -_KPTphys: .long 0 - - .globl _cyloffset,_proc0paddr -_cyloffset: .long 0 -_proc0paddr: .long 0 - - .space 512 -tmpstk: - - -/* - * System Initialization - */ - .text - -/* - * btext: beginning of text section. - * Also the entry point (jumped to directly from the boot blocks). - */ -ENTRY(btext) - movw $0x1234,0x472 /* warm boot */ - jmp 1f - .space 0x500 /* skip over warm boot shit */ - - /* - * pass parameters on stack (howto, bootdev, unit, cyloffset, esym) - * note: (%esp) is return address of boot - * ( if we want to hold onto /boot, it's physical %esp up to _end) - */ - - 1: movl 4(%esp),%eax - movl %eax,_boothowto-KERNBASE - movl 8(%esp),%eax - movl %eax,_bootdev-KERNBASE - movl 12(%esp),%eax - movl %eax,_cyloffset-KERNBASE - movl 16(%esp),%eax - addl $KERNBASE,%eax - movl %eax,_esym-KERNBASE - - /* find out our CPU type. */ - pushfl - popl %eax - movl %eax,%ecx - xorl $0x40000,%eax - pushl %eax - popfl - pushfl - popl %eax - xorl %ecx,%eax - shrl $18,%eax - andl $1,%eax - push %ecx - popfl - - cmpl $0,%eax - jne 1f - movl $CPU_386,_cpu-KERNBASE - jmp 2f -1: movl $CPU_486,_cpu-KERNBASE -2: - - /* - * Finished with old stack; load new %esp now instead of later so - * we can trace this code without having to worry about the trace - * trap clobbering the memory test or the zeroing of the bss+bootstrap - * page tables. - * - * XXX - wdboot clears the bss after testing that this is safe. - * This is too wasteful - memory below 640K is scarce. The boot - * program should check: - * text+data <= &stack_variable - more_space_for_stack - * text+data+bss+pad+space_for_page_tables <= end_of_memory - * Oops, the gdt is in the carcass of the boot program so clearing - * the rest of memory is still not possible. - */ - movl $tmpstk-KERNBASE,%esp /* bootstrap stack end location */ - -/* - * Virtual address space of kernel: - * - * text | data | bss | [syms] | page dir | proc0 kernel stack | usr stk map | Sysmap - * 0 1 2 3 4 - */ - -/* find end of kernel image */ - movl $_end-KERNBASE,%ecx - addl $NBPG-1,%ecx /* page align up */ - andl $~(NBPG-1),%ecx - movl %ecx,%esi /* esi=start of tables */ - -/* clear bss and memory for bootstrap pagetables. */ - movl $_edata-KERNBASE,%edi - subl %edi,%ecx - addl $(UPAGES+5)*NBPG,%ecx /* size of tables */ - - xorl %eax,%eax /* pattern */ - cld - rep - stosb - -/* - * If we are loaded at 0x0 check to see if we have space for the - * page tables pages after the kernel and before the 640K ISA memory - * hole. If we do not have space relocate the page table pages and - * the kernel stack to start at 1MB. The value that ends up in esi - * is used by the rest of locore to build the tables. Locore adjusts - * esi each time it allocates a structure and then passes the final - * value to init386(first) as the value first. esi should ALWAYS - * be page aligned!! - */ - movl %esi,%ecx /* Get current first availiable address */ - cmpl $0x100000,%ecx /* Lets see if we are already above 1MB */ - jge 1f /* yep, don't need to check for room */ - addl $(NKPDE + 4) * NBPG,%ecx /* XXX the 4 is for kstack */ - /* space for kstack, PTD and PTE's */ - cmpl $(640*1024),%ecx - /* see if it fits in low memory */ - jle 1f /* yep, don't need to relocate it */ - movl $0x100000,%esi /* won't fit, so start it at 1MB */ -1: - -/* physical address of Idle Address space */ - movl %esi,_IdlePTD-KERNBASE - -/* - * fillkpt - * eax = (page frame address | control | status) == pte - * ebx = address of page table - * ecx = how many pages to map - */ -#define fillkpt \ -1: movl %eax,(%ebx) ; \ - addl $NBPG,%eax ; /* increment physical address */ \ - addl $4,%ebx ; /* next pte */ \ - loop 1b ; - -/* - * Map Kernel - * N.B. don't bother with making kernel text RO, as 386 - * ignores R/W AND U/S bits on kernel access (only v works) ! - * - * First step - build page tables - */ - movl %esi,%ecx /* this much memory, */ - shrl $PGSHIFT,%ecx /* for this many pte s */ - addl $UPAGES+4,%ecx /* including our early context */ - cmpl $0xa0,%ecx /* XXX - cover debugger pages */ - jae 1f - movl $0xa0,%ecx -1: - movl $PG_V|PG_KW,%eax /* having these bits set, */ - lea (4*NBPG)(%esi),%ebx /* physical address of KPT in proc 0, */ - movl %ebx,_KPTphys-KERNBASE /* in the kernel page table, */ - fillkpt - -/* map I/O memory map */ - - movl $0x100-0xa0,%ecx /* for this many pte s, */ - movl $(0xa0000|PG_V|PG_UW),%eax /* having these bits set,(perhaps URW?) XXX 06 Aug 92 */ - movl %ebx,_atdevphys-KERNBASE /* remember phys addr of ptes */ - fillkpt - - /* map proc 0's kernel stack into user page table page */ - - movl $UPAGES,%ecx /* for this many pte s, */ - lea (1*NBPG)(%esi),%eax /* physical address in proc 0 */ - lea (KERNBASE)(%eax),%edx - movl %edx,_proc0paddr-KERNBASE - /* remember VA for 0th process init */ - orl $PG_V|PG_KW,%eax /* having these bits set, */ - lea (3*NBPG)(%esi),%ebx /* physical address of stack pt in proc 0 */ - addl $(PPTEOFF*4),%ebx - fillkpt - -/* - * Construct a page table directory - * (of page directory elements - pde's) - */ - /* install a pde for temporary double map of bottom of VA */ - lea (4*NBPG)(%esi),%eax /* physical address of kernel page table */ - orl $PG_V|PG_UW,%eax /* pde entry is valid XXX 06 Aug 92 */ - movl %eax,(%esi) /* which is where temp maps! */ - - /* kernel pde's */ - movl $(NKPDE),%ecx /* for this many pde s, */ - lea (KPTDI*4)(%esi),%ebx /* offset of pde for kernel */ - fillkpt - - /* install a pde recursively mapping page directory as a page table! */ - movl %esi,%eax /* phys address of ptd in proc 0 */ - orl $PG_V|PG_UW,%eax /* pde entry is valid XXX 06 Aug 92 */ - movl %eax,PTDPTDI*4(%esi) /* which is where PTmap maps! */ - - /* install a pde to map kernel stack for proc 0 */ - lea (3*NBPG)(%esi),%eax /* physical address of pt in proc 0 */ - orl $PG_V|PG_KW,%eax /* pde entry is valid */ - movl %eax,PPDROFF*4(%esi) /* which is where kernel stack maps! */ - - /* copy and convert stuff from old gdt and idt for debugger */ - - cmpl $0x0375c339,0x96104 /* XXX - debugger signature */ - jne 1f - movb $1,_bdb_exists-KERNBASE -1: - pushal - subl $2*6,%esp - - sgdt (%esp) - movl 2(%esp),%esi /* base address of current gdt */ - movl $_gdt-KERNBASE,%edi - movl %edi,2(%esp) - movl $8*18/4,%ecx - rep /* copy gdt */ - movsl - movl $_gdt-KERNBASE,-8+2(%edi) /* adjust gdt self-ptr */ - movb $0x92,-8+5(%edi) - - sidt 6(%esp) - movl 6+2(%esp),%esi /* base address of current idt */ - movl 8+4(%esi),%eax /* convert dbg descriptor to ... */ - movw 8(%esi),%ax - movl %eax,bdb_dbg_ljmp+1-KERNBASE /* ... immediate offset ... */ - movl 8+2(%esi),%eax - movw %ax,bdb_dbg_ljmp+5-KERNBASE /* ... and selector for ljmp */ - movl 24+4(%esi),%eax /* same for bpt descriptor */ - movw 24(%esi),%ax - movl %eax,bdb_bpt_ljmp+1-KERNBASE - movl 24+2(%esi),%eax - movw %ax,bdb_bpt_ljmp+5-KERNBASE - - movl $_idt-KERNBASE,%edi - movl %edi,6+2(%esp) - movl $8*4/4,%ecx - rep /* copy idt */ - movsl - - lgdt (%esp) - lidt 6(%esp) - - addl $2*6,%esp - popal - - /* load base of page directory and enable mapping */ - movl %esi,%eax /* phys address of ptd in proc 0 */ - orl $I386_CR3PAT,%eax - movl %eax,%cr3 /* load ptd addr into mmu */ - movl %cr0,%eax /* get control word */ -/* - * XXX it is now safe to always (attempt to) set CR0_WP and to set up - * the page tables assuming it works, so USE_486_WRITE_PROTECT will go - * away. The special 386 PTE checking needs to be conditional on - * whatever distingiushes 486-only kernels from 386-486 kernels. - */ -#ifdef USE_486_WRITE_PROTECT - orl $CR0_PE|CR0_PG|CR0_WP,%eax /* enable paging */ -#else - orl $CR0_PE|CR0_PG,%eax /* enable paging */ -#endif - movl %eax,%cr0 /* and let's page NOW! */ - - pushl $begin /* jump to high mem */ - ret - -begin: /* now running relocated at KERNBASE where the system is linked to run */ - - .globl _Crtat /* XXX - locore should not know about */ - movl _Crtat,%eax /* variables of device drivers (pccons)! */ - subl $(KERNBASE+0xA0000),%eax - movl _atdevphys,%edx /* get pte PA */ - subl _KPTphys,%edx /* remove base of ptes, now have phys offset */ - shll $PGSHIFT-2,%edx /* corresponding to virt offset */ - addl $KERNBASE,%edx /* add virtual base */ - movl %edx,_atdevbase - addl %eax,%edx - movl %edx,_Crtat - - /* set up bootstrap stack */ - movl $_kstack+UPAGES*NBPG-4*12,%esp /* bootstrap stack end location */ - xorl %eax,%eax /* mark end of frames */ - movl %eax,%ebp - movl _proc0paddr,%eax - movl %esi,PCB_CR3(%eax) - - /* relocate debugger gdt entries */ - - movl $_gdt+8*9,%eax /* adjust slots 9-17 */ - movl $9,%ecx -reloc_gdt: - movb $0xfe,7(%eax) /* top byte of base addresses, was 0, */ - addl $8,%eax /* now KERNBASE>>24 */ - loop reloc_gdt - - cmpl $0,_bdb_exists - je 1f - int $3 -1: - - /* - * Skip over the page tables and the kernel stack - * XXX 4 is kstack size - */ - lea (NKPDE + 4) * NBPG(%esi),%esi - - pushl %esi /* value of first for init386(first) */ - call _init386 /* wire 386 chip for unix operation */ - - movl $0,_PTD - call _main /* autoconfiguration, mountroot etc */ - popl %esi - - /* - * now we've run main() and determined what cpu-type we are, we can - * enable WP mode on i486 cpus and above. - * on return from main(), we are process 1 - * set up address space and stack so that we can 'return' to user mode - */ - - .globl __ucodesel,__udatasel - movl __ucodesel,%eax - movl __udatasel,%ecx - /* build outer stack frame */ - pushl %ecx /* user ss */ - pushl $USRSTACK /* user esp */ - pushl %eax /* user cs */ - pushl $0 /* user ip */ - movl %cx,%ds - movl %cx,%es - movl %ax,%fs /* double map cs to fs */ - movl %cx,%gs /* and ds to gs */ - lret /* goto user! */ - - pushl $lretmsg1 /* "should never get here!" */ - call _panic -lretmsg1: - .asciz "lret: toinit\n" - - - .set exec,59 - .set exit,1 - -#define LCALL(x,y) .byte 0x9a ; .long y; .word x -/* - * Icode is copied out to process 1 and executed in user mode: - * execve("/sbin/init", argv, envp); exit(0); - * If the execve fails, process 1 exits and the system panics. - */ -NON_GPROF_ENTRY(icode) - pushl $0 /* envp for execve() */ - -# pushl $argv-_icode /* can't do this 'cos gas 1.38 is broken */ - movl $argv,%eax - subl $_icode,%eax - pushl %eax /* argp for execve() */ - -# pushl $init-_icode - movl $init,%eax - subl $_icode,%eax - pushl %eax /* fname for execve() */ - - pushl %eax /* dummy return address */ - - movl $exec,%eax - LCALL(0x7,0x0) - - /* exit if something botches up in the above execve() */ - pushl %eax /* execve failed, the errno will do for an */ - /* exit code because errnos are < 128 */ - pushl %eax /* dummy return address */ - movl $exit,%eax - LCALL(0x7,0x0) - -init: - .asciz "/sbin/init" - ALIGN_DATA -argv: - .long init+6-_icode /* argv[0] = "init" ("/sbin/init" + 6) */ - .long eicode-_icode /* argv[1] follows icode after copyout */ - .long 0 -eicode: - - .globl _szicode -_szicode: - .long _szicode-_icode - -NON_GPROF_ENTRY(sigcode) - call SIGF_HANDLER(%esp) - lea SIGF_SC(%esp),%eax /* scp (the call may have clobbered the */ - /* copy at 8(%esp)) */ - pushl %eax - pushl %eax /* junk to fake return address */ - movl $103,%eax /* XXX sigreturn() */ - LCALL(0x7,0) /* enter kernel with args on stack */ - hlt /* never gets here */ - - .globl _szsigcode -_szsigcode: - .long _szsigcode-_sigcode - -/* - * Support routines for GCC, general C-callable functions - */ -ENTRY(__udivsi3) - movl 4(%esp),%eax - xorl %edx,%edx - divl 8(%esp) - ret - -ENTRY(__divsi3) - movl 4(%esp),%eax - cltd - idivl 8(%esp) - ret - - /* - * I/O bus instructions via C - */ -ENTRY(inb) /* val = inb(port) */ - movl 4(%esp),%edx - subl %eax,%eax - NOP - inb %dx,%al - ret - -ENTRY(inw) /* val = inw(port) */ - movl 4(%esp),%edx - subl %eax,%eax - NOP - inw %dx,%ax - ret - -ENTRY(insb) /* insb(port, addr, cnt) */ - pushl %edi - movw 8(%esp),%dx - movl 12(%esp),%edi - movl 16(%esp),%ecx - cld - NOP - rep - insb - NOP - movl %edi,%eax - popl %edi - ret - -ENTRY(insw) /* insw(port, addr, cnt) */ - pushl %edi - movw 8(%esp),%dx - movl 12(%esp),%edi - movl 16(%esp),%ecx - cld - NOP - rep - insw - NOP - movl %edi,%eax - popl %edi - ret - -ENTRY(rtcin) /* rtcin(val) */ - movl 4(%esp),%eax - outb %al,$0x70 - subl %eax,%eax - inb $0x71,%al - ret - -ENTRY(outb) /* outb(port, val) */ - movl 4(%esp),%edx - NOP - movl 8(%esp),%eax - outb %al,%dx - NOP - ret - -ENTRY(outw) /* outw(port, val) */ - movl 4(%esp),%edx - NOP - movl 8(%esp),%eax - outw %ax,%dx - NOP - ret - -ENTRY(outsb) /* outsb(port, addr, cnt) */ - pushl %esi - movw 8(%esp),%dx - movl 12(%esp),%esi - movl 16(%esp),%ecx - cld - NOP - rep - outsb - NOP - movl %esi,%eax - popl %esi - ret - -ENTRY(outsw) /* outsw(port, addr, cnt) */ - pushl %esi - movw 8(%esp),%dx - movl 12(%esp),%esi - movl 16(%esp),%ecx - cld - NOP - rep - outsw - NOP - movl %esi,%eax - popl %esi - ret - - /* - * bcopy family - */ -ENTRY(bzero) /* void bzero(void *base, u_int cnt) */ - pushl %edi - movl 8(%esp),%edi - movl 12(%esp),%ecx - xorl %eax,%eax - shrl $2,%ecx - cld - rep - stosl - movl 12(%esp),%ecx - andl $3,%ecx - rep - stosb - popl %edi - ret - -ENTRY(fillw) /* fillw(pat, base, cnt) */ - pushl %edi - movl 8(%esp),%eax - movl 12(%esp),%edi - movl 16(%esp),%ecx - cld - rep - stosw - popl %edi - ret - -ENTRY(bcopyb) -bcopyb: - pushl %esi - pushl %edi - movl 12(%esp),%esi - movl 16(%esp),%edi - movl 20(%esp),%ecx - cmpl %esi,%edi /* potentially overlapping? */ - jnb 1f - cld /* nope, copy forwards */ - rep - movsb - popl %edi - popl %esi - ret - - ALIGN_TEXT -1: - addl %ecx,%edi /* copy backwards. */ - addl %ecx,%esi - std - decl %edi - decl %esi - rep - movsb - popl %edi - popl %esi - cld - ret - -ENTRY(bcopyw) -bcopyw: - pushl %esi - pushl %edi - movl 12(%esp),%esi - movl 16(%esp),%edi - movl 20(%esp),%ecx - cmpl %esi,%edi /* potentially overlapping? */ - jnb 1f - cld /* nope, copy forwards */ - shrl $1,%ecx /* copy by 16-bit words */ - rep - movsw - adc %ecx,%ecx /* any bytes left? */ - rep - movsb - popl %edi - popl %esi - ret - - ALIGN_TEXT -1: - addl %ecx,%edi /* copy backwards */ - addl %ecx,%esi - std - andl $1,%ecx /* any fractional bytes? */ - decl %edi - decl %esi - rep - movsb - movl 20(%esp),%ecx /* copy remainder by 16-bit words */ - shrl $1,%ecx - decl %esi - decl %edi - rep - movsw - popl %edi - popl %esi - cld - ret - -ENTRY(bcopyx) - movl 16(%esp),%eax - cmpl $2,%eax - je bcopyw /* not _bcopyw, to avoid multiple mcounts */ - cmpl $4,%eax - je bcopy - jmp bcopyb - - /* - * (ov)bcopy(src, dst, cnt) - * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 - */ -ALTENTRY(ovbcopy) -ENTRY(bcopy) -bcopy: - pushl %esi - pushl %edi - movl 12(%esp),%esi - movl 16(%esp),%edi - movl 20(%esp),%ecx - cmpl %esi,%edi /* potentially overlapping? */ - jnb 1f - cld /* nope, copy forwards */ - shrl $2,%ecx /* copy by 32-bit words */ - rep - movsl - movl 20(%esp),%ecx - andl $3,%ecx /* any bytes left? */ - rep - movsb - popl %edi - popl %esi - ret - - ALIGN_TEXT -1: - addl %ecx,%edi /* copy backwards */ - addl %ecx,%esi - std - andl $3,%ecx /* any fractional bytes? */ - decl %edi - decl %esi - rep - movsb - movl 20(%esp),%ecx /* copy remainder by 32-bit words */ - shrl $2,%ecx - subl $3,%esi - subl $3,%edi - rep - movsl - popl %edi - popl %esi - cld - ret - -ALTENTRY(ntohl) -ENTRY(htonl) - movl 4(%esp),%eax -#ifdef i486 - /* XXX */ - /* Since Gas 1.38 does not grok bswap this has been coded as the - * equivalent bytes. This can be changed back to bswap when we - * upgrade to a newer version of Gas */ - /* bswap %eax */ - .byte 0x0f - .byte 0xc8 -#else - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah -#endif - ret - -ALTENTRY(ntohs) -ENTRY(htons) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret - -/*****************************************************************************/ -/* copyout and fubyte family */ -/*****************************************************************************/ -/* - * Access user memory from inside the kernel. These routines and possibly - * the math- and DOS emulators should be the only places that do this. - * - * We have to access the memory with user's permissions, so use a segment - * selector with RPL 3. For writes to user space we have to additionally - * check the PTE for write permission, because the 386 does not check - * write permissions when we are executing with EPL 0. The 486 does check - * this if the WP bit is set in CR0, so we can use a simpler version here. - * - * These routines set curpcb->onfault for the time they execute. When a - * protection violation occurs inside the functions, the trap handler - * returns to *curpcb->onfault instead of the function. - */ - - -ENTRY(copyout) /* copyout(from_kernel, to_user, len) */ - movl _curpcb,%eax - movl $copyout_fault,PCB_ONFAULT(%eax) - pushl %esi - pushl %edi - pushl %ebx - movl 16(%esp),%esi - movl 20(%esp),%edi - movl 24(%esp),%ebx - orl %ebx,%ebx /* anything to do? */ - jz done_copyout - - /* - * Check explicitly for non-user addresses. If 486 write protection - * is being used, this check is essential because we are in kernel - * mode so the h/w does not provide any protection against writing - * kernel addresses. - * - * Otherwise, it saves having to load and restore %es to get the - * usual segment-based protection (the destination segment for movs - * is always %es). The other explicit checks for user-writablility - * are not quite sufficient. They fail for the user area because - * we mapped the user area read/write to avoid having an #ifdef in - * vm_machdep.c. They fail for user PTEs and/or PTDs! (107 - * addresses including 0xff800000 and 0xfc000000). I'm not sure if - * this can be fixed. Marking the PTEs supervisor mode and the - * PDE's user mode would almost work, but there may be a problem - * with the self-referential PDE. - */ - movl %edi,%eax - addl %ebx,%eax - jc copyout_fault -#define VM_END_USER_ADDRESS 0xFDBFE000 /* XXX */ - cmpl $VM_END_USER_ADDRESS,%eax - ja copyout_fault - -#ifndef USE_486_WRITE_PROTECT - /* - * We have to check each PTE for user write permission. - * The checking may cause a page fault, so it is important to set - * up everything for return via copyout_fault before here. - */ - /* compute number of pages */ - movl %edi,%ecx - andl $NBPG-1,%ecx - addl %ebx,%ecx - decl %ecx - shrl $IDXSHIFT+2,%ecx - incl %ecx - - /* compute PTE offset for start address */ - movl %edi,%edx - shrl $IDXSHIFT,%edx - andb $0xfc,%dl - -1: /* check PTE for each page */ - movb _PTmap(%edx),%al - andb $0x07,%al /* Pages must be VALID + USERACC + WRITABLE */ - cmpb $0x07,%al - je 2f - - /* simulate a trap */ - pushl %edx - pushl %ecx - shll $IDXSHIFT,%edx - pushl %edx - call _trapwrite /* trapwrite(addr) */ - popl %edx - popl %ecx - popl %edx - - orl %eax,%eax /* if not ok, return EFAULT */ - jnz copyout_fault - -2: - addl $4,%edx - decl %ecx - jnz 1b /* check next page */ -#endif /* ndef USE_486_WRITE_PROTECT */ - - /* bcopy(%esi, %edi, %ebx) */ - cld - movl %ebx,%ecx - shrl $2,%ecx - rep - movsl - movb %bl,%cl - andb $3,%cl /* XXX can we trust the rest of %ecx on clones? */ - rep - movsb - -done_copyout: - popl %ebx - popl %edi - popl %esi - xorl %eax,%eax - movl _curpcb,%edx - movl %eax,PCB_ONFAULT(%edx) - ret - - ALIGN_TEXT -copyout_fault: - popl %ebx - popl %edi - popl %esi - movl _curpcb,%edx - movl $0,PCB_ONFAULT(%edx) - movl $EFAULT,%eax - ret - -ENTRY(copyin) /* copyin(from_user, to_kernel, len) */ - movl _curpcb,%eax - movl $copyin_fault,PCB_ONFAULT(%eax) - pushl %esi - pushl %edi - movl 12(%esp),%esi /* caddr_t from */ - movl 16(%esp),%edi /* caddr_t to */ - movl 20(%esp),%ecx /* size_t len */ - - movb %cl,%al - shrl $2,%ecx /* copy longword-wise */ - cld - gs - rep - movsl - movb %al,%cl - andb $3,%cl /* copy remaining bytes */ - gs - rep - movsb - - popl %edi - popl %esi - xorl %eax,%eax - movl _curpcb,%edx - movl %eax,PCB_ONFAULT(%edx) - ret - - ALIGN_TEXT -copyin_fault: - popl %edi - popl %esi - movl _curpcb,%edx - movl $0,PCB_ONFAULT(%edx) - movl $EFAULT,%eax - ret - - /* - * fu{byte,sword,word} : fetch a byte(sword, word) from user memory - */ -ALTENTRY(fuiword) -ENTRY(fuword) - movl _curpcb,%ecx - movl $fusufault,PCB_ONFAULT(%ecx) - movl 4(%esp),%edx - gs - movl (%edx),%eax - movl $0,PCB_ONFAULT(%ecx) - ret - -ENTRY(fusword) - movl _curpcb,%ecx - movl $fusufault,PCB_ONFAULT(%ecx) - movl 4(%esp),%edx - gs - movzwl (%edx),%eax - movl $0,PCB_ONFAULT(%ecx) - ret - -ALTENTRY(fuibyte) -ENTRY(fubyte) - movl _curpcb,%ecx - movl $fusufault,PCB_ONFAULT(%ecx) - movl 4(%esp),%edx - gs - movzbl (%edx),%eax - movl $0,PCB_ONFAULT(%ecx) - ret - - ALIGN_TEXT -fusufault: - movl _curpcb,%ecx - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - decl %eax - ret - - /* - * su{byte,sword,word}: write a byte(word, longword) to user memory - */ -#ifdef USE_486_WRITE_PROTECT - /* - * we only have to set the right segment selector. - */ -ALTENTRY(suiword) -ENTRY(suword) - movl _curpcb,%ecx - movl $fusufault,PCB_ONFAULT(%ecx) - movl 4(%esp),%edx - movl 8(%esp),%eax - gs - movl %eax,(%edx) - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - ret - -ENTRY(susword) - movl _curpcb,%ecx - movl $fusufault,PCB_ONFAULT(%ecx) - movl 4(%esp),%edx - movw 8(%esp),%ax - gs - movw %ax,(%edx) - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - ret - -ALTENTRY(suibyte) -ENTRY(subyte) - movl _curpcb,%ecx - movl $fusufault,PCB_ONFAULT(%ecx) - movl 4(%esp),%edx - movb 8(%esp),%al - gs - movb %al,(%edx) - xorl %eax,%eax - movl %eax,PCB_ONFAULT(%ecx) - ret - - -#else /* USE_486_WRITE_PROTECT */ - /* - * here starts the trouble again: check PTE, twice if word crosses - * a page boundary. - */ - /* XXX - page boundary crossing is not handled yet */ - -ALTENTRY(suibyte) -ENTRY(subyte) - movl _curpcb,%ecx - movl $fusufault,PCB_ONFAULT(%ecx) - movl 4(%esp),%edx - movl %edx,%eax - shrl $IDXSHIFT,%edx - andb $0xfc,%dl - movb _PTmap(%edx),%dl - andb $0x7,%dl /* must be VALID + USERACC + WRITE */ - cmpb $0x7,%dl - je 1f - /* simulate a trap */ - pushl %eax - call _trapwrite - popl %edx - orl %eax,%eax - jnz fusufault -1: - movl 4(%esp),%edx - movl 8(%esp),%eax - gs - movb %al,(%edx) - xorl %eax,%eax - movl _curpcb,%ecx - movl %eax,PCB_ONFAULT(%ecx) - ret - -ENTRY(susword) - movl _curpcb,%ecx - movl $fusufault,PCB_ONFAULT(%ecx) - movl 4(%esp),%edx - movl %edx,%eax - shrl $IDXSHIFT,%edx - andb $0xfc,%dl - movb _PTmap(%edx),%dl - andb $0x7,%dl /* must be VALID + USERACC + WRITE */ - cmpb $0x7,%dl - je 1f - /* simulate a trap */ - pushl %eax - call _trapwrite - popl %edx - orl %eax,%eax - jnz fusufault -1: - movl 4(%esp),%edx - movl 8(%esp),%eax - gs - movw %ax,(%edx) - xorl %eax,%eax - movl _curpcb,%ecx - movl %eax,PCB_ONFAULT(%ecx) - ret - -ALTENTRY(suiword) -ENTRY(suword) - movl _curpcb,%ecx - movl $fusufault,PCB_ONFAULT(%ecx) - movl 4(%esp),%edx - movl %edx,%eax - shrl $IDXSHIFT,%edx - andb $0xfc,%dl - movb _PTmap(%edx),%dl - andb $0x7,%dl /* must be VALID + USERACC + WRITE */ - cmpb $0x7,%dl - je 1f - /* simulate a trap */ - pushl %eax - call _trapwrite - popl %edx - orl %eax,%eax - jnz fusufault -1: - movl 4(%esp),%edx - movl 8(%esp),%eax - gs - movl %eax,0(%edx) - xorl %eax,%eax - movl _curpcb,%ecx - movl %eax,PCB_ONFAULT(%ecx) - ret - -#endif /* USE_486_WRITE_PROTECT */ - -/* - * copyoutstr(from, to, maxlen, int *lencopied) - * copy a string from from to to, stop when a 0 character is reached. - * return ENAMETOOLONG if string is longer than maxlen, and - * EFAULT on protection violations. If lencopied is non-zero, - * return the actual length in *lencopied. - */ -#ifdef USE_486_WRITE_PROTECT - -ENTRY(copyoutstr) - pushl %esi - pushl %edi - movl _curpcb,%ecx - movl $cpystrflt,PCB_ONFAULT(%ecx) - - movl 12(%esp),%esi /* %esi = from */ - movl 16(%esp),%edi /* %edi = to */ - movl 20(%esp),%edx /* %edx = maxlen */ - incl %edx - -1: - decl %edx - jz 4f - /* - * gs override doesn't work for stosb. Use the same explicit check - * as in copyout(). It's much slower now because it is per-char. - * XXX - however, it would be faster to rewrite this function to use - * strlen() and copyout(). - */ - cmpl $VM_END_USER_ADDRESS,%edi - jae cpystrflt - lodsb - gs - stosb - orb %al,%al - jnz 1b - /* Success -- 0 byte reached */ - decl %edx - xorl %eax,%eax - jmp 6f -4: - /* edx is zero -- return ENAMETOOLONG */ - movl $ENAMETOOLONG,%eax - jmp 6f - -#else /* ndef USE_486_WRITE_PROTECT */ - -ENTRY(copyoutstr) - pushl %esi - pushl %edi - movl _curpcb,%ecx - movl $cpystrflt,PCB_ONFAULT(%ecx) - - movl 12(%esp),%esi /* %esi = from */ - movl 16(%esp),%edi /* %edi = to */ - movl 20(%esp),%edx /* %edx = maxlen */ -1: - /* - * It suffices to check that the first byte is in user space, because - * we look at a page at a time and the end address is on a page - * boundary. - */ - cmpl $VM_END_USER_ADDRESS,%edi - jae cpystrflt - movl %edi,%eax - shrl $IDXSHIFT,%eax - andb $0xfc,%al - movb _PTmap(%eax),%al - andb $7,%al - cmpb $7,%al - je 2f - - /* simulate trap */ - pushl %edx - pushl %edi - call _trapwrite - popl %edi - popl %edx - orl %eax,%eax - jnz cpystrflt - -2: /* copy up to end of this page */ - movl %edi,%eax - andl $NBPG-1,%eax - movl $NBPG,%ecx - subl %eax,%ecx /* ecx = NBPG - (src % NBPG) */ - cmpl %ecx,%edx - jge 3f - movl %edx,%ecx /* ecx = min(ecx, edx) */ -3: - orl %ecx,%ecx - jz 4f - decl %ecx - decl %edx - lodsb - stosb - orb %al,%al - jnz 3b - - /* Success -- 0 byte reached */ - decl %edx - xorl %eax,%eax - jmp 6f - -4: /* next page */ - orl %edx,%edx - jnz 1b - /* edx is zero -- return ENAMETOOLONG */ - movl $ENAMETOOLONG,%eax - jmp 6f - -#endif /* USE_486_WRITE_PROTECT */ - -/* - * copyinstr(from, to, maxlen, int *lencopied) - * copy a string from from to to, stop when a 0 character is reached. - * return ENAMETOOLONG if string is longer than maxlen, and - * EFAULT on protection violations. If lencopied is non-zero, - * return the actual length in *lencopied. - */ -ENTRY(copyinstr) - pushl %esi - pushl %edi - movl _curpcb,%ecx - movl $cpystrflt,PCB_ONFAULT(%ecx) - - movl 12(%esp),%esi /* %esi = from */ - movl 16(%esp),%edi /* %edi = to */ - movl 20(%esp),%edx /* %edx = maxlen */ - incl %edx - -1: - decl %edx - jz 4f - gs - lodsb - stosb - orb %al,%al - jnz 1b - /* Success -- 0 byte reached */ - decl %edx - xorl %eax,%eax - jmp 6f -4: - /* edx is zero -- return ENAMETOOLONG */ - movl $ENAMETOOLONG,%eax - jmp 6f - -cpystrflt: - movl $EFAULT,%eax -6: /* set *lencopied and return %eax */ - movl _curpcb,%ecx - movl $0,PCB_ONFAULT(%ecx) - movl 20(%esp),%ecx - subl %edx,%ecx - movl 24(%esp),%edx - orl %edx,%edx - jz 7f - movl %ecx,(%edx) -7: - popl %edi - popl %esi - ret - - -/* - * copystr(from, to, maxlen, int *lencopied) - */ -ENTRY(copystr) - pushl %esi - pushl %edi - - movl 12(%esp),%esi /* %esi = from */ - movl 16(%esp),%edi /* %edi = to */ - movl 20(%esp),%edx /* %edx = maxlen */ - incl %edx - -1: - decl %edx - jz 4f - lodsb - stosb - orb %al,%al - jnz 1b - /* Success -- 0 byte reached */ - decl %edx - xorl %eax,%eax - jmp 6f -4: - /* edx is zero -- return ENAMETOOLONG */ - movl $ENAMETOOLONG,%eax - -6: /* set *lencopied and return %eax */ - movl 20(%esp),%ecx - subl %edx,%ecx - movl 24(%esp),%edx - orl %edx,%edx - jz 7f - movl %ecx,(%edx) -7: - popl %edi - popl %esi - ret - -/* - * Handling of special 386 registers and descriptor tables etc - */ -ENTRY(lgdt) /* void lgdt(struct region_descriptor *rdp); */ - /* reload the descriptor table */ - movl 4(%esp),%eax - lgdt (%eax) - /* flush the prefetch q */ - jmp 1f - nop -1: - /* reload "stale" selectors */ - movl $KDSEL,%eax - movl %ax,%ds - movl %ax,%es - movl %ax,%ss - - /* reload code selector by turning return into intersegmental return */ - movl (%esp),%eax - pushl %eax -# movl $KCSEL,4(%esp) - movl $8,4(%esp) - lret - - /* - * void lidt(struct region_descriptor *rdp); - */ -ENTRY(lidt) - movl 4(%esp),%eax - lidt (%eax) - ret - - /* - * void lldt(u_short sel) - */ -ENTRY(lldt) - lldt 4(%esp) - ret - - /* - * void ltr(u_short sel) - */ -ENTRY(ltr) - ltr 4(%esp) - ret - -ENTRY(ssdtosd) /* ssdtosd(*ssdp,*sdp) */ - pushl %ebx - movl 8(%esp),%ecx - movl 8(%ecx),%ebx - shll $16,%ebx - movl (%ecx),%edx - roll $16,%edx - movb %dh,%bl - movb %dl,%bh - rorl $8,%ebx - movl 4(%ecx),%eax - movw %ax,%dx - andl $0xf0000,%eax - orl %eax,%ebx - movl 12(%esp),%ecx - movl %edx,(%ecx) - movl %ebx,4(%ecx) - popl %ebx - ret - - -ENTRY(tlbflush) /* tlbflush() */ - movl %cr3,%eax - orl $I386_CR3PAT,%eax - movl %eax,%cr3 - ret - - -ENTRY(load_cr0) /* load_cr0(cr0) */ - movl 4(%esp),%eax - movl %eax,%cr0 - ret - - -ENTRY(rcr0) /* rcr0() */ - movl %cr0,%eax - ret - - -ENTRY(rcr2) /* rcr2() */ - movl %cr2,%eax - ret - - -ENTRY(rcr3) /* rcr3() */ - movl %cr3,%eax - ret - - -ENTRY(load_cr3) /* void load_cr3(caddr_t cr3) */ - movl 4(%esp),%eax - orl $I386_CR3PAT,%eax - movl %eax,%cr3 - ret - - -/*****************************************************************************/ -/* setjump, longjump */ -/*****************************************************************************/ - -ENTRY(setjmp) - movl 4(%esp),%eax - movl %ebx,(%eax) /* save ebx */ - movl %esp,4(%eax) /* save esp */ - movl %ebp,8(%eax) /* save ebp */ - movl %esi,12(%eax) /* save esi */ - movl %edi,16(%eax) /* save edi */ - movl (%esp),%edx /* get rta */ - movl %edx,20(%eax) /* save eip */ - xorl %eax,%eax /* return(0); */ - ret - -ENTRY(longjmp) - movl 4(%esp),%eax - movl (%eax),%ebx /* restore ebx */ - movl 4(%eax),%esp /* restore esp */ - movl 8(%eax),%ebp /* restore ebp */ - movl 12(%eax),%esi /* restore esi */ - movl 16(%eax),%edi /* restore edi */ - movl 20(%eax),%edx /* get rta */ - movl %edx,(%esp) /* put in return frame */ - xorl %eax,%eax /* return(1); */ - incl %eax - ret - - -/*****************************************************************************/ -/* Scheduling */ -/*****************************************************************************/ - -/* - * The following primitives manipulate the run queues. - * _whichqs tells which of the 32 queues _qs - * have processes in them. Setrq puts processes into queues, Remrq - * removes them from queues. The running process is on no queue, - * other processes are on a queue related to p->p_pri, divided by 4 - * actually to shrink the 0-127 range of priorities into the 32 available - * queues. - */ - - .globl _whichqs,_qs,_cnt,_panic - .comm _noproc,4 - .comm _runrun,4 - -/* - * Setrq(p) - * - * Call should be made at spl6(), and p->p_stat should be SRUN - */ -ENTRY(setrq) - movl 4(%esp),%eax - cmpl $0,P_RLINK(%eax) /* should not be on q already */ - je set1 - pushl $set2 - call _panic -set1: - movzbl P_PRI(%eax),%edx - shrl $2,%edx - btsl %edx,_whichqs /* set q full bit */ - shll $3,%edx - addl $_qs,%edx /* locate q hdr */ - movl %edx,P_LINK(%eax) /* link process on tail of q */ - movl P_RLINK(%edx),%ecx - movl %ecx,P_RLINK(%eax) - movl %eax,P_RLINK(%edx) - movl %eax,P_LINK(%ecx) - ret - -set2: .asciz "setrq" - -/* - * Remrq(p) - * - * Call should be made at spl6(). - */ -ENTRY(remrq) - movl 4(%esp),%eax - movzbl P_PRI(%eax),%edx - shrl $2,%edx - btrl %edx,_whichqs /* clear full bit, panic if clear already */ - jb rem1 - pushl $rem3 - call _panic -rem1: - pushl %edx - movl P_LINK(%eax),%ecx /* unlink process */ - movl P_RLINK(%eax),%edx - movl %edx,P_RLINK(%ecx) - movl P_RLINK(%eax),%ecx - movl P_LINK(%eax),%edx - movl %edx,P_LINK(%ecx) - popl %edx - movl $_qs,%ecx - shll $3,%edx - addl %edx,%ecx - cmpl P_LINK(%ecx),%ecx /* q still has something? */ - je rem2 - shrl $3,%edx /* yes, set bit as still full */ - btsl %edx,_whichqs -rem2: - movl $0,P_RLINK(%eax) /* zap reverse link to indicate off list */ - ret - -rem3: .asciz "remrq" -sw0: .asciz "swtch" - -/* - * When no processes are on the runq, Swtch branches to idle - * to wait for something to come ready. - */ - ALIGN_TEXT -Idle: - sti - SHOW_STI - - ALIGN_TEXT -idle_loop: - call _spl0 - cmpl $0,_whichqs - jne sw1 - hlt /* wait for interrupt */ - jmp idle_loop - -badsw: - pushl $sw0 - call _panic - /*NOTREACHED*/ - -/* - * Swtch() - */ - SUPERALIGN_TEXT /* so profiling doesn't lump Idle with swtch().. */ -ENTRY(swtch) - - incl _cnt+V_SWTCH - - /* switch to new process. first, save context as needed */ - - movl _curproc,%ecx - - /* if no process to save, don't bother */ - testl %ecx,%ecx - je sw1 - - movl P_ADDR(%ecx),%ecx - - movl (%esp),%eax /* Hardware registers */ - movl %eax,PCB_EIP(%ecx) - movl %ebx,PCB_EBX(%ecx) - movl %esp,PCB_ESP(%ecx) - movl %ebp,PCB_EBP(%ecx) - movl %esi,PCB_ESI(%ecx) - movl %edi,PCB_EDI(%ecx) - -#if NNPX > 0 - /* have we used fp, and need a save? */ - mov _curproc,%eax - cmp %eax,_npxproc - jne 1f - pushl %ecx /* h/w bugs make saving complicated */ - leal PCB_SAVEFPU(%ecx),%eax - pushl %eax - call _npxsave /* do it in a big C function */ - popl %eax - popl %ecx -1: -#endif /* NNPX > 0 */ - - movl _CMAP2,%eax /* save temporary map PTE */ - movl %eax,PCB_CMAP2(%ecx) /* in our context */ - movl $0,_curproc /* out of process */ - -# movw _cpl,%ax -# movw %ax,PCB_IML(%ecx) /* save ipl */ - - /* save is done, now choose a new process or idle */ -sw1: - cli - SHOW_CLI - movl _whichqs,%edi -2: - /* XXX - bsf is sloow */ - bsfl %edi,%eax /* find a full q */ - je Idle /* if none, idle */ - /* XX update whichqs? */ -swfnd: - btrl %eax,%edi /* clear q full status */ - jnb 2b /* if it was clear, look for another */ - movl %eax,%ebx /* save which one we are using */ - - shll $3,%eax - addl $_qs,%eax /* select q */ - movl %eax,%esi - -#ifdef DIAGNOSTIC - cmpl P_LINK(%eax),%eax /* linked to self? (e.g. not on list) */ - je badsw /* not possible */ -#endif - - movl P_LINK(%eax),%ecx /* unlink from front of process q */ - movl P_LINK(%ecx),%edx - movl %edx,P_LINK(%eax) - movl P_RLINK(%ecx),%eax - movl %eax,P_RLINK(%edx) - - cmpl P_LINK(%ecx),%esi /* q empty */ - je 3f - btsl %ebx,%edi /* nope, set to indicate full */ -3: - movl %edi,_whichqs /* update q status */ - - movl $0,%eax - movl %eax,_want_resched - -#ifdef DIAGNOSTIC - cmpl %eax,P_WCHAN(%ecx) - jne badsw - cmpb $SRUN,P_STAT(%ecx) - jne badsw -#endif - - movl %eax,P_RLINK(%ecx) /* isolate process to run */ - movl P_ADDR(%ecx),%edx - movl PCB_CR3(%edx),%ebx - - /* switch address space */ - movl %ebx,%cr3 - - /* restore context */ - movl PCB_EBX(%edx),%ebx - movl PCB_ESP(%edx),%esp - movl PCB_EBP(%edx),%ebp - movl PCB_ESI(%edx),%esi - movl PCB_EDI(%edx),%edi - movl PCB_EIP(%edx),%eax - movl %eax,(%esp) - - movl PCB_CMAP2(%edx),%eax /* get temporary map */ - movl %eax,_CMAP2 /* reload temporary map PTE */ - - movl %ecx,_curproc /* into next process */ - movl %edx,_curpcb - - pushl %edx /* save p to return */ -/* - * XXX - 0.0 forgot to save it - is that why this was commented out in 0.1? - * I think restoring the cpl is unnecessary, but we must turn off the cli - * now that spl*() don't do it as a side affect. - */ - pushl PCB_IML(%edx) - sti - SHOW_STI -#if 0 - call _splx -#endif - addl $4,%esp -/* - * XXX - 0.0 gets here via swtch_to_inactive(). I think 0.1 gets here in the - * same way. Better return a value. - */ - popl %eax /* return(p); */ - ret - -ENTRY(mvesp) - movl %esp,%eax - ret -/* - * struct proc *swtch_to_inactive(p) ; struct proc *p; - * - * At exit of a process, move off the address space of the - * process and onto a "safe" one. Then, on a temporary stack - * return and run code that disposes of the old state. - * Since this code requires a parameter from the "old" stack, - * pass it back as a return value. - */ -ENTRY(swtch_to_inactive) - popl %edx /* old pc */ - popl %eax /* arg, our return value */ - movl _IdlePTD,%ecx - movl %ecx,%cr3 /* good bye address space */ - #write buffer? - movl $tmpstk-4,%esp /* temporary stack, compensated for call */ - jmp %edx /* return, execute remainder of cleanup */ - -/* - * savectx(pcb, altreturn) - * Update pcb, saving current processor state and arranging - * for alternate return ala longjmp in swtch if altreturn is true. - */ -ENTRY(savectx) - movl 4(%esp),%ecx - movw _cpl,%ax - movw %ax,PCB_IML(%ecx) - movl (%esp),%eax - movl %eax,PCB_EIP(%ecx) - movl %ebx,PCB_EBX(%ecx) - movl %esp,PCB_ESP(%ecx) - movl %ebp,PCB_EBP(%ecx) - movl %esi,PCB_ESI(%ecx) - movl %edi,PCB_EDI(%ecx) - -#if NNPX > 0 - /* - * If npxproc == NULL, then the npx h/w state is irrelevant and the - * state had better already be in the pcb. This is true for forks - * but not for dumps (the old book-keeping with FP flags in the pcb - * always lost for dumps because the dump pcb has 0 flags). - * - * If npxproc != NULL, then we have to save the npx h/w state to - * npxproc's pcb and copy it to the requested pcb, or save to the - * requested pcb and reload. Copying is easier because we would - * have to handle h/w bugs for reloading. We used to lose the - * parent's npx state for forks by forgetting to reload. - */ - mov _npxproc,%eax - testl %eax,%eax - je 1f - - pushl %ecx - movl P_ADDR(%eax),%eax - leal PCB_SAVEFPU(%eax),%eax - pushl %eax - pushl %eax - call _npxsave - popl %eax - popl %eax - popl %ecx - - pushl %ecx - pushl $108+8*2 /* XXX h/w state size + padding */ - leal PCB_SAVEFPU(%ecx),%ecx - pushl %ecx - pushl %eax - call _bcopy - addl $12,%esp - popl %ecx -1: -#endif /* NNPX > 0 */ - - movl _CMAP2,%edx /* save temporary map PTE */ - movl %edx,PCB_CMAP2(%ecx) /* in our context */ - - cmpl $0,8(%esp) - je 1f - movl %esp,%edx /* relocate current sp relative to pcb */ - subl $_kstack,%edx /* (sp is relative to kstack): */ - addl %edx,%ecx /* pcb += sp - kstack; */ - movl %eax,(%ecx) /* write return pc at (relocated) sp@ */ - /* this mess deals with replicating register state gcc hides */ - movl 12(%esp),%eax - movl %eax,12(%ecx) - movl 16(%esp),%eax - movl %eax,16(%ecx) - movl 20(%esp),%eax - movl %eax,20(%ecx) - movl 24(%esp),%eax - movl %eax,24(%ecx) -1: - xorl %eax,%eax /* return 0 */ - ret - -/* - * addupc(int pc, struct uprof *up, int ticks): - * update profiling information for the user process. - */ -ENTRY(addupc) - pushl %ebp - movl %esp,%ebp - movl 12(%ebp),%edx /* up */ - movl 8(%ebp),%eax /* pc */ - - subl PR_OFF(%edx),%eax /* pc -= up->pr_off */ - jl L1 /* if (pc < 0) return */ - - shrl $1,%eax /* praddr = pc >> 1 */ - imull PR_SCALE(%edx),%eax /* praddr *= up->pr_scale */ - shrl $15,%eax /* praddr = praddr << 15 */ - andl $-2,%eax /* praddr &= ~1 */ - - cmpl PR_SIZE(%edx),%eax /* if (praddr > up->pr_size) return */ - ja L1 - -/* addl %eax,%eax /* praddr -> word offset */ - addl PR_BASE(%edx),%eax /* praddr += up-> pr_base */ - movl 16(%ebp),%ecx /* ticks */ - - movl _curpcb,%edx - movl $proffault,PCB_ONFAULT(%edx) - addl %ecx,(%eax) /* storage location += ticks */ - movl $0,PCB_ONFAULT(%edx) -L1: - leave - ret - - ALIGN_TEXT -proffault: - /* if we get a fault, then kill profiling all together */ - movl $0,PCB_ONFAULT(%edx) /* squish the fault handler */ - movl 12(%ebp),%ecx - movl $0,PR_SCALE(%ecx) /* up->pr_scale = 0 */ - leave - ret - -/* To be done: */ -ENTRY(astoff) - ret - - -/*****************************************************************************/ -/* Trap handling */ -/*****************************************************************************/ -/* - * Trap and fault vector routines - * - * XXX - debugger traps are now interrupt gates so at least bdb doesn't lose - * control. The sti's give the standard losing behaviour for ddb and kgdb. - */ -#define IDTVEC(name) ALIGN_TEXT; .globl _X/**/name; _X/**/name: -#define TRAP(a) pushl $(a) ; jmp alltraps -#ifdef KGDB -# define BPTTRAP(a) sti; pushl $(a) ; jmp bpttraps -#else -# define BPTTRAP(a) sti; TRAP(a) -#endif - -IDTVEC(div) - pushl $0; TRAP(T_DIVIDE) -IDTVEC(dbg) -#ifdef BDBTRAP - BDBTRAP(dbg) -#endif - pushl $0; BPTTRAP(T_TRCTRAP) -IDTVEC(nmi) - pushl $0; TRAP(T_NMI) -IDTVEC(bpt) -#ifdef BDBTRAP - BDBTRAP(bpt) -#endif - pushl $0; BPTTRAP(T_BPTFLT) -IDTVEC(ofl) - pushl $0; TRAP(T_OFLOW) -IDTVEC(bnd) - pushl $0; TRAP(T_BOUND) -IDTVEC(ill) - pushl $0; TRAP(T_PRIVINFLT) -IDTVEC(dna) - pushl $0; TRAP(T_DNA) -IDTVEC(dble) - TRAP(T_DOUBLEFLT) - /*PANIC("Double Fault");*/ -IDTVEC(fpusegm) - pushl $0; TRAP(T_FPOPFLT) -IDTVEC(tss) - TRAP(T_TSSFLT) - /*PANIC("TSS not valid");*/ -IDTVEC(missing) - TRAP(T_SEGNPFLT) -IDTVEC(stk) - TRAP(T_STKFLT) -IDTVEC(prot) - TRAP(T_PROTFLT) -IDTVEC(page) - TRAP(T_PAGEFLT) -IDTVEC(rsvd) - pushl $0; TRAP(T_RESERVED) -IDTVEC(fpu) -#if NNPX > 0 - /* - * Handle like an interrupt so that we can call npxintr to clear the - * error. It would be better to handle npx interrupts as traps but - * this is difficult for nested interrupts. - */ - pushl $0 /* dummy error code */ - pushl $T_ASTFLT - pushal - nop /* silly, the bug is for popal and it only - * bites when the next instruction has a - * complicated address mode */ - pushl %ds - pushl %es /* now the stack frame is a trap frame */ - movl $KDSEL,%eax - movl %ax,%ds - movl %ax,%es - pushl _cpl - pushl $0 /* dummy unit to finish building intr frame */ - incl _cnt+V_TRAP - call _npxintr - jmp doreti -#else /* NNPX > 0 */ - pushl $0; TRAP(T_ARITHTRAP) -#endif /* NNPX > 0 */ - /* 17 - 31 reserved for future exp */ -IDTVEC(rsvd0) - pushl $0; TRAP(17) -IDTVEC(rsvd1) - pushl $0; TRAP(18) -IDTVEC(rsvd2) - pushl $0; TRAP(19) -IDTVEC(rsvd3) - pushl $0; TRAP(20) -IDTVEC(rsvd4) - pushl $0; TRAP(21) -IDTVEC(rsvd5) - pushl $0; TRAP(22) -IDTVEC(rsvd6) - pushl $0; TRAP(23) -IDTVEC(rsvd7) - pushl $0; TRAP(24) -IDTVEC(rsvd8) - pushl $0; TRAP(25) -IDTVEC(rsvd9) - pushl $0; TRAP(26) -IDTVEC(rsvd10) - pushl $0; TRAP(27) -IDTVEC(rsvd11) - pushl $0; TRAP(28) -IDTVEC(rsvd12) - pushl $0; TRAP(29) -IDTVEC(rsvd13) - pushl $0; TRAP(30) -IDTVEC(rsvd14) - pushl $0; TRAP(31) - - SUPERALIGN_TEXT -alltraps: - pushal - nop - pushl %ds - pushl %es - movl $KDSEL,%eax - movl %ax,%ds - movl %ax,%es -calltrap: - incl _cnt+V_TRAP - call _trap - /* - * Return through doreti to handle ASTs. Have to change trap frame - * to interrupt frame. - */ - movl $T_ASTFLT,4+4+32(%esp) /* new trap type (err code not used) */ - pushl _cpl - pushl $0 /* dummy unit */ - jmp doreti - -#ifdef KGDB -/* - * This code checks for a kgdb trap, then falls through - * to the regular trap code. - */ - SUPERALIGN_TEXT -bpttraps: - pushal - nop - pushl %es - pushl %ds - movl $KDSEL,%eax - movl %ax,%ds - movl %ax,%es - testb $SEL_RPL_MASK,TRAPF_CS_OFF(%esp) - /* non-kernel mode? */ - jne calltrap /* yes */ - call _kgdb_trap_glue - jmp calltrap -#endif - -/* - * Call gate entry for syscall - */ - SUPERALIGN_TEXT -IDTVEC(syscall) - pushfl /* only for stupid carry bit and more stupid wait3 cc kludge */ - /* XXX - also for direction flag (bzero, etc. clear it) */ - pushal /* only need eax,ecx,edx - trap resaves others */ - nop - movl $KDSEL,%eax /* switch to kernel segments */ - movl %ax,%ds - movl %ax,%es - incl _cnt+V_SYSCALL /* kml 3/25/93 */ - call _syscall - /* - * Return through doreti to handle ASTs. Have to change syscall frame - * to interrupt frame. - * - * XXX - we should have set up the frame earlier to avoid the - * following popal/pushal (not much can be done to avoid shuffling - * the flags). Consistent frames would simplify things all over. - */ - movl 32+0(%esp),%eax /* old flags, shuffle to above cs:eip */ - movl 32+4(%esp),%ebx /* `int' frame should have been ef, eip, cs */ - movl 32+8(%esp),%ecx - movl %ebx,32+0(%esp) - movl %ecx,32+4(%esp) - movl %eax,32+8(%esp) - popal - nop - pushl $0 /* dummy error code */ - pushl $T_ASTFLT - pushal - nop - movl __udatasel,%eax /* switch back to user segments */ - pushl %eax /* XXX - better to preserve originals? */ - pushl %eax - pushl _cpl - pushl $0 - jmp doreti - -#ifdef SHOW_A_LOT -/* - * 'show_bits' was too big when defined as a macro. The line length for some - * enclosing macro was too big for gas. Perhaps the code would have blown - * the cache anyway. - */ - ALIGN_TEXT -show_bits: - pushl %eax - SHOW_BIT(0) - SHOW_BIT(1) - SHOW_BIT(2) - SHOW_BIT(3) - SHOW_BIT(4) - SHOW_BIT(5) - SHOW_BIT(6) - SHOW_BIT(7) - SHOW_BIT(8) - SHOW_BIT(9) - SHOW_BIT(10) - SHOW_BIT(11) - SHOW_BIT(12) - SHOW_BIT(13) - SHOW_BIT(14) - SHOW_BIT(15) - popl %eax - ret - - .data -bit_colors: - .byte GREEN,RED,0,0 - .text - -#endif /* SHOW_A_LOT */ - - -/* - * include generated interrupt vectors and ISA intr code - */ -#include "i386/isa/vector.s" -#include "i386/isa/icu.s" diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c deleted file mode 100644 index 49b9304..0000000 --- a/sys/i386/i386/machdep.c +++ /dev/null @@ -1,1285 +0,0 @@ -/*- - * Copyright (c) 1992 Terrence R. Lambert. - * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.11 1993/10/14 18:15:35 rgrimes Exp $ - */ - -#include "npx.h" -#include "isa.h" - -#include -#include "param.h" -#include "systm.h" -#include "signalvar.h" -#include "kernel.h" -#include "map.h" -#include "proc.h" -#include "user.h" -#include "exec.h" /* for PS_STRINGS */ -#include "buf.h" -#include "reboot.h" -#include "conf.h" -#include "file.h" -#include "callout.h" -#include "malloc.h" -#include "mbuf.h" -#include "msgbuf.h" -#include "net/netisr.h" - -#ifdef SYSVSHM -#include "sys/shm.h" -#endif - -#include "vm/vm.h" -#include "vm/vm_kern.h" -#include "vm/vm_page.h" - -#include "sys/exec.h" -#include "sys/vnode.h" - -#ifndef MACHINE_NONCONTIG -extern vm_offset_t avail_end; -#else -extern vm_offset_t avail_start, avail_end; -static vm_offset_t hole_start, hole_end; -static vm_offset_t avail_next; -static unsigned int avail_remaining; -#endif /* MACHINE_NONCONTIG */ - -#include "machine/cpu.h" -#include "machine/reg.h" -#include "machine/psl.h" -#include "machine/specialreg.h" -#include "machine/sysarch.h" - -#include "i386/isa/isa.h" -#include "i386/isa/rtc.h" - - -#define EXPECT_BASEMEM 640 /* The expected base memory*/ -#define INFORM_WAIT 1 /* Set to pause berfore crash in weird cases*/ - -/* - * Declare these as initialized data so we can patch them. - */ -int nswbuf = 0; -#ifdef NBUF -int nbuf = NBUF; -#else -int nbuf = 0; -#endif -#ifdef BUFPAGES -int bufpages = BUFPAGES; -#else -int bufpages = 0; -#endif -extern int freebufspace; - -int _udatasel, _ucodesel; - -/* - * Machine-dependent startup code - */ -int boothowto = 0, Maxmem = 0; -long dumplo; -int physmem, maxmem; -extern int bootdev; -#ifdef SMALL -extern int forcemaxmem; -#endif -int biosmem; - -extern cyloffset; - -int cpu_class; - -void dumpsys __P((void)); - -void -cpu_startup() -{ - register int unixsize; - register unsigned i; - register struct pte *pte; - int mapaddr, j; - register caddr_t v; - int maxbufs, base, residual; - extern long Usrptsize; - vm_offset_t minaddr, maxaddr; - vm_size_t size; - int firstaddr; - - /* - * Initialize error message buffer (at end of core). - */ - - /* avail_end was pre-decremented in pmap_bootstrap to compensate */ - for (i = 0; i < btoc(sizeof (struct msgbuf)); i++) -#ifndef MACHINE_NONCONTIG - pmap_enter(pmap_kernel(), msgbufp, avail_end + i * NBPG, - VM_PROT_ALL, TRUE); -#else - pmap_enter(pmap_kernel(), (caddr_t)msgbufp + i * NBPG, - avail_end + i * NBPG, VM_PROT_ALL, TRUE); -#endif - msgbufmapped = 1; - - /* - * Good {morning,afternoon,evening,night}. - */ - printf(version); - identifycpu(); - printf("real mem = %d\n", ctob(physmem)); - - /* - * Allocate space for system data structures. - * The first available kernel virtual address is in "v". - * As pages of kernel virtual memory are allocated, "v" is incremented. - * As pages of memory are allocated and cleared, - * "firstaddr" is incremented. - * An index into the kernel page table corresponding to the - * virtual memory address maintained in "v" is kept in "mapaddr". - */ - - /* - * Make two passes. The first pass calculates how much memory is - * needed and allocates it. The second pass assigns virtual - * addresses to the various data structures. - */ - firstaddr = 0; -again: - v = (caddr_t)firstaddr; - -#define valloc(name, type, num) \ - (name) = (type *)v; v = (caddr_t)((name)+(num)) -#define valloclim(name, type, num, lim) \ - (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num))) -/* valloc(cfree, struct cblock, nclist); no clists any more!!! - cgd */ - valloc(callout, struct callout, ncallout); -#ifdef NetBSD - valloc(swapmap, struct map, nswapmap = maxproc * 2); -#endif -#ifdef SYSVSHM - valloc(shmsegs, struct shmid_ds, shminfo.shmmni); -#endif - /* - * Determine how many buffers to allocate. - * Use 20% of memory of memory beyond the first 2MB - * Insure a minimum of 16 fs buffers. - * We allocate 1/2 as many swap buffer headers as file i/o buffers. - */ - if (bufpages == 0) - bufpages = (ctob(physmem) - 2048*1024) / NBPG / 5; - if (bufpages < 32) - bufpages = 32; - - /* - * We must still limit the maximum number of buffers to be no - * more than 2/5's of the size of the kernal malloc region, this - * will only take effect for machines with lots of memory - */ - bufpages = min(bufpages, (VM_KMEM_SIZE / NBPG) * 2 / 5); - if (nbuf == 0) { - nbuf = bufpages / 2; - if (nbuf < 16) - nbuf = 16; - } - freebufspace = bufpages * NBPG; - if (nswbuf == 0) { - nswbuf = (nbuf / 2) &~ 1; /* force even */ - if (nswbuf > 256) - nswbuf = 256; /* sanity */ - } - valloc(swbuf, struct buf, nswbuf); - valloc(buf, struct buf, nbuf); - - /* - * End of first pass, size has been calculated so allocate memory - */ - if (firstaddr == 0) { - size = (vm_size_t)(v - firstaddr); - firstaddr = (int)kmem_alloc(kernel_map, round_page(size)); - if (firstaddr == 0) - panic("startup: no room for tables"); - goto again; - } - /* - * End of second pass, addresses have been assigned - */ - if ((vm_size_t)(v - firstaddr) != size) - panic("startup: table size inconsistency"); - - /* - * Allocate a submap for buffer space allocations. - * XXX we are NOT using buffer_map, but due to - * the references to it we will just allocate 1 page of - * vm (not real memory) to make things happy... - */ - buffer_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, - /* bufpages * */NBPG, TRUE); - /* - * Allocate a submap for exec arguments. This map effectively - * limits the number of processes exec'ing at any time. - */ -/* exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, - * 16*NCARGS, TRUE); - * NOT CURRENTLY USED -- cgd - */ - /* - * Allocate a submap for physio - */ - phys_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, - VM_PHYS_SIZE, TRUE); - - /* - * Finally, allocate mbuf pool. Since mclrefcnt is an off-size - * we use the more space efficient malloc in place of kmem_alloc. - */ - mclrefcnt = (char *)malloc(NMBCLUSTERS+CLBYTES/MCLBYTES, - M_MBUF, M_NOWAIT); - bzero(mclrefcnt, NMBCLUSTERS+CLBYTES/MCLBYTES); - mb_map = kmem_suballoc(kernel_map, (vm_offset_t)&mbutl, &maxaddr, - VM_MBUF_SIZE, FALSE); - /* - * Initialize callouts - */ - callfree = callout; - for (i = 1; i < ncallout; i++) - callout[i-1].c_next = &callout[i]; - - printf("avail mem = %d\n", ptoa(vm_page_free_count)); - printf("using %d buffers containing %d bytes of memory\n", - nbuf, bufpages * CLBYTES); - - /* - * Set up CPU-specific registers, cache, etc. - */ - initcpu(); - - /* - * Set up buffers, so they can be used to read disk labels. - */ - bufinit(); - - /* - * Configure the system. - */ - configure(); -} - - -struct cpu_nameclass i386_cpus[] = { - { "Intel 80286", CPUCLASS_286 }, /* CPU_286 */ - { "i386SX", CPUCLASS_386 }, /* CPU_386SX */ - { "i386DX", CPUCLASS_386 }, /* CPU_386 */ - { "i486SX", CPUCLASS_486 }, /* CPU_486SX */ - { "i486DX", CPUCLASS_486 }, /* CPU_486 */ - { "i586", CPUCLASS_586 }, /* CPU_586 */ -}; - -identifycpu() /* translated from hp300 -- cgd */ -{ - printf("CPU: "); - if (cpu >= 0 && cpu < (sizeof i386_cpus/sizeof(struct cpu_nameclass))) { - printf("%s", i386_cpus[cpu].cpu_name); - cpu_class = i386_cpus[cpu].cpu_class; - } else { - printf("unknown cpu type %d\n", cpu); - panic("startup: bad cpu id"); - } - printf(" ("); - switch(cpu_class) { - case CPUCLASS_286: - printf("286"); - break; - case CPUCLASS_386: - printf("386"); - break; - case CPUCLASS_486: - printf("486"); - break; - case CPUCLASS_586: - printf("586"); - break; - default: - printf("unknown"); /* will panic below... */ - } - printf("-class CPU)"); - printf("\n"); /* cpu speed would be nice, but how? */ - - /* - * Now that we have told the user what they have, - * let them know if that machine type isn't configured. - */ - switch (cpu_class) { - case CPUCLASS_286: /* a 286 should not make it this far, anyway */ -#if !defined(I386_CPU) && !defined(I486_CPU) && !defined(I586_CPU) -#error This kernel is not configured for one of the supported CPUs -#endif -#if !defined(I386_CPU) - case CPUCLASS_386: -#endif -#if !defined(I486_CPU) - case CPUCLASS_486: -#endif -#if !defined(I586_CPU) - case CPUCLASS_586: -#endif - panic("CPU class not configured"); - default: - break; - } -} - -#ifdef PGINPROF -/* - * Return the difference (in microseconds) - * between the current time and a previous - * time as represented by the arguments. - * If there is a pending clock interrupt - * which has not been serviced due to high - * ipl, return error code. - */ -/*ARGSUSED*/ -vmtime(otime, olbolt, oicr) - register int otime, olbolt, oicr; -{ - - return (((time.tv_sec-otime)*60 + lbolt-olbolt)*16667); -} -#endif - -extern int kstack[]; - -/* - * Send an interrupt to process. - * - * Stack is set up to allow sigcode stored - * in u. to call routine, followed by kcall - * to sigreturn routine below. After sigreturn - * resets the signal mask, the stack, and the - * frame pointer, it returns to the user - * specified pc, psl. - */ -void -sendsig(catcher, sig, mask, code) - sig_t catcher; - int sig, mask; - unsigned code; -{ - register struct proc *p = curproc; - register int *regs; - register struct sigframe *fp; - struct sigacts *ps = p->p_sigacts; - int oonstack, frmtrap; - - regs = p->p_regs; - oonstack = ps->ps_onstack; - frmtrap = curpcb->pcb_flags & FM_TRAP; - /* - * Allocate and validate space for the signal handler - * context. Note that if the stack is in P0 space, the - * call to grow() is a nop, and the useracc() check - * will fail if the process has not already allocated - * the space with a `brk'. - */ - if (!ps->ps_onstack && (ps->ps_sigonstack & sigmask(sig))) { - fp = (struct sigframe *)(ps->ps_sigsp - - sizeof(struct sigframe)); - ps->ps_onstack = 1; - } else { - if (frmtrap) - fp = (struct sigframe *)(regs[tESP] - - sizeof(struct sigframe)); - else - fp = (struct sigframe *)(regs[sESP] - - sizeof(struct sigframe)); - } - - if ((unsigned)fp <= (unsigned)p->p_vmspace->vm_maxsaddr + MAXSSIZ - ctob(p->p_vmspace->vm_ssize)) - (void)grow(p, (unsigned)fp); - - if (useracc((caddr_t)fp, sizeof (struct sigframe), B_WRITE) == 0) { - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - SIGACTION(p, SIGILL) = SIG_DFL; - sig = sigmask(SIGILL); - p->p_sigignore &= ~sig; - p->p_sigcatch &= ~sig; - p->p_sigmask &= ~sig; - psignal(p, SIGILL); - return; - } - - /* - * Build the argument list for the signal handler. - */ - fp->sf_signum = sig; - fp->sf_code = code; - fp->sf_scp = &fp->sf_sc; - fp->sf_handler = catcher; - - /* save scratch registers */ - if(frmtrap) { - fp->sf_eax = regs[tEAX]; - fp->sf_edx = regs[tEDX]; - fp->sf_ecx = regs[tECX]; - } else { - fp->sf_eax = regs[sEAX]; - fp->sf_edx = regs[sEDX]; - fp->sf_ecx = regs[sECX]; - } - /* - * Build the signal context to be used by sigreturn. - */ - fp->sf_sc.sc_onstack = oonstack; - fp->sf_sc.sc_mask = mask; - if(frmtrap) { - fp->sf_sc.sc_sp = regs[tESP]; - fp->sf_sc.sc_fp = regs[tEBP]; - fp->sf_sc.sc_pc = regs[tEIP]; - fp->sf_sc.sc_ps = regs[tEFLAGS]; - regs[tESP] = (int)fp; - regs[tEIP] = (int)((struct pcb *)kstack)->pcb_sigc; - } else { - fp->sf_sc.sc_sp = regs[sESP]; - fp->sf_sc.sc_fp = regs[sEBP]; - fp->sf_sc.sc_pc = regs[sEIP]; - fp->sf_sc.sc_ps = regs[sEFLAGS]; - regs[sESP] = (int)fp; - regs[sEIP] = (int)((struct pcb *)kstack)->pcb_sigc; - } -} - -/* - * System call to cleanup state after a signal - * has been taken. Reset signal mask and - * stack state from context left by sendsig (above). - * Return to previous pc and psl as specified by - * context left by sendsig. Check carefully to - * make sure that the user has not modified the - * psl to gain improper priviledges or to cause - * a machine fault. - */ -struct sigreturn_args { - struct sigcontext *sigcntxp; -}; - -sigreturn(p, uap, retval) - struct proc *p; - struct sigreturn_args *uap; - int *retval; -{ - register struct sigcontext *scp; - register struct sigframe *fp; - register int *regs = p->p_regs; - - /* - * (XXX old comment) regs[sESP] points to the return address. - * The user scp pointer is above that. - * The return address is faked in the signal trampoline code - * for consistency. - */ - scp = uap->sigcntxp; - fp = (struct sigframe *) - ((caddr_t)scp - offsetof(struct sigframe, sf_sc)); - - if (useracc((caddr_t)fp, sizeof (*fp), 0) == 0) - return(EINVAL); - - /* restore scratch registers */ - regs[sEAX] = fp->sf_eax ; - regs[sEDX] = fp->sf_edx ; - regs[sECX] = fp->sf_ecx ; - - if (useracc((caddr_t)scp, sizeof (*scp), 0) == 0) - return(EINVAL); -#ifdef notyet - if ((scp->sc_ps & PSL_MBZ) != 0 || (scp->sc_ps & PSL_MBO) != PSL_MBO) { - return(EINVAL); - } -#endif - p->p_sigacts->ps_onstack = scp->sc_onstack & 01; - p->p_sigmask = scp->sc_mask &~ - (sigmask(SIGKILL)|sigmask(SIGCONT)|sigmask(SIGSTOP)); - regs[sEBP] = scp->sc_fp; - regs[sESP] = scp->sc_sp; - regs[sEIP] = scp->sc_pc; - regs[sEFLAGS] = scp->sc_ps; - return(EJUSTRETURN); -} - -/* - * a simple function to make the system panic (and dump a vmcore) - * in a predictable fashion - */ -void diediedie() -{ - panic("because you said to!"); -} - -int waittime = -1; -struct pcb dumppcb; - -void -boot(arghowto) - int arghowto; -{ - register long dummy; /* r12 is reserved */ - register int howto; /* r11 == how to boot */ - register int devtype; /* r10 == major of root dev */ - extern int cold; - int nomsg = 1; - - if(cold) { - printf("hit reset please"); - for(;;); - } - howto = arghowto; - if ((howto&RB_NOSYNC) == 0 && waittime < 0 && bfreelist[0].b_forw) { - register struct buf *bp; - int iter, nbusy; - - waittime = 0; - (void) splnet(); - printf("syncing disks... "); - /* - * Release inodes held by texts before update. - */ - if (panicstr == 0) - vnode_pager_umount(NULL); - sync((struct sigcontext *)0); - /* - * Unmount filesystems - */ -#if 0 - if (panicstr == 0) - vfs_unmountall(); -#endif - - for (iter = 0; iter < 20; iter++) { - nbusy = 0; - for (bp = &buf[nbuf]; --bp >= buf; ) - if ((bp->b_flags & (B_BUSY|B_INVAL)) == B_BUSY) - nbusy++; - if (nbusy == 0) - break; - if (nomsg) { - printf("updating disks before rebooting... "); - nomsg = 0; - } - printf("%d ", nbusy); - DELAY(40000 * iter); - } - if (nbusy) - printf("giving up\n"); - else - printf("done\n"); - DELAY(10000); /* wait for printf to finish */ - } - splhigh(); - devtype = major(rootdev); - if (howto&RB_HALT) { - printf("\n"); - printf("The operating system has halted.\n"); - printf("Please press any key to reboot.\n\n"); - cngetc(); - } else { - if (howto & RB_DUMP) { - savectx(&dumppcb, 0); - dumppcb.pcb_ptd = rcr3(); - dumpsys(); - /*NOTREACHED*/ - } - } -#ifdef lint - dummy = 0; dummy = dummy; - printf("howto %d, devtype %d\n", arghowto, devtype); -#endif - cpu_reset(); - for(;;) ; - /*NOTREACHED*/ -} - -unsigned dumpmag = 0x8fca0101; /* magic number for savecore */ -int dumpsize = 0; /* also for savecore */ -/* - * Doadump comes here after turning off memory management and - * getting on the dump stack, either when called above, or by - * the auto-restart code. - */ -void -dumpsys() -{ - - if (dumpdev == NODEV) - return; - if ((minor(dumpdev)&07) != 1) - return; - dumpsize = physmem; - printf("\ndumping to dev %x, offset %d\n", dumpdev, dumplo); - printf("dump "); - switch ((*bdevsw[major(dumpdev)].d_dump)(dumpdev)) { - - case ENXIO: - printf("device bad\n"); - break; - - case EFAULT: - printf("device not ready\n"); - break; - - case EINVAL: - printf("area improper\n"); - break; - - case EIO: - printf("i/o error\n"); - break; - - case EINTR: - printf("aborted from console\n"); - break; - - default: - printf("succeeded\n"); - break; - } - printf("\n\n"); - DELAY(1000); -} - -#ifdef HZ -/* - * If HZ is defined we use this code, otherwise the code in - * /sys/i386/i386/microtime.s is used. The othercode only works - * for HZ=100. - */ -microtime(tvp) - register struct timeval *tvp; -{ - int s = splhigh(); - - *tvp = time; - tvp->tv_usec += tick; - while (tvp->tv_usec > 1000000) { - tvp->tv_sec++; - tvp->tv_usec -= 1000000; - } - splx(s); -} -#endif /* HZ */ - -physstrat(bp, strat, prio) - struct buf *bp; - int (*strat)(), prio; -{ - register int s; - caddr_t baddr; - - /* - * vmapbuf clobbers b_addr so we must remember it so that it - * can be restored after vunmapbuf. This is truely rude, we - * should really be storing this in a field in the buf struct - * but none are available and I didn't want to add one at - * this time. Note that b_addr for dirty page pushes is - * restored in vunmapbuf. (ugh!) - */ - baddr = bp->b_un.b_addr; - vmapbuf(bp); - (*strat)(bp); - /* pageout daemon doesn't wait for pushed pages */ - if (bp->b_flags & B_DIRTY) - return; - s = splbio(); - while ((bp->b_flags & B_DONE) == 0) - sleep((caddr_t)bp, prio); - splx(s); - vunmapbuf(bp); - bp->b_un.b_addr = baddr; -} - -initcpu() -{ -} - -/* - * Clear registers on exec - */ -void -setregs(p, entry) - struct proc *p; - u_long entry; -{ - - p->p_regs[sEBP] = 0; /* bottom of the fp chain */ - p->p_regs[sEIP] = entry; - - p->p_addr->u_pcb.pcb_flags = 0; /* no fp at all */ - load_cr0(rcr0() | CR0_TS); /* start emulating */ -#if NNPX > 0 - npxinit(__INITIAL_NPXCW__); -#endif /* NNPX > 0 */ -} - -/* - * Initialize 386 and configure to run kernel - */ - -/* - * Initialize segments & interrupt table - */ -#define DESCRIPTOR_SIZE 8 - -#define GNULL_SEL 0 /* Null Descriptor */ -#define GCODE_SEL 1 /* Kernel Code Descriptor */ -#define GDATA_SEL 2 /* Kernel Data Descriptor */ -#define GLDT_SEL 3 /* LDT - eventually one per process */ -#define GTGATE_SEL 4 /* Process task switch gate */ -#define GPANIC_SEL 5 /* Task state to consider panic from */ -#define GPROC0_SEL 6 /* Task state process slot zero and up */ -#define NGDT GPROC0_SEL+1 - -unsigned char gdt[GPROC0_SEL+1][DESCRIPTOR_SIZE]; - -/* interrupt descriptor table */ -struct gate_descriptor idt[NIDT]; - -/* local descriptor table */ -unsigned char ldt[5][DESCRIPTOR_SIZE]; -#define LSYS5CALLS_SEL 0 /* forced by intel BCS */ -#define LSYS5SIGR_SEL 1 - -#define L43BSDCALLS_SEL 2 /* notyet */ -#define LUCODE_SEL 3 -#define LUDATA_SEL 4 -/* seperate stack, es,fs,gs sels ? */ -/* #define LPOSIXCALLS_SEL 5 /* notyet */ - -struct i386tss tss, panic_tss; - -extern struct user *proc0paddr; - -/* software prototypes -- in more palatable form */ -struct soft_segment_descriptor gdt_segs[] = { - /* Null Descriptor */ -{ 0x0, /* segment base address */ - 0x0, /* length */ - 0, /* segment type */ - 0, /* segment descriptor priority level */ - 0, /* segment descriptor present */ - 0, 0, - 0, /* default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Code Descriptor for kernel */ -{ 0x0, /* segment base address */ - 0xfffff, /* length - all address space */ - SDT_MEMERA, /* segment type */ - 0, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 1, /* default 32 vs 16 bit size */ - 1 /* limit granularity (byte/page units)*/ }, - /* Data Descriptor for kernel */ -{ 0x0, /* segment base address */ - 0xfffff, /* length - all address space */ - SDT_MEMRWA, /* segment type */ - 0, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 1, /* default 32 vs 16 bit size */ - 1 /* limit granularity (byte/page units)*/ }, - /* LDT Descriptor */ -{ (int) ldt, /* segment base address */ - sizeof(ldt)-1, /* length - all address space */ - SDT_SYSLDT, /* segment type */ - 0, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 0, /* unused - default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Null Descriptor - Placeholder */ -{ 0x0, /* segment base address */ - 0x0, /* length - all address space */ - 0, /* segment type */ - 0, /* segment descriptor priority level */ - 0, /* segment descriptor present */ - 0, 0, - 0, /* default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Panic Tss Descriptor */ -{ (int) &panic_tss, /* segment base address */ - sizeof(tss)-1, /* length - all address space */ - SDT_SYS386TSS, /* segment type */ - 0, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 0, /* unused - default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Proc 0 Tss Descriptor */ -{ (int) kstack, /* segment base address */ - sizeof(tss)-1, /* length - all address space */ - SDT_SYS386TSS, /* segment type */ - 0, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 0, /* unused - default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }}; - -struct soft_segment_descriptor ldt_segs[] = { - /* Null Descriptor - overwritten by call gate */ -{ 0x0, /* segment base address */ - 0x0, /* length - all address space */ - 0, /* segment type */ - 0, /* segment descriptor priority level */ - 0, /* segment descriptor present */ - 0, 0, - 0, /* default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Null Descriptor - overwritten by call gate */ -{ 0x0, /* segment base address */ - 0x0, /* length - all address space */ - 0, /* segment type */ - 0, /* segment descriptor priority level */ - 0, /* segment descriptor present */ - 0, 0, - 0, /* default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Null Descriptor - overwritten by call gate */ -{ 0x0, /* segment base address */ - 0x0, /* length - all address space */ - 0, /* segment type */ - 0, /* segment descriptor priority level */ - 0, /* segment descriptor present */ - 0, 0, - 0, /* default 32 vs 16 bit size */ - 0 /* limit granularity (byte/page units)*/ }, - /* Code Descriptor for user */ -{ 0x0, /* segment base address */ - 0xfffff, /* length - all address space */ - SDT_MEMERA, /* segment type */ - SEL_UPL, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 1, /* default 32 vs 16 bit size */ - 1 /* limit granularity (byte/page units)*/ }, - /* Data Descriptor for user */ -{ 0x0, /* segment base address */ - 0xfffff, /* length - all address space */ - SDT_MEMRWA, /* segment type */ - SEL_UPL, /* segment descriptor priority level */ - 1, /* segment descriptor present */ - 0, 0, - 1, /* default 32 vs 16 bit size */ - 1 /* limit granularity (byte/page units)*/ } }; - -setidt(idx, func, typ, dpl) char *func; { - struct gate_descriptor *ip = idt + idx; - - ip->gd_looffset = (int)func; - ip->gd_selector = 8; - ip->gd_stkcpy = 0; - ip->gd_xx = 0; - ip->gd_type = typ; - ip->gd_dpl = dpl; - ip->gd_p = 1; - ip->gd_hioffset = ((int)func)>>16 ; -} - -#define IDTVEC(name) __CONCAT(X, name) -extern IDTVEC(div), IDTVEC(dbg), IDTVEC(nmi), IDTVEC(bpt), IDTVEC(ofl), - IDTVEC(bnd), IDTVEC(ill), IDTVEC(dna), IDTVEC(dble), IDTVEC(fpusegm), - IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot), - IDTVEC(page), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(rsvd0), - IDTVEC(rsvd1), IDTVEC(rsvd2), IDTVEC(rsvd3), IDTVEC(rsvd4), - IDTVEC(rsvd5), IDTVEC(rsvd6), IDTVEC(rsvd7), IDTVEC(rsvd8), - IDTVEC(rsvd9), IDTVEC(rsvd10), IDTVEC(rsvd11), IDTVEC(rsvd12), - IDTVEC(rsvd13), IDTVEC(rsvd14), IDTVEC(rsvd14), IDTVEC(syscall); - -int lcr0(), lcr3(), rcr0(), rcr2(); -int _gsel_tss; - -init386(first) -{ - extern ssdtosd(), lgdt(), lidt(), lldt(), etext; - int x, *pi; - unsigned biosbasemem, biosextmem; - struct gate_descriptor *gdp; - extern int sigcode,szsigcode; - /* table descriptors - used to load tables by microp */ - unsigned short r_gdt[3], r_idt[3]; - int pagesinbase, pagesinext; - - - proc0.p_addr = proc0paddr; - - /* - * Initialize the console before we print anything out. - */ - - cninit (); - - /* - * make gdt memory segments, the code segment goes up to end of the - * page with etext in it, the data segment goes to the end of - * the address space - */ - gdt_segs[GCODE_SEL].ssd_limit = i386_btop(i386_round_page(&etext)) - 1; - gdt_segs[GDATA_SEL].ssd_limit = 0xffffffff; /* XXX constant? */ - for (x=0; x < NGDT; x++) ssdtosd(gdt_segs+x, gdt+x); - /* make ldt memory segments */ - /* - * The data segment limit must not cover the user area because we - * don't want the user area to be writable in copyout() etc. (page - * level protection is lost in kernel mode on 386's). Also, we - * don't want the user area to be writable directly (page level - * protection of the user area is not available on 486's with - * CR0_WP set, because there is no user-read/kernel-write mode). - * - * XXX - VM_MAXUSER_ADDRESS is an end address, not a max. And it - * should be spelled ...MAX_USER... - */ -#define VM_END_USER_RW_ADDRESS VM_MAXUSER_ADDRESS - /* - * The code segment limit has to cover the user area until we move - * the signal trampoline out of the user area. This is safe because - * the code segment cannot be written to directly. - */ -#define VM_END_USER_R_ADDRESS (VM_END_USER_RW_ADDRESS + UPAGES * NBPG) - ldt_segs[LUCODE_SEL].ssd_limit = i386_btop(VM_END_USER_R_ADDRESS) - 1; - ldt_segs[LUDATA_SEL].ssd_limit = i386_btop(VM_END_USER_RW_ADDRESS) - 1; - /* Note. eventually want private ldts per process */ - for (x=0; x < 5; x++) ssdtosd(ldt_segs+x, ldt+x); - - /* exceptions */ - setidt(0, &IDTVEC(div), SDT_SYS386TGT, SEL_KPL); - setidt(1, &IDTVEC(dbg), SDT_SYS386TGT, SEL_KPL); - setidt(2, &IDTVEC(nmi), SDT_SYS386TGT, SEL_KPL); - setidt(3, &IDTVEC(bpt), SDT_SYS386TGT, SEL_UPL); - setidt(4, &IDTVEC(ofl), SDT_SYS386TGT, SEL_KPL); - setidt(5, &IDTVEC(bnd), SDT_SYS386TGT, SEL_KPL); - setidt(6, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL); - setidt(7, &IDTVEC(dna), SDT_SYS386TGT, SEL_KPL); - setidt(8, &IDTVEC(dble), SDT_SYS386TGT, SEL_KPL); - setidt(9, &IDTVEC(fpusegm), SDT_SYS386TGT, SEL_KPL); - setidt(10, &IDTVEC(tss), SDT_SYS386TGT, SEL_KPL); - setidt(11, &IDTVEC(missing), SDT_SYS386TGT, SEL_KPL); - setidt(12, &IDTVEC(stk), SDT_SYS386TGT, SEL_KPL); - setidt(13, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL); - setidt(14, &IDTVEC(page), SDT_SYS386TGT, SEL_KPL); - setidt(15, &IDTVEC(rsvd), SDT_SYS386TGT, SEL_KPL); - setidt(16, &IDTVEC(fpu), SDT_SYS386TGT, SEL_KPL); - setidt(17, &IDTVEC(rsvd0), SDT_SYS386TGT, SEL_KPL); - setidt(18, &IDTVEC(rsvd1), SDT_SYS386TGT, SEL_KPL); - setidt(19, &IDTVEC(rsvd2), SDT_SYS386TGT, SEL_KPL); - setidt(20, &IDTVEC(rsvd3), SDT_SYS386TGT, SEL_KPL); - setidt(21, &IDTVEC(rsvd4), SDT_SYS386TGT, SEL_KPL); - setidt(22, &IDTVEC(rsvd5), SDT_SYS386TGT, SEL_KPL); - setidt(23, &IDTVEC(rsvd6), SDT_SYS386TGT, SEL_KPL); - setidt(24, &IDTVEC(rsvd7), SDT_SYS386TGT, SEL_KPL); - setidt(25, &IDTVEC(rsvd8), SDT_SYS386TGT, SEL_KPL); - setidt(26, &IDTVEC(rsvd9), SDT_SYS386TGT, SEL_KPL); - setidt(27, &IDTVEC(rsvd10), SDT_SYS386TGT, SEL_KPL); - setidt(28, &IDTVEC(rsvd11), SDT_SYS386TGT, SEL_KPL); - setidt(29, &IDTVEC(rsvd12), SDT_SYS386TGT, SEL_KPL); - setidt(30, &IDTVEC(rsvd13), SDT_SYS386TGT, SEL_KPL); - setidt(31, &IDTVEC(rsvd14), SDT_SYS386TGT, SEL_KPL); - -#include "isa.h" -#if NISA >0 - isa_defaultirq(); -#endif - - r_gdt[0] = (unsigned short) (sizeof(gdt) - 1); - r_gdt[1] = (unsigned short) ((int) gdt & 0xffff); - r_gdt[2] = (unsigned short) ((int) gdt >> 16); - lgdt(&r_gdt); - r_idt[0] = (unsigned short) (sizeof(idt) - 1); - r_idt[1] = (unsigned short) ((int) idt & 0xfffff); - r_idt[2] = (unsigned short) ((int) idt >> 16); - lidt(&r_idt); - lldt(GSEL(GLDT_SEL, SEL_KPL)); - -#include "ddb.h" -#if NDDB > 0 - kdb_init(); - if (boothowto & RB_KDB) - Debugger(); -#endif - - /* Use BIOS values stored in RTC CMOS RAM, since probing - * breaks certain 386 AT relics. - */ - biosbasemem = rtcin(RTC_BASELO)+ (rtcin(RTC_BASEHI)<<8); - biosextmem = rtcin(RTC_EXTLO)+ (rtcin(RTC_EXTHI)<<8); -/*printf("bios base %d ext %d ", biosbasemem, biosextmem);*/ - - /* - * 15 Aug 92 Terry Lambert The real fix for the CMOS bug - */ - if( biosbasemem != EXPECT_BASEMEM) { - printf( "Warning: Base memory %dK, assuming %dK\n", biosbasemem, EXPECT_BASEMEM); - biosbasemem = EXPECT_BASEMEM; /* assume base*/ - } - - if( biosextmem > 65536) { - printf( "Warning: Extended memory %dK(>64M), assuming 0K\n", biosextmem); - biosextmem = 0; /* assume none*/ - } - - /* - * Go into normal calculation; Note that we try to run in 640K, and - * that invalid CMOS values of non 0xffff are no longer a cause of - * ptdi problems. I have found a gutted kernel can run in 640K. - */ - pagesinbase = 640/4 - first/NBPG; - pagesinext = biosextmem/4; - /* use greater of either base or extended memory. do this - * until I reinstitue discontiguous allocation of vm_page - * array. - */ - if (pagesinbase > pagesinext) - Maxmem = 640/4; - else { - Maxmem = pagesinext + 0x100000/NBPG; - if (first < 0x100000) - first = 0x100000; /* skip hole */ - } - - /* This used to explode, since Maxmem used to be 0 for bas CMOS*/ - maxmem = Maxmem - 1; /* highest page of usable memory */ - physmem = maxmem; /* number of pages of physmem addr space */ -/*printf("using first 0x%x to 0x%x\n ", first, maxmem*NBPG);*/ - if (maxmem < 2048/4) { - printf("Too little RAM memory. Warning, running in degraded mode.\n"); -#ifdef INFORM_WAIT - /* - * People with less than 2 Meg have to hit return; this way - * we see the messages and can tell them why they blow up later. - * If they get working well enough to recompile, they can unset - * the flag; otherwise, it's a toy and they have to lump it. - */ - cngetc(); -#endif /* !INFORM_WAIT*/ - } - - /* call pmap initialization to make new kernel address space */ -#ifndef MACHINCE_NONCONTIG - pmap_bootstrap (first, 0); -#else - pmap_bootstrap ((vm_offset_t)atdevbase + IOM_SIZE); - -#endif /* MACHINE_NONCONTIG */ - /* now running on new page tables, configured,and u/iom is accessible */ - - /* make a initial tss so microp can get interrupt stack on syscall! */ - proc0.p_addr->u_pcb.pcb_tss.tss_esp0 = (int) kstack + UPAGES*NBPG; - proc0.p_addr->u_pcb.pcb_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL) ; - _gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); - - ((struct i386tss *)gdt_segs[GPROC0_SEL].ssd_base)->tss_ioopt = - (sizeof(tss))<<16; - - ltr(_gsel_tss); - - /* make a call gate to reenter kernel with */ - gdp = (struct gate_descriptor *) &ldt[LSYS5CALLS_SEL][0]; - - x = (int) &IDTVEC(syscall); - gdp->gd_looffset = x++; - gdp->gd_selector = GSEL(GCODE_SEL,SEL_KPL); - gdp->gd_stkcpy = 0; - gdp->gd_type = SDT_SYS386CGT; - gdp->gd_dpl = SEL_UPL; - gdp->gd_p = 1; - gdp->gd_hioffset = ((int) &IDTVEC(syscall)) >>16; - - /* transfer to user mode */ - - _ucodesel = LSEL(LUCODE_SEL, SEL_UPL); - _udatasel = LSEL(LUDATA_SEL, SEL_UPL); - - /* setup proc 0's pcb */ - bcopy(&sigcode, proc0.p_addr->u_pcb.pcb_sigc, szsigcode); - proc0.p_addr->u_pcb.pcb_flags = 0; - proc0.p_addr->u_pcb.pcb_ptd = IdlePTD; -} - -extern struct pte *CMAP1, *CMAP2; -extern caddr_t CADDR1, CADDR2; -/* - * zero out physical memory - * specified in relocation units (NBPG bytes) - */ -clearseg(n) { - - *(int *)CMAP2 = PG_V | PG_KW | ctob(n); - load_cr3(rcr3()); - bzero(CADDR2,NBPG); -#ifndef MACHINE_NONCONTIG - *(int *) CADDR2 = 0; -#endif /* MACHINE_NONCONTIG */ -} - -/* - * copy a page of physical memory - * specified in relocation units (NBPG bytes) - */ -void -copyseg(frm, n) { - - *(int *)CMAP2 = PG_V | PG_KW | ctob(n); - load_cr3(rcr3()); - bcopy((void *)frm, (void *)CADDR2, NBPG); -} - -/* - * copy a page of physical memory - * specified in relocation units (NBPG bytes) - */ -void -physcopyseg(frm, to) { - - *(int *)CMAP1 = PG_V | PG_KW | ctob(frm); - *(int *)CMAP2 = PG_V | PG_KW | ctob(to); - load_cr3(rcr3()); - bcopy(CADDR1, CADDR2, NBPG); -} - -/*aston() { - schednetisr(NETISR_AST); -}*/ - -void -setsoftclock() { - schednetisr(NETISR_SCLK); -} - -/* - * insert an element into a queue - */ -#undef insque -_insque(element, head) - register struct prochd *element, *head; -{ - element->ph_link = head->ph_link; - head->ph_link = (struct proc *)element; - element->ph_rlink = (struct proc *)head; - ((struct prochd *)(element->ph_link))->ph_rlink=(struct proc *)element; -} - -/* - * remove an element from a queue - */ -#undef remque -_remque(element) - register struct prochd *element; -{ - ((struct prochd *)(element->ph_link))->ph_rlink = element->ph_rlink; - ((struct prochd *)(element->ph_rlink))->ph_link = element->ph_link; - element->ph_rlink = (struct proc *)0; -} - -#ifdef SLOW_OLD_COPYSTRS -vmunaccess() {} - -#if 0 /* assembler versions now in locore.s */ -/* - * Below written in C to allow access to debugging code - */ -copyinstr(fromaddr, toaddr, maxlength, lencopied) u_int *lencopied, maxlength; - void *toaddr, *fromaddr; { - int c,tally; - - tally = 0; - while (maxlength--) { - c = fubyte(fromaddr++); - if (c == -1) { - if(lencopied) *lencopied = tally; - return(EFAULT); - } - tally++; - *(char *)toaddr++ = (char) c; - if (c == 0){ - if(lencopied) *lencopied = (u_int)tally; - return(0); - } - } - if(lencopied) *lencopied = (u_int)tally; - return(ENAMETOOLONG); -} - -copyoutstr(fromaddr, toaddr, maxlength, lencopied) u_int *lencopied, maxlength; - void *fromaddr, *toaddr; { - int c; - int tally; - - tally = 0; - while (maxlength--) { - c = subyte(toaddr++, *(char *)fromaddr); - if (c == -1) return(EFAULT); - tally++; - if (*(char *)fromaddr++ == 0){ - if(lencopied) *lencopied = tally; - return(0); - } - } - if(lencopied) *lencopied = tally; - return(ENAMETOOLONG); -} - -#endif /* SLOW_OLD_COPYSTRS */ - -copystr(fromaddr, toaddr, maxlength, lencopied) u_int *lencopied, maxlength; - void *fromaddr, *toaddr; { - u_int tally; - - tally = 0; - while (maxlength--) { - *(u_char *)toaddr = *(u_char *)fromaddr++; - tally++; - if (*(u_char *)toaddr++ == 0) { - if(lencopied) *lencopied = tally; - return(0); - } - } - if(lencopied) *lencopied = tally; - return(ENAMETOOLONG); -} -#endif diff --git a/sys/i386/i386/math_emu.h b/sys/i386/i386/math_emu.h deleted file mode 100644 index 453a903..0000000 --- a/sys/i386/i386/math_emu.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * linux/include/linux/math_emu.h - * - * (C) 1991 Linus Torvalds - * - * $Id$ - */ -#ifndef _LINUX_MATH_EMU_H -#define _LINUX_MATH_EMU_H - -/*#define math_abort(x,y) \ -(((volatile void (*)(struct info *,unsigned int)) __math_abort)((x),(y)))*/ - -/* - * Gcc forces this stupid alignment problem: I want to use only two longs - * for the temporary real 64-bit mantissa, but then gcc aligns out the - * structure to 12 bytes which breaks things in math_emulate.c. Shit. I - * want some kind of "no-alignt" pragma or something. - */ - -typedef struct { - long a,b; - short exponent; -} temp_real; - -typedef struct { - short m0,m1,m2,m3; - short exponent; -} temp_real_unaligned; - -#define real_to_real(a,b) \ -((*(long long *) (b) = *(long long *) (a)),((b)->exponent = (a)->exponent)) - -typedef struct { - long a,b; -} long_real; - -typedef long short_real; - -typedef struct { - long a,b; - short sign; -} temp_int; - -struct swd { - int ie:1; - int de:1; - int ze:1; - int oe:1; - int ue:1; - int pe:1; - int sf:1; - int ir:1; - int c0:1; - int c1:1; - int c2:1; - int top:3; - int c3:1; - int b:1; -}; -struct i387_struct { - long cwd; - long swd; - long twd; - long fip; - long fcs; - long foo; - long fos; - long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ -}; - -#define I387 (*(struct i387_struct *)&(((struct pcb *)curproc->p_addr)->pcb_savefpu)) -#define SWD (*(struct swd *) &I387.swd) -#define ROUNDING ((I387.cwd >> 10) & 3) -#define PRECISION ((I387.cwd >> 8) & 3) - -#define BITS24 0 -#define BITS53 2 -#define BITS64 3 - -#define ROUND_NEAREST 0 -#define ROUND_DOWN 1 -#define ROUND_UP 2 -#define ROUND_0 3 - -#define CONSTZ (temp_real_unaligned) {0x0000,0x0000,0x0000,0x0000,0x0000} -#define CONST1 (temp_real_unaligned) {0x0000,0x0000,0x0000,0x8000,0x3FFF} -#define CONSTPI (temp_real_unaligned) {0xC235,0x2168,0xDAA2,0xC90F,0x4000} -#define CONSTLN2 (temp_real_unaligned) {0x79AC,0xD1CF,0x17F7,0xB172,0x3FFE} -#define CONSTLG2 (temp_real_unaligned) {0xF799,0xFBCF,0x9A84,0x9A20,0x3FFD} -#define CONSTL2E (temp_real_unaligned) {0xF0BC,0x5C17,0x3B29,0xB8AA,0x3FFF} -#define CONSTL2T (temp_real_unaligned) {0x8AFE,0xCD1B,0x784B,0xD49A,0x4000} - -#define set_IE() (I387.swd |= 1) -#define set_DE() (I387.swd |= 2) -#define set_ZE() (I387.swd |= 4) -#define set_OE() (I387.swd |= 8) -#define set_UE() (I387.swd |= 16) -#define set_PE() (I387.swd |= 32) - -#define set_C0() (I387.swd |= 0x0100) -#define set_C1() (I387.swd |= 0x0200) -#define set_C2() (I387.swd |= 0x0400) -#define set_C3() (I387.swd |= 0x4000) - -/* ea.c */ - -char * ea(struct trapframe *, unsigned short); - -/* convert.c */ - -void frndint(const temp_real * __a, temp_real * __b); -void Fscale(const temp_real *, const temp_real *, temp_real *); -void short_to_temp(const short_real * __a, temp_real * __b); -void long_to_temp(const long_real * __a, temp_real * __b); -void temp_to_short(const temp_real * __a, short_real * __b); -void temp_to_long(const temp_real * __a, long_real * __b); -void real_to_int(const temp_real * __a, temp_int * __b); -void int_to_real(const temp_int * __a, temp_real * __b); - -/* get_put.c */ - -void get_short_real(temp_real *, struct trapframe *, unsigned short); -void get_long_real(temp_real *, struct trapframe *, unsigned short); -void get_temp_real(temp_real *, struct trapframe *, unsigned short); -void get_short_int(temp_real *, struct trapframe *, unsigned short); -void get_long_int(temp_real *, struct trapframe *, unsigned short); -void get_longlong_int(temp_real *, struct trapframe *, unsigned short); -void get_BCD(temp_real *, struct trapframe *, unsigned short); -void put_short_real(const temp_real *, struct trapframe *, unsigned short); -void put_long_real(const temp_real *, struct trapframe *, unsigned short); -void put_temp_real(const temp_real *, struct trapframe *, unsigned short); -void put_short_int(const temp_real *, struct trapframe *, unsigned short); -void put_long_int(const temp_real *, struct trapframe *, unsigned short); -void put_longlong_int(const temp_real *, struct trapframe *, unsigned short); -void put_BCD(const temp_real *, struct trapframe *, unsigned short); - -/* add.c */ - -void fadd(const temp_real *, const temp_real *, temp_real *); - -/* mul.c */ - -void fmul(const temp_real *, const temp_real *, temp_real *); - -/* div.c */ - -void fdiv(const temp_real *, const temp_real *, temp_real *); - -/* compare.c */ - -void fcom(const temp_real *, const temp_real *); -void fucom(const temp_real *, const temp_real *); -void ftst(const temp_real *); - -#endif diff --git a/sys/i386/i386/math_emulate.c b/sys/i386/i386/math_emulate.c deleted file mode 100644 index f7fa88e..0000000 --- a/sys/i386/i386/math_emulate.c +++ /dev/null @@ -1,1475 +0,0 @@ -/* - * linux/kernel/math/math_emulate.c - * - * (C) 1991 Linus Torvalds - * - * [expediant "port" of linux 8087 emulator to 386BSD, with apologies -wfj] - * - * from: 386BSD 0.1 - * $Id$ - */ - -/* - * Limited emulation 27.12.91 - mostly loads/stores, which gcc wants - * even for soft-float, unless you use bruce evans' patches. The patches - * are great, but they have to be re-applied for every version, and the - * library is different for soft-float and 80387. So emulation is more - * practical, even though it's slower. - * - * 28.12.91 - loads/stores work, even BCD. I'll have to start thinking - * about add/sub/mul/div. Urgel. I should find some good source, but I'll - * just fake up something. - * - * 30.12.91 - add/sub/mul/div/com seem to work mostly. I should really - * test every possible combination. - */ - -/* - * This file is full of ugly macros etc: one problem was that gcc simply - * didn't want to make the structures as they should be: it has to try to - * align them. Sickening code, but at least I've hidden the ugly things - * in this one file: the other files don't need to know about these things. - * - * The other files also don't care about ST(x) etc - they just get addresses - * to 80-bit temporary reals, and do with them as they please. I wanted to - * hide most of the 387-specific things here. - * - */ - -#include "machine/cpu.h" -#include "machine/psl.h" -#include "machine/reg.h" - -#include "param.h" -#include "systm.h" -#include "proc.h" -#include "user.h" -#include "acct.h" -#include "kernel.h" -#include "signal.h" - -#define __ALIGNED_TEMP_REAL 1 -#include "i386/i386/math_emu.h" - -#define bswapw(x) __asm__("xchgb %%al,%%ah":"=a" (x):"0" ((short)x)) -#define ST(x) (*__st((x))) -#define PST(x) ((const temp_real *) __st((x))) -#define math_abort(tfp, signo) tfp->tf_eip = oldeip; return (signo); - -/* - * We don't want these inlined - it gets too messy in the machine-code. - */ -static void fpop(void); -static void fpush(void); -static void fxchg(temp_real_unaligned * a, temp_real_unaligned * b); -static temp_real_unaligned * __st(int i); - -unsigned char get_fs_byte(char *adr) { return(fubyte(adr)); } -unsigned short get_fs_word(unsigned short *adr) { return(fuword(adr)); } -unsigned long get_fs_long(unsigned long *adr) { return(fuword(adr)); } -put_fs_byte(unsigned char val, char *adr) { (void)subyte(adr,val); } -put_fs_word(unsigned short val, short *adr) { (void)susword(adr,val); } -put_fs_long(unsigned long val, unsigned long *adr) { (void)suword(adr,val); } - -math_emulate(struct trapframe * info) -{ - unsigned short code; - temp_real tmp; - char * address; - u_long oldeip; - - /* ever used fp? */ - if ((((struct pcb *)curproc->p_addr)->pcb_flags & FP_SOFTFP) == 0) { - ((struct pcb *)curproc->p_addr)->pcb_flags |= FP_SOFTFP; - I387.cwd = 0x037f; - I387.swd = 0x0000; - I387.twd = 0x0000; - } - - if (I387.cwd & I387.swd & 0x3f) - I387.swd |= 0x8000; - else - I387.swd &= 0x7fff; - oldeip = info->tf_eip; -/* 0x001f means user code space */ - if ((u_short)info->tf_cs != 0x001F) { - printf("math_emulate: %04x:%08x\n\r", (u_short)info->tf_cs, - oldeip); - panic("?Math emulation needed in kernel?"); - } - code = get_fs_word((unsigned short *) oldeip); - bswapw(code); - code &= 0x7ff; - I387.fip = oldeip; - *(unsigned short *) &I387.fcs = (u_short) info->tf_cs; - *(1+(unsigned short *) &I387.fcs) = code; - info->tf_eip += 2; - switch (code) { - case 0x1d0: /* fnop */ - return(0); - case 0x1d1: case 0x1d2: case 0x1d3: - case 0x1d4: case 0x1d5: case 0x1d6: case 0x1d7: - math_abort(info,SIGILL); - case 0x1e0: - ST(0).exponent ^= 0x8000; - return(0); - case 0x1e1: - ST(0).exponent &= 0x7fff; - return(0); - case 0x1e2: case 0x1e3: - math_abort(info,SIGILL); - case 0x1e4: - ftst(PST(0)); - return(0); - case 0x1e5: - printf("fxam not implemented\n\r"); - math_abort(info,SIGILL); - case 0x1e6: case 0x1e7: - math_abort(info,SIGILL); - case 0x1e8: - fpush(); - ST(0) = CONST1; - return(0); - case 0x1e9: - fpush(); - ST(0) = CONSTL2T; - return(0); - case 0x1ea: - fpush(); - ST(0) = CONSTL2E; - return(0); - case 0x1eb: - fpush(); - ST(0) = CONSTPI; - return(0); - case 0x1ec: - fpush(); - ST(0) = CONSTLG2; - return(0); - case 0x1ed: - fpush(); - ST(0) = CONSTLN2; - return(0); - case 0x1ee: - fpush(); - ST(0) = CONSTZ; - return(0); - case 0x1ef: - math_abort(info,SIGILL); - case 0x1f0: case 0x1f1: case 0x1f2: case 0x1f3: - case 0x1f4: case 0x1f5: case 0x1f6: case 0x1f7: - case 0x1f8: case 0x1f9: case 0x1fa: case 0x1fb: - case 0x1fe: case 0x1ff: - uprintf( - "math_emulate: instruction %04x not implemented\n", - code + 0xd800); - math_abort(info,SIGILL); - case 0x1fd: - /* incomplete and totally inadequate -wfj */ - Fscale(PST(0), PST(1), &tmp); - real_to_real(&tmp,&ST(0)); - return(0); /* 19 Sep 92*/ - case 0x1fc: - frndint(PST(0),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 0x2e9: - fucom(PST(1),PST(0)); - fpop(); fpop(); - return(0); - case 0x3d0: case 0x3d1: - return(0); - case 0x3e2: - I387.swd &= 0x7f00; - return(0); - case 0x3e3: - I387.cwd = 0x037f; - I387.swd = 0x0000; - I387.twd = 0x0000; - return(0); - case 0x3e4: - return(0); - case 0x6d9: - fcom(PST(1),PST(0)); - fpop(); fpop(); - return(0); - case 0x7e0: - *(short *) &info->tf_eax = I387.swd; - return(0); - } - switch (code >> 3) { - case 0x18: - fadd(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 0x19: - fmul(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 0x1a: - fcom(PST(code & 7),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 0x1b: - fcom(PST(code & 7),&tmp); - real_to_real(&tmp,&ST(0)); - fpop(); - return(0); - case 0x1c: - real_to_real(&ST(code & 7),&tmp); - tmp.exponent ^= 0x8000; - fadd(PST(0),&tmp,&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 0x1d: - ST(0).exponent ^= 0x8000; - fadd(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 0x1e: - fdiv(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 0x1f: - fdiv(PST(code & 7),PST(0),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 0x38: - fpush(); - ST(0) = ST((code & 7)+1); - return(0); - case 0x39: - fxchg(&ST(0),&ST(code & 7)); - return(0); - case 0x3b: - ST(code & 7) = ST(0); - fpop(); - return(0); - case 0x98: - fadd(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(code & 7)); - return(0); - case 0x99: - fmul(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(code & 7)); - return(0); - case 0x9a: - fcom(PST(code & 7),PST(0)); - return(0); - case 0x9b: - fcom(PST(code & 7),PST(0)); - fpop(); - return(0); - case 0x9c: - ST(code & 7).exponent ^= 0x8000; - fadd(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(code & 7)); - return(0); - case 0x9d: - real_to_real(&ST(0),&tmp); - tmp.exponent ^= 0x8000; - fadd(PST(code & 7),&tmp,&tmp); - real_to_real(&tmp,&ST(code & 7)); - return(0); - case 0x9e: - fdiv(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(code & 7)); - return(0); - case 0x9f: - fdiv(PST(code & 7),PST(0),&tmp); - real_to_real(&tmp,&ST(code & 7)); - return(0); - case 0xb8: - printf("ffree not implemented\n\r"); - math_abort(info,SIGILL); - case 0xb9: - fxchg(&ST(0),&ST(code & 7)); - return(0); - case 0xba: - ST(code & 7) = ST(0); - return(0); - case 0xbb: - ST(code & 7) = ST(0); - fpop(); - return(0); - case 0xbc: - fucom(PST(code & 7),PST(0)); - return(0); - case 0xbd: - fucom(PST(code & 7),PST(0)); - fpop(); - return(0); - case 0xd8: - fadd(PST(code & 7),PST(0),&tmp); - real_to_real(&tmp,&ST(code & 7)); - fpop(); - return(0); - case 0xd9: - fmul(PST(code & 7),PST(0),&tmp); - real_to_real(&tmp,&ST(code & 7)); - fpop(); - return(0); - case 0xda: - fcom(PST(code & 7),PST(0)); - fpop(); - return(0); - case 0xdc: - ST(code & 7).exponent ^= 0x8000; - fadd(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(code & 7)); - fpop(); - return(0); - case 0xdd: - real_to_real(&ST(0),&tmp); - tmp.exponent ^= 0x8000; - fadd(PST(code & 7),&tmp,&tmp); - real_to_real(&tmp,&ST(code & 7)); - fpop(); - return(0); - case 0xde: - fdiv(PST(0),PST(code & 7),&tmp); - real_to_real(&tmp,&ST(code & 7)); - fpop(); - return(0); - case 0xdf: - fdiv(PST(code & 7),PST(0),&tmp); - real_to_real(&tmp,&ST(code & 7)); - fpop(); - return(0); - case 0xf8: - printf("ffree not implemented\n\r"); - math_abort(info,SIGILL); - fpop(); - return(0); - case 0xf9: - fxchg(&ST(0),&ST(code & 7)); - return(0); - case 0xfa: - case 0xfb: - ST(code & 7) = ST(0); - fpop(); - return(0); - } - switch ((code>>3) & 0xe7) { - case 0x22: - put_short_real(PST(0),info,code); - return(0); - case 0x23: - put_short_real(PST(0),info,code); - fpop(); - return(0); - case 0x24: - address = ea(info,code); - for (code = 0 ; code < 7 ; code++) { - ((long *) & I387)[code] = - get_fs_long((unsigned long *) address); - address += 4; - } - return(0); - case 0x25: - address = ea(info,code); - *(unsigned short *) &I387.cwd = - get_fs_word((unsigned short *) address); - return(0); - case 0x26: - address = ea(info,code); - /*verify_area(address,28);*/ - for (code = 0 ; code < 7 ; code++) { - put_fs_long( ((long *) & I387)[code], - (unsigned long *) address); - address += 4; - } - return(0); - case 0x27: - address = ea(info,code); - /*verify_area(address,2);*/ - put_fs_word(I387.cwd,(short *) address); - return(0); - case 0x62: - put_long_int(PST(0),info,code); - return(0); - case 0x63: - put_long_int(PST(0),info,code); - fpop(); - return(0); - case 0x65: - fpush(); - get_temp_real(&tmp,info,code); - real_to_real(&tmp,&ST(0)); - return(0); - case 0x67: - put_temp_real(PST(0),info,code); - fpop(); - return(0); - case 0xa2: - put_long_real(PST(0),info,code); - return(0); - case 0xa3: - put_long_real(PST(0),info,code); - fpop(); - return(0); - case 0xa4: - address = ea(info,code); - for (code = 0 ; code < 27 ; code++) { - ((long *) & I387)[code] = - get_fs_long((unsigned long *) address); - address += 4; - } - return(0); - case 0xa6: - address = ea(info,code); - /*verify_area(address,108);*/ - for (code = 0 ; code < 27 ; code++) { - put_fs_long( ((long *) & I387)[code], - (unsigned long *) address); - address += 4; - } - I387.cwd = 0x037f; - I387.swd = 0x0000; - I387.twd = 0x0000; - return(0); - case 0xa7: - address = ea(info,code); - /*verify_area(address,2);*/ - put_fs_word(I387.swd,(short *) address); - return(0); - case 0xe2: - put_short_int(PST(0),info,code); - return(0); - case 0xe3: - put_short_int(PST(0),info,code); - fpop(); - return(0); - case 0xe4: - fpush(); - get_BCD(&tmp,info,code); - real_to_real(&tmp,&ST(0)); - return(0); - case 0xe5: - fpush(); - get_longlong_int(&tmp,info,code); - real_to_real(&tmp,&ST(0)); - return(0); - case 0xe6: - put_BCD(PST(0),info,code); - fpop(); - return(0); - case 0xe7: - put_longlong_int(PST(0),info,code); - fpop(); - return(0); - } - switch (code >> 9) { - case 0: - get_short_real(&tmp,info,code); - break; - case 1: - get_long_int(&tmp,info,code); - break; - case 2: - get_long_real(&tmp,info,code); - break; - case 4: - get_short_int(&tmp,info,code); - } - switch ((code>>3) & 0x27) { - case 0: - fadd(&tmp,PST(0),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 1: - fmul(&tmp,PST(0),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 2: - fcom(&tmp,PST(0)); - return(0); - case 3: - fcom(&tmp,PST(0)); - fpop(); - return(0); - case 4: - tmp.exponent ^= 0x8000; - fadd(&tmp,PST(0),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 5: - ST(0).exponent ^= 0x8000; - fadd(&tmp,PST(0),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 6: - fdiv(PST(0),&tmp,&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - case 7: - fdiv(&tmp,PST(0),&tmp); - real_to_real(&tmp,&ST(0)); - return(0); - } - if ((code & 0x138) == 0x100) { - fpush(); - real_to_real(&tmp,&ST(0)); - return(0); - } - printf("Unknown math-insns: %04x:%08x %04x\n\r",(u_short)info->tf_cs, - info->tf_eip,code); - math_abort(info,SIGFPE); -} - -static void fpop(void) -{ - unsigned long tmp; - - tmp = I387.swd & 0xffffc7ff; - I387.swd += 0x00000800; - I387.swd &= 0x00003800; - I387.swd |= tmp; -} - -static void fpush(void) -{ - unsigned long tmp; - - tmp = I387.swd & 0xffffc7ff; - I387.swd += 0x00003800; - I387.swd &= 0x00003800; - I387.swd |= tmp; -} - -static void fxchg(temp_real_unaligned * a, temp_real_unaligned * b) -{ - temp_real_unaligned c; - - c = *a; - *a = *b; - *b = c; -} - -static temp_real_unaligned * __st(int i) -{ - i += I387.swd >> 11; - i &= 7; - return (temp_real_unaligned *) (i*10 + (char *)(I387.st_space)); -} - -/* - * linux/kernel/math/ea.c - * - * (C) 1991 Linus Torvalds - */ - -/* - * Calculate the effective address. - */ - - -static int __regoffset[] = { - tEAX, tECX, tEDX, tEBX, tESP, tEBP, tESI, tEDI -}; - -#define REG(x) (curproc->p_regs[__regoffset[(x)]]) - -static char * sib(struct trapframe * info, int mod) -{ - unsigned char ss,index,base; - long offset = 0; - - base = get_fs_byte((char *) info->tf_eip); - info->tf_eip++; - ss = base >> 6; - index = (base >> 3) & 7; - base &= 7; - if (index == 4) - offset = 0; - else - offset = REG(index); - offset <<= ss; - if (mod || base != 5) - offset += REG(base); - if (mod == 1) { - offset += (signed char) get_fs_byte((char *) info->tf_eip); - info->tf_eip++; - } else if (mod == 2 || base == 5) { - offset += (signed) get_fs_long((unsigned long *) info->tf_eip); - info->tf_eip += 4; - } - I387.foo = offset; - I387.fos = 0x17; - return (char *) offset; -} - -char * ea(struct trapframe * info, unsigned short code) -{ - unsigned char mod,rm; - long * tmp; - int offset = 0; - - mod = (code >> 6) & 3; - rm = code & 7; - if (rm == 4 && mod != 3) - return sib(info,mod); - if (rm == 5 && !mod) { - offset = get_fs_long((unsigned long *) info->tf_eip); - info->tf_eip += 4; - I387.foo = offset; - I387.fos = 0x17; - return (char *) offset; - } - tmp = (long *) ®(rm); - switch (mod) { - case 0: offset = 0; break; - case 1: - offset = (signed char) get_fs_byte((char *) info->tf_eip); - info->tf_eip++; - break; - case 2: - offset = (signed) get_fs_long((unsigned long *) info->tf_eip); - info->tf_eip += 4; - break; -#ifdef notyet - case 3: - math_abort(info,1<<(SIGILL-1)); -#endif - } - I387.foo = offset; - I387.fos = 0x17; - return offset + (char *) *tmp; -} -/* - * linux/kernel/math/get_put.c - * - * (C) 1991 Linus Torvalds - */ - -/* - * This file handles all accesses to user memory: getting and putting - * ints/reals/BCD etc. This is the only part that concerns itself with - * other than temporary real format. All other cals are strictly temp_real. - */ - -void get_short_real(temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - short_real sr; - - addr = ea(info,code); - sr = get_fs_long((unsigned long *) addr); - short_to_temp(&sr,tmp); -} - -void get_long_real(temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - long_real lr; - - addr = ea(info,code); - lr.a = get_fs_long((unsigned long *) addr); - lr.b = get_fs_long(1 + (unsigned long *) addr); - long_to_temp(&lr,tmp); -} - -void get_temp_real(temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - - addr = ea(info,code); - tmp->a = get_fs_long((unsigned long *) addr); - tmp->b = get_fs_long(1 + (unsigned long *) addr); - tmp->exponent = get_fs_word(4 + (unsigned short *) addr); -} - -void get_short_int(temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - temp_int ti; - - addr = ea(info,code); - ti.a = (signed short) get_fs_word((unsigned short *) addr); - ti.b = 0; - if (ti.sign = (ti.a < 0)) - ti.a = - ti.a; - int_to_real(&ti,tmp); -} - -void get_long_int(temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - temp_int ti; - - addr = ea(info,code); - ti.a = get_fs_long((unsigned long *) addr); - ti.b = 0; - if (ti.sign = (ti.a < 0)) - ti.a = - ti.a; - int_to_real(&ti,tmp); -} - -void get_longlong_int(temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - temp_int ti; - - addr = ea(info,code); - ti.a = get_fs_long((unsigned long *) addr); - ti.b = get_fs_long(1 + (unsigned long *) addr); - if (ti.sign = (ti.b < 0)) - __asm__("notl %0 ; notl %1\n\t" - "addl $1,%0 ; adcl $0,%1" - :"=r" (ti.a),"=r" (ti.b) - :"0" (ti.a),"1" (ti.b)); - int_to_real(&ti,tmp); -} - -#define MUL10(low,high) \ -__asm__("addl %0,%0 ; adcl %1,%1\n\t" \ -"movl %0,%%ecx ; movl %1,%%ebx\n\t" \ -"addl %0,%0 ; adcl %1,%1\n\t" \ -"addl %0,%0 ; adcl %1,%1\n\t" \ -"addl %%ecx,%0 ; adcl %%ebx,%1" \ -:"=a" (low),"=d" (high) \ -:"0" (low),"1" (high):"cx","bx") - -#define ADD64(val,low,high) \ -__asm__("addl %4,%0 ; adcl $0,%1":"=r" (low),"=r" (high) \ -:"0" (low),"1" (high),"r" ((unsigned long) (val))) - -void get_BCD(temp_real * tmp, struct trapframe * info, unsigned short code) -{ - int k; - char * addr; - temp_int i; - unsigned char c; - - addr = ea(info,code); - addr += 9; - i.sign = 0x80 & get_fs_byte(addr--); - i.a = i.b = 0; - for (k = 0; k < 9; k++) { - c = get_fs_byte(addr--); - MUL10(i.a, i.b); - ADD64((c>>4), i.a, i.b); - MUL10(i.a, i.b); - ADD64((c&0xf), i.a, i.b); - } - int_to_real(&i,tmp); -} - -void put_short_real(const temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - short_real sr; - - addr = ea(info,code); - /*verify_area(addr,4);*/ - temp_to_short(tmp,&sr); - put_fs_long(sr,(unsigned long *) addr); -} - -void put_long_real(const temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - long_real lr; - - addr = ea(info,code); - /*verify_area(addr,8);*/ - temp_to_long(tmp,&lr); - put_fs_long(lr.a, (unsigned long *) addr); - put_fs_long(lr.b, 1 + (unsigned long *) addr); -} - -void put_temp_real(const temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - - addr = ea(info,code); - /*verify_area(addr,10);*/ - put_fs_long(tmp->a, (unsigned long *) addr); - put_fs_long(tmp->b, 1 + (unsigned long *) addr); - put_fs_word(tmp->exponent, 4 + (short *) addr); -} - -void put_short_int(const temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - temp_int ti; - - addr = ea(info,code); - real_to_int(tmp,&ti); - /*verify_area(addr,2);*/ - if (ti.sign) - ti.a = -ti.a; - put_fs_word(ti.a,(short *) addr); -} - -void put_long_int(const temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - temp_int ti; - - addr = ea(info,code); - real_to_int(tmp,&ti); - /*verify_area(addr,4);*/ - if (ti.sign) - ti.a = -ti.a; - put_fs_long(ti.a,(unsigned long *) addr); -} - -void put_longlong_int(const temp_real * tmp, - struct trapframe * info, unsigned short code) -{ - char * addr; - temp_int ti; - - addr = ea(info,code); - real_to_int(tmp,&ti); - /*verify_area(addr,8);*/ - if (ti.sign) - __asm__("notl %0 ; notl %1\n\t" - "addl $1,%0 ; adcl $0,%1" - :"=r" (ti.a),"=r" (ti.b) - :"0" (ti.a),"1" (ti.b)); - put_fs_long(ti.a,(unsigned long *) addr); - put_fs_long(ti.b,1 + (unsigned long *) addr); -} - -#define DIV10(low,high,rem) \ -__asm__("divl %6 ; xchgl %1,%2 ; divl %6" \ - :"=d" (rem),"=a" (low),"=r" (high) \ - :"0" (0),"1" (high),"2" (low),"c" (10)) - -void put_BCD(const temp_real * tmp,struct trapframe * info, unsigned short code) -{ - int k,rem; - char * addr; - temp_int i; - unsigned char c; - - addr = ea(info,code); - /*verify_area(addr,10);*/ - real_to_int(tmp,&i); - if (i.sign) - put_fs_byte(0x80, addr+9); - else - put_fs_byte(0, addr+9); - for (k = 0; k < 9; k++) { - DIV10(i.a,i.b,rem); - c = rem; - DIV10(i.a,i.b,rem); - c += rem<<4; - put_fs_byte(c,addr++); - } -} - -/* - * linux/kernel/math/mul.c - * - * (C) 1991 Linus Torvalds - */ - -/* - * temporary real multiplication routine. - */ - - -static void shift(int * c) -{ - __asm__("movl (%0),%%eax ; addl %%eax,(%0)\n\t" - "movl 4(%0),%%eax ; adcl %%eax,4(%0)\n\t" - "movl 8(%0),%%eax ; adcl %%eax,8(%0)\n\t" - "movl 12(%0),%%eax ; adcl %%eax,12(%0)" - ::"r" ((long) c):"ax"); -} - -static void mul64(const temp_real * a, const temp_real * b, int * c) -{ - __asm__("movl (%0),%%eax\n\t" - "mull (%1)\n\t" - "movl %%eax,(%2)\n\t" - "movl %%edx,4(%2)\n\t" - "movl 4(%0),%%eax\n\t" - "mull 4(%1)\n\t" - "movl %%eax,8(%2)\n\t" - "movl %%edx,12(%2)\n\t" - "movl (%0),%%eax\n\t" - "mull 4(%1)\n\t" - "addl %%eax,4(%2)\n\t" - "adcl %%edx,8(%2)\n\t" - "adcl $0,12(%2)\n\t" - "movl 4(%0),%%eax\n\t" - "mull (%1)\n\t" - "addl %%eax,4(%2)\n\t" - "adcl %%edx,8(%2)\n\t" - "adcl $0,12(%2)" - ::"S" ((long) a),"c" ((long) b),"D" ((long) c) - :"ax","dx"); -} - -void fmul(const temp_real * src1, const temp_real * src2, temp_real * result) -{ - int i,sign; - int tmp[4] = {0,0,0,0}; - - sign = (src1->exponent ^ src2->exponent) & 0x8000; - i = (src1->exponent & 0x7fff) + (src2->exponent & 0x7fff) - 16383 + 1; - if (i<0) { - result->exponent = sign; - result->a = result->b = 0; - return; - } - if (i>0x7fff) { - set_OE(); - return; - } - mul64(src1,src2,tmp); - if (tmp[0] || tmp[1] || tmp[2] || tmp[3]) - while (i && tmp[3] >= 0) { - i--; - shift(tmp); - } - else - i = 0; - result->exponent = i | sign; - result->a = tmp[2]; - result->b = tmp[3]; -} - -/* - * linux/kernel/math/div.c - * - * (C) 1991 Linus Torvalds - */ - -/* - * temporary real division routine. - */ - -static void shift_left(int * c) -{ - __asm__ __volatile__("movl (%0),%%eax ; addl %%eax,(%0)\n\t" - "movl 4(%0),%%eax ; adcl %%eax,4(%0)\n\t" - "movl 8(%0),%%eax ; adcl %%eax,8(%0)\n\t" - "movl 12(%0),%%eax ; adcl %%eax,12(%0)" - ::"r" ((long) c):"ax"); -} - -static void shift_right(int * c) -{ - __asm__("shrl $1,12(%0) ; rcrl $1,8(%0) ; rcrl $1,4(%0) ; rcrl $1,(%0)" - ::"r" ((long) c)); -} - -static int try_sub(int * a, int * b) -{ - char ok; - - __asm__ __volatile__("movl (%1),%%eax ; subl %%eax,(%2)\n\t" - "movl 4(%1),%%eax ; sbbl %%eax,4(%2)\n\t" - "movl 8(%1),%%eax ; sbbl %%eax,8(%2)\n\t" - "movl 12(%1),%%eax ; sbbl %%eax,12(%2)\n\t" - "setae %%al":"=a" (ok):"c" ((long) a),"d" ((long) b)); - return ok; -} - -static void div64(int * a, int * b, int * c) -{ - int tmp[4]; - int i; - unsigned int mask = 0; - - c += 4; - for (i = 0 ; i<64 ; i++) { - if (!(mask >>= 1)) { - c--; - mask = 0x80000000; - } - tmp[0] = a[0]; tmp[1] = a[1]; - tmp[2] = a[2]; tmp[3] = a[3]; - if (try_sub(b,tmp)) { - *c |= mask; - a[0] = tmp[0]; a[1] = tmp[1]; - a[2] = tmp[2]; a[3] = tmp[3]; - } - shift_right(b); - } -} - -void fdiv(const temp_real * src1, const temp_real * src2, temp_real * result) -{ - int i,sign; - int a[4],b[4],tmp[4] = {0,0,0,0}; - - sign = (src1->exponent ^ src2->exponent) & 0x8000; - if (!(src2->a || src2->b)) { - set_ZE(); - return; - } - i = (src1->exponent & 0x7fff) - (src2->exponent & 0x7fff) + 16383; - if (i<0) { - set_UE(); - result->exponent = sign; - result->a = result->b = 0; - return; - } - a[0] = a[1] = 0; - a[2] = src1->a; - a[3] = src1->b; - b[0] = b[1] = 0; - b[2] = src2->a; - b[3] = src2->b; - while (b[3] >= 0) { - i++; - shift_left(b); - } - div64(a,b,tmp); - if (tmp[0] || tmp[1] || tmp[2] || tmp[3]) { - while (i && tmp[3] >= 0) { - i--; - shift_left(tmp); - } - if (tmp[3] >= 0) - set_DE(); - } else - i = 0; - if (i>0x7fff) { - set_OE(); - return; - } - if (tmp[0] || tmp[1]) - set_PE(); - result->exponent = i | sign; - result->a = tmp[2]; - result->b = tmp[3]; -} - -/* - * linux/kernel/math/add.c - * - * (C) 1991 Linus Torvalds - */ - -/* - * temporary real addition routine. - * - * NOTE! These aren't exact: they are only 62 bits wide, and don't do - * correct rounding. Fast hack. The reason is that we shift right the - * values by two, in order not to have overflow (1 bit), and to be able - * to move the sign into the mantissa (1 bit). Much simpler algorithms, - * and 62 bits (61 really - no rounding) accuracy is usually enough. The - * only time you should notice anything weird is when adding 64-bit - * integers together. When using doubles (52 bits accuracy), the - * 61-bit accuracy never shows at all. - */ - -#define NEGINT(a) \ -__asm__("notl %0 ; notl %1 ; addl $1,%0 ; adcl $0,%1" \ - :"=r" (a->a),"=r" (a->b) \ - :"0" (a->a),"1" (a->b)) - -static void signify(temp_real * a) -{ - a->exponent += 2; - __asm__("shrdl $2,%1,%0 ; shrl $2,%1" - :"=r" (a->a),"=r" (a->b) - :"0" (a->a),"1" (a->b)); - if (a->exponent < 0) - NEGINT(a); - a->exponent &= 0x7fff; -} - -static void unsignify(temp_real * a) -{ - if (!(a->a || a->b)) { - a->exponent = 0; - return; - } - a->exponent &= 0x7fff; - if (a->b < 0) { - NEGINT(a); - a->exponent |= 0x8000; - } - while (a->b >= 0) { - a->exponent--; - __asm__("addl %0,%0 ; adcl %1,%1" - :"=r" (a->a),"=r" (a->b) - :"0" (a->a),"1" (a->b)); - } -} - -void fadd(const temp_real * src1, const temp_real * src2, temp_real * result) -{ - temp_real a,b; - int x1,x2,shift; - - x1 = src1->exponent & 0x7fff; - x2 = src2->exponent & 0x7fff; - if (x1 > x2) { - a = *src1; - b = *src2; - shift = x1-x2; - } else { - a = *src2; - b = *src1; - shift = x2-x1; - } - if (shift >= 64) { - *result = a; - return; - } - if (shift >= 32) { - b.a = b.b; - b.b = 0; - shift -= 32; - } - __asm__("shrdl %4,%1,%0 ; shrl %4,%1" - :"=r" (b.a),"=r" (b.b) - :"0" (b.a),"1" (b.b),"c" ((char) shift)); - signify(&a); - signify(&b); - __asm__("addl %4,%0 ; adcl %5,%1" - :"=r" (a.a),"=r" (a.b) - :"0" (a.a),"1" (a.b),"g" (b.a),"g" (b.b)); - unsignify(&a); - *result = a; -} - -/* - * linux/kernel/math/compare.c - * - * (C) 1991 Linus Torvalds - */ - -/* - * temporary real comparison routines - */ - - -#define clear_Cx() (I387.swd &= ~0x4500) - -static void normalize(temp_real * a) -{ - int i = a->exponent & 0x7fff; - int sign = a->exponent & 0x8000; - - if (!(a->a || a->b)) { - a->exponent = 0; - return; - } - while (i && a->b >= 0) { - i--; - __asm__("addl %0,%0 ; adcl %1,%1" - :"=r" (a->a),"=r" (a->b) - :"0" (a->a),"1" (a->b)); - } - a->exponent = i | sign; -} - -void ftst(const temp_real * a) -{ - temp_real b; - - clear_Cx(); - b = *a; - normalize(&b); - if (b.a || b.b || b.exponent) { - if (b.exponent < 0) - set_C0(); - } else - set_C3(); -} - -void fcom(const temp_real * src1, const temp_real * src2) -{ - temp_real a; - - a = *src1; - a.exponent ^= 0x8000; - fadd(&a,src2,&a); - ftst(&a); -} - -void fucom(const temp_real * src1, const temp_real * src2) -{ - fcom(src1,src2); -} - -/* - * linux/kernel/math/convert.c - * - * (C) 1991 Linus Torvalds - */ - - -/* - * NOTE!!! There is some "non-obvious" optimisations in the temp_to_long - * and temp_to_short conversion routines: don't touch them if you don't - * know what's going on. They are the adding of one in the rounding: the - * overflow bit is also used for adding one into the exponent. Thus it - * looks like the overflow would be incorrectly handled, but due to the - * way the IEEE numbers work, things are correct. - * - * There is no checking for total overflow in the conversions, though (ie - * if the temp-real number simply won't fit in a short- or long-real.) - */ - -void short_to_temp(const short_real * a, temp_real * b) -{ - if (!(*a & 0x7fffffff)) { - b->a = b->b = 0; - if (*a) - b->exponent = 0x8000; - else - b->exponent = 0; - return; - } - b->exponent = ((*a>>23) & 0xff)-127+16383; - if (*a<0) - b->exponent |= 0x8000; - b->b = (*a<<8) | 0x80000000; - b->a = 0; -} - -void long_to_temp(const long_real * a, temp_real * b) -{ - if (!a->a && !(a->b & 0x7fffffff)) { - b->a = b->b = 0; - if (a->b) - b->exponent = 0x8000; - else - b->exponent = 0; - return; - } - b->exponent = ((a->b >> 20) & 0x7ff)-1023+16383; - if (a->b<0) - b->exponent |= 0x8000; - b->b = 0x80000000 | (a->b<<11) | (((unsigned long)a->a)>>21); - b->a = a->a<<11; -} - -void temp_to_short(const temp_real * a, short_real * b) -{ - if (!(a->exponent & 0x7fff)) { - *b = (a->exponent)?0x80000000:0; - return; - } - *b = ((((long) a->exponent)-16383+127) << 23) & 0x7f800000; - if (a->exponent < 0) - *b |= 0x80000000; - *b |= (a->b >> 8) & 0x007fffff; - switch (ROUNDING) { - case ROUND_NEAREST: - if ((a->b & 0xff) > 0x80) - ++*b; - break; - case ROUND_DOWN: - if ((a->exponent & 0x8000) && (a->b & 0xff)) - ++*b; - break; - case ROUND_UP: - if (!(a->exponent & 0x8000) && (a->b & 0xff)) - ++*b; - break; - } -} - -void temp_to_long(const temp_real * a, long_real * b) -{ - if (!(a->exponent & 0x7fff)) { - b->a = 0; - b->b = (a->exponent)?0x80000000:0; - return; - } - b->b = (((0x7fff & (long) a->exponent)-16383+1023) << 20) & 0x7ff00000; - if (a->exponent < 0) - b->b |= 0x80000000; - b->b |= (a->b >> 11) & 0x000fffff; - b->a = a->b << 21; - b->a |= (a->a >> 11) & 0x001fffff; - switch (ROUNDING) { - case ROUND_NEAREST: - if ((a->a & 0x7ff) > 0x400) - __asm__("addl $1,%0 ; adcl $0,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b)); - break; - case ROUND_DOWN: - if ((a->exponent & 0x8000) && (a->b & 0xff)) - __asm__("addl $1,%0 ; adcl $0,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b)); - break; - case ROUND_UP: - if (!(a->exponent & 0x8000) && (a->b & 0xff)) - __asm__("addl $1,%0 ; adcl $0,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b)); - break; - } -} - -void frndint(const temp_real * a, temp_real * b) -{ - int shift = 16383 + 63 - (a->exponent & 0x7fff); - unsigned long underflow; - - if ((shift < 0) || (shift == 16383+63)) { - *b = *a; - return; - } - b->a = b->b = underflow = 0; - b->exponent = a->exponent; - if (shift < 32) { - b->b = a->b; b->a = a->a; - } else if (shift < 64) { - b->a = a->b; underflow = a->a; - shift -= 32; - b->exponent += 32; - } else if (shift < 96) { - underflow = a->b; - shift -= 64; - b->exponent += 64; - } else { - underflow = 1; - shift = 0; - } - b->exponent += shift; - __asm__("shrdl %2,%1,%0" - :"=r" (underflow),"=r" (b->a) - :"c" ((char) shift),"0" (underflow),"1" (b->a)); - __asm__("shrdl %2,%1,%0" - :"=r" (b->a),"=r" (b->b) - :"c" ((char) shift),"0" (b->a),"1" (b->b)); - __asm__("shrl %1,%0" - :"=r" (b->b) - :"c" ((char) shift),"0" (b->b)); - switch (ROUNDING) { - case ROUND_NEAREST: - __asm__("addl %4,%5 ; adcl $0,%0 ; adcl $0,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b) - ,"r" (0x7fffffff + (b->a & 1)) - ,"m" (*&underflow)); - break; - case ROUND_UP: - if ((b->exponent >= 0) && underflow) - __asm__("addl $1,%0 ; adcl $0,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b)); - break; - case ROUND_DOWN: - if ((b->exponent < 0) && underflow) - __asm__("addl $1,%0 ; adcl $0,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b)); - break; - } - if (b->a || b->b) - while (b->b >= 0) { - b->exponent--; - __asm__("addl %0,%0 ; adcl %1,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b)); - } - else - b->exponent = 0; -} - -void Fscale(const temp_real *a, const temp_real *b, temp_real *c) -{ - temp_int ti; - - *c = *a; - if(!c->a && !c->b) { /* 19 Sep 92*/ - c->exponent = 0; - return; - } - real_to_int(b, &ti); - if(ti.sign) - c->exponent -= ti.a; - else - c->exponent += ti.a; -} - -void real_to_int(const temp_real * a, temp_int * b) -{ - int shift = 16383 + 63 - (a->exponent & 0x7fff); - unsigned long underflow; - - b->a = b->b = underflow = 0; - b->sign = (a->exponent < 0); - if (shift < 0) { - set_OE(); - return; - } - if (shift < 32) { - b->b = a->b; b->a = a->a; - } else if (shift < 64) { - b->a = a->b; underflow = a->a; - shift -= 32; - } else if (shift < 96) { - underflow = a->b; - shift -= 64; - } else { - underflow = 1; - shift = 0; - } - __asm__("shrdl %2,%1,%0" - :"=r" (underflow),"=r" (b->a) - :"c" ((char) shift),"0" (underflow),"1" (b->a)); - __asm__("shrdl %2,%1,%0" - :"=r" (b->a),"=r" (b->b) - :"c" ((char) shift),"0" (b->a),"1" (b->b)); - __asm__("shrl %1,%0" - :"=r" (b->b) - :"c" ((char) shift),"0" (b->b)); - switch (ROUNDING) { - case ROUND_NEAREST: - __asm__("addl %4,%5 ; adcl $0,%0 ; adcl $0,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b) - ,"r" (0x7fffffff + (b->a & 1)) - ,"m" (*&underflow)); - break; - case ROUND_UP: - if (!b->sign && underflow) - __asm__("addl $1,%0 ; adcl $0,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b)); - break; - case ROUND_DOWN: - if (b->sign && underflow) - __asm__("addl $1,%0 ; adcl $0,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b)); - break; - } -} - -void int_to_real(const temp_int * a, temp_real * b) -{ - b->a = a->a; - b->b = a->b; - if (b->a || b->b) - b->exponent = 16383 + 63 + (a->sign? 0x8000:0); - else { - b->exponent = 0; - return; - } - while (b->b >= 0) { - b->exponent--; - __asm__("addl %0,%0 ; adcl %1,%1" - :"=r" (b->a),"=r" (b->b) - :"0" (b->a),"1" (b->b)); - } -} diff --git a/sys/i386/i386/mem.c b/sys/i386/i386/mem.c deleted file mode 100644 index 51c62ca..0000000 --- a/sys/i386/i386/mem.c +++ /dev/null @@ -1,230 +0,0 @@ -/*- - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department, and code derived from software contributed to - * Berkeley by William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: mem.c 1.13 89/10/08$ - * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * Memory special file - */ - -#include "param.h" -#include "conf.h" -#include "buf.h" -#include "systm.h" -#include "uio.h" -#include "malloc.h" -#include "proc.h" - -#include "machine/cpu.h" -#include "machine/psl.h" - -#include "vm/vm_param.h" -#include "vm/lock.h" -#include "vm/vm_statistics.h" -#include "vm/pmap.h" -#include "vm/vm_prot.h" - -extern char *vmmap; /* poor name! */ -/*ARGSUSED*/ -mmclose(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; -{ - struct syscframe *fp; - - switch (minor(dev)) { - case 14: - fp = (struct syscframe *)curproc->p_regs; - fp->sf_eflags &= ~PSL_IOPL; - break; - default: - break; - } - return(0); -} -/*ARGSUSED*/ -mmopen(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; -{ - struct syscframe *fp; - - switch (minor(dev)) { - case 14: - fp = (struct syscframe *)curproc->p_regs; - fp->sf_eflags |= PSL_IOPL; - break; - default: - break; - } - return(0); -} -/*ARGSUSED*/ -mmrw(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; -{ - register int o; - register u_int c, v; - register struct iovec *iov; - int error = 0; - caddr_t zbuf = NULL; - - 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; - pmap_enter(pmap_kernel(), vmmap, v, - uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE, - TRUE); - o = (int)uio->uio_offset & PGOFSET; - c = (u_int)(NBPG - ((int)iov->iov_base & PGOFSET)); - c = MIN(c, (u_int)(NBPG - o)); - c = MIN(c, (u_int)iov->iov_len); - error = uiomove((caddr_t)&vmmap[o], (int)c, uio); - pmap_remove(pmap_kernel(), vmmap, &vmmap[NBPG]); - continue; - -/* minor device 1 is kernel memory */ - case 1: - c = iov->iov_len; - if (!kernacc((caddr_t)uio->uio_offset, c, - uio->uio_rw == UIO_READ ? B_READ : B_WRITE)) - return(EFAULT); - error = uiomove((caddr_t)uio->uio_offset, (int)c, uio); - continue; - -/* minor device 2 is EOF/RATHOLE */ - case 2: - if (uio->uio_rw == UIO_READ) - return (0); - c = iov->iov_len; - break; - -/* 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; - } - if (zbuf == NULL) { - zbuf = (caddr_t) - malloc(CLBYTES, M_TEMP, M_WAITOK); - bzero(zbuf, CLBYTES); - } - c = MIN(iov->iov_len, CLBYTES); - error = uiomove(zbuf, (int)c, uio); - continue; - -#ifdef notyet -/* 386 I/O address space (/dev/ioport[bwl]) is a read/write access to seperate - i/o device address bus, different than memory bus. Semantics here are - very different than ordinary read/write, as if iov_len is a multiple - an implied string move from a single port will be done. Note that lseek - must be used to set the port number reliably. */ - case 14: - if (iov->iov_len == 1) { - u_char tmp; - tmp = inb(uio->uio_offset); - error = uiomove (&tmp, iov->iov_len, uio); - } else { - if (!useracc((caddr_t)iov->iov_base, - iov->iov_len, uio->uio_rw)) - return (EFAULT); - insb(uio->uio_offset, iov->iov_base, - iov->iov_len); - } - break; - case 15: - if (iov->iov_len == sizeof (short)) { - u_short tmp; - tmp = inw(uio->uio_offset); - error = uiomove (&tmp, iov->iov_len, uio); - } else { - if (!useracc((caddr_t)iov->iov_base, - iov->iov_len, uio->uio_rw)) - return (EFAULT); - insw(uio->uio_offset, iov->iov_base, - iov->iov_len/ sizeof (short)); - } - break; - case 16: - if (iov->iov_len == sizeof (long)) { - u_long tmp; - tmp = inl(uio->uio_offset); - error = uiomove (&tmp, iov->iov_len, uio); - } else { - if (!useracc((caddr_t)iov->iov_base, - iov->iov_len, uio->uio_rw)) - return (EFAULT); - insl(uio->uio_offset, iov->iov_base, - iov->iov_len/ sizeof (long)); - } - break; -#endif - - default: - return (ENXIO); - } - if (error) - break; - iov->iov_base += c; - iov->iov_len -= c; - uio->uio_offset += c; - uio->uio_resid -= c; - } - if (zbuf) - free(zbuf, M_TEMP); - return (error); -} diff --git a/sys/i386/i386/microtime.s b/sys/i386/i386/microtime.s deleted file mode 100644 index 99f8601..0000000 --- a/sys/i386/i386/microtime.s +++ /dev/null @@ -1,136 +0,0 @@ -/*- - * Copyright (c) 1993 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Steve McCanne's microtime code - * $Id$ - */ - -#include "asm.h" -#include "../isa/isa.h" -#include "../isa/timerreg.h" - -/* - * Use a higher resolution version of microtime if HZ is not - * overridden (i.e. it is 100Hz). - */ -#ifndef HZ -ENTRY(microtime) - pushl %edi - pushl %esi - pushl %ebx - - movl $_time,%ebx - - cli # disable interrupts - - movl (%ebx),%edi # sec = time.tv_sec - movl 4(%ebx),%esi # usec = time.tv_usec - - movl $(TIMER_SEL0|TIMER_LATCH),%eax - outb %al,$TIMER_MODE # latch timer 0's counter - - # - # Read counter value into ebx, LSB first - # - inb $TIMER_CNTR0,%al - movzbl %al,%ebx - inb $TIMER_CNTR0,%al - movzbl %al,%eax - sall $8,%eax - orl %eax,%ebx - - # - # Now check for counter overflow. This is tricky because the - # timer chip doesn't let us atomically read the current counter - # value and the output state (i.e., overflow state). We have - # to read the ICU interrupt request register (IRR) to see if the - # overflow has occured. Because we lack atomicity, we use - # the (very accurate) heuristic that we only check for - # overflow if the value read is close to the interrupt period. - # E.g., if we just checked the IRR, we might read a non-overflowing - # value close to 0, experience overflow, then read this overflow - # from the IRR, and mistakenly add a correction to the "close - # to zero" value. - # - # We compare the counter value to heuristic constant 11890. - # If the counter value is less than this, we assume the counter - # didn't overflow between disabling interrupts above and latching - # the counter value. For example, we assume that the above 10 or so - # instructions take less than 11932 - 11890 = 42 microseconds to - # execute. - # - # Otherwise, the counter might have overflowed. We check for this - # condition by reading the interrupt request register out of the ICU. - # If it overflowed, we add in one clock period. - # - # The heuristic is "very accurate" because it works 100% if - # we're called from an ipl less than the clock. Otherwise, - # it might not work. Currently, only gettimeofday and bpf - # call microtime so it's not a problem. - # - cmpl $11890,%ebx - jle 2f - movl $0x0a,%eax # tell ICU we want IRR - outb %al,$IO_ICU1 - - inb $IO_ICU1,%al # read IRR in ICU - testb $1,%al # is a timer interrupt pending? - je 1f - addl $-11932,%ebx # yes, subtract one clock period -1: - movl $0x0b,%eax # tell ICU we want ISR - outb %al,$IO_ICU1 # (rest of kernel expects this) -2: - sti # enable interrupts - - movl $11932,%eax # subtract counter value from 11932 since - subl %ebx,%eax # it is a count-down value - imull $1000,%eax,%eax - movl $0,%edx # zero extend eax for div - movl $1193,%ecx - idivl %ecx # convert to usecs: mult by 1000/1193 - - addl %eax,%esi # add counter usecs to time.tv_usec - cmpl $1000000,%esi # carry in timeval? - jl 3f - subl $1000000,%esi # adjust usec - incl %edi # bump sec -3: - movl 16(%esp),%ecx # load timeval pointer arg - movl %edi,(%ecx) # tvp->tv_sec = sec - movl %esi,4(%ecx) # tvp->tv_usec = usec - - popl %ebx # restore regs - popl %esi - popl %edi - ret -#endif diff --git a/sys/i386/i386/ns_cksum.c b/sys/i386/i386/ns_cksum.c deleted file mode 100644 index 1473f85..0000000 --- a/sys/i386/i386/ns_cksum.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 1982, 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ns_cksum.c 7.7 (Berkeley) 4/29/91 - * from NetBSD: ns_cksum.c,v 1.2 1993/05/22 07:59:55 cgd Exp - * $Id$ - */ - -#include "sys/param.h" -#include "sys/mbuf.h" - -/* - * Checksum routine for Network Systems Protocol Packets (Big-Endian). - * - * This routine is very heavily used in the network - * code and should be modified for each CPU to be as fast as possible. - */ - -#define ADDCARRY(x) { if ((x) > 65535) (x) -= 65535; } -#define FOLD(x) {l_util.l = (x); (x) = l_util.s[0] + l_util.s[1]; ADDCARRY(x);} - -u_short -ns_cksum(m, len) - register struct mbuf *m; - register int len; -{ - register u_short *w; - register int sum = 0; - register int mlen = 0; - register int sum2; - - union { - u_short s[2]; - long l; - } l_util; - - for (;m && len; m = m->m_next) { - if (m->m_len == 0) - continue; - /* - * Each trip around loop adds in - * word from one mbuf segment. - */ - w = mtod(m, u_short *); - if (mlen == -1) { - /* - * There is a byte left from the last segment; - * ones-complement add it into the checksum. - */ -#if BYTE_ORDER == BIG_ENDIAN - sum += *(u_char *)w; -#else - sum += *(u_char *)w << 8; -#endif - sum += sum; - w = (u_short *)(1 + (char *)w); - mlen = m->m_len - 1; - len--; - FOLD(sum); - } else - mlen = m->m_len; - if (len < mlen) - mlen = len; - len -= mlen; - /* - * We can do a 16 bit ones complement sum using - * 32 bit arithmetic registers for adding, - * with carries from the low added - * into the high (by normal carry-chaining) - * so long as we fold back before 16 carries have occured. - */ - if (1 & (int) w) - goto uuuuglyy; -#ifndef TINY -/* -DTINY reduces the size from 1250 to 550, but slows it down by 22% */ - while ((mlen -= 32) >= 0) { - sum += w[0]; sum += sum; sum += w[1]; sum += sum; - sum += w[2]; sum += sum; sum += w[3]; sum += sum; - sum += w[4]; sum += sum; sum += w[5]; sum += sum; - sum += w[6]; sum += sum; sum += w[7]; sum += sum; - FOLD(sum); - sum += w[8]; sum += sum; sum += w[9]; sum += sum; - sum += w[10]; sum += sum; sum += w[11]; sum += sum; - sum += w[12]; sum += sum; sum += w[13]; sum += sum; - sum += w[14]; sum += sum; sum += w[15]; sum += sum; - FOLD(sum); - w += 16; - } - mlen += 32; -#endif - while ((mlen -= 8) >= 0) { - sum += w[0]; sum += sum; sum += w[1]; sum += sum; - sum += w[2]; sum += sum; sum += w[3]; sum += sum; - FOLD(sum); - w += 4; - } - mlen += 8; - while ((mlen -= 2) >= 0) { - sum += *w++; sum += sum; - } - goto commoncase; -uuuuglyy: -#if BYTE_ORDER == BIG_ENDIAN -#define ww(n) (((u_char *)w)[n + n + 1]) -#define vv(n) (((u_char *)w)[n + n]) -#else -#if BYTE_ORDER == LITTLE_ENDIAN -#define vv(n) (((u_char *)w)[n + n + 1]) -#define ww(n) (((u_char *)w)[n + n]) -#endif -#endif - sum2 = 0; -#ifndef TINY - while ((mlen -= 32) >= 0) { - sum += ww(0); sum += sum; sum += ww(1); sum += sum; - sum += ww(2); sum += sum; sum += ww(3); sum += sum; - sum += ww(4); sum += sum; sum += ww(5); sum += sum; - sum += ww(6); sum += sum; sum += ww(7); sum += sum; - FOLD(sum); - sum += ww(8); sum += sum; sum += ww(9); sum += sum; - sum += ww(10); sum += sum; sum += ww(11); sum += sum; - sum += ww(12); sum += sum; sum += ww(13); sum += sum; - sum += ww(14); sum += sum; sum += ww(15); sum += sum; - FOLD(sum); - sum2 += vv(0); sum2 += sum2; sum2 += vv(1); sum2 += sum2; - sum2 += vv(2); sum2 += sum2; sum2 += vv(3); sum2 += sum2; - sum2 += vv(4); sum2 += sum2; sum2 += vv(5); sum2 += sum2; - sum2 += vv(6); sum2 += sum2; sum2 += vv(7); sum2 += sum2; - FOLD(sum2); - sum2 += vv(8); sum2 += sum2; sum2 += vv(9); sum2 += sum2; - sum2 += vv(10); sum2 += sum2; sum2 += vv(11); sum2 += sum2; - sum2 += vv(12); sum2 += sum2; sum2 += vv(13); sum2 += sum2; - sum2 += vv(14); sum2 += sum2; sum2 += vv(15); sum2 += sum2; - FOLD(sum2); - w += 16; - } - mlen += 32; -#endif - while ((mlen -= 8) >= 0) { - sum += ww(0); sum += sum; sum += ww(1); sum += sum; - sum += ww(2); sum += sum; sum += ww(3); sum += sum; - FOLD(sum); - sum2 += vv(0); sum2 += sum2; sum2 += vv(1); sum2 += sum2; - sum2 += vv(2); sum2 += sum2; sum2 += vv(3); sum2 += sum2; - FOLD(sum2); - w += 4; - } - mlen += 8; - while ((mlen -= 2) >= 0) { - sum += ww(0); sum += sum; - sum2 += vv(0); sum2 += sum2; - w++; - } - sum += (sum2 << 8); -commoncase: - if (mlen == -1) { -#if BYTE_ORDER == BIG_ENDIAN - sum += *(u_char *)w << 8; -#else - sum += *(u_char *)w; -#endif - } - FOLD(sum); - } - if (mlen == -1) { - /* We had an odd number of bytes to sum; assume a garbage - byte of zero and clean up */ - sum += sum; - FOLD(sum); - } - /* - * sum has already been kept to low sixteen bits. - * just examine result and exit. - */ - if(sum==0xffff) sum = 0; - return (sum); -} diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c deleted file mode 100644 index f35dd0f..0000000 --- a/sys/i386/i386/pmap.c +++ /dev/null @@ -1,1722 +0,0 @@ -/* - * Copyright (c) 1991 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department and William Jolitz of UUNET Technologies Inc. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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: @(#)pmap.c 7.7 (Berkeley) 5/12/91 - * $Id: pmap.c,v 1.6 1993/10/12 15:09:37 rgrimes Exp $ - */ - -/* - * Derived from hp300 version by Mike Hibler, this version by William - * Jolitz uses a recursive map [a pde points to the page directory] to - * map the page tables using the pagetables themselves. This is done to - * reduce the impact on kernel virtual memory for lots of sparse address - * space, and to reduce the cost of memory to each process. - * - * Derived from: hp300/@(#)pmap.c 7.1 (Berkeley) 12/5/90 - */ - -/* - * Reno i386 version, from Mike Hibler's hp300 version. - */ - -/* - * Manages physical address maps. - * - * In addition to hardware address maps, this - * module is called upon to provide software-use-only - * maps which may or may not be stored in the same - * form as hardware maps. These pseudo-maps are - * used to store intermediate results from copy - * operations to and from address spaces. - * - * Since the information managed by this module is - * also stored by the logical address mapping module, - * this module may throw away valid virtual-to-physical - * mappings at almost any time. However, invalidations - * of virtual-to-physical mappings must be done as - * requested. - * - * In order to cope with hardware architectures which - * make virtual-to-physical map invalidates expensive, - * this module may delay invalidate or reduced protection - * operations until such time as they are actually - * necessary. This module is given full information as - * to which processors are currently using which maps, - * and to when physical maps must be made correct. - */ - -#include "param.h" -#include "proc.h" -#include "malloc.h" -#include "user.h" - -#include "vm/vm.h" -#include "vm/vm_kern.h" -#include "vm/vm_page.h" -/*#include "vm/vm_pageout.h"*/ - -#include "i386/isa/isa.h" - -/* - * Allocate various and sundry SYSMAPs used in the days of old VM - * and not yet converted. XXX. - */ -#define BSDVM_COMPAT 1 - -#ifdef DEBUG -struct { - int kernel; /* entering kernel mapping */ - int user; /* entering user mapping */ - int ptpneeded; /* needed to allocate a PT page */ - int pwchange; /* no mapping change, just wiring or protection */ - int wchange; /* no mapping change, just wiring */ - int mchange; /* was mapped but mapping to different page */ - int managed; /* a managed page */ - int firstpv; /* first mapping for this PA */ - int secondpv; /* second mapping for this PA */ - int ci; /* cache inhibited */ - int unmanaged; /* not a managed page */ - int flushes; /* cache flushes */ -} enter_stats; -struct { - int calls; - int removes; - int pvfirst; - int pvsearch; - int ptinvalid; - int uflushes; - int sflushes; -} remove_stats; - -int debugmap = 0; -int pmapdebug = 0 /* 0xffff */; -#define PDB_FOLLOW 0x0001 -#define PDB_INIT 0x0002 -#define PDB_ENTER 0x0004 -#define PDB_REMOVE 0x0008 -#define PDB_CREATE 0x0010 -#define PDB_PTPAGE 0x0020 -#define PDB_CACHE 0x0040 -#define PDB_BITS 0x0080 -#define PDB_COLLECT 0x0100 -#define PDB_PROTECT 0x0200 -#define PDB_PDRTAB 0x0400 -#define PDB_PARANOIA 0x2000 -#define PDB_WIRING 0x4000 -#define PDB_PVDUMP 0x8000 - -int pmapvacflush = 0; -#define PVF_ENTER 0x01 -#define PVF_REMOVE 0x02 -#define PVF_PROTECT 0x04 -#define PVF_TOTAL 0x80 -#endif - -/* - * Get PDEs and PTEs for user/kernel address space - */ -#define pmap_pde(m, v) (&((m)->pm_pdir[((vm_offset_t)(v) >> PD_SHIFT)&1023])) - -#define pmap_pte_pa(pte) (*(int *)(pte) & PG_FRAME) - -#define pmap_pde_v(pte) ((pte)->pd_v) -#define pmap_pte_w(pte) ((pte)->pg_w) -/* #define pmap_pte_ci(pte) ((pte)->pg_ci) */ -#define pmap_pte_m(pte) ((pte)->pg_m) -#define pmap_pte_u(pte) ((pte)->pg_u) -#define pmap_pte_v(pte) ((pte)->pg_v) -#define pmap_pte_set_w(pte, v) ((pte)->pg_w = (v)) -#define pmap_pte_set_prot(pte, v) ((pte)->pg_prot = (v)) - -/* - * Given a map and a machine independent protection code, - * convert to a vax protection code. - */ -#define pte_prot(m, p) (protection_codes[p]) -int protection_codes[8]; - -struct pmap kernel_pmap_store; -pmap_t kernel_pmap; - -vm_offset_t avail_start; /* PA of first available physical page */ -vm_offset_t avail_end; /* PA of last available physical page */ -vm_size_t mem_size; /* memory size in bytes */ -vm_offset_t virtual_avail; /* VA of first avail page (after kernel bss)*/ -vm_offset_t virtual_end; /* VA of last avail page (end of kernel AS) */ -vm_offset_t vm_first_phys; /* PA of first managed page */ -vm_offset_t vm_last_phys; /* PA just past last managed page */ -int i386pagesperpage; /* PAGE_SIZE / NBPG */ -boolean_t pmap_initialized = FALSE; /* Has pmap_init completed? */ -char *pmap_attributes; /* reference and modify bits */ - -boolean_t pmap_testbit(); -void pmap_clear_modify(); - -#if BSDVM_COMPAT -#include "msgbuf.h" - -/* - * All those kernel PT submaps that BSD is so fond of - */ -struct pte *CMAP1, *CMAP2, *mmap; -caddr_t CADDR1, CADDR2, vmmap; -struct pte *msgbufmap; -struct msgbuf *msgbufp; -#endif - -/* - * Bootstrap the system enough to run with virtual memory. - * Map the kernel's code and data, and allocate the system page table. - * - * On the I386 this is called after mapping has already been enabled - * and just syncs the pmap module with what has already been done. - * [We can't call it easily with mapping off since the kernel is not - * mapped with PA == VA, hence we would have to relocate every address - * from the linked base (virtual) address KERNBASE to the actual - * (physical) address starting relative to 0] - */ -struct pte *pmap_pte(); - -void -pmap_bootstrap(firstaddr, loadaddr) - vm_offset_t firstaddr; - vm_offset_t loadaddr; -{ -#if BSDVM_COMPAT - vm_offset_t va; - struct pte *pte; -#endif - extern vm_offset_t maxmem, physmem; -extern int IdlePTD; - - avail_start = firstaddr + 8 * NBPG; - avail_end = maxmem << PG_SHIFT; - - /* XXX: allow for msgbuf */ - avail_end -= i386_round_page(sizeof(struct msgbuf)); - - mem_size = physmem << PG_SHIFT; - virtual_avail = (vm_offset_t)atdevbase + 0x100000 - 0xa0000 + 10*NBPG; - virtual_end = VM_MAX_KERNEL_ADDRESS; - i386pagesperpage = PAGE_SIZE / NBPG; - - /* - * Initialize protection array. - */ - i386_protection_init(); - - /* - * The kernel's pmap is statically allocated so we don't - * have to use pmap_create, which is unlikely to work - * correctly at this part of the boot sequence. - */ - kernel_pmap = &kernel_pmap_store; - -#ifdef notdef - /* - * Create Kernel page directory table and page maps. - * [ currently done in locore. i have wild and crazy ideas -wfj ] - * XXX IF THIS IS EVER USED, IT MUST BE MOVED TO THE TOP - * OF THIS ROUTINE -- cgd - */ - bzero(firstaddr, 4*NBPG); - kernel_pmap->pm_pdir = firstaddr + VM_MIN_KERNEL_ADDRESS; - kernel_pmap->pm_ptab = firstaddr + VM_MIN_KERNEL_ADDRESS + NBPG; - - firstaddr += NBPG; - for (x = i386_btod(VM_MIN_KERNEL_ADDRESS); - x < i386_btod(VM_MIN_KERNEL_ADDRESS)+3; x++) { - struct pde *pde; - pde = kernel_pmap->pm_pdir + x; - *(int *)pde = firstaddr + x*NBPG | PG_V | PG_KW; - } -#else - kernel_pmap->pm_pdir = (pd_entry_t *)(KERNBASE + IdlePTD); -#endif - - - simple_lock_init(&kernel_pmap->pm_lock); - kernel_pmap->pm_count = 1; - -#if BSDVM_COMPAT - /* - * Allocate all the submaps we need - */ -#define SYSMAP(c, p, v, n) \ - v = (c)va; va += ((n)*NBPG); p = pte; pte += (n); - - va = virtual_avail; - pte = pmap_pte(kernel_pmap, va); - - SYSMAP(caddr_t ,CMAP1 ,CADDR1 ,1 ) - SYSMAP(caddr_t ,CMAP2 ,CADDR2 ,1 ) - SYSMAP(caddr_t ,mmap ,vmmap ,1 ) - SYSMAP(struct msgbuf * ,msgbufmap ,msgbufp ,1 ) - virtual_avail = va; -#endif - /* - * reserve special hunk of memory for use by bus dma as a bounce - * buffer (contiguous virtual *and* physical memory). - * do it from firstaddr -> firstaddr+8 pages. note that - * avail_start was bumped up 8 pages, above, to accomodate this. - */ - { - extern vm_offset_t isaphysmem; - - isaphysmem = va; - virtual_avail = pmap_map(va, firstaddr, firstaddr + 8*NBPG, - VM_PROT_ALL); - } - - *(int *)PTD = 0; - load_cr3(rcr3()); - -} - -/* - * Initialize the pmap module. - * Called by vm_init, to initialize any structures that the pmap - * system needs to map virtual memory. - */ -void -pmap_init(phys_start, phys_end) - vm_offset_t phys_start, phys_end; -{ - vm_offset_t addr, addr2; - vm_size_t npg, s; - int rv; - extern int KPTphys; - -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_init(%x, %x)\n", phys_start, phys_end); -#endif - /* - * Now that kernel map has been allocated, we can mark as - * unavailable regions which we have mapped in locore. - */ - addr = atdevbase; - (void) vm_map_find(kernel_map, NULL, (vm_offset_t) 0, - &addr, (0x100000-0xa0000), FALSE); - - addr = (vm_offset_t) KERNBASE + KPTphys/* *NBPG */; - vm_object_reference(kernel_object); - (void) vm_map_find(kernel_map, kernel_object, addr, - &addr, 2*NBPG, FALSE); - - /* - * Allocate memory for random pmap data structures. Includes the - * pv_head_table and pmap_attributes. - */ - npg = atop(phys_end - phys_start); - s = (vm_size_t) (sizeof(struct pv_entry) * npg + npg); - s = round_page(s); - addr = (vm_offset_t) kmem_alloc(kernel_map, s); - pv_table = (pv_entry_t) addr; - addr += sizeof(struct pv_entry) * npg; - pmap_attributes = (char *) addr; -#ifdef DEBUG - if (pmapdebug & PDB_INIT) - printf("pmap_init: %x bytes (%x pgs): tbl %x attr %x\n", - s, npg, pv_table, pmap_attributes); -#endif - - /* - * Now it is safe to enable pv_table recording. - */ - vm_first_phys = phys_start; - vm_last_phys = phys_end; - pmap_initialized = TRUE; -} - -/* - * Used to map a range of physical addresses into kernel - * virtual address space. - * - * For now, VM is already on, we only need to map the - * specified memory. - */ -vm_offset_t -pmap_map(virt, start, end, prot) - vm_offset_t virt; - vm_offset_t start; - vm_offset_t end; - int prot; -{ -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_map(%x, %x, %x, %x)\n", virt, start, end, prot); -#endif - while (start < end) { - pmap_enter(kernel_pmap, virt, start, prot, FALSE); - virt += PAGE_SIZE; - start += PAGE_SIZE; - } - return(virt); -} - -/* - * Create and return a physical map. - * - * If the size specified for the map - * is zero, the map is an actual physical - * map, and may be referenced by the - * hardware. - * - * If the size specified is non-zero, - * the map will be used in software only, and - * is bounded by that size. - * - * [ just allocate a ptd and mark it uninitialize -- should we track - * with a table which process has which ptd? -wfj ] - */ - -pmap_t -pmap_create(size) - vm_size_t size; -{ - register pmap_t pmap; - -#ifdef DEBUG - if (pmapdebug & (PDB_FOLLOW|PDB_CREATE)) - printf("pmap_create(%x)\n", size); -#endif - /* - * Software use map does not need a pmap - */ - if (size) - return(NULL); - - /* XXX: is it ok to wait here? */ - pmap = (pmap_t) malloc(sizeof *pmap, M_VMPMAP, M_WAITOK); -#ifdef notifwewait - if (pmap == NULL) - panic("pmap_create: cannot allocate a pmap"); -#endif - bzero(pmap, sizeof(*pmap)); - pmap_pinit(pmap); - return (pmap); -} - -/* - * Initialize a preallocated and zeroed pmap structure, - * such as one in a vmspace structure. - */ -void -pmap_pinit(pmap) - register struct pmap *pmap; -{ - -#ifdef DEBUG - if (pmapdebug & (PDB_FOLLOW|PDB_CREATE)) - pg("pmap_pinit(%x)\n", pmap); -#endif - - /* - * No need to allocate page table space yet but we do need a - * valid page directory table. - */ - pmap->pm_pdir = (pd_entry_t *) kmem_alloc(kernel_map, NBPG); - - /* wire in kernel global address entries */ - bcopy(PTD+KPTDI, pmap->pm_pdir+KPTDI, NKPDE*4); - - /* install self-referential address mapping entry */ - *(int *)(pmap->pm_pdir+PTDPTDI) = - (int)pmap_extract(kernel_pmap, pmap->pm_pdir) | PG_V | PG_KW; - - pmap->pm_count = 1; - simple_lock_init(&pmap->pm_lock); -} - -/* - * Retire the given physical map from service. - * Should only be called if the map contains - * no valid mappings. - */ -void -pmap_destroy(pmap) - register pmap_t pmap; -{ - int count; - -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_destroy(%x)\n", pmap); -#endif - if (pmap == NULL) - return; - - simple_lock(&pmap->pm_lock); - count = --pmap->pm_count; - simple_unlock(&pmap->pm_lock); - if (count == 0) { - pmap_release(pmap); - free((caddr_t)pmap, M_VMPMAP); - } -} - -/* - * Release any resources held by the given physical map. - * Called when a pmap initialized by pmap_pinit is being released. - * Should only be called if the map contains no valid mappings. - */ -void -pmap_release(pmap) - register struct pmap *pmap; -{ - -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - pg("pmap_release(%x)\n", pmap); -#endif -#ifdef notdef /* DIAGNOSTIC */ - /* count would be 0 from pmap_destroy... */ - simple_lock(&pmap->pm_lock); - if (pmap->pm_count != 1) - panic("pmap_release count"); -#endif - kmem_free(kernel_map, (vm_offset_t)pmap->pm_pdir, NBPG); -} - -/* - * Add a reference to the specified pmap. - */ -void -pmap_reference(pmap) - pmap_t pmap; -{ -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_reference(%x)", pmap); -#endif - if (pmap != NULL) { - simple_lock(&pmap->pm_lock); - pmap->pm_count++; - simple_unlock(&pmap->pm_lock); - } -} - -/* - * Remove the given range of addresses from the specified map. - * - * It is assumed that the start and end are properly - * rounded to the page size. - */ -void -pmap_remove(pmap, sva, eva) - struct pmap *pmap; - register vm_offset_t sva; - register vm_offset_t eva; -{ - register pt_entry_t *ptp,*ptq; - vm_offset_t va; - vm_offset_t pa; - pt_entry_t *pte; - pv_entry_t pv, npv; - int ix; - int s, bits; -#ifdef DEBUG - pt_entry_t opte; - - if (pmapdebug & (PDB_FOLLOW|PDB_REMOVE|PDB_PROTECT)) - pg("pmap_remove(%x, %x, %x)", pmap, sva, eva); -#endif - - if (pmap == NULL) - return; - - /* are we current address space or kernel? */ - if (pmap->pm_pdir[PTDPTDI].pd_pfnum == PTDpde.pd_pfnum - || pmap == kernel_pmap) - ptp=PTmap; - - /* otherwise, we are alternate address space */ - else { - if (pmap->pm_pdir[PTDPTDI].pd_pfnum - != APTDpde.pd_pfnum) { - APTDpde = pmap->pm_pdir[PTDPTDI]; - tlbflush(); - } - ptp=APTmap; - } -#ifdef DEBUG - remove_stats.calls++; -#endif - - /* this is essential since we must check the PDE(sva) for precense */ - while (sva <= eva && !pmap_pde_v(pmap_pde(pmap, sva))) - sva = (sva & PD_MASK) + (1<= eva) - return; - ptq++; - } - - - if(!(sva & 0x3ff)) /* Only check once in a while */ - { - if (!pmap_pde_v(pmap_pde(pmap, i386_ptob(sva)))) - { - /* We can race ahead here, straight to next pde.. */ - sva = (sva & 0xffc00) + (1<<10) -1 ; - continue; - } - } - if(!pmap_pte_pa(ptp+sva)) - continue; - - pte = ptp + sva; - pa = pmap_pte_pa(pte); - va = i386_ptob(sva); -#ifdef DEBUG - opte = *pte; - remove_stats.removes++; -#endif - /* - * Update statistics - */ - if (pmap_pte_w(pte)) - pmap->pm_stats.wired_count--; - pmap->pm_stats.resident_count--; - - /* - * Invalidate the PTEs. - * XXX: should cluster them up and invalidate as many - * as possible at once. - */ -#ifdef DEBUG - if (pmapdebug & PDB_REMOVE) - printf("remove: inv %x ptes at %x(%x) ", - i386pagesperpage, pte, *(int *)pte); -#endif - bits = ix = 0; - do { - bits |= *(int *)pte & (PG_U|PG_M); - *(int *)pte++ = 0; - /*TBIS(va + ix * NBPG);*/ - } while (++ix != i386pagesperpage); - if (curproc && pmap == &curproc->p_vmspace->vm_pmap) - pmap_activate(pmap, (struct pcb *)curproc->p_addr); - /* are we current address space or kernel? */ - /*if (pmap->pm_pdir[PTDPTDI].pd_pfnum == PTDpde.pd_pfnum - || pmap == kernel_pmap) - load_cr3(curpcb->pcb_ptd);*/ - tlbflush(); - -#ifdef needednotdone -reduce wiring count on page table pages as references drop -#endif - - /* - * Remove from the PV table (raise IPL since we - * may be called at interrupt time). - */ - if (pa < vm_first_phys || pa >= vm_last_phys) - continue; - pv = pa_to_pvh(pa); - s = splimp(); - /* - * If it is the first entry on the list, it is actually - * in the header and we must copy the following entry up - * to the header. Otherwise we must search the list for - * the entry. In either case we free the now unused entry. - */ - if (pmap == pv->pv_pmap && va == pv->pv_va) { - npv = pv->pv_next; - if (npv) { - *pv = *npv; - free((caddr_t)npv, M_VMPVENT); - } else - pv->pv_pmap = NULL; -#ifdef DEBUG - remove_stats.pvfirst++; -#endif - } else { - for (npv = pv->pv_next; npv; npv = npv->pv_next) { -#ifdef DEBUG - remove_stats.pvsearch++; -#endif - if (pmap == npv->pv_pmap && va == npv->pv_va) - break; - pv = npv; - } -#ifdef DEBUG - if (npv == NULL) - panic("pmap_remove: PA not in pv_tab"); -#endif - pv->pv_next = npv->pv_next; - free((caddr_t)npv, M_VMPVENT); - pv = pa_to_pvh(pa); - } - -#ifdef notdef -[tally number of pagetable pages, if sharing of ptpages adjust here] -#endif - /* - * Update saved attributes for managed page - */ - pmap_attributes[pa_index(pa)] |= bits; - splx(s); - } -#ifdef notdef -[cache and tlb flushing, if needed] -#endif -} - -/* - * Routine: pmap_remove_all - * Function: - * Removes this physical page from - * all physical maps in which it resides. - * Reflects back modify bits to the pager. - */ -void -pmap_remove_all(pa) - vm_offset_t pa; -{ - register pv_entry_t pv; - int s; - -#ifdef DEBUG - if (pmapdebug & (PDB_FOLLOW|PDB_REMOVE|PDB_PROTECT)) - printf("pmap_remove_all(%x)", pa); - /*pmap_pvdump(pa);*/ -#endif - /* - * Not one of ours - */ - if (pa < vm_first_phys || pa >= vm_last_phys) - return; - - pv = pa_to_pvh(pa); - s = splimp(); - /* - * Do it the easy way for now - */ - while (pv->pv_pmap != NULL) { -#ifdef DEBUG - if (!pmap_pde_v(pmap_pde(pv->pv_pmap, pv->pv_va)) || - pmap_pte_pa(pmap_pte(pv->pv_pmap, pv->pv_va)) != pa) - panic("pmap_remove_all: bad mapping"); -#endif - pmap_remove(pv->pv_pmap, pv->pv_va, pv->pv_va + PAGE_SIZE); - } - splx(s); -} - -/* - * Routine: pmap_copy_on_write - * Function: - * Remove write privileges from all - * physical maps for this physical page. - */ -void -pmap_copy_on_write(pa) - vm_offset_t pa; -{ -#ifdef DEBUG - if (pmapdebug & (PDB_FOLLOW|PDB_PROTECT)) - printf("pmap_copy_on_write(%x)", pa); -#endif - pmap_changebit(pa, PG_RO, TRUE); -} - -/* - * Set the physical protection on the - * specified range of this map as requested. - */ -void -pmap_protect(pmap, sva, eva, prot) - register pmap_t pmap; - vm_offset_t sva, eva; - vm_prot_t prot; -{ - register pt_entry_t *pte; - register vm_offset_t va; - register int ix; - int i386prot; - boolean_t firstpage = TRUE; - register pt_entry_t *ptp; - -#ifdef DEBUG - if (pmapdebug & (PDB_FOLLOW|PDB_PROTECT)) - printf("pmap_protect(%x, %x, %x, %x)", pmap, sva, eva, prot); -#endif - if (pmap == NULL) - return; - - if ((prot & VM_PROT_READ) == VM_PROT_NONE) { - pmap_remove(pmap, sva, eva); - return; - } - if (prot & VM_PROT_WRITE) - return; - - /* are we current address space or kernel? */ - if (pmap->pm_pdir[PTDPTDI].pd_pfnum == PTDpde.pd_pfnum - || pmap == kernel_pmap) - ptp=PTmap; - - /* otherwise, we are alternate address space */ - else { - if (pmap->pm_pdir[PTDPTDI].pd_pfnum - != APTDpde.pd_pfnum) { - APTDpde = pmap->pm_pdir[PTDPTDI]; - tlbflush(); - } - ptp=APTmap; - } - for (va = sva; va < eva; va += PAGE_SIZE) { - /* - * Page table page is not allocated. - * Skip it, we don't want to force allocation - * of unnecessary PTE pages just to set the protection. - */ - if (!pmap_pde_v(pmap_pde(pmap, va))) { - /* XXX: avoid address wrap around */ - if (va >= i386_trunc_pdr((vm_offset_t)-1)) - break; - va = i386_round_pdr(va + PAGE_SIZE) - PAGE_SIZE; - continue; - } - - pte = ptp + i386_btop(va); - - /* - * Page not valid. Again, skip it. - * Should we do this? Or set protection anyway? - */ - if (!pmap_pte_v(pte)) - continue; - - ix = 0; - i386prot = pte_prot(pmap, prot); - if(va < UPT_MAX_ADDRESS) - i386prot |= 2 /*PG_u*/; - do { - /* clear VAC here if PG_RO? */ - pmap_pte_set_prot(pte++, i386prot); - /*TBIS(va + ix * NBPG);*/ - } while (++ix != i386pagesperpage); - } - if (curproc && pmap == &curproc->p_vmspace->vm_pmap) - pmap_activate(pmap, (struct pcb *)curproc->p_addr); -} - -/* - * Insert the given physical page (p) at - * the specified virtual address (v) in the - * target physical map with the protection requested. - * - * If specified, the page will be wired down, meaning - * that the related pte can not be reclaimed. - * - * NB: This is the only routine which MAY NOT lazy-evaluate - * or lose information. That is, this routine must actually - * insert this page into the given map NOW. - */ -void -pmap_enter(pmap, va, pa, prot, wired) - register pmap_t pmap; - vm_offset_t va; - register vm_offset_t pa; - vm_prot_t prot; - boolean_t wired; -{ - register pt_entry_t *pte; - register int npte, ix; - vm_offset_t opa; - boolean_t cacheable = TRUE; - boolean_t checkpv = TRUE; - -#ifdef DEBUG - if (pmapdebug & (PDB_FOLLOW|PDB_ENTER)) - printf("pmap_enter(%x, %x, %x, %x, %x)", - pmap, va, pa, prot, wired); -#endif - if (pmap == NULL) - return; - - if(va > VM_MAX_KERNEL_ADDRESS)panic("pmap_enter: toobig"); - /* also, should not muck with PTD va! */ - -#ifdef DEBUG - if (pmap == kernel_pmap) - enter_stats.kernel++; - else - enter_stats.user++; -#endif - - /* - * Page Directory table entry not valid, we need a new PT page - */ - if (!pmap_pde_v(pmap_pde(pmap, va))) { - printf("ptdi %x\n", pmap->pm_pdir[PTDPTDI]); - panic("Page Table Directory Invalid (ptdi)"); - } - - pte = pmap_pte(pmap, va); - opa = pmap_pte_pa(pte); -#ifdef DEBUG - if (pmapdebug & PDB_ENTER) - printf("enter: pte %x, *pte %x ", pte, *(int *)pte); -#endif - - /* - * Mapping has not changed, must be protection or wiring change. - */ - if (opa == pa) { -#ifdef DEBUG - enter_stats.pwchange++; -#endif - /* - * Wiring change, just update stats. - * We don't worry about wiring PT pages as they remain - * resident as long as there are valid mappings in them. - * Hence, if a user page is wired, the PT page will be also. - */ - if (wired && !pmap_pte_w(pte) || !wired && pmap_pte_w(pte)) { -#ifdef DEBUG - if (pmapdebug & PDB_ENTER) - pg("enter: wiring change -> %x ", wired); -#endif - if (wired) - pmap->pm_stats.wired_count++; - else - pmap->pm_stats.wired_count--; -#ifdef DEBUG - enter_stats.wchange++; -#endif - } - goto validate; - } - - /* - * Mapping has changed, invalidate old range and fall through to - * handle validating new mapping. - */ - if (opa) { -#ifdef DEBUG - if (pmapdebug & PDB_ENTER) - printf("enter: removing old mapping %x pa %x ", va, opa); -#endif - pmap_remove(pmap, va, va + PAGE_SIZE); -#ifdef DEBUG - enter_stats.mchange++; -#endif - } - - /* - * Enter on the PV list if part of our managed memory - * Note that we raise IPL while manipulating pv_table - * since pmap_enter can be called at interrupt time. - */ - if (pa >= vm_first_phys && pa < vm_last_phys) { - register pv_entry_t pv, npv; - int s; - -#ifdef DEBUG - enter_stats.managed++; -#endif - pv = pa_to_pvh(pa); - s = splimp(); -#ifdef DEBUG - if (pmapdebug & PDB_ENTER) - printf("enter: pv at %x: %x/%x/%x ", - pv, pv->pv_va, pv->pv_pmap, pv->pv_next); -#endif - /* - * No entries yet, use header as the first entry - */ - if (pv->pv_pmap == NULL) { -#ifdef DEBUG - enter_stats.firstpv++; -#endif - pv->pv_va = va; - pv->pv_pmap = pmap; - pv->pv_next = NULL; - pv->pv_flags = 0; - } - /* - * There is at least one other VA mapping this page. - * Place this entry after the header. - */ - else { - /*printf("second time: ");*/ -#ifdef DEBUG - for (npv = pv; npv; npv = npv->pv_next) - if (pmap == npv->pv_pmap && va == npv->pv_va) - panic("pmap_enter: already in pv_tab"); -#endif - npv = (pv_entry_t) - malloc(sizeof *npv, M_VMPVENT, M_NOWAIT); - npv->pv_va = va; - npv->pv_pmap = pmap; - npv->pv_next = pv->pv_next; - pv->pv_next = npv; -#ifdef DEBUG - if (!npv->pv_next) - enter_stats.secondpv++; -#endif - } - splx(s); - } - /* - * Assumption: if it is not part of our managed memory - * then it must be device memory which may be volitile. - */ - if (pmap_initialized) { - checkpv = cacheable = FALSE; -#ifdef DEBUG - enter_stats.unmanaged++; -#endif - } - - /* - * Increment counters - */ - pmap->pm_stats.resident_count++; - if (wired) - pmap->pm_stats.wired_count++; - -validate: - /* - * Now validate mapping with desired protection/wiring. - * Assume uniform modified and referenced status for all - * I386 pages in a MACH page. - */ - npte = (pa & PG_FRAME) | pte_prot(pmap, prot) | PG_V; - npte |= (*(int *)pte & (PG_M|PG_U)); - if (wired) - npte |= PG_W; - if(va < UPT_MIN_ADDRESS) - npte |= PG_u; - else if(va < UPT_MAX_ADDRESS) - npte |= PG_u | PG_RW; -#ifdef DEBUG - if (pmapdebug & PDB_ENTER) - printf("enter: new pte value %x ", npte); -#endif - ix = 0; - do { - *(int *)pte++ = npte; - /*TBIS(va);*/ - npte += NBPG; - va += NBPG; - } while (++ix != i386pagesperpage); - pte--; -/*pads(pmap);*/ - /*load_cr3(((struct pcb *)curproc->p_addr)->pcb_ptd);*/ - tlbflush(); -} - -/* - * pmap_page_protect: - * - * Lower the permission for all mappings to a given page. - */ -void -pmap_page_protect(phys, prot) - vm_offset_t phys; - vm_prot_t prot; -{ - switch (prot) { - case VM_PROT_READ: - case VM_PROT_READ|VM_PROT_EXECUTE: - pmap_copy_on_write(phys); - break; - case VM_PROT_ALL: - break; - default: - pmap_remove_all(phys); - break; - } -} - -/* - * Routine: pmap_change_wiring - * Function: Change the wiring attribute for a map/virtual-address - * pair. - * In/out conditions: - * The mapping must already exist in the pmap. - */ -void -pmap_change_wiring(pmap, va, wired) - register pmap_t pmap; - vm_offset_t va; - boolean_t wired; -{ - register pt_entry_t *pte; - register int ix; - -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_change_wiring(%x, %x, %x)", pmap, va, wired); -#endif - if (pmap == NULL) - return; - - pte = pmap_pte(pmap, va); -#ifdef DEBUG - /* - * Page table page is not allocated. - * Should this ever happen? Ignore it for now, - * we don't want to force allocation of unnecessary PTE pages. - */ - if (!pmap_pde_v(pmap_pde(pmap, va))) { - if (pmapdebug & PDB_PARANOIA) - pg("pmap_change_wiring: invalid PDE for %x ", va); - return; - } - /* - * Page not valid. Should this ever happen? - * Just continue and change wiring anyway. - */ - if (!pmap_pte_v(pte)) { - if (pmapdebug & PDB_PARANOIA) - pg("pmap_change_wiring: invalid PTE for %x ", va); - } -#endif - if (wired && !pmap_pte_w(pte) || !wired && pmap_pte_w(pte)) { - if (wired) - pmap->pm_stats.wired_count++; - else - pmap->pm_stats.wired_count--; - } - /* - * Wiring is not a hardware characteristic so there is no need - * to invalidate TLB. - */ - ix = 0; - do { - pmap_pte_set_w(pte++, wired); - } while (++ix != i386pagesperpage); -} - -/* - * Routine: pmap_pte - * Function: - * Extract the page table entry associated - * with the given map/virtual_address pair. - * [ what about induced faults -wfj] - */ - -struct pte *pmap_pte(pmap, va) - register pmap_t pmap; - vm_offset_t va; -{ - -#ifdef DEBUGx - if (pmapdebug & PDB_FOLLOW) - printf("pmap_pte(%x, %x) ->\n", pmap, va); -#endif - - if (pmap && pmap_pde_v(pmap_pde(pmap, va))) { - - /* are we current address space or kernel? */ - if (pmap->pm_pdir[PTDPTDI].pd_pfnum == PTDpde.pd_pfnum - || pmap == kernel_pmap) - return ((struct pte *) vtopte(va)); - - /* otherwise, we are alternate address space */ - else { - if (pmap->pm_pdir[PTDPTDI].pd_pfnum - != APTDpde.pd_pfnum) { - APTDpde = pmap->pm_pdir[PTDPTDI]; - tlbflush(); - } - return((struct pte *) avtopte(va)); - } - } - return(0); -} - -/* - * Routine: pmap_extract - * Function: - * Extract the physical page address associated - * with the given map/virtual_address pair. - */ - -vm_offset_t -pmap_extract(pmap, va) - register pmap_t pmap; - vm_offset_t va; -{ - register vm_offset_t pa; - -#ifdef DEBUGx - if (pmapdebug & PDB_FOLLOW) - pg("pmap_extract(%x, %x) -> ", pmap, va); -#endif - pa = 0; - if (pmap && pmap_pde_v(pmap_pde(pmap, va))) { - pa = *(int *) pmap_pte(pmap, va); - } - if (pa) - pa = (pa & PG_FRAME) | (va & ~PG_FRAME); -#ifdef DEBUGx - if (pmapdebug & PDB_FOLLOW) - printf("%x\n", pa); -#endif - return(pa); -} - -/* - * Copy the range specified by src_addr/len - * from the source map to the range dst_addr/len - * in the destination map. - * - * This routine is only advisory and need not do anything. - */ -void pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) - pmap_t dst_pmap; - pmap_t src_pmap; - vm_offset_t dst_addr; - vm_size_t len; - vm_offset_t src_addr; -{ -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_copy(%x, %x, %x, %x, %x)", - dst_pmap, src_pmap, dst_addr, len, src_addr); -#endif -} - -/* - * Require that all active physical maps contain no - * incorrect entries NOW. [This update includes - * forcing updates of any address map caching.] - * - * Generally used to insure that a thread about - * to run will see a semantically correct world. - */ -void pmap_update() -{ -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_update()"); -#endif - tlbflush(); -} - -/* - * Routine: pmap_collect - * Function: - * Garbage collects the physical map system for - * pages which are no longer used. - * Success need not be guaranteed -- that is, there - * may well be pages which are not referenced, but - * others may be collected. - * Usage: - * Called by the pageout daemon when pages are scarce. - * [ needs to be written -wfj ] - */ -void -pmap_collect(pmap) - pmap_t pmap; -{ - register vm_offset_t pa; - register pv_entry_t pv; - register int *pte; - vm_offset_t kpa; - int s; - -#ifdef DEBUG - int *pde; - int opmapdebug; - printf("pmap_collect(%x) ", pmap); -#endif - if (pmap != kernel_pmap) - return; - -} - -/* [ macro again?, should I force kstack into user map here? -wfj ] */ -void -pmap_activate(pmap, pcbp) - register pmap_t pmap; - struct pcb *pcbp; -{ -int x; -#ifdef DEBUG - if (pmapdebug & (PDB_FOLLOW|PDB_PDRTAB)) - pg("pmap_activate(%x, %x) ", pmap, pcbp); -#endif - PMAP_ACTIVATE(pmap, pcbp); -/*printf("pde "); -for(x=0x3f6; x < 0x3fA; x++) - printf("%x ", pmap->pm_pdir[x]);*/ -/*pads(pmap);*/ -/*pg(" pcb_cr3 %x", pcbp->pcb_cr3);*/ -} - -/* - * Routine: pmap_kernel - * Function: - * Returns the physical map handle for the kernel. - */ -pmap_t -pmap_kernel() -{ - return (kernel_pmap); -} - -/* - * pmap_zero_page zeros the specified (machine independent) - * page by mapping the page into virtual memory and using - * bzero to clear its contents, one machine dependent page - * at a time. - */ -pmap_zero_page(phys) - register vm_offset_t phys; -{ - register int ix; - -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_zero_page(%x)", phys); -#endif - phys >>= PG_SHIFT; - ix = 0; - do { - clearseg(phys++); - } while (++ix != i386pagesperpage); -} - -/* - * pmap_copy_page copies the specified (machine independent) - * page by mapping the page into virtual memory and using - * bcopy to copy the page, one machine dependent page at a - * time. - */ -pmap_copy_page(src, dst) - register vm_offset_t src, dst; -{ - register int ix; - -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_copy_page(%x, %x)", src, dst); -#endif - src >>= PG_SHIFT; - dst >>= PG_SHIFT; - ix = 0; - do { - physcopyseg(src++, dst++); - } while (++ix != i386pagesperpage); -} - - -/* - * Routine: pmap_pageable - * Function: - * Make the specified pages (by pmap, offset) - * pageable (or not) as requested. - * - * A page which is not pageable may not take - * a fault; therefore, its page table entry - * must remain valid for the duration. - * - * This routine is merely advisory; pmap_enter - * will specify that these pages are to be wired - * down (or not) as appropriate. - */ -pmap_pageable(pmap, sva, eva, pageable) - pmap_t pmap; - vm_offset_t sva, eva; - boolean_t pageable; -{ -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_pageable(%x, %x, %x, %x)", - pmap, sva, eva, pageable); -#endif - /* - * If we are making a PT page pageable then all valid - * mappings must be gone from that page. Hence it should - * be all zeros and there is no need to clean it. - * Assumptions: - * - we are called with only one page at a time - * - PT pages have only one pv_table entry - */ - if (pmap == kernel_pmap && pageable && sva + PAGE_SIZE == eva) { - register pv_entry_t pv; - register vm_offset_t pa; - -#ifdef DEBUG - if ((pmapdebug & (PDB_FOLLOW|PDB_PTPAGE)) == PDB_PTPAGE) - printf("pmap_pageable(%x, %x, %x, %x)", - pmap, sva, eva, pageable); -#endif - /*if (!pmap_pde_v(pmap_pde(pmap, sva))) - return;*/ - if(pmap_pte(pmap, sva) == 0) - return; - pa = pmap_pte_pa(pmap_pte(pmap, sva)); - if (pa < vm_first_phys || pa >= vm_last_phys) - return; - pv = pa_to_pvh(pa); - /*if (!ispt(pv->pv_va)) - return;*/ -#ifdef DEBUG - if (pv->pv_va != sva || pv->pv_next) { - pg("pmap_pageable: bad PT page va %x next %x\n", - pv->pv_va, pv->pv_next); - return; - } -#endif - /* - * Mark it unmodified to avoid pageout - */ - pmap_clear_modify(pa); -#ifdef needsomethinglikethis - if (pmapdebug & PDB_PTPAGE) - pg("pmap_pageable: PT page %x(%x) unmodified\n", - sva, *(int *)pmap_pte(pmap, sva)); - if (pmapdebug & PDB_WIRING) - pmap_check_wiring("pageable", sva); -#endif - } -} - -/* - * Clear the modify bits on the specified physical page. - */ - -void -pmap_clear_modify(pa) - vm_offset_t pa; -{ -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_clear_modify(%x)", pa); -#endif - pmap_changebit(pa, PG_M, FALSE); -} - -/* - * pmap_clear_reference: - * - * Clear the reference bit on the specified physical page. - */ - -void pmap_clear_reference(pa) - vm_offset_t pa; -{ -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) - printf("pmap_clear_reference(%x)", pa); -#endif - pmap_changebit(pa, PG_U, FALSE); -} - -/* - * pmap_is_referenced: - * - * Return whether or not the specified physical page is referenced - * by any physical maps. - */ - -boolean_t -pmap_is_referenced(pa) - vm_offset_t pa; -{ -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) { - boolean_t rv = pmap_testbit(pa, PG_U); - printf("pmap_is_referenced(%x) -> %c", pa, "FT"[rv]); - return(rv); - } -#endif - return(pmap_testbit(pa, PG_U)); -} - -/* - * pmap_is_modified: - * - * Return whether or not the specified physical page is modified - * by any physical maps. - */ - -boolean_t -pmap_is_modified(pa) - vm_offset_t pa; -{ -#ifdef DEBUG - if (pmapdebug & PDB_FOLLOW) { - boolean_t rv = pmap_testbit(pa, PG_M); - printf("pmap_is_modified(%x) -> %c", pa, "FT"[rv]); - return(rv); - } -#endif - return(pmap_testbit(pa, PG_M)); -} - -vm_offset_t -pmap_phys_address(ppn) - int ppn; -{ - return(i386_ptob(ppn)); -} - -/* - * Miscellaneous support routines follow - */ - -i386_protection_init() -{ - register int *kp, prot; - - kp = protection_codes; - for (prot = 0; prot < 8; prot++) { - switch (prot) { - case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_NONE: - *kp++ = 0; - break; - case VM_PROT_READ | VM_PROT_NONE | VM_PROT_NONE: - case VM_PROT_READ | VM_PROT_NONE | VM_PROT_EXECUTE: - case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_EXECUTE: - *kp++ = PG_RO; - break; - case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_NONE: - case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_EXECUTE: - case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_NONE: - case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE: - *kp++ = PG_RW; - break; - } - } -} - -boolean_t -pmap_testbit(pa, bit) - register vm_offset_t pa; - int bit; -{ - register pv_entry_t pv; - register int *pte, ix; - int s; - - if (pa < vm_first_phys || pa >= vm_last_phys) - return(FALSE); - - pv = pa_to_pvh(pa); - s = splimp(); - /* - * Check saved info first - */ - if (pmap_attributes[pa_index(pa)] & bit) { - splx(s); - return(TRUE); - } - /* - * Not found, check current mappings returning - * immediately if found. - */ - if (pv->pv_pmap != NULL) { - for (; pv; pv = pv->pv_next) { - pte = (int *) pmap_pte(pv->pv_pmap, pv->pv_va); - ix = 0; - do { - if (*pte++ & bit) { - splx(s); - return(TRUE); - } - } while (++ix != i386pagesperpage); - } - } - splx(s); - return(FALSE); -} - -pmap_changebit(pa, bit, setem) - register vm_offset_t pa; - int bit; - boolean_t setem; -{ - register pv_entry_t pv; - register int *pte, npte, ix; - vm_offset_t va; - int s; - boolean_t firstpage = TRUE; - -#ifdef DEBUG - if (pmapdebug & PDB_BITS) - printf("pmap_changebit(%x, %x, %s)", - pa, bit, setem ? "set" : "clear"); -#endif - if (pa < vm_first_phys || pa >= vm_last_phys) - return; - - pv = pa_to_pvh(pa); - s = splimp(); - /* - * Clear saved attributes (modify, reference) - */ - if (!setem) - pmap_attributes[pa_index(pa)] &= ~bit; - /* - * Loop over all current mappings setting/clearing as appropos - * If setting RO do we need to clear the VAC? - */ - if (pv->pv_pmap != NULL) { -#ifdef DEBUG - int toflush = 0; -#endif - for (; pv; pv = pv->pv_next) { -#ifdef DEBUG - toflush |= (pv->pv_pmap == kernel_pmap) ? 2 : 1; -#endif - va = pv->pv_va; - - /* - * XXX don't write protect pager mappings - */ - if (bit == PG_RO) { - extern vm_offset_t pager_sva, pager_eva; - - if (va >= pager_sva && va < pager_eva) - continue; - } - - pte = (int *) pmap_pte(pv->pv_pmap, va); - ix = 0; - do { - if (setem) - npte = *pte | bit; - else - npte = *pte & ~bit; - if (*pte != npte) { - *pte = npte; - /*TBIS(va);*/ - } - va += NBPG; - pte++; - } while (++ix != i386pagesperpage); - - if (curproc && pv->pv_pmap == &curproc->p_vmspace->vm_pmap) - pmap_activate(pv->pv_pmap, (struct pcb *)curproc->p_addr); - } -#ifdef somethinglikethis - if (setem && bit == PG_RO && (pmapvacflush & PVF_PROTECT)) { - if ((pmapvacflush & PVF_TOTAL) || toflush == 3) - DCIA(); - else if (toflush == 2) - DCIS(); - else - DCIU(); - } -#endif - } - splx(s); -} - -#ifdef DEBUG -pmap_pvdump(pa) - vm_offset_t pa; -{ - register pv_entry_t pv; - - printf("pa %x", pa); - for (pv = pa_to_pvh(pa); pv; pv = pv->pv_next) { - printf(" -> pmap %x, va %x, flags %x", - pv->pv_pmap, pv->pv_va, pv->pv_flags); - pads(pv->pv_pmap); - } - printf(" "); -} - -#ifdef notyet -pmap_check_wiring(str, va) - char *str; - vm_offset_t va; -{ - vm_map_entry_t entry; - register int count, *pte; - - va = trunc_page(va); - if (!pmap_pde_v(pmap_pde(kernel_pmap, va)) || - !pmap_pte_v(pmap_pte(kernel_pmap, va))) - return; - - if (!vm_map_lookup_entry(pt_map, va, &entry)) { - pg("wired_check: entry for %x not found\n", va); - return; - } - count = 0; - for (pte = (int *)va; pte < (int *)(va+PAGE_SIZE); pte++) - if (*pte) - count++; - if (entry->wired_count != count) - pg("*%s*: %x: w%d/a%d\n", - str, va, entry->wired_count, count); -} -#endif - -/* print address space of pmap*/ -pads(pm) pmap_t pm; { - unsigned va, i, j; - struct pte *ptep; - - if(pm == kernel_pmap) return; - for (i = 0; i < 1024; i++) - if(pm->pm_pdir[i].pd_v) - for (j = 0; j < 1024 ; j++) { - va = (i< UPT_MAX_ADDRESS) - continue; - ptep = pmap_pte(pm, va); - if(pmap_pte_v(ptep)) - printf("%x:%x ", va, *(int *)ptep); - } ; - -} -#endif diff --git a/sys/i386/i386/swapgeneric.c b/sys/i386/i386/swapgeneric.c deleted file mode 100644 index 8aa78a6..0000000 --- a/sys/i386/i386/swapgeneric.c +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)swapgeneric.c 5.5 (Berkeley) 5/9/91 - * $Id$ - */ - -#include "machine/pte.h" - -#include "sys/param.h" -#include "sys/conf.h" -#include "sys/buf.h" -#include "sys/vm.h" -#include "sys/systm.h" -#include "sys/reboot.h" - -/* - * Generic configuration; all in one - */ -dev_t rootdev = makedev(0,0); -dev_t dumpdev = makedev(0,1); -int nswap; -struct swdevt swdevt[] = { - { 1, 0, 0 }, - { 0, 1, 0 }, -}; -long dumplo; -int dmmin, dmmax, dmtext; - -extern struct driver wddriver; - -struct genericconf { - caddr_t gc_driver; - char *gc_name; - dev_t gc_root; -} genericconf[] = { - { (caddr_t)&wddriver, "wd", makedev(0, 0), }, - { 0 }, -}; - -setconf() -{ -#ifdef notdef - register struct genericconf *gc; - int unit, swaponroot = 0; - - if (rootdev != NODEV) - goto doswap; - if (boothowto & RB_ASKNAME) { - char name[128]; -retry: - printf("root device? "); - gets(name); - for (gc = genericconf; gc->gc_driver; gc++) - if (gc->gc_name[0] == name[0] && - gc->gc_name[1] == name[1]) - goto gotit; - goto bad; -gotit: - if (name[3] == '*') { - name[3] = name[4]; - swaponroot++; - } - if (name[2] >= '0' && name[2] <= '7' && name[3] == 0) { - unit = name[2] - '0'; - goto found; - } - printf("bad/missing unit number\n"); -bad: - printf("use dk%%d\n"); - goto retry; - } - unit = 0; - for (gc = genericconf; gc->gc_driver; gc++) { - for (ui = vbdinit; ui->ui_driver; ui++) { - if (ui->ui_alive == 0) - continue; - if (ui->ui_unit == 0 && ui->ui_driver == - (struct vba_driver *)gc->gc_driver) { - printf("root on %s0\n", - ui->ui_driver->ud_dname); - goto found; - } - } - } - printf("no suitable root\n"); - asm("halt"); -found: - gc->gc_root = makedev(major(gc->gc_root), unit*8); - rootdev = gc->gc_root; -doswap: - swdevt[0].sw_dev = argdev = dumpdev = - makedev(major(rootdev), minor(rootdev)+1); - /* swap size and dumplo set during autoconfigure */ - if (swaponroot) - rootdev = dumpdev; -#endif -} - -gets(cp) - char *cp; -{ - register char *lp; - register c; - - lp = cp; - for (;;) { - printf("%c", c = cngetc()&0177); - switch (c) { - case '\n': - case '\r': - *lp++ = '\0'; - return; - case '\b': - case '\177': - if (lp > cp) { - printf(" \b"); - lp--; - } - continue; - case '#': - lp--; - if (lp < cp) - lp = cp; - continue; - case '@': - case 'u'&037: - lp = cp; - printf("%c", '\n'); - continue; - default: - *lp++ = c; - } - } -} diff --git a/sys/i386/i386/symbols.raw b/sys/i386/i386/symbols.raw deleted file mode 100644 index 0f5bafd..0000000 --- a/sys/i386/i386/symbols.raw +++ /dev/null @@ -1,84 +0,0 @@ -# @(#)symbols.raw 7.6 (Berkeley) 5/8/91 -# -# $Id$ -# - - -#gdb - _IdlePTD - _PTD - _curpcb - _kstack - _panicstr - _atdevbase -# _version -#dmesg - _msgbufp -# _msgbuf -#iostat - _dk_busy - _dk_time - _dk_xfer - _dk_wds - _tk_nin - _tk_nout - _dk_seek - _cp_time - _dk_wpms -# _io_info -#ps - _nswap - _maxslp - _ccpu - _fscale - _avail_start - _avail_end -#pstat -# _cons - _nswap - _swapmap -#vmstat - _cp_time - _rate - _total - _sum -# _rectime -# _pgintime - _dk_xfer - _boottime -#w - _swapdev - _nswap - _averunnable - _boottime -#netstat - _mbstat - _ipstat - _tcb - _tcpstat - _udb - _udpstat - _rawcb - _Sysmap - _ifnet - _rthost - _rtnet - _icmpstat - _filehead - _nfiles - _rthashsize - _radix_node_head -#routed - _ifnet -#rwho - _boottime -#savecore - _dumpdev - _dumplo - _version - _time - _dumpsize - _panicstr - _dumpmag -#deprecated -# _avenrun diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c deleted file mode 100644 index 2b63cee..0000000 --- a/sys/i386/i386/sys_machdep.c +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 - * $Id$ - */ - -#include "param.h" -#include "systm.h" -#include "ioctl.h" -#include "file.h" -#include "time.h" -#include "proc.h" -#include "uio.h" -#include "kernel.h" -#include "mtio.h" -#include "buf.h" -#include "trace.h" - -#ifdef TRACE -int nvualarm; - -struct vtrace_args { - int request; - int value; -}; - -vtrace(p, uap, retval) - struct proc *p; - register struct vtrace_args *uap; - int *retval; -{ - int vdoualarm(); - - switch (uap->request) { - - case VTR_DISABLE: /* disable a trace point */ - case VTR_ENABLE: /* enable a trace point */ - if (uap->value < 0 || uap->value >= TR_NFLAGS) - return (EINVAL); - *retval = traceflags[uap->value]; - traceflags[uap->value] = uap->request; - break; - - case VTR_VALUE: /* return a trace point setting */ - if (uap->value < 0 || uap->value >= TR_NFLAGS) - return (EINVAL); - *retval = traceflags[uap->value]; - break; - - case VTR_UALARM: /* set a real-time ualarm, less than 1 min */ - if (uap->value <= 0 || uap->value > 60 * hz || nvualarm > 5) - return (EINVAL); - nvualarm++; - timeout(vdoualarm, (caddr_t)p->p_pid, uap->value); - break; - - case VTR_STAMP: - trace(TR_STAMP, uap->value, p->p_pid); - break; - } - return (0); -} - -vdoualarm(arg) - int arg; -{ - register struct proc *p; - - p = pfind(arg); - if (p) - psignal(p, 16); - nvualarm--; -} -#endif diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c deleted file mode 100644 index 989a732..0000000 --- a/sys/i386/i386/trap.c +++ /dev/null @@ -1,585 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the University of Utah, and William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id$ - */ - -/* - * 386 Trap and System call handleing - */ - -#include "npx.h" -#include "machine/cpu.h" -#include "machine/psl.h" -#include "machine/reg.h" - -#include "param.h" -#include "systm.h" -#include "proc.h" -#include "user.h" -#include "acct.h" -#include "kernel.h" -#ifdef KTRACE -#include "ktrace.h" -#endif - -#include "vm/vm_param.h" -#include "vm/pmap.h" -#include "vm/vm_map.h" -#include "sys/vmmeter.h" - -#include "machine/trap.h" - -#ifdef __GNUC__ - -/* - * The "r" contraint could be "rm" except for fatal bugs in gas. As usual, - * we omit the size from the mov instruction to avoid nonfatal bugs in gas. - */ -#define read_gs() ({ u_short gs; __asm("mov %%gs,%0" : "=r" (gs)); gs; }) -#define write_gs(gs) __asm("mov %0,%%gs" : : "r" ((u_short) gs)) - -#else /* not __GNUC__ */ - -u_short read_gs __P((void)); -void write_gs __P((/* promoted u_short */ int gs)); - -#endif /* __GNUC__ */ - -struct sysent sysent[]; -int nsysent; -int dostacklimits; -unsigned rcr2(); -extern short cpl; - - -/* - * trap(frame): - * Exception, fault, and trap interface to BSD kernel. This - * common code is called from assembly language IDT gate entry - * routines that prepare a suitable stack frame, and restore this - * frame after the exception has been processed. Note that the - * effect is as if the arguments were passed call by reference. - */ - -/*ARGSUSED*/ -trap(frame) - struct trapframe frame; -{ - register int i; - register struct proc *p = curproc; - struct timeval syst; - int ucode, type, code, eva; - - frame.tf_eflags &= ~PSL_NT; /* clear nested trap XXX */ - type = frame.tf_trapno; -#include "ddb.h" -#if NDDB > 0 - if (curpcb && curpcb->pcb_onfault) { - if (frame.tf_trapno == T_BPTFLT - || frame.tf_trapno == T_TRCTRAP) - if (kdb_trap (type, 0, &frame)) - return; - } -#endif - -/*pg("trap type %d code = %x eip = %x cs = %x eva = %x esp %x", - frame.tf_trapno, frame.tf_err, frame.tf_eip, - frame.tf_cs, rcr2(), frame.tf_esp);*/ -if(curpcb == 0 || curproc == 0) goto we_re_toast; - if (curpcb->pcb_onfault && frame.tf_trapno != T_PAGEFLT) { - extern int _udatasel; - - if (read_gs() != (u_short) _udatasel) - /* - * Some user has corrupted %gs but we depend on it in - * copyout() etc. Fix it up and retry. - * - * (We don't preserve %fs or %gs, so users can change - * them to either _ucodesel, _udatasel or a not-present - * selector, possibly ORed with 0 to 3, making them - * volatile for other users. Not preserving them saves - * time and doesn't lose functionality or open security - * holes.) - */ - write_gs(_udatasel); - else -copyfault: - frame.tf_eip = (int)curpcb->pcb_onfault; - return; - } - - syst = p->p_stime; - if (ISPL(frame.tf_cs) == SEL_UPL) { - type |= T_USER; - p->p_regs = (int *)&frame; - curpcb->pcb_flags |= FM_TRAP; /* used by sendsig */ - } - - ucode=0; - eva = rcr2(); - code = frame.tf_err; - switch (type) { - - default: - we_re_toast: -#ifdef KDB - if (kdb_trap(&psl)) - return; -#endif -#if NDDB > 0 - if (kdb_trap (type, 0, &frame)) - return; -#endif - - printf("trap type %d code = %x eip = %x cs = %x eflags = %x ", - frame.tf_trapno, frame.tf_err, frame.tf_eip, - frame.tf_cs, frame.tf_eflags); - eva = rcr2(); - printf("cr2 %x cpl %x\n", eva, cpl); - /* type &= ~T_USER; */ /* XXX what the hell is this */ - panic("trap"); - /*NOTREACHED*/ - - case T_SEGNPFLT|T_USER: - case T_STKFLT|T_USER: - case T_PROTFLT|T_USER: /* protection fault */ - ucode = code + BUS_SEGM_FAULT ; - i = SIGBUS; - break; - - case T_PRIVINFLT|T_USER: /* privileged instruction fault */ - case T_RESADFLT|T_USER: /* reserved addressing fault */ - case T_RESOPFLT|T_USER: /* reserved operand fault */ - case T_FPOPFLT|T_USER: /* coprocessor operand fault */ - ucode = type &~ T_USER; - i = SIGILL; - break; - - case T_ASTFLT|T_USER: /* Allow process switch */ - astoff(); - cnt.v_soft++; - if ((p->p_flag & SOWEUPC) && p->p_stats->p_prof.pr_scale) { - addupc(frame.tf_eip, &p->p_stats->p_prof, 1); - p->p_flag &= ~SOWEUPC; - } - goto out; - - case T_DNA|T_USER: -#if NNPX > 0 - /* if a transparent fault (due to context switch "late") */ - if (npxdna()) return; -#endif /* NNPX > 0 */ -#ifdef MATH_EMULATE - i = math_emulate(&frame); - if (i == 0) return; -#else /* MATH_EMULTATE */ - panic("trap: math emulation necessary!"); -#endif /* MATH_EMULTATE */ - ucode = FPE_FPU_NP_TRAP; - break; - - case T_BOUND|T_USER: - ucode = FPE_SUBRNG_TRAP; - i = SIGFPE; - break; - - case T_OFLOW|T_USER: - ucode = FPE_INTOVF_TRAP; - i = SIGFPE; - break; - - case T_DIVIDE|T_USER: - ucode = FPE_INTDIV_TRAP; - i = SIGFPE; - break; - - case T_ARITHTRAP|T_USER: - ucode = code; - i = SIGFPE; - break; - - case T_PAGEFLT: /* allow page faults in kernel mode */ -#if 0 - /* XXX - check only applies to 386's and 486's with WP off */ - if (code & PGEX_P) goto we_re_toast; -#endif - - /* fall into */ - case T_PAGEFLT|T_USER: /* page fault */ - { - register vm_offset_t va; - register struct vmspace *vm = p->p_vmspace; - register vm_map_t map; - int rv; - vm_prot_t ftype; - extern vm_map_t kernel_map; - unsigned nss,v; - - va = trunc_page((vm_offset_t)eva); - /* - * 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 space fault - * The last can occur during an exec() copyin where the - * argument space is lazy-allocated. - */ - if (type == T_PAGEFLT && va >= KERNBASE) - map = kernel_map; - else - map = &vm->vm_map; - if (code & PGEX_W) - ftype = VM_PROT_READ | VM_PROT_WRITE; - else - ftype = VM_PROT_READ; - -#ifdef DEBUG - if (map == kernel_map && va == 0) { - printf("trap: bad kernel access at %x\n", va); - goto we_re_toast; - } -#endif - - /* - * XXX: rude hack to make stack limits "work" - */ - nss = 0; - if ((caddr_t)va >= vm->vm_maxsaddr && map != kernel_map - && dostacklimits) { - nss = clrnd(btoc((unsigned)vm->vm_maxsaddr - + MAXSSIZ - (unsigned)va)); - if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur)) { -/*pg("trap rlimit %d, maxsaddr %x va %x ", nss, vm->vm_maxsaddr, va);*/ - rv = KERN_FAILURE; - goto nogo; - } - } - - /* check if page table is mapped, if not, fault it first */ -#define pde_v(v) (PTD[((v)>>PD_SHIFT)&1023].pd_v) - if (!pde_v(va)) { - v = trunc_page(vtopte(va)); - rv = vm_fault(map, v, ftype, FALSE); - if (rv != KERN_SUCCESS) goto nogo; - /* check if page table fault, increment wiring */ - vm_map_pageable(map, v, round_page(v+1), FALSE); - } else v=0; - rv = vm_fault(map, va, ftype, FALSE); - if (rv == KERN_SUCCESS) { - /* - * XXX: continuation of rude stack hack - */ - if (nss > vm->vm_ssize) - vm->vm_ssize = nss; - va = trunc_page(vtopte(va)); - /* for page table, increment wiring - as long as not a page table fault as well */ - if (!v && type != T_PAGEFLT) - vm_map_pageable(map, va, round_page(va+1), FALSE); - if (type == T_PAGEFLT) - return; - goto out; - } -nogo: - if (type == T_PAGEFLT) { - if (curpcb->pcb_onfault) - goto copyfault; - printf("vm_fault(%x, %x, %x, 0) -> %x\n", - map, va, ftype, rv); - printf(" type %x, code %x\n", - type, code); - goto we_re_toast; - } - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; - break; - } - -#if NDDB == 0 - case T_TRCTRAP: /* trace trap -- someone single stepping lcall's */ - frame.tf_eflags &= ~PSL_T; - - /* Q: how do we turn it on again? */ - return; -#endif - - case T_BPTFLT|T_USER: /* bpt instruction fault */ - case T_TRCTRAP|T_USER: /* trace trap */ - frame.tf_eflags &= ~PSL_T; - i = SIGTRAP; - break; - -#include "isa.h" -#if NISA > 0 - case T_NMI: - case T_NMI|T_USER: -#if NDDB > 0 - /* NMI can be hooked up to a pushbutton for debugging */ - printf ("NMI ... going to debugger\n"); - if (kdb_trap (type, 0, &frame)) - return; -#endif - /* machine/parity/power fail/"kitchen sink" faults */ - if(isa_nmi(code) == 0) return; - else goto we_re_toast; -#endif - } - - trapsignal(p, i, ucode); - if ((type & T_USER) == 0) - return; -out: - while (i = CURSIG(p)) - psig(i); - p->p_pri = p->p_usrpri; - if (want_resched) { - /* - * Since we are curproc, clock will normally just change - * our priority without moving us from one queue to another - * (since the running process is not on a queue.) - * If that happened after we setrq ourselves but before we - * swtch()'ed, we might not be on the queue indicated by - * our priority. - */ - (void) splclock(); - setrq(p); - p->p_stats->p_ru.ru_nivcsw++; - swtch(); - (void) splnone(); - while (i = CURSIG(p)) - psig(i); - } - if (p->p_stats->p_prof.pr_scale) { - int ticks; - struct timeval *tv = &p->p_stime; - - ticks = ((tv->tv_sec - syst.tv_sec) * 1000 + - (tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000); - if (ticks) { -#ifdef PROFTIMER - extern int profscale; - addupc(frame.tf_eip, &p->p_stats->p_prof, - ticks * profscale); -#else - addupc(frame.tf_eip, &p->p_stats->p_prof, ticks); -#endif - } - } - curpri = p->p_pri; - curpcb->pcb_flags &= ~FM_TRAP; /* used by sendsig */ -} - -/* - * Compensate for 386 brain damage (missing URKR). - * This is a little simpler than the pagefault handler in trap() because - * it the page tables have already been faulted in and high addresses - * are thrown out early for other reasons. - */ -int trapwrite(addr) - unsigned addr; -{ - unsigned nss; - struct proc *p; - vm_offset_t va; - struct vmspace *vm; - - va = trunc_page((vm_offset_t)addr); - /* - * XXX - MAX is END. Changed > to >= for temp. fix. - */ - if (va >= VM_MAXUSER_ADDRESS) - return (1); - /* - * XXX: rude stack hack adapted from trap(). - */ - nss = 0; - p = curproc; - vm = p->p_vmspace; - if ((caddr_t)va >= vm->vm_maxsaddr && dostacklimits) { - nss = clrnd(btoc((unsigned)vm->vm_maxsaddr + MAXSSIZ - - (unsigned)va)); - if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur)) - return (1); - } - - if (vm_fault(&vm->vm_map, va, VM_PROT_READ | VM_PROT_WRITE, FALSE) - != KERN_SUCCESS) - return (1); - - /* - * XXX: continuation of rude stack hack - */ - if (nss > vm->vm_ssize) - vm->vm_ssize = nss; - - return (0); -} - -/* - * syscall(frame): - * System call request from POSIX system call gate interface to kernel. - * Like trap(), argument is call by reference. - */ -/*ARGSUSED*/ -syscall(frame) - volatile struct syscframe frame; -{ - register int *locr0 = ((int *)&frame); - register caddr_t params; - register int i; - register struct sysent *callp; - register struct proc *p = curproc; - struct timeval syst; - int error, opc; - int args[8], rval[2]; - int code; - -#ifdef lint - r0 = 0; r0 = r0; r1 = 0; r1 = r1; -#endif - syst = p->p_stime; - if (ISPL(frame.sf_cs) != SEL_UPL) - panic("syscall"); - - code = frame.sf_eax; - curpcb->pcb_flags &= ~FM_TRAP; /* used by sendsig */ - p->p_regs = (int *)&frame; - params = (caddr_t)frame.sf_esp + sizeof (int) ; - - /* - * Reconstruct pc, assuming lcall $X,y is 7 bytes, as it is always. - */ - opc = frame.sf_eip - 7; - callp = (code >= nsysent) ? &sysent[63] : &sysent[code]; - if (callp == sysent) { - i = fuword(params); - params += sizeof (int); - callp = (code >= nsysent) ? &sysent[63] : &sysent[code]; - } - - if ((i = callp->sy_narg * sizeof (int)) && - (error = copyin(params, (caddr_t)args, (u_int)i))) { - frame.sf_eax = error; - frame.sf_eflags |= PSL_C; /* carry bit */ -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, callp->sy_narg, &args); -#endif - goto done; - } -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, callp->sy_narg, &args); -#endif - rval[0] = 0; - rval[1] = frame.sf_edx; -/*pg("%d. s %d\n", p->p_pid, code);*/ - error = (*callp->sy_call)(p, args, rval); - if (error == ERESTART) - frame.sf_eip = opc; - else if (error != EJUSTRETURN) { - if (error) { -/*pg("error %d", error);*/ - frame.sf_eax = error; - frame.sf_eflags |= PSL_C; /* carry bit */ - } else { - frame.sf_eax = rval[0]; - frame.sf_edx = rval[1]; - frame.sf_eflags &= ~PSL_C; /* carry bit */ - } - } - /* else if (error == EJUSTRETURN) */ - /* nothing to do */ -done: - /* - * Reinitialize proc pointer `p' as it may be different - * if this is a child returning from fork syscall. - */ - p = curproc; - while (i = CURSIG(p)) - psig(i); - p->p_pri = p->p_usrpri; - if (want_resched) { - /* - * Since we are curproc, clock will normally just change - * our priority without moving us from one queue to another - * (since the running process is not on a queue.) - * If that happened after we setrq ourselves but before we - * swtch()'ed, we might not be on the queue indicated by - * our priority. - */ - (void) splclock(); - setrq(p); - p->p_stats->p_ru.ru_nivcsw++; - swtch(); - (void) splnone(); - while (i = CURSIG(p)) - psig(i); - } - if (p->p_stats->p_prof.pr_scale) { - int ticks; - struct timeval *tv = &p->p_stime; - - ticks = ((tv->tv_sec - syst.tv_sec) * 1000 + - (tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000); - if (ticks) { -#ifdef PROFTIMER - extern int profscale; - addupc(frame.sf_eip, &p->p_stats->p_prof, - ticks * profscale); -#else - addupc(frame.sf_eip, &p->p_stats->p_prof, ticks); -#endif - } - } - curpri = p->p_pri; -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) - ktrsysret(p->p_tracep, code, error, rval[0]); -#endif -#ifdef DIAGNOSTICx -{ extern int _udatasel, _ucodesel; - if (frame.sf_ss != _udatasel) - printf("ss %x call %d\n", frame.sf_ss, code); - if ((frame.sf_cs&0xffff) != _ucodesel) - printf("cs %x call %d\n", frame.sf_cs, code); - if (frame.sf_eip > VM_MAXUSER_ADDRESS) { - printf("eip %x call %d\n", frame.sf_eip, code); - frame.sf_eip = 0; - } -} -#endif -} diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c deleted file mode 100644 index 53497c8..0000000 --- a/sys/i386/i386/tsc.c +++ /dev/null @@ -1,252 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz and Don Ahn. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id$ - */ - -/* - * Primitive clock interrupt routines. - */ -#include "param.h" -#include "systm.h" -#include "time.h" -#include "kernel.h" -#include "machine/segments.h" -#include "i386/isa/icu.h" -#include "i386/isa/isa.h" -#include "i386/isa/rtc.h" -#include "i386/isa/timerreg.h" - -#define DAYST 119 -#define DAYEN 303 - -/* X-tals being what they are, it's nice to be able to fudge this one... */ -/* Note, the name changed here from XTALSPEED to TIMER_FREQ rgrimes 4/26/93 */ -#ifndef TIMER_FREQ -#define TIMER_FREQ 1193182 /* XXX - should be in isa.h */ -#endif - -startrtclock() { - int s; - - findcpuspeed(); /* use the clock (while it's free) - to find the cpu speed */ - /* initialize 8253 clock */ - outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT); - - /* Correct rounding will buy us a better precision in timekeeping */ - outb (IO_TIMER1, (TIMER_FREQ+hz/2)/hz); - outb (IO_TIMER1, ((TIMER_FREQ+hz/2)/hz)/256); - - /* initialize brain-dead battery powered clock */ - outb (IO_RTC, RTC_STATUSA); - outb (IO_RTC+1, 0x26); - outb (IO_RTC, RTC_STATUSB); - outb (IO_RTC+1, 2); - - outb (IO_RTC, RTC_DIAG); - if (s = inb (IO_RTC+1)) - printf("RTC BIOS diagnostic error %b\n", s, RTCDG_BITS); - outb (IO_RTC, RTC_DIAG); - outb (IO_RTC+1, 0); -} - -unsigned int delaycount; /* calibrated loop variable (1 millisecond) */ - -#define FIRST_GUESS 0x2000 -findcpuspeed() -{ - unsigned char low; - unsigned int remainder; - - /* Put counter in count down mode */ - outb(IO_TIMER1+3, 0x34); - outb(IO_TIMER1, 0xff); - outb(IO_TIMER1, 0xff); - delaycount = FIRST_GUESS; - spinwait(1); - /* Read the value left in the counter */ - low = inb(IO_TIMER1); /* least siginifcant */ - remainder = inb(IO_TIMER1); /* most significant */ - remainder = (remainder<<8) + low ; - /* Formula for delaycount is : - * (loopcount * timer clock speed)/ (counter ticks * 1000) - */ - delaycount = (FIRST_GUESS * (TIMER_FREQ/1000)) / (0xffff-remainder); -} - - -/* convert 2 digit BCD number */ -bcd(i) -int i; -{ - return ((i/16)*10 + (i%16)); -} - -/* convert years to seconds (from 1970) */ -unsigned long -ytos(y) -int y; -{ - int i; - unsigned long ret; - - ret = 0; - for(i = 1970; i < y; i++) { - if (i % 4) ret += 365*24*60*60; - else ret += 366*24*60*60; - } - return ret; -} - -/* convert months to seconds */ -unsigned long -mtos(m,leap) -int m,leap; -{ - int i; - unsigned long ret; - - ret = 0; - for(i=1;i= DAYST) && ( yd <= DAYEN)) { - sec -= 60*60; - } - sec += tz.tz_minuteswest * 60; - - time.tv_sec = sec; -} - -#ifdef garbage -/* - * Initialze the time of day register, based on the time base which is, e.g. - * from a filesystem. - */ -test_inittodr(base) - time_t base; -{ - - outb(IO_RTC,9); /* year */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,8); /* month */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,7); /* day */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,4); /* hour */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,2); /* minutes */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,0); /* seconds */ - printf("%d\n",bcd(inb(IO_RTC+1))); - - time.tv_sec = base; -} -#endif - -/* - * Restart the clock. - */ -resettodr() -{ -} - -/* - * Wire clock interrupt in. - */ -#define V(s) __CONCAT(V, s) -extern V(clk)(); -enablertclock() { - setidt(ICU_OFFSET+0, &V(clk), SDT_SYS386IGT, SEL_KPL); - INTREN(IRQ0); -} - -/* - * Delay for some number of milliseconds. - */ -void -spinwait(millisecs) - int millisecs; -{ - DELAY(1000 * millisecs); -} diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c deleted file mode 100644 index 3807721..0000000 --- a/sys/i386/i386/vm_machdep.c +++ /dev/null @@ -1,415 +0,0 @@ -/*- - * Copyright (c) 1982, 1986 The Regents of the University of California. - * Copyright (c) 1989, 1990 William Jolitz - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department, and William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 - * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ - * $Id$ - */ - -#include "npx.h" -#include "param.h" -#include "systm.h" -#include "proc.h" -#include "malloc.h" -#include "buf.h" -#include "user.h" - -#include "../include/cpu.h" - -#include "vm/vm.h" -#include "vm/vm_kern.h" - -/* - * 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. - */ -cpu_fork(p1, p2) - register struct proc *p1, *p2; -{ - register struct user *up = p2->p_addr; - int foo, offset, addr, i; - extern char kstack[]; - extern int mvesp(); - - /* - * Copy pcb and stack from proc p1 to p2. - * We do this as cheaply as possible, copying only the active - * part of the stack. The stack and pcb need to agree; - * this is tricky, as the final pcb is constructed by savectx, - * but its frame isn't yet on the stack when the stack is copied. - * swtch compensates for this when the child eventually runs. - * This should be done differently, with a single call - * that copies and updates the pcb+stack, - * replacing the bcopy and savectx. - */ - p2->p_addr->u_pcb = p1->p_addr->u_pcb; - offset = mvesp() - (int)kstack; - bcopy((caddr_t)kstack + offset, (caddr_t)p2->p_addr + offset, - (unsigned) ctob(UPAGES) - offset); - p2->p_regs = p1->p_regs; - - /* - * Wire top of address space of child to it's kstack. - * First, fault in a page of pte's to map it. - */ - addr = trunc_page((u_int)vtopte(kstack)); - vm_map_pageable(&p2->p_vmspace->vm_map, addr, addr+NBPG, FALSE); - for (i=0; i < UPAGES; i++) - pmap_enter(&p2->p_vmspace->vm_pmap, kstack+i*NBPG, - pmap_extract(kernel_pmap, ((int)p2->p_addr)+i*NBPG), - /* - * The user area has to be mapped writable because - * it contains the kernel stack (when CR0_WP is on - * on a 486 there is no user-read/kernel-write - * mode). It is protected from user mode access - * by the segment limits. - */ - VM_PROT_READ|VM_PROT_WRITE, TRUE); - pmap_activate(&p2->p_vmspace->vm_pmap, &up->u_pcb); - - /* - * - * Arrange for a non-local goto when the new process - * is started, to resume here, returning nonzero from setjmp. - */ - if (savectx(up, 1)) { - /* - * Return 1 in child. - */ - return (1); - } - return (0); -} - -#ifdef notyet -/* - * cpu_exit is called as the last action during exit. - * - * We change to an inactive address space and a "safe" stack, - * passing thru an argument to the new stack. Now, safely isolated - * from the resources we're shedding, we release the address space - * and any remaining machine-dependent resources, including the - * memory for the user structure and kernel stack. - * - * Next, we assign a dummy context to be written over by swtch, - * calling it to send this process off to oblivion. - * [The nullpcb allows us to minimize cost in swtch() by not having - * a special case]. - */ -struct proc *swtch_to_inactive(); -volatile void -cpu_exit(p) - register struct proc *p; -{ - static struct pcb nullpcb; /* pcb to overwrite on last swtch */ - -#if NNPX > 0 - npxexit(p); -#endif /* NNPX */ - - /* move to inactive space and stack, passing arg accross */ - p = swtch_to_inactive(p); - - /* drop per-process resources */ - vmspace_free(p->p_vmspace); - kmem_free(kernel_map, (vm_offset_t)p->p_addr, ctob(UPAGES)); - - p->p_addr = (struct user *) &nullpcb; - splclock(); - swtch(); - /* NOTREACHED */ -} -#else -void -cpu_exit(p) - register struct proc *p; -{ - -#if NNPX > 0 - npxexit(p); -#endif /* NNPX */ - splclock(); - swtch(); - /* - * This is to shutup the compiler, and if swtch() failed I suppose - * this would be a good thing. This keeps gcc happy because panic - * is a volatile void function as well. - */ - panic("cpu_exit"); -} - -cpu_wait(p) struct proc *p; { - - /* drop per-process resources */ - vmspace_free(p->p_vmspace); - kmem_free(kernel_map, (vm_offset_t)p->p_addr, ctob(UPAGES)); -} -#endif - -/* - * Set a red zone in the kernel stack after the u. area. - */ -setredzone(pte, vaddr) - u_short *pte; - caddr_t vaddr; -{ -/* eventually do this by setting up an expand-down stack segment - for ss0: selector, allowing stack access down to top of u. - this means though that protection violations need to be handled - thru a double fault exception that must do an integral task - switch to a known good context, within which a dump can be - taken. a sensible scheme might be to save the initial context - used by sched (that has physical memory mapped 1:1 at bottom) - and take the dump while still in mapped mode */ -} - -/* - * Move pages from one kernel virtual address to another. - * Both addresses are assumed to reside in the Sysmap, - * and size must be a multiple of CLSIZE. - */ -pagemove(from, to, size) - register caddr_t from, to; - int size; -{ - register struct pte *fpte, *tpte; - - if (size % CLBYTES) - panic("pagemove"); - fpte = kvtopte(from); - tpte = kvtopte(to); - while (size > 0) { - *tpte++ = *fpte; - *(int *)fpte++ = 0; - from += NBPG; - to += NBPG; - size -= NBPG; - } - tlbflush(); -} - -/* - * Convert kernel VA to physical address - */ -kvtop(addr) - register caddr_t addr; -{ - vm_offset_t va; - - va = pmap_extract(kernel_pmap, (vm_offset_t)addr); - if (va == 0) - panic("kvtop: zero page frame"); - return((int)va); -} - -#ifdef notdef -/* - * The probe[rw] routines should probably be redone in assembler - * for efficiency. - */ -prober(addr) - register u_int addr; -{ - register int page; - register struct proc *p; - - if (addr >= USRSTACK) - return(0); - p = u.u_procp; - page = btop(addr); - if (page < dptov(p, p->p_dsize) || page > sptov(p, p->p_ssize)) - return(1); - return(0); -} - -probew(addr) - register u_int addr; -{ - register int page; - register struct proc *p; - - if (addr >= USRSTACK) - return(0); - p = u.u_procp; - page = btop(addr); - if (page < dptov(p, p->p_dsize) || page > sptov(p, p->p_ssize)) - return((*(int *)vtopte(p, page) & PG_PROT) == PG_UW); - return(0); -} - -/* - * NB: assumes a physically contiguous kernel page table - * (makes life a LOT simpler). - */ -kernacc(addr, count, rw) - register u_int addr; - int count, rw; -{ - register struct pde *pde; - register struct pte *pte; - register int ix, cnt; - extern long Syssize; - - if (count <= 0) - return(0); - pde = (struct pde *)((u_int)u.u_procp->p_p0br + u.u_procp->p_szpt * NBPG); - ix = (addr & PD_MASK) >> PD_SHIFT; - cnt = ((addr + count + (1 << PD_SHIFT) - 1) & PD_MASK) >> PD_SHIFT; - cnt -= ix; - for (pde += ix; cnt; cnt--, pde++) - if (pde->pd_v == 0) - return(0); - ix = btop(addr-KERNBASE); - cnt = btop(addr-KERNBASE+count+NBPG-1); - if (cnt > (int)&Syssize) - return(0); - cnt -= ix; - for (pte = &Sysmap[ix]; cnt; cnt--, pte++) - if (pte->pg_v == 0 /*|| (rw == B_WRITE && pte->pg_prot == 1)*/) - return(0); - return(1); -} - -useracc(addr, count, rw) - register u_int addr; - int count, rw; -{ - register int (*func)(); - register u_int addr2; - extern int prober(), probew(); - - if (count <= 0) - return(0); - addr2 = addr; - addr += count; - func = (rw == B_READ) ? prober : probew; - do { - if ((*func)(addr2) == 0) - return(0); - addr2 = (addr2 + NBPG) & ~PGOFSET; - } while (addr2 < addr); - return(1); -} -#endif - -extern vm_map_t phys_map; - -/* - * Map an IO request into kernel virtual address space. Requests fall into - * one of five catagories: - * - * B_PHYS|B_UAREA: User u-area swap. - * Address is relative to start of u-area (p_addr). - * B_PHYS|B_PAGET: User page table swap. - * Address is a kernel VA in usrpt (Usrptmap). - * B_PHYS|B_DIRTY: Dirty page push. - * Address is a VA in proc2's address space. - * B_PHYS|B_PGIN: Kernel pagein of user pages. - * Address is VA in user's address space. - * B_PHYS: User "raw" IO request. - * Address is VA in user's address space. - * - * All requests are (re)mapped into kernel VA space via the useriomap - * (a name with only slightly more meaning than "kernelmap") - */ -vmapbuf(bp) - register struct buf *bp; -{ - register int npf; - register caddr_t addr; - register long flags = bp->b_flags; - struct proc *p; - int off; - vm_offset_t kva; - register vm_offset_t pa; - - if ((flags & B_PHYS) == 0) - panic("vmapbuf"); - addr = bp->b_saveaddr = bp->b_un.b_addr; - off = (int)addr & PGOFSET; - p = bp->b_proc; - npf = btoc(round_page(bp->b_bcount + off)); - kva = kmem_alloc_wait(phys_map, ctob(npf)); - bp->b_un.b_addr = (caddr_t) (kva + off); - while (npf--) { - pa = pmap_extract(&p->p_vmspace->vm_pmap, (vm_offset_t)addr); - if (pa == 0) - panic("vmapbuf: null page frame"); - pmap_enter(vm_map_pmap(phys_map), kva, trunc_page(pa), - VM_PROT_READ|VM_PROT_WRITE, TRUE); - addr += PAGE_SIZE; - kva += PAGE_SIZE; - } -} - -/* - * Free the io map PTEs associated with this IO operation. - * We also invalidate the TLB entries and restore the original b_addr. - */ -vunmapbuf(bp) - register struct buf *bp; -{ - register int npf; - register caddr_t addr = bp->b_un.b_addr; - vm_offset_t kva; - - if ((bp->b_flags & B_PHYS) == 0) - panic("vunmapbuf"); - npf = btoc(round_page(bp->b_bcount + ((int)addr & PGOFSET))); - kva = (vm_offset_t)((int)addr & ~PGOFSET); - kmem_free_wakeup(phys_map, kva, ctob(npf)); - bp->b_un.b_addr = bp->b_saveaddr; - bp->b_saveaddr = NULL; -} - -/* - * Force reset the processor by invalidating the entire address space! - */ -cpu_reset() { - - /* force a shutdown by unmapping entire address space ! */ - bzero((caddr_t) PTD, NBPG); - - /* "good night, sweet prince .... " */ - tlbflush(); - /* NOTREACHED */ -} diff --git a/sys/i386/include/_limits.h b/sys/i386/include/_limits.h deleted file mode 100644 index 82fac5f..0000000 --- a/sys/i386/include/_limits.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1988 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)limits.h 7.2 (Berkeley) 6/28/90 - * $Id$ - */ - -#define CHAR_BIT 8 /* number of bits in a char */ -#define CLK_TCK 60 /* ticks per second */ -#define MB_LEN_MAX 1 /* no multibyte characters */ - -#define SCHAR_MIN (-0x7f-1) /* max value for a signed char */ -#define SCHAR_MAX 0x7f /* min value for a signed char */ - -#define UCHAR_MAX 0xff /* max value for an unsigned char */ -#define CHAR_MAX 0x7f /* max value for a char */ -#define CHAR_MIN (-0x7f-1) /* min value for a char */ - -#define USHRT_MAX 0xffff /* max value for an unsigned short */ -#define SHRT_MAX 0x7fff /* max value for a short */ -#define SHRT_MIN (-0x7fff-1) /* min value for a short */ - -#define UINT_MAX 0xffffffff /* max value for an unsigned int */ -#define INT_MAX 0x7fffffff /* max value for an int */ -#define INT_MIN (-0x7fffffff-1) /* min value for an int */ - -#define ULONG_MAX 0xffffffff /* max value for an unsigned long */ -#define LONG_MAX 0x7fffffff /* max value for a long */ -#define LONG_MIN (-0x7fffffff-1) /* min value for a long */ diff --git a/sys/i386/include/ansi.h b/sys/i386/include/ansi.h deleted file mode 100644 index cdb3af8..0000000 --- a/sys/i386/include/ansi.h +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ansi.h 7.1 (Berkeley) 3/9/91 - * $Id$ - */ - -#ifndef _ANSI_H_ -#define _ANSI_H_ - -/* - * Types which are fundamental to the implementation and may appear in - * more than one standard header are defined here. Standard headers - * then use: - * #ifdef _SIZE_T_ - * typedef _SIZE_T_ size_t; - * #undef _SIZE_T_ - * #endif - * - * Thanks, ANSI! - */ -#define _CLOCK_T_ unsigned long /* clock() */ -#define _PTRDIFF_T_ int /* ptr1 - ptr2 */ -#define _SIZE_T_ unsigned int /* sizeof() */ -#define _TIME_T_ long /* time() */ -#define _VA_LIST_ char * /* va_list */ -#define _WCHAR_T_ unsigned short /* wchar_t */ - -#endif /* _ANSI_H_ */ diff --git a/sys/i386/include/console.h b/sys/i386/include/console.h deleted file mode 100644 index 23cdb50..0000000 --- a/sys/i386/include/console.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (C) 1992, 1993 Søren Schmidt - * - * This program is free software; you may redistribute it and/or - * modify it, provided that it retain the above copyright notice - * and the following disclaimer. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Søren Schmidt Email: sos@kmd-ac.dk - * Tritonvej 36 UUCP: ...uunet!dkuug!kmd-ac!sos - * DK9210 Aalborg SO Phone: +45 9814 8076 - * - * $Id$ - */ - -#ifndef _CONSOLE_H_ -#define _CONSOLE_H_ - -#include -#include - -#define KDGKBMODE _IOR('K', 6, int) -#define KDSKBMODE _IO('K', 7) -#define KDMKTONE _IO('K', 8) -#define KDGETMODE _IOR('K', 9, int) -#define KDSETMODE _IO('K', 10) -#define KDSBORDER _IO('K', 13) -#define KDGKBSTATE _IOR('K', 19, int) -#define KDSKBSTATE _IO('K', 20) -#define KDENABIO _IO('K', 60) -#define KDDISABIO _IO('K', 61) -#define KIOCSOUND _IO('k', 63) -#define KDGKBTYPE _IOR('K', 64, int) -#define KDGETLED _IOR('K', 65, int) -#define KDSETLED _IO('K', 66) -#define KDSETRAD _IO('K', 67) - -#define GETFKEY _IOWR('k', 0, fkeyarg_t) -#define SETFKEY _IOWR('k', 1, fkeyarg_t) -#define GIO_SCRNMAP _IOR('k', 2, scrmap_t) -#define PIO_SCRNMAP _IOW('k', 3, scrmap_t) -#define GIO_KEYMAP _IOR('k', 6, keymap_t) -#define PIO_KEYMAP _IOW('k', 7, keymap_t) - -#define CONS_BLANKTIME _IOW('c', 4, long) -#define PIO_FONT8x8 _IOW('c', 64, fnt8_t) -#define GIO_FONT8x8 _IOR('c', 65, fnt8_t) -#define PIO_FONT8x14 _IOW('c', 66, fnt14_t) -#define GIO_FONT8x14 _IOR('c', 67, fnt14_t) -#define PIO_FONT8x16 _IOW('c', 68, fnt16_t) -#define GIO_FONT8x16 _IOR('c', 69, fnt16_t) -#define CONS_GETINFO _IOR('c', 73, vid_info_t) -#define CONS_GETVERS _IOR('c', 74, long) -#define CONS_80x25TEXT _IO('c', 102) -#define CONS_80x50TEXT _IO('c', 103) - -#define VT_OPENQRY _IOR('v', 1, int) -#define VT_SETMODE _IOW('v', 2, vtmode_t) -#define VT_GETMODE _IOR('v', 3, vtmode_t) -#define VT_RELDISP _IO('v', 4) -#define VT_ACTIVATE _IO('v', 5) -#define VT_WAITACTIVE _IO('v', 6) -#define VT_GETACTIVE _IOR('v', 7, int) - -#define VT_FALSE 0 -#define VT_TRUE 1 -#define VT_ACKACQ 2 - -#define VT_AUTO 0 /* switching is automatic */ -#define VT_PROCESS 1 /* switching controlled by prog */ - -/* compatibility to old pccons & X386 */ -#define CONSOLE_X_MODE_ON _IO('t', 121) -#define CONSOLE_X_MODE_OFF _IO('t', 122) -#define CONSOLE_X_BELL _IOW('t',123,int[2]) - -struct vt_mode { - char mode; - char waitv; /* not implemented yet SOS */ - short relsig; - short acqsig; - short frsig; /* not implemented yet SOS */ -}; - -typedef struct vt_mode vtmode_t; - -#define KD_MONO 1 /* monochrome adapter */ -#define KD_HERCULES 2 /* hercules adapter */ -#define KD_CGA 3 /* color graphics adapter */ -#define KD_EGA 4 /* enhanced graphics adapter */ -#define KD_VGA 5 /* video graohics adapter */ - -#define KD_TEXT 0 /* set text mode restore fonts */ -#define KD_TEXT0 0 /* ditto */ -#define KD_TEXT1 2 /* set text mode !restore fonts */ -#define KD_GRAPHICS 1 /* set graphics mode */ - -#define K_RAW 0 /* keyboard returns scancodes */ -#define K_XLATE 1 /* keyboard returns ascii */ - -#define KB_84 1 -#define KB_101 2 -#define KB_OTHER 3 - -#define CLKED 1 -#define NLKED 2 -#define SLKED 4 -#define ALKED 8 -#define LED_CAP 1 -#define LED_NUM 2 -#define LED_SCR 4 - -/* possible flag values */ -#define FLAG_LOCK_O 0 -#define FLAG_LOCK_C 1 -#define FLAG_LOCK_N 2 - -#define NUM_KEYS 256 -#define NUM_STATES 8 -#define ALTGR_OFFSET 128 - -struct keymap { - u_short n_keys; - struct key_t { - u_char map[NUM_STATES]; - u_char spcl; - u_char flgs; - } key[NUM_KEYS]; -}; - -#define MAXFK 16 - -struct fkeytab { - u_char str[MAXFK]; - u_char len; -}; - -struct fkeyarg { - u_short keynum; - char keydef[MAXFK]; - char flen; -}; - -struct colors { - char fore; - char back; -}; - -struct vid_info { - short size; - short m_num; - u_short mv_row, mv_col; - u_short mv_rsz, mv_csz; - struct colors mv_norm, - mv_rev, - mv_grfc; - u_char mv_ovscan; - u_char mk_keylock; -}; - -typedef struct keymap keymap_t; -typedef struct fkeytab fkeytab_t; -typedef struct fkeyarg fkeyarg_t; -typedef struct vid_info vid_info_t; -typedef struct {char scrmap[256];} scrmap_t; -typedef struct {char fnt8x8[8*256];} fnt8_t; -typedef struct {char fnt8x14[14*256];} fnt14_t; -typedef struct {char fnt8x16[16*256];} fnt16_t; - -#define F(x) ((x)+F_FN-1) -#define S(x) ((x)+F_SCR-1) -#define NOP 0x00 -#define LSH 0x02 -#define RSH 0x03 -#define CLK 0x04 -#define NLK 0x05 -#define SLK 0x06 -#define LALT 0x07 -#define LCTR 0x09 -#define RCTR 0x7b -#define RALT 0x7c -#define ALK 0x7d -#define ASH 0x7e - -#define F_SCR 11 /* switch to first screen */ -#define L_SCR 26 /* switch to last screen */ -#define F_FN 27 /* first function key */ -#define L_FN 122 /* last function key */ -#define FKEY 0x200 /* funtion key marker */ - -#define KB_DATA 0x60 /* kbd data port */ -#define KB_STAT 0x64 /* kbd status port */ -#define KB_BUF_FULL 0x01 /* kbd has char pending */ -#define KB_READY 0x02 /* kbd ready for command */ -#define KB_WRITE 0x60 /* kbd write command */ -#define KB_SETLEDS 0xed /* kbd set leds */ -#define KB_SETRAD 0xf3 /* kbd set repeat&delay command */ -#define KB_ACK 0xfa /* kbd acknowledge answer */ -#define KB_RESET_CPU 0xfe /* kbd reset main cpu command */ -#define KB_RESET 0xff /* kbd reset */ - -#endif diff --git a/sys/i386/include/cpu.h b/sys/i386/include/cpu.h deleted file mode 100644 index 43a6bec..0000000 --- a/sys/i386/include/cpu.h +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * Definitions unique to i386 cpu support. - */ -#include "machine/frame.h" -#include "machine/segments.h" - -/* - * definitions of cpu-dependent requirements - * referenced in generic code - */ -#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */ - -#define cpu_exec(p) /* nothing */ - -/* - * Arguments to hardclock, softclock and gatherstats - * encapsulate the previous machine state in an opaque - * clockframe; for now, use generic intrframe. - */ -typedef struct intrframe clockframe; - -#define CLKF_USERMODE(framep) (ISPL((framep)->if_cs) == SEL_UPL) -#define CLKF_BASEPRI(framep) ((framep)->if_ppl == 0) -#define CLKF_PC(framep) ((framep)->if_eip) - -/* - * Preempt the current process if in interrupt from user mode, - * or after the current trap/syscall if in system mode. - */ -#define need_resched() { want_resched++; aston(); } - -/* - * Give a profiling tick to the current process from the softclock - * interrupt. On tahoe, request an ast to send us through trap(), - * marking the proc as needing a profiling tick. - */ -#define profile_tick(p, framep) { (p)->p_flag |= SOWEUPC; aston(); } - -/* - * Notify the current process (p) that it has a signal pending, - * process as soon as possible. - */ -#define signotify(p) aston() - -#define aston() (astpending++) - -int astpending; /* need to trap before returning to user mode */ -int want_resched; /* resched() was called */ - -/* - * pull in #defines for kinds of processors - */ -#include "machine/cputypes.h" - -struct cpu_nameclass { - char *cpu_name; - int cpu_class; -}; - -#ifdef KERNEL -extern int cpu; -extern int cpu_class; -extern struct cpu_nameclass i386_cpus[]; -#endif diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h deleted file mode 100644 index db5cf95..0000000 --- a/sys/i386/include/cpufunc.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Functions to provide access to special i386 instructions. - * XXX - bezillions more are defined in locore.s but are not declared anywhere. - * - * $Id$ - */ - -#include -#include - -#ifdef __GNUC__ - -static __inline int bdb(void) -{ - extern int bdb_exists; - - if (!bdb_exists) - return (0); - __asm("int $3"); - return (1); -} - -static __inline void -disable_intr(void) -{ - __asm __volatile("cli"); -} - -static __inline void -enable_intr(void) -{ - __asm __volatile("sti"); -} - -/* - * This roundabout method of returning a u_char helps stop gcc-1.40 from - * generating unnecessary movzbl's. - */ -#define inb(port) ((u_char) u_int_inb(port)) - -static __inline u_int -u_int_inb(u_int port) -{ - u_char data; - /* - * We use %%dx and not %1 here because i/o is done at %dx and not at - * %edx, while gcc-2.2.2 generates inferior code (movw instead of movl) - * if we tell it to load (u_short) port. - */ - __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port)); - return data; -} - -static __inline void -outb(u_int port, u_char data) -{ - register u_char al asm("ax"); - - al = data; /* help gcc-1.40's register allocator */ - __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port)); -} - -static __inline__ -imin(a, b) - int a, b; -{ - - return (a < b ? a : b); -} - -static __inline__ -imax(a, b) - int a, b; -{ - - return (a > b ? a : b); -} - -static __inline__ -unsigned int -min(a, b) - unsigned int a, b; -{ - - return (a < b ? a : b); -} - -static __inline__ -unsigned int -max(a, b) - unsigned int a, b; -{ - - return (a > b ? a : b); -} - -static __inline__ -long -lmin(a, b) - long a, b; -{ - - return (a < b ? a : b); -} - -static __inline__ -long -lmax(a, b) - long a, b; -{ - - return (a > b ? a : b); -} - -static __inline__ -unsigned long -ulmin(a, b) - unsigned long a, b; -{ - - return (a < b ? a : b); -} - -static __inline__ -unsigned long -ulmax(a, b) - unsigned long a, b; -{ - - return (a > b ? a : b); -} - -static __inline__ -ffs(mask) - register long mask; -{ - register int bit; - - if (!mask) - return(0); - for (bit = 1;; ++bit) { - if (mask&0x01) - return(bit); - mask >>= 1; - } -} - -static __inline__ -bcmp(v1, v2, len) - void *v1, *v2; - register unsigned len; -{ - register u_char *s1 = v1, *s2 = v2; - - while (len--) - if (*s1++ != *s2++) - return (1); - return (0); -} - -static __inline__ -size_t -strlen(s1) - register __const__ char *s1; -{ - register size_t len; - - for (len = 0; *s1++ != '\0'; len++) - ; - return (len); -} - -#else /* not __GNUC__ */ - -int bdb __P((void)); -void disable_intr __P((void)); -void enable_intr __P((void)); -u_char inb __P((u_int port)); -void outb __P((u_int port, u_int data)); /* XXX - incompat */ - -#endif /* __GNUC__ */ - -#define really_u_int int /* XXX */ -#define really_void int /* XXX */ - -void load_cr0 __P((u_int cr0)); -really_u_int rcr0 __P((void)); - -#ifdef notyet -really_void setidt __P((int idx, /*XXX*/caddr_t func, int typ, int dpl)); -#endif - -#undef really_u_int -#undef really_void - diff --git a/sys/i386/include/cputypes.h b/sys/i386/include/cputypes.h deleted file mode 100644 index b922494..0000000 --- a/sys/i386/include/cputypes.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1993 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. The name of the author may not be used to endorse or promote products - * derived from this software withough 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. - * - * $Id$ - */ - -/* - * Classes of Processor - */ - -#define CPUCLASS_286 0 -#define CPUCLASS_386 1 -#define CPUCLASS_486 2 -#define CPUCLASS_586 3 - -/* - * Kinds of Processor - */ - -#define CPU_286 0 /* Intel 80286 */ -#define CPU_386SX 1 /* Intel 80386SX */ -#define CPU_386 2 /* Intel 80386DX */ -#define CPU_486SX 3 /* Intel 80486SX */ -#define CPU_486 4 /* Intel 80486DX */ -#define CPU_586 5 /* Intel P.....m (I hate lawyers; it's TM) */ - diff --git a/sys/i386/include/db_machdep.h b/sys/i386/include/db_machdep.h deleted file mode 100644 index aa0f006..0000000 --- a/sys/i386/include/db_machdep.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1991,1990 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * $Id$ - */ - -#ifndef _I386_DB_MACHDEP_H_ -#define _I386_DB_MACHDEP_H_ - -/* - * Machine-dependent defines for new kernel debugger. - */ - - -/* #include */ -/* #include */ -#include -#include -#include -#include -/* #include */ /* for thread_status */ -#include /* for struct trapframe */ -/* #include */ -#include /* from Mach... */ -/* #include */ -#include - -#define i386_saved_state trapframe -/* end of mangling */ - -typedef vm_offset_t db_addr_t; /* address - unsigned */ -typedef int db_expr_t; /* expression - signed */ - -typedef struct i386_saved_state db_regs_t; -db_regs_t ddb_regs; /* register state */ -#define DDB_REGS (&ddb_regs) - -#define PC_REGS(regs) ((db_addr_t)(regs)->tf_eip) - -#define BKPT_INST 0xcc /* breakpoint instruction */ -#define BKPT_SIZE (1) /* size of breakpoint inst */ -#define BKPT_SET(inst) (BKPT_INST) - -#define FIXUP_PC_AFTER_BREAK ddb_regs.tf_eip -= 1; - -#define db_clear_single_step(regs) ((regs)->tf_eflags &= ~EFL_TF) -#define db_set_single_step(regs) ((regs)->tf_eflags |= EFL_TF) - -/* #define IS_BREAKPOINT_TRAP(type, code) ((type) == T_INT3) */ -/* #define IS_WATCHPOINT_TRAP(type, code) ((type) == T_WATCHPOINT) */ -/* using the 386bsd values, rather than the Mach ones: */ -#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) -#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_KDBTRAP) - -#define I_CALL 0xe8 -#define I_CALLI 0xff -#define I_RET 0xc3 -#define I_IRET 0xcf - -#define inst_trap_return(ins) (((ins)&0xff) == I_IRET) -#define inst_return(ins) (((ins)&0xff) == I_RET) -#define inst_call(ins) (((ins)&0xff) == I_CALL || \ - (((ins)&0xff) == I_CALLI && \ - ((ins)&0x3800) == 0x1000)) -#define inst_load(ins) 0 -#define inst_store(ins) 0 - -/* access capability and access macros */ - -#define DB_ACCESS_LEVEL 2 /* access any space */ -#define DB_CHECK_ACCESS(addr,size,task) \ - db_check_access(addr,size,task) -#define DB_PHYS_EQ(task1,addr1,task2,addr2) \ - db_phys_eq(task1,addr1,task2,addr2) -#define DB_VALID_KERN_ADDR(addr) \ - ((addr) >= VM_MIN_KERNEL_ADDRESS && \ - (addr) < VM_MAX_KERNEL_ADDRESS) -#define DB_VALID_ADDRESS(addr,user) \ - ((!(user) && DB_VALID_KERN_ADDR(addr)) || \ - ((user) && (addr) < VM_MIN_KERNEL_ADDRESS)) - -boolean_t db_check_access(/* vm_offset_t, int, task_t */); -boolean_t db_phys_eq(/* task_t, vm_offset_t, task_t, vm_offset_t */); - -/* macros for printing OS server dependent task name */ - -#define DB_TASK_NAME(task) db_task_name(task) -#define DB_TASK_NAME_TITLE "COMMAND " -#define DB_TASK_NAME_LEN 23 -#define DB_NULL_TASK_NAME "? " - -void db_task_name(/* task_t */); - -/* macro for checking if a thread has used floating-point */ - -#define db_thread_fp_used(thread) ((thread)->pcb->ims.ifps != 0) - -#endif /* _I386_DB_MACHDEP_H_ */ diff --git a/sys/i386/include/dkio.h b/sys/i386/include/dkio.h deleted file mode 100644 index 90f0721..0000000 --- a/sys/i386/include/dkio.h +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)dkio.h 5.2 (Berkeley) 1/18/91 - * $Id$ - */ - -/* - * Structures and definitions for disk io control commands - * - * THIS WHOLE AREA NEEDS MORE THOUGHT. FOR NOW JUST IMPLEMENT - * ENOUGH TO READ AND WRITE HEADERS ON MASSBUS DISKS. EVENTUALLY - * SHOULD BE ABLE TO DETERMINE DRIVE TYPE AND DO OTHER GOOD STUFF. - */ - -/* disk io control commands */ -#define DKIOCHDR _IO(d, 1) /* next I/O will read/write header */ diff --git a/sys/i386/include/eflags.h b/sys/i386/include/eflags.h deleted file mode 100644 index 663b317..0000000 --- a/sys/i386/include/eflags.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 "AS IS" - * 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 Mellon - * the rights to redistribute these changes. - * - * $Id$ - */ - -#ifndef _I386_EFLAGS_H_ -#define _I386_EFLAGS_H_ - -/* - * i386 flags register - */ -#define EFL_CF 0x00000001 /* carry */ -#define EFL_PF 0x00000004 /* parity of low 8 bits */ -#define EFL_AF 0x00000010 /* carry out of bit 3 */ -#define EFL_ZF 0x00000040 /* zero */ -#define EFL_SF 0x00000080 /* sign */ -#define EFL_TF 0x00000100 /* trace trap */ -#define EFL_IF 0x00000200 /* interrupt enable */ -#define EFL_DF 0x00000400 /* direction */ -#define EFL_OF 0x00000800 /* overflow */ -#define EFL_IOPL 0x00003000 /* IO privilege level: */ -#define EFL_IOPL_KERNEL 0x00000000 /* kernel */ -#define EFL_IOPL_USER 0x00003000 /* user */ -#define EFL_NT 0x00004000 /* nested task */ -#define EFL_RF 0x00010000 /* resume without tracing */ -#define EFL_VM 0x00020000 /* virtual 8086 mode */ - -#define EFL_USER_SET (EFL_IF) -#define EFL_USER_CLEAR (EFL_IOPL|EFL_NT|EFL_RF) - -#endif _I386_EFLAGS_H_ diff --git a/sys/i386/include/endian.h b/sys/i386/include/endian.h deleted file mode 100644 index 9abd47e..0000000 --- a/sys/i386/include/endian.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 1987, 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)endian.h 7.8 (Berkeley) 4/3/91 - * $Id$ - */ - -/* - * Definitions for byte order, according to byte significance from low - * address to high. - */ -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ - -#define BYTE_ORDER LITTLE_ENDIAN - -#ifndef KERNEL -#include -#endif - -#define __word_swap_long(x) \ -({ register u_long X = (x); \ - asm ("rorl $16, %1" \ - : "=r" (X) \ - : "0" (X)); \ - X; }) -#if __GNUC__ >= 2 -#define __byte_swap_long(x) \ -({ register u_long X = (x); \ - asm ("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" \ - : "=q" (X) \ - : "0" (X)); \ - X; }) -#define __byte_swap_word(x) \ -({ register u_short X = (x); \ - asm ("xchgb %h1, %b1" \ - : "=q" (X) \ - : "0" (X)); \ - X; }) -#else /* __GNUC__ >= 2 */ -#define __byte_swap_long(x) \ -({ register u_long X = (x); \ - asm ("rorw $8, %w1\n\trorl $16, %1\n\trorw $8, %w1" \ - : "=r" (X) \ - : "0" (X)); \ - X; }) -#define __byte_swap_word(x) \ -({ register u_short X = (x); \ - asm ("rorw $8, %w1" \ - : "=r" (X) \ - : "0" (X)); \ - X; }) -#endif /* __GNUC__ >= 2 */ - -/* - * Macros for network/external number representation conversion. - */ -#if BYTE_ORDER == BIG_ENDIAN && !defined(lint) -#define ntohl(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define htons(x) (x) - -#define NTOHL(x) (x) -#define NTOHS(x) (x) -#define HTONL(x) (x) -#define HTONS(x) (x) - -#else - -#define ntohl __byte_swap_long -#define ntohs __byte_swap_word -#define htonl __byte_swap_long -#define htons __byte_swap_word - -#define NTOHL(x) (x) = ntohl((u_long)x) -#define NTOHS(x) (x) = ntohs((u_short)x) -#define HTONL(x) (x) = htonl((u_long)x) -#define HTONS(x) (x) = htons((u_short)x) -#endif diff --git a/sys/i386/include/float.h b/sys/i386/include/float.h deleted file mode 100644 index d6232a0..0000000 --- a/sys/i386/include/float.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1989 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)float.h 7.1 (Berkeley) 5/8/90 - * $Id$ - */ - -#define FLT_RADIX 2 /* b */ -#define FLT_ROUNDS 1 /* FP addition rounds to nearest */ - -#define FLT_MANT_DIG 24 /* p */ -#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */ -#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ -#define FLT_MIN_EXP (-125) /* emin */ -#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ -#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ -#define FLT_MAX_EXP 128 /* emax */ -#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ -#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ - -#define DBL_MANT_DIG 53 -#define DBL_EPSILON 2.2204460492503131E-16 -#define DBL_DIG 15 -#define DBL_MIN_EXP (-1021) -#define DBL_MIN 2.2250738585072014E-308 -#define DBL_MIN_10_EXP (-307) -#define DBL_MAX_EXP 1024 -#define DBL_MAX 1.7976931348623157E+308 -#define DBL_MAX_10_EXP 308 - -#define LDBL_MANT_DIG DBL_MANT_DIG -#define LDBL_EPSILON DBL_EPSILON -#define LDBL_DIG DBL_DIG -#define LDBL_MIN_EXP DBL_MIN_EXP -#define LDBL_MIN DBL_MIN -#define LDBL_MIN_10_EXP DBL_MIN_10_EXP -#define LDBL_MAX_EXP DBL_MAX_EXP -#define LDBL_MAX DBL_MAX -#define LDBL_MAX_10_EXP DBL_MAX_10_EXP diff --git a/sys/i386/include/floatingpoint.h b/sys/i386/include/floatingpoint.h deleted file mode 100644 index c17bd2c..0000000 --- a/sys/i386/include/floatingpoint.h +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * Copyright (c) 1993 Andrew Moore, Talke Studio - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93 - * $Id$ - */ - -/* - * IEEE floating point structure and function definitions - */ - -#ifndef _FLOATINGPOINT_H_ -#define _FLOATINGPOINT_H_ - -#include -#include - -#ifdef __GNUC__ - -#define fnstcw(addr) __asm("fnstcw %0" : "=m" (*addr) : "0" (*addr)) -#define fnstsw(addr) __asm("fnstsw %0" : "=m" (*addr) : "0" (*addr)) -#define fnstenv(addr) __asm("fnstenv %0" : "=m" (*addr) : "0" (*addr)) -#define fldenv(addr) __asm("fldenv %0" : : "m" (*addr)) - -#ifdef __i386__ - -/* - * return the contents of a FP register - */ -static __inline__ int -__fpgetreg(int _reg) -{ - unsigned short _mem; - - switch(_reg) { - default: - fnstcw(&_mem); - break; - case FP_STKY_REG: - fnstsw(&_mem); - break; - } - return _mem; -} - -/* - * set a FP mode; return previous mode - */ -static __inline__ int -__fpsetreg(int _m, int _reg, int _fld, int _off) -{ - unsigned _env[7]; - unsigned _p; - - fnstenv(_env); - _p = (_env[_reg] & _fld) >> _off; - _env[_reg] = (_env[_reg] & ~_fld) | (_m << _off & _fld); - fldenv(_env); - return _p; -} - -#endif /* __i386__ */ - -#endif /* __GNUC__ */ - -/* - * SysV/386 FP control interface - */ -#define fpgetround() ((__fpgetreg(FP_RND_REG) & FP_RND_FLD) >> FP_RND_OFF) -#define fpsetround(m) __fpsetreg((m), FP_RND_REG, FP_RND_FLD, FP_RND_OFF) -#define fpgetprec() ((__fpgetreg(FP_PRC_REG) & FP_PRC_FLD) >> FP_PRC_OFF) -#define fpsetprec(m) __fpsetreg((m), FP_PRC_REG, FP_PRC_FLD, FP_PRC_OFF) -#define fpgetmask() ((~__fpgetreg(FP_MSKS_REG) & FP_MSKS_FLD) >> FP_MSKS_OFF) -#define fpsetmask(m) __fpsetreg(~(m), FP_MSKS_REG, FP_MSKS_FLD, FP_MSKS_OFF) -#define fpgetsticky() ((__fpgetreg(FP_STKY_REG) & FP_STKY_FLD) >> FP_STKY_OFF) -#define fpresetsticky(m) __fpsetreg(0, FP_STKY_REG, (m), FP_STKY_OFF) -#define fpsetsticky(m) fpresetsticky(m) - -#endif /* !_FLOATINGPOINT_H_ */ diff --git a/sys/i386/include/frame.h b/sys/i386/include/frame.h deleted file mode 100644 index 250e5c5..0000000 --- a/sys/i386/include/frame.h +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 - * $Id$ - */ - -#include - -/* - * System stack frames. - */ - -/* - * Exception/Trap Stack Frame - */ - -struct trapframe { - int tf_es; - int tf_ds; - int tf_edi; - int tf_esi; - int tf_ebp; - int tf_isp; - int tf_ebx; - int tf_edx; - int tf_ecx; - int tf_eax; - int tf_trapno; - /* below portion defined in 386 hardware */ - int tf_err; - int tf_eip; - int tf_cs; - int tf_eflags; - /* below only when transitting rings (e.g. user to kernel) */ - int tf_esp; - int tf_ss; -}; - -/* Interrupt stack frame */ - -struct intrframe { - int if_vec; - int if_ppl; - int if_es; - int if_ds; - int if_edi; - int if_esi; - int if_ebp; - int :32; - int if_ebx; - int if_edx; - int if_ecx; - int if_eax; - int :32; /* for compat with trap frame - trapno */ - int :32; /* for compat with trap frame - err */ - /* below portion defined in 386 hardware */ - int if_eip; - int if_cs; - int if_eflags; - /* below only when transitting rings (e.g. user to kernel) */ - int if_esp; - int if_ss; -}; - -/* - * Signal frame - */ -struct sigframe { - int sf_signum; - int sf_code; - struct sigcontext *sf_scp; - sig_t sf_handler; - int sf_eax; - int sf_edx; - int sf_ecx; - struct sigcontext sf_sc; -} ; - -/* - * Call Gate/System Call Stack Frame - */ - -struct syscframe { - int sf_edi; - int sf_esi; - int sf_ebp; - int :32; /* redundant save of isp */ - int sf_ebx; - int sf_edx; - int sf_ecx; - int sf_eax; - int sf_eflags; - /* below portion defined in 386 hardware */ -/* int sf_args[N]; /* if call gate copy args enabled!*/ - int sf_eip; - int sf_cs; - /* below only when transitting rings (e.g. user to kernel) */ - int sf_esp; - int sf_ss; -}; diff --git a/sys/i386/include/ioctl_pc.h b/sys/i386/include/ioctl_pc.h deleted file mode 100644 index bc6a255..0000000 --- a/sys/i386/include/ioctl_pc.h +++ /dev/null @@ -1,797 +0,0 @@ -/* Copyright 1992,1993 by Holger Veit - * May be freely used with Bill Jolitz's port of - * 386bsd and may be included in a 386bsd collection - * as long as binary and source are available and reproduce the above - * copyright. - * - * You may freely modify this code and contribute improvements based - * on this code as long as you don't claim to be the original author. - * Commercial use of this source requires permittance of the copyright - * holder. A general license for 386bsd will override this restriction. - * - * Use at your own risk. The copyright holder or any person who makes - * this code available for the public (administrators of public archives - * for instance) are not responsible for any harm to hardware or software - * that might happen due to wrong application or program faults. - * - * Addendum: The XFree86 developers and maintainers are hereby granted the - * right to distribute this file together with their source distributions - * and patchkits of XFree86 without further explicit permission of the - * above copyright holder. - * This and another file is a necessary include file for the unified - * pccons/codrv implementation of XFree86. This file is needed if - * someone wants to compile an Xserver on a system which does not have, - * for some reasons, the codrv console driver which comes with this file. The - * availability of this file avoids a large number of #ifdef's and - * allows to make the xserver code easier runtime-configurable. - * To make use of this file, it must be installed in /usr/include/sys. - * This file is not the complete console device driver, so it is possible - * that properties described in this file do not work without having the - * complete driver distribution. This is not a fault of the Xserver that - * was built with this file. - * - * - * - * From: @(#)$RCSfile: ioctl_pc.h,v - * Revision: 1.1.1.1 (Contributed to 386bsd) - * Date: 1993/06/12 14:58:11 - * - * Important notice: #defined values are subject to be changed!!! - * Don't use the constant, use the name instead! - * - * codrv1-style uses ioctls 'K': 1-33,255 - * 'V': 100-109 - * - * -hv- Holger Veit, Holger.Veit@gmd.de - * -hm Hellmuth Michaelis, hm@hcshh.hcs.de - * -vak- Sergey Vakulenko, vak@kiae.su - * - * 25-07-92 -hv- First version - * 16-08-92 -hm adding vga ioctl for cursor shape - * 25-10-92 -hv- X11 + video related ioctls - * 01/12/92 -vak- 8x16 font loading, beep ioctl, - * LED reassignment ioctl. - * 22-04-93 -hv- unified most CODRV1/CODRV2 codes - * 24-04-93 -hv- revised parts of keymap structures - * - * $Id$ - */ - -#ifndef _IOCTL_PC_H_ -#define _IOCTL_PC_H_ - -#ifdef NOTDEF -#if __GNUC__ >= 2 -#pragma pack(1) -#endif -#endif - -#ifndef KERNEL -#include -#ifndef _TYPES_H_ -#include -#endif -#else -#include "ioctl.h" -#endif - - -/*************************************************************************** - * Basic definitions - ***************************************************************************/ - -/* Use this data type when manipulating characters, don't use 'char' or 'u_char' - * some day this will be changed to 'u_short' or 'u_long' size to allow - * characters > 255 - */ -typedef u_char XCHAR; - -/*************************************************************************** - * driver identification - ***************************************************************************/ - -/* - * This defines the CONSOLE INFORMATION data structure, used to - * describe console capabilities, to distinguish between different - * versions. If this ioctl fail, you probably have an old style "pccons" - * driver (or an "improved" console driver, whose writer is not interested - * in providing compatibility for anything). - * In this case, a considerable number of features may not work as expected, - * or do not work at all. - */ - -#define MAXINFOSIZE 16 -struct consinfo { - u_long info1; - u_long __reserved1__; - u_long __reserved2__; - u_long __reserved3__; - XCHAR drv_name[MAXINFOSIZE+1]; - XCHAR emul_name[MAXINFOSIZE+1]; - XCHAR __reserved1_name__[MAXINFOSIZE+1]; - XCHAR __reserved2_name__[MAXINFOSIZE+1]; -}; - -struct oldconsinfo { - u_long info1; - u_long __reserved__; -}; - -#define CONSGINFO _IOR('K',255,struct consinfo) /* Get console capabilities */ -#define OLDCONSGINFO _IOR('K',255,struct oldconsinfo) /* compatibility */ -#define CONS_ISPC 0x00000001 /* is derived from old PCCONS */ -#define CONS_ISCO 0x00000002 /* is derived from CO driver */ -#define CONS_reserved1 0x00000004 /* reserved for other console drivers */ -#define CONS_reserved2 0x00000008 /* reserved for other console drivers */ -#define CONS_HASKBD 0x00000010 /* has /dev/kbd */ -#define CONS_HASSCAN 0x00000020 /* uses Scan codes */ -#define CONS_HASKEYNUM 0x00000040 /* uses KEYNUMS */ -#define CONS_HASVTY 0x00000080 /* has /dev/vty* */ -#define CONS_HASPC3 0x00000100 /* unused, historical */ -#define CONS_HASVTHP 0x00000200 /* unused, historical */ -#define CONS_reserved3 0x00000400 /* reserved */ -#define CONS_reserved4 0x00000800 /* reserved */ -#define CONS_HASPX386 0x00001000 /* has X386 probing support +new CONSOLE_X_MODE */ -#define CONS_HASOX386 0x00002000 /* has old X386 support CONSOLE_X_MODE_ON/OFF */ -#define CONS_reserved5 0x00004000 /* reserved */ -#define CONS_reserved6 0x00008000 /* reserved */ -#define CONS_HASKCAP 0x00010000 /* has ioctl keycap support */ -#define CONS_HASFNT 0x00020000 /* has ioctl font support */ -#define CONS_reserved7 0x00040000 /* reserved */ -#define CONS_reserved8 0x00080000 /* reserved */ -#define CONS_USE7BIT 0x00100000 /* does not support 8bit characters */ -#define CONS_USEPC8 0x00200000 /* uses PC8 8-bit mapping */ -#define CONS_USELATIN1 0x00400000 /* uses ISO LATIN1 mapping */ -#define CONS_HAS10646 0x00800000 /* has /dev/unicode */ -#define CONS_PCCONS2 0x01000000 /* modified pccons */ -#define CONS_CODRV1 0x02000000 /* old codrv ioctls */ -#define CONS_CODRV2 0x04000000 /* codrv ioctls 0.1.2 */ -#define CONS_reserved9 0x08000000 /* reserved */ -#define CONS_reserved10 0x10000000 /* reserved */ -#define CONS_reserved11 0x20000000 /* reserved */ -#define CONS_reserved12 0x40000000 /* reserved */ -#define CONS_reserved13 0x80000000 /* reserved */ - - -/*************************************************************************** - * IOCTLs for AT Keyboard - ***************************************************************************/ - -/**** initializing the keyboard ****/ - -/* reset keyboard, run selftests and set default values: - * default keymap, no overloaded keys, default typematic rate - * KBD_TPD500|KBD_TPM100, repetition on - */ -#define KBDCOLDRESET _IO('K', 1) /* reset keyboard and set default - * values: - * default keymap, no overloaded - * keys, default typematic rate - * KBD_TPD500|KBD_TPM100 - */ -/* resets the mode in keyboard controller only */ -#define KBDWARMRESET _IO('K', 23) - - - -/**** key repetition (typematic) feature ****/ - -/* get (G) / set (S) key repetition rate and delay - * see below for a definition of rate and delay and the necessary - * argument - */ -#define KBDGTPMAT _IOR('K', 2, int) -#define KBDSTPMAT _IOW('K', 3, int) - -/* Typematic rates: - * Rate = 1 / Period, with - * Period = (8+ (Val&7)) * 2^((Val>>3)&3) * 0.00417 seconds, - * and Val the typematic value below - * - * The typematic delay is determined by - * Delay = (1+((Val>>5)&3)) * 250 msec +/- 20 % - * - * Source IBM/AT reference manual, 1987 - * - * Note that you have to pass one TPD* and one TPM* value to the KBDSTPMAT - * ioctl: they are different flags of the same data word. Also note that - * 0x00 is a valid value: KBD_TPD250|KBD_TPM300 which is really fast, instead - * of turning off key repetition entirely. You can turn off key repetition - * with the ioctls KBDGREPSW/KBDSREPSW. -*/ - -#define KBD_TPD250 0x0000 /* 250 ms */ -#define KBD_TPD500 0x0020 /* 500 ms */ -#define KBD_TPD750 0x0040 /* 750 ms */ -#define KBD_TPD1000 0x0060 /* 1000 ms */ - -#define KBD_TPM300 0x0000 /* 30.0 rate */ -#define KBD_TPM267 0x0001 /* 26.7 rate */ -#define KBD_TPM240 0x0002 /* 24.0 rate */ -#define KBD_TPM218 0x0003 /* 21.8 rate */ -#define KBD_TPM200 0x0004 /* 20.0 rate */ -#define KBD_TPM185 0x0005 /* 18.5 rate */ -#define KBD_TPM171 0x0006 /* 17.1 rate */ -#define KBD_TPM160 0x0007 /* 16.0 rate */ -#define KBD_TPM150 0x0008 /* 15.0 rate */ -#define KBD_TPM133 0x0009 /* 13.3 rate */ -#define KBD_TPM120 0x000a /* 12.0 rate */ -#define KBD_TPM109 0x000b /* 10.9 rate */ -#define KBD_TPM100 0x000c /* 10.0 rate */ -#define KBD_TPM92 0x000d /* 9.2 rate */ -#define KBD_TPM86 0x000e /* 8.6 rate */ -#define KBD_TPM80 0x000f /* 8.0 rate */ -#define KBD_TPM75 0x0010 /* 7.5 rate */ -#define KBD_TPM67 0x0011 /* 6.7 rate */ -#define KBD_TPM60 0x0012 /* 6.0 rate */ -#define KBD_TPM55 0x0013 /* 5.5 rate */ -#define KBD_TPM50 0x0014 /* 5.0 rate */ -#define KBD_TPM46 0x0015 /* 4.6 rate */ -#define KBD_TPM43 0x0016 /* 4.3 rate */ -#define KBD_TPM40 0x0017 /* 4.0 rate */ -#define KBD_TPM37 0x0018 /* 3.7 rate */ -#define KBD_TPM33 0x0019 /* 3.3 rate */ -#define KBD_TPM30 0x001a /* 3.0 rate */ -#define KBD_TPM27 0x001b /* 2.7 rate */ -#define KBD_TPM25 0x001c /* 2.5 rate */ -#define KBD_TPM23 0x001d /* 2.3 rate */ -#define KBD_TPM21 0x001e /* 2.1 rate */ -#define KBD_TPM20 0x001f /* 2.0 rate */ - - -/* get (G) / set (S) the key repetition switch */ -#define KBD_REPEATOFF 0 -#define KBD_REPEATON 1 -#define KBDGREPSW _IOR('K', 4, int) -#define KBDSREPSW _IOW('K', 5, int) - - - -/**** handling keyboard LEDS and Lock keys ****/ - -/* get (G) / set (S) the keyboard LEDs, - * does not influence the state of the lock keys. - * Note: if keyboard serves tty console mode (VTYs have keyboard focus), - * the lock keys will still modify the state when used - */ -#define KBDGLEDS _IOR('K', 6, int) -#define KBDSLEDS _IOW('K', 7, int) - -/* get (G) / set (S) the SCROLL, NUM, CAPS ALTGRLOCK keys - * (note: ALTGRLOCK or SHIFTLOCK are not necessarily accessible - * on your keyboard) - */ -#define KBD_LOCKSCROLL 0x0001 -#define KBD_LOCKNUM 0x0002 -#define KBD_LOCKCAPS 0x0004 -#define KBD_LOCKALTGR 0x0008 -#define KBD_LOCKSHIFT 0x0010 -#define KBDGLOCK _IOR('K', 8, int) -#define KBDSLOCK _IOW('K', 9, int) - - - -/**** making noise ****/ - -/* get (G) / set (S) the beeper frequency and tone duration - * the nr param determines the VTY which parameters are changed - * VTY# = 0...n, n < max_vtys - * nr = -1: actual vty - * nr = -2: Set the system default beep frequency - * - * in some emulations, you can also set pitch and duration by an ESC code - */ -#define KBD_ACTVTY -1 -#define KBD_DEFLT -2 -struct kbd_bell { - int pitch; - int duration; - int nr; -}; - -#define KBDGETBEEP _IOWR('K',28, struct kbd_bell) -#define KBDSETBEEP _IOW('K',29, struct kbd_bell) - -/* do a beep of specified frequency and duration - * the argument nr is unused - * a NULL arg performs a default system beep - */ -#define KBDBELL _IOW('K',30, struct kbd_bell) - - - -/**** I/O access ****/ - -/* This call allows programs to access I/O ports. - * The ioctl is intended to perform several tasks for the XFree86 Xserver, - * but currently has other interesting applications. This is why it is - * priviledged and can only be executed by root (or with setuid-root). - * In future the ioctl might be restricted to allow access to video ports - * only. - */ -#define X_MODE_ON 1 -#define X_MODE_OFF 0 -#define CONSOLE_X_MODE _IOW('K',22,int) - - -/**** keyboard overloading ****/ - -/* Codrv allows loading of strings to keys in six layers. - * Any string may have a length of up to KBDMAXOVLKEYSIZE XCHARS. - * !!! Warning: This ioctl uses the type XCHAR. In future, this may - * !!! no longer be a char type, so str*** functions might not work any more - * !!! some day. - * The available layers are: - * - * - unshifted - * - with shift key - * - with ctrl key - * - with meta key (usually ALT-left) - * - with altgr key (usually ALT-right) - * - with shift+altgr key - * - * There are no combinations: shift-ctrl, ctrl-alt, shift-meta. - * The combination ctrl-altleft-somekey is reserved for system purposes. - * These keys are usually processed before the above keys. To gain control - * over these keys, you must run the keyboard in raw mode (/dev/kbd) and - * do ALL the processing yourself. The Xserver for instance does it this way. - * The following special keys are currently defined: - * - * CTRL-ALTLEFT-DELETE: Reboot - * CTRL-ALTLEFT-ESCAPE: Call the debugger (if compiled into the kernel) - * CTRL-ALTLEFT-KP+: Switch to next resolution (Xserver only) - * CTRL-ALTLEFT-KP-: Switch to previous resolution (Xserver only) - */ - -/* values for type field of various kbd_overload ioctls */ -#define KBD_NONE 0 /* no function, key is disabled */ -#define KBD_SHIFT 1 /* keyboard shift */ -#define KBD_META 2 /* (ALT) alternate shift, sets bit8 to ASCII code */ -#define KBD_NUM 3 /* numeric shift cursors vs. numeric */ -#define KBD_CTL 4 /* control shift -- allows ctl function */ -#define KBD_CAPS 5 /* caps shift -- swaps case of letter */ -#define KBD_ASCII 6 /* ascii code for this key */ -#define KBD_SCROLL 7 /* stop output */ -#define KBD_FUNC 8 /* function key */ -#define KBD_KP 9 /* Keypad keys */ -#define KBD_BREAK 10 /* The damned BREAK key, ignored in ioctl */ -#define KBD_ALTGR 11 /* AltGr Translation feature */ -#define KBD_SHFTLOCK 12 /* some people are accustomed to this nonsense */ -#define KBD_ALTGRLOCK 13 /* Useful for 8-bit national kbds (cyrillic) */ -#define KBD_DOALTCAPS 0x0400 /* change by altgr + caps shift */ -#define KBD_DOCAPS 0x0800 /* change by caps shift */ -#define KBD_DIACPFX 0x4000 /* Key carries a diacritical prefix */ -#define KBD_OVERLOAD 0x8000 /* Key is overloaded, ignored in ioctl */ -#define KBD_MASK 0x001f /* mask for type */ - -#define KBDMAXOVLKEYSIZE 15 /* excl. zero byte */ -struct kbd_ovlkey { - u_short keynum; - u_short type; - XCHAR unshift[KBDMAXOVLKEYSIZE+1]; - XCHAR shift[KBDMAXOVLKEYSIZE+1]; - XCHAR ctrl[KBDMAXOVLKEYSIZE+1]; - XCHAR meta[KBDMAXOVLKEYSIZE+1]; - XCHAR altgr[KBDMAXOVLKEYSIZE+1]; - XCHAR shiftaltgr[KBDMAXOVLKEYSIZE+1]; -}; - - -/* Get (G) / Set (S) a key assignment. This will influence the current - * key value only - */ -#define KBDGCKEY _IOWR('K',16, struct kbd_ovlkey) -#define KBDSCKEY _IOW('K',17, struct kbd_ovlkey) - -/* Get (G) the default (old) key assignment. You cannot overwrite the - * default setting, so this ioctl is unpaired - */ -#define KBDGOKEY _IOWR('K',18, struct kbd_ovlkey) - - - -/* Remove a key assignment for a key, i.e. restore default setting for key - * arg = keynum - */ -#define KBDRMKEY _IOW('K', 19, int) - -/* Restore the default key setting */ -#define KBDDEFAULT _IO('K',20) - - - -/* Set behavior of unassigned key layers - * Note that there is a hack from further versions which uses - * the flags KBD_C0 and KBD_A0 for this. This is still supported, but - * is not recommended way to do. It may disappear in future - * (what means that it won't :-)) - */ -#define KBD_CLEARCTRL 2 -#define KBD_CLEARMETA 4 -#define KBD_CLEARALT 1 -#ifdef notyet - #define KBD_CLEARNORM 8 - #define KBD_CLEARSHIFT 16 - #define KBD_CLEARSHALT 32 -#endif -#define KBDSCLRLYR _IOW('K',31,int) - -/* get (G) / set (S) CAPSLOCK LED behaviour. - * Not all of this keys may be accessible at your keyboard - * Note: For compatibility, the S ioctl returns the old state in arg - */ -#define KBD_CAPSCAPS 0 /* LED follows CAPSLOCK state */ -#define KBD_CAPSSHIFT 1 /* LED follows SHIFTLOCK state */ -#define KBD_CAPSALTGR 2 /* LED follows ALTGRLOCK state */ -#define KBD_CAPSINIT 0x04 /* bit to set to set a default for all VTYs */ -#define KBDGCAPSLED _IOR('K',27,int) -#define KBDSCAPSLED _IOWR('K',25,int) - -/* extended functions: functions that are triggered by a keypress - * before key is converted to ASCII - * - * use function KBD_HOTKEYDELETE to remove a hotkey from a key - */ -struct kbd_hotkey { - u_short key; - u_short modifier; - u_short function; -}; -#define KBDGSPECF _IOWR('K',32,struct kbd_hotkey) -#define KBDSSPECF _IOW('K',33,struct kbd_hotkey) - -/* extended function prefixes (in modifier field) - * bit set triggers a special function on the key layer - */ -#define KBD_NOEXT 0x00 /* trigger never */ -#define KBD_EXT_N 0x01 /* on normal key (normal layer) */ -#define KBD_EXT_S 0x02 /* on shift key (shift layer) */ -#define KBD_EXT_C 0x04 /* on ctrl key (ctrl layer) */ -#define KBD_EXT_A 0x08 /* on alt key (alt layer) */ -#define KBD_EXT_SK 0x10 /* on syskey (PRINTSCREEN) (Meta Layer) */ -#define KBD_EXT_CA 0x20 /* on ctrl-alt (shift alt layer) */ - -/* extended functions (in function field) */ -#define KBD_VTY0 0 /* select vty 0 */ -#define KBD_VTY1 1 /* select vty 1 */ -#define KBD_VTY2 2 /* select vty 2 */ -#define KBD_VTY3 3 /* select vty 3 */ -#define KBD_VTY4 4 /* select vty 4 */ -#define KBD_VTY5 5 /* select vty 5 */ -#define KBD_VTY6 6 /* select vty 6 */ -#define KBD_VTY7 7 /* select vty 7 */ -#define KBD_VTY8 8 /* select vty 8 */ -#define KBD_VTY9 9 /* select vty 9 */ -#define KBD_VTY10 10 /* select vty 10 */ -#define KBD_VTY11 11 /* select vty 11 */ -#define KBD_VTYUP 0x80 /* select next vty */ -#define KBD_VTYDOWN 0x81 /* select previous vty */ -#define KBD_RESETKEY 0x82 /* the CTRL-ALT-DEL key (movable) */ -#define KBD_DEBUGKEY 0x83 /* the CTRL-ALT-ESC key (debugger) */ - -#define KBD_HOTKEYDELETE 0xff /* use to delete a hotkey KBDSSPECF */ - - - -/* These are names used in older versions of keycap/codrv */ -/* do not use the following functions any longer in future */ -#ifdef COMPAT_CO011 -#define KBDRESET KBDCOLDRESET -#define KBDRESET8042 KBDWARMRESET -#define KBDFORCEASCII _IOW('K', 24, int) /* no op in codrv-0.1.2 */ -#define KBD_SCROLLLOCK KBD_LOCKSCROLL -#define KBD_NUMLOCK KBD_LOCKNUM -#define KBD_CAPSLOCK KBD_LOCKCAPS -#define KBDASGNLEDS KBDSCAPSLED -#ifndef KERNEL -struct kbd_sound { - int pitch; /* Frequency in Hz */ - int duration; /* Time in msec */ -}; -#endif -#define KBDSETBELL _IOW('K',21, struct kbd_sound) /* do some music */ -#define OLDKBDSETBEEP _IOW('K',26, struct kbd_sound) /* change beep settings */ - -struct oldkbd_ovlkey { - u_short keynum; - u_short type; - char unshift[KBDMAXOVLKEYSIZE+1]; - char shift[KBDMAXOVLKEYSIZE+1]; - char ctrl[KBDMAXOVLKEYSIZE+1]; - char altgr[KBDMAXOVLKEYSIZE+1]; -}; -#define OLDKBDGCKEY _IOWR('K',16, struct oldkbd_ovlkey) /* get current key values */ - - - -#endif /*COMPAT_CO011*/ - -/*************************************************************************** - * IOCTLs for Video Adapter - ***************************************************************************/ - -/* to define the cursor shape for ioctl */ -struct cursorshape { - int start; /* topmost scanline, range 0...31 */ - int end; /* bottom scanline, range 0...31 */ -}; - -#define VGAGCURSOR _IOR('V',100, struct cursorshape) /* get cursor shape */ -#define VGASCURSOR _IOW('V',101, struct cursorshape) /* set cursor shape */ - - - -/**** information ****/ - -/* the video information structure for ioctl */ -struct videoinfo { - char name[20]; /* ASCIZ name of detected card */ - short type; /* Adapter type, see below */ - short subtype; /* Adapter specific subtype */ - short ram; /* in KBytes */ - short iobase; /* Address of 6845: 0x3b0 / 0x3d0 */ -}; - -/* Get information about the videoboard */ -#define VGAGINFO _IOR('V',102, struct videoinfo) - -/* recognized Adapter types */ -#define VG_UNKNOWN 0 -#define VG_MONO 1 -#define VG_CGA 2 -#define VG_EGA 3 -#define VG_VGA 4 -#define VG_CHIPS 5 -/* CHIPS & TECHNOLOGIES has subtypes: - * 0x10 82c451 - * 0x11 82c452 - * 0x20 82c455 - * 0x30 82c453 - * 0x50 82c455 - */ -#define VG_GENOA 6 -/* GENOA has subtypes: - * 0x33/0x55 5100-5400, ET3000 based - * 0x22 6100 - * 0x00 6200,6300 - * 0x11 6400,6600 - */ -#define VG_PARADISE 7 -/* PARADISE has subtypes: - * 01 PVGA1A,WD90C90 - * 02 WD90C00 - * 03 WD90C10 - * 04 WD90C11 - */ -#define VG_TVGA 8 -/* TVGA has subtypes: - * 00-02 8800 - * 03 8900B - * 04 8900C - * 13 8900C - * 23 9000 - */ -#define VG_ET3000 9 -#define VG_ET4000 10 -#define VG_VIDEO7 11 -/* VIDEO7 has subtypes: - * 0x80-0xfe VEGA VGA - * 0x70-0x7e V7VGA FASTWRITE/VRAM - * 0x50-0x59 V7VGA version 5 - * 0x41-0x49 1024i - */ -#define VG_ATI 12 -/* ATI has subtypes: - * 0x01nn 18800 - * 0x02nn 18800-1 - * 0x03nn 28800-2 - * 0x04nn-05nn - * with nn: - * 0x01 VGA WONDER - * 0x02 EGA WONDER800+ - * 0x03 VGA BASIC 16+ - */ - - - -/**** Screen blanking ****/ - -/* Get (G) / Set (S) screen blanker timeout (seconds), - * time=0 disables blanking - * - * The blanking state is coded in bits 31 and 30 of word returned by get - */ -#define VGA_BLANKOFF 0x00000000 /* display is on, no blanking */ -#define VGA_BLANKON 0x40000000 /* display is on, wait for blank */ -#define VGA_BLANKED 0x80000000 /* display is dark */ -#define VGAGBLANK _IOR('V',2,int) -#define VGASBLANK _IOW('V',3,int) - - - -/**** Text/Attribute direct access, block move ****/ - -struct vga_block { - short mode; - short pagenum; - short x0,y0; /* upper left coordinates 0..x-1, 0..y-1 */ - short x1,y1; /* lower right coordinates >= x0,y0 */ - u_char *map; /* must be allocated by user process ! */ -}; - -/* mode word */ -#define VGA_SCREEN 0x01 /* entire screen, ignore x,y */ -#define VGA_WINDOW 0x02 /* use x,y for a rectangular window */ -#define VGA_TEXT 0x10 /* copy text information only */ -#define VGA_ATTR 0x20 /* copy attribute information only */ -#define VGA_BOTH 0x30 /* copy text and attribute */ -#define VGA_ALL 0x31 /* copy complete screen */ - -/* Get (G) / Set (S) a rectangular block of screen - * The virtual screen need not be visible. - * The buffer must be provided by the user process and must be large enough - * use VGAGVRES to find out how many bytes - * pagenum: 0..n, n < max_vty, VTY number - * -1, actual VTY - */ -#define VGAGBLOCK _IOWR('V',4,struct vga_block) -#define VGASBLOCK _IOW('V',5,struct vga_block) - - - -#define VGA_TXTPAGE0 0 -#define VGA_TXTPAGE1 1 -#ifdef notyet -#define VGA_GFXPAGE 2 -#endif -#define VGA_PC8CODING 0x80 /* obsolete ! */ - -/* maximum dimension of pixels - * Note: this is the space reserved in the fontchar map, but - * does not mean, that this resolution is accepted in the current release - * codrv-0.1.2 accepts 8x16 / "9x16" fonts only - */ -#define VGA_MAXX 16 -#define VGA_MAXY 16 - -struct fchar { - XCHAR encoding; /* encoding of character */ - char _f1_,_f2_,_f3_; /* filler */ - u_char map[VGA_MAXX/8*VGA_MAXY]; -}; - -struct fmap { - short page; /* page to load */ - short nr; /* nr of characters to load */ - char x,y; /* x,y pixel width */ - XCHAR start; /* first character in sequence (get only) */ - struct fchar *fntmap; /* allocated by user process */ -}; - -/* get (G) / set (S) font map. Must provide page,nr,start for get */ -#define VGAGFONTMAP _IOWR('V',6,struct fmap) -#define VGASFONTMAP _IOW('V',7,struct fmap) - - - -/* do not use the following functions any longer in future */ -#ifdef COMPAT_CO011 -/* miscellaneous functions: */ -#define VGA_DIS1 1 /* disable font 1 */ -#define VGA_GTENC 2 /* get current encoding */ -#define VGA_SBLANK 3 /* set screen blanking timeout (use VGASBLANK!) */ -#define VGA_GBLANK 4 /* get screen blanking timeout (use VGAGBLANK!) */ - -struct miscfcns { - u_char cmd; - union { - short enc[2]; - int timeout; - } u; -}; -#define VGAMISCFCNS _IOWR('V',107,struct miscfcns) /* misc functions */ - - -/* Font mapping this needs at least an EGA card (else EINVAL) */ -#define VGAFNTLATIN1 0x00 -#define VGAFNTEXTEND1 0x01 -#define VGAFNTEXTEND2 0x02 -#define VGAFNTGREEK 0x03 -#define VGAFNTCYRILLIC 0x04 -#define VGAFNTHEBREW 0x05 -#define VGAFNTARABIAN 0x06 - -#define VGA_FNTNCHARS 256 -#define VGA_FNTCSIZE 15 - -struct fontchar { - u_char page; /* which font page */ - u_char idx; /* which char in font page */ - u_char cmap[VGA_FNTCSIZE]; /* character bitmap */ -}; - -#define OLDVGAGCHAR _IOWR('V',105,struct fontchar) /* get character of font */ -#define OLDVGASCHAR _IOW('V',106,struct fontchar) /* set character in font */ - -struct fontmap { - u_char page; /* page to load */ - u_short encoding; /* font encoding */ - u_char map[VGA_FNTNCHARS*VGA_FNTCSIZE]; -}; - -#define OLDVGAGFNTMAP _IOWR('V',103,struct fontmap) /* get font */ -#define VGAGFNTMAP OLDVGAGFNTMAP -#define OLDVGASFNTMAP _IOW('V',104,struct fontmap) /* set font */ -#define VGASFNTMAP OLDVGASFNTMAP - -#endif - - - - -struct textpage { - u_char pagenum; /* note: only page 0 used by vtys */ -#define VGA_TEXTATTR 0 -#define VGA_TEXTDATA 1 - u_char ad; -#define VGA_LINES 50 /* only 25 used for now */ -#define VGA_COLUMNS 80 - u_char map[VGA_LINES*VGA_COLUMNS]; -}; - -#define VGAGPAGE _IOWR('V',108,struct textpage) /* get a data page */ -#define VGASPAGE _IOW('V',109,struct textpage) /* set a data page */ - -/**** Signalling access ****/ - -/* Use "take control" in an application program to signal the kernel - * that the program wants to use video memory (such as Xserver) - * before the program switches modes - * - * Use "give control" to return the control to the kernel. The application - * should have restored the original state before giving back control. - * Close /dev/vga also returns control. - * - * However, the kernel remains the master in the house, and reserves the right - * to grab control back at any time. (It usually doesn't). - * - */ -#define VGATAKECTRL _IO('V',8) -#define VGAGIVECTRL _IO('V',9) - -/*************************************************************************** - * Pandora's box, don't even think of using the following ioctl's - * (if you happen to find some; codrv_experimental might not be - * available at your system) - ***************************************************************************/ - -#ifdef PANDORA -#include "codrv_experimental.h" -#endif - - - -/*************************************************************************** - * XFree86 pccons support - ***************************************************************************/ - -#ifdef COMPAT_PCCONS -/* The following calls are special to the old pccons driver and are - * not understood or supported by codrv. - * This file serves as a central definition base for these calls - * in order to avoid defining them in applications that want to - * use them. - * - * One word of warning: There are different purpose tty ioctls - * with the same encoding, see - * TIOCSDTR = _IO('t', 121) - * TIOCCBRK = _IO('t', 122) - * - */ -#define CONSOLE_X_MODE_ON _IO('t',121) -#define CONSOLE_X_MODE_OFF _IO('t',122) -#define CONSOLE_X_BELL _IOW('t',123,int[2]) -#endif /* COMPAT_PCCONS */ - -#endif /* _IOCTL_PC_H_ */ - diff --git a/sys/i386/include/limits.h b/sys/i386/include/limits.h deleted file mode 100644 index 82fac5f..0000000 --- a/sys/i386/include/limits.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1988 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)limits.h 7.2 (Berkeley) 6/28/90 - * $Id$ - */ - -#define CHAR_BIT 8 /* number of bits in a char */ -#define CLK_TCK 60 /* ticks per second */ -#define MB_LEN_MAX 1 /* no multibyte characters */ - -#define SCHAR_MIN (-0x7f-1) /* max value for a signed char */ -#define SCHAR_MAX 0x7f /* min value for a signed char */ - -#define UCHAR_MAX 0xff /* max value for an unsigned char */ -#define CHAR_MAX 0x7f /* max value for a char */ -#define CHAR_MIN (-0x7f-1) /* min value for a char */ - -#define USHRT_MAX 0xffff /* max value for an unsigned short */ -#define SHRT_MAX 0x7fff /* max value for a short */ -#define SHRT_MIN (-0x7fff-1) /* min value for a short */ - -#define UINT_MAX 0xffffffff /* max value for an unsigned int */ -#define INT_MAX 0x7fffffff /* max value for an int */ -#define INT_MIN (-0x7fffffff-1) /* min value for an int */ - -#define ULONG_MAX 0xffffffff /* max value for an unsigned long */ -#define LONG_MAX 0x7fffffff /* max value for a long */ -#define LONG_MIN (-0x7fffffff-1) /* min value for a long */ diff --git a/sys/i386/include/mtpr.h b/sys/i386/include/mtpr.h deleted file mode 100644 index e8347e6..0000000 --- a/sys/i386/include/mtpr.h +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Unused in 386BSD port - * $Id$ - */ diff --git a/sys/i386/include/npx.h b/sys/i386/include/npx.h deleted file mode 100644 index eab6457..0000000 --- a/sys/i386/include/npx.h +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 - * $Id$ - */ - -/* - * 287/387 NPX Coprocessor Data Structures and Constants - * W. Jolitz 1/90 - */ - -#ifndef ___NPX87___ -#define ___NPX87___ - -/* Environment information of floating point unit */ -struct env87 { - long en_cw; /* control word (16bits) */ - long en_sw; /* status word (16bits) */ - long en_tw; /* tag word (16bits) */ - long en_fip; /* floating point instruction pointer */ - u_short en_fcs; /* floating code segment selector */ - u_short en_opcode; /* opcode last executed (11 bits ) */ - long en_foo; /* floating operand offset */ - long en_fos; /* floating operand segment selector */ -}; - -/* Contents of each floating point accumulator */ -struct fpacc87 { -#ifdef dontdef /* too unportable */ - u_long fp_mantlo; /* mantissa low (31:0) */ - u_long fp_manthi; /* mantissa high (63:32) */ - int fp_exp:15; /* exponent */ - int fp_sgn:1; /* mantissa sign */ -#else - u_char fp_bytes[10]; -#endif -}; - -/* Floating point context */ -struct save87 { - struct env87 sv_env; /* floating point control/status */ - struct fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */ -#ifndef dontdef - u_long sv_ex_sw; /* status word for last exception (was pad) */ - u_long sv_ex_tw; /* tag word for last exception (was pad) */ - u_char sv_pad[8 * 2 - 2 * 4]; /* bogus historical padding */ -#endif -}; - -/* Cyrix EMC memory - mapped coprocessor context switch information */ -struct emcsts { - long em_msw; /* memory mapped status register when swtched */ - long em_tar; /* memory mapped temp A register when swtched */ - long em_dl; /* memory mapped D low register when swtched */ -}; - -/* Intel prefers long real (53 bit) precision */ -#define __iBCS_NPXCW__ 0x262 -/* wfj prefers temporary real (64 bit) precision */ -#define __386BSD_NPXCW__ 0x362 -/* - * bde prefers 53 bit precision and all exceptions masked. - * - * The standard control word from finit is 0x37F, giving: - * - * round to nearest - * 64-bit precision - * all exceptions masked. - * - * Now I want: - * - * affine mode for 287's (if they work at all) (1 in bitfield 1<<12) - * 53-bit precision (2 in bitfield 3<<8) - * overflow exception unmasked (0 in bitfield 1<<3) - * zero divide exception unmasked (0 in bitfield 1<<2) - * invalid-operand exception unmasked (0 in bitfield 1<<0). - * - * 64-bit precision often gives bad results with high level languages - * because it makes the results of calculations depend on whether - * intermediate values are stored in memory or in FPU registers. - * - * The "Intel" and wfj control words have: - * - * underflow exception unmasked (0 in bitfield 1<<4) - * - * but that causes an unexpected exception in the test program 'paranoia' - * and makes denormals useless (DBL_MIN / 2 underflows). It doesn't make - * a lot of sense to trap underflow without trapping denormals. - * - * Later I will want the IEEE default of all exceptions masked. See the - * 0.0 math manpage for why this is better. The 0.1 math manpage is empty. - */ -#define __BDE_NPXCW__ 0x1272 -#define __BETTER_BDE_NPXCW__ 0x127f - -#ifdef __BROKEN_NPXCW__ -#ifdef __386BSD__ -#define __INITIAL_NPXCW__ __386BSD_NPXCW__ -#else -#define __INITIAL_NPXCW__ __iBCS_NPXCW__ -#endif -#else -#define __INITIAL_NPXCW__ __BDE_NPXCW__ -#endif - -#endif ___NPX87___ diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h deleted file mode 100644 index 546a8f31..0000000 --- a/sys/i386/include/param.h +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 - * $Id: param.h,v 1.6 1993/10/12 12:08:16 rgrimes Exp $ - */ - -/* - * Machine dependent constants for Intel 386. - */ - -#define MACHINE "i386" -#define MID_MACHINE MID_I386 - -/* - * Round p (pointer or byte index) up to a correctly-aligned value - * for all data types (int, long, ...). The result is u_int and - * must be cast to any desired pointer type. - */ -#define ALIGNBYTES (sizeof(int) - 1) -#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) - -/* XXX PGSHIFT and PG_SHIFT are two names for the same thing */ -#define PGSHIFT 12 /* LOG2(NBPG) */ -#define NBPG (1 << PGSHIFT) /* bytes/page */ -#define PGOFSET (NBPG-1) /* byte offset into page */ -#define NPTEPG (NBPG/(sizeof (struct pte))) - -/* XXX PDRSHIFT and PD_SHIFT are two names for the same thing */ -#define PDRSHIFT 22 /* LOG2(NBPDR) */ -#define NBPDR (1 << PDRSHIFT) /* bytes/page dir */ -#define PDROFSET (NBPDR-1) /* byte offset into page dir */ - -/* - * XXX This should really be KPTDPTDI << PDRSHIFT, but since KPTDPTDI is - * defined in pmap.h which is included after this we can't do that - * (YET!) - */ -#define KERNBASE 0xFE000000 /* start of kernel virtual */ -#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) - -#define KERNSIZE 0x00C00000 /* size of kernel virtual */ - -#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ -#define DEV_BSIZE (1 << DEV_BSHIFT) - -#define BLKDEV_IOSIZE 2048 -#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ - -#define CLSIZELOG2 0 -#define CLSIZE (1 << CLSIZELOG2) - -/* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ -#define SSIZE 1 /* initial stack size/NBPG */ -#define SINCR 1 /* increment of stack/NBPG */ - -#define UPAGES 2 /* pages of u-area */ - -/* - * Constants related to network buffer management. - * MCLBYTES must be no larger than CLBYTES (the software page size), and, - * on machines that exchange pages of input or output buffers with mbuf - * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple - * of the hardware page size. - */ -#ifndef MSIZE -#define MSIZE 128 /* size of an mbuf */ -#endif /* MSIZE */ - -#ifndef MCLSHIFT -#define MCLSHIFT 11 /* convert bytes to m_buf clusters */ -#endif /* MCLSHIFT */ -#define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */ -#define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */ - -#ifndef NMBCLUSTERS -#ifdef GATEWAY -#define NMBCLUSTERS 512 /* map size, max cluster allocation */ -#else -#define NMBCLUSTERS 256 /* map size, max cluster allocation */ -#endif /* GATEWAY */ -#endif /* NMBCLUSTERS */ - -/* - * Some macros for units conversion - */ -/* Core clicks (4096 bytes) to segments and vice versa */ -#define ctos(x) (x) -#define stoc(x) (x) - -/* Core clicks (4096 bytes) to disk blocks */ -#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) -#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) -#define dtob(x) ((x)<>PGSHIFT) - -#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ - ((unsigned)(bytes) >> DEV_BSHIFT) -#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ - ((unsigned)(db) << DEV_BSHIFT) - -/* - * Map a ``block device block'' to a file system block. - * This should be device dependent, and will be if we - * add an entry to cdevsw/bdevsw for that purpose. - * For now though just use DEV_BSIZE. - */ -#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) - -/* - * Mach derived conversion macros - */ -#define i386_round_pdr(x) ((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1)) -#define i386_trunc_pdr(x) ((unsigned)(x) & ~(NBPDR-1)) -#define i386_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) -#define i386_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) -#define i386_btod(x) ((unsigned)(x) >> PDRSHIFT) -#define i386_dtob(x) ((unsigned)(x) << PDRSHIFT) -#define i386_btop(x) ((unsigned)(x) >> PGSHIFT) -#define i386_ptob(x) ((unsigned)(x) << PGSHIFT) - -/* - * phystokv stolen from SCSI device drivers and fixed to use KERNBASE - */ -#define PHYSTOKV(x) (x | KERNBASE) diff --git a/sys/i386/include/pc/display.h b/sys/i386/include/pc/display.h deleted file mode 100644 index 9e64a3f..0000000 --- a/sys/i386/include/pc/display.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * IBM PC display definitions - * - * $Id$ - */ - -/* Color attributes for foreground text */ - -#define FG_BLACK 0 -#define FG_BLUE 1 -#define FG_GREEN 2 -#define FG_CYAN 3 -#define FG_RED 4 -#define FG_MAGENTA 5 -#define FG_BROWN 6 -#define FG_LIGHTGREY 7 -#define FG_DARKGREY 8 -#define FG_LIGHTBLUE 9 -#define FG_LIGHTGREEN 10 -#define FG_LIGHTCYAN 11 -#define FG_LIGHTRED 12 -#define FG_LIGHTMAGENTA 13 -#define FG_YELLOW 14 -#define FG_WHITE 15 -#define FG_BLINK 0x80 - -/* Color attributes for text background */ - -#define BG_BLACK 0x00 -#define BG_BLUE 0x10 -#define BG_GREEN 0x20 -#define BG_CYAN 0x30 -#define BG_RED 0x40 -#define BG_MAGENTA 0x50 -#define BG_BROWN 0x60 -#define BG_LIGHTGREY 0x70 - -/* Monochrome attributes for foreground text */ - -#define FG_UNDERLINE 0x01 -#define FG_INTENSE 0x08 - -/* Monochrome attributes for text background */ - -#define BG_INTENSE 0x10 diff --git a/sys/i386/include/pc/msdos.h b/sys/i386/include/pc/msdos.h deleted file mode 100644 index ea221c7..0000000 --- a/sys/i386/include/pc/msdos.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * msdos common header file - * [obtained from mtools -wfj] - * how to decipher DOS disk structures in coexisting with DOS - * - * $Id$ - */ - -#define MSECTOR_SIZE 512 /* MSDOS sector size in bytes */ -#define MDIR_SIZE 32 /* MSDOS directory size in bytes */ -#define MAX_CLUSTER 8192 /* largest cluster size */ -#define MAX_PATH 128 /* largest MSDOS path length */ -#define MAX_DIR_SECS 64 /* largest directory (in sectors) */ - -#define NEW 1 -#define OLD 0 - -struct directory { - unsigned char name[8]; /* file name */ - unsigned char ext[3]; /* file extension */ - unsigned char attr; /* attribute byte */ - unsigned char reserved[10]; /* ?? */ - unsigned char time[2]; /* time stamp */ - unsigned char date[2]; /* date stamp */ - unsigned char start[2]; /* starting cluster number */ - unsigned char size[4]; /* size of the file */ -}; - -struct bootsector { - unsigned char jump[3]; /* Jump to boot code */ - unsigned char banner[8]; /* OEM name & version */ - unsigned char secsiz[2]; /* Bytes per sector hopefully 512 */ - unsigned char clsiz; /* Cluster size in sectors */ - unsigned char nrsvsect[2]; /* Number of reserved (boot) sectors */ - unsigned char nfat; /* Number of FAT tables hopefully 2 */ - unsigned char dirents[2]; /* Number of directory slots */ - unsigned char psect[2]; /* Total sectors on disk */ - unsigned char descr; /* Media descriptor=first byte of FAT */ - unsigned char fatlen[2]; /* Sectors in FAT */ - unsigned char nsect[2]; /* Sectors/track */ - unsigned char nheads[2]; /* Heads */ - unsigned char nhs[4]; /* number of hidden sectors */ - unsigned char bigsect[4]; /* big total sectors */ - unsigned char junk[476]; /* who cares? */ -}; - -/* DOS partition table -- located in boot block */ - -#define DOSBBSECTOR 0 /* DOS boot block relative sector number */ -#define DOSPARTOFF 446 -#define NDOSPART 4 - -struct dos_partition { - unsigned char dp_flag; /* bootstrap flags */ - unsigned char dp_shd; /* starting head */ - unsigned char dp_ssect; /* starting sector */ - unsigned char dp_scyl; /* starting cylinder */ - unsigned char dp_typ; /* partition type */ -#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */ - unsigned char dp_ehd; /* end head */ - unsigned char dp_esect; /* end sector */ - unsigned char dp_ecyl; /* end cylinder */ - unsigned long dp_start; /* absolute starting sector number */ - unsigned long dp_size; /* partition size in sectors */ -} dos_partitions[NDOSPART]; diff --git a/sys/i386/include/pcb.h b/sys/i386/include/pcb.h deleted file mode 100644 index 96485b4..0000000 --- a/sys/i386/include/pcb.h +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 - * $Id$ - */ - -#ifndef _I386_PCB_H_ -#define _I386_PCB_H_ - -/* - * Intel 386 process control block - */ -#include "machine/tss.h" -#include "machine/npx.h" - -struct pcb { - struct i386tss pcb_tss; -#define pcb_ksp pcb_tss.tss_esp0 -#define pcb_ptd pcb_tss.tss_cr3 -#define pcb_cr3 pcb_ptd -#define pcb_pc pcb_tss.tss_eip -#define pcb_psl pcb_tss.tss_eflags -#define pcb_usp pcb_tss.tss_esp -#define pcb_fp pcb_tss.tss_ebp -#ifdef notyet - u_char pcb_iomap[NPORT/sizeof(u_char)]; /* i/o port bitmap */ -#endif - caddr_t pcb_ldt; /* per process (user) LDT */ - int pcb_ldt_len; /* number of LDT entries */ - struct save87 pcb_savefpu; /* floating point state for 287/387 */ - struct emcsts pcb_saveemc; /* Cyrix EMC state */ -/* - * Software pcb (extension) - */ - int pcb_flags; -#ifdef notused -#define FP_WASUSED 0x01 /* process has used fltng pnt hardware */ -#define FP_NEEDSSAVE 0x02 /* ... that needs save on next context switch */ -#define FP_NEEDSRESTORE 0x04 /* ... that needs restore on next DNA fault */ -#endif -#define FP_USESEMC 0x08 /* process uses EMC memory-mapped mode */ -#define FM_TRAP 0x10 /* process entered kernel on a trap frame */ -#define FP_SOFTFP 0x20 /* process using software fltng pnt emulator */ - short pcb_iml; /* interrupt mask level */ - caddr_t pcb_onfault; /* copyin/out fault recovery */ - long pcb_sigc[8]; /* XXX signal code trampoline */ - int pcb_cmap2; /* XXX temporary PTE - will prefault instead */ -}; - -#ifdef KERNEL -struct pcb *curpcb; /* our current running pcb */ -#endif - -#endif /* _I386_PCB_H_ */ diff --git a/sys/i386/include/pio.h b/sys/i386/include/pio.h deleted file mode 100644 index 2cb714c..0000000 --- a/sys/i386/include/pio.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1990 Carnegie-Mellon University - * All rights reserved. The CMU software License Agreement specifies - * the terms and conditions for use and redistribution. - * - * from: Mach, unknown, 386BSD patch kit - * $Id$ - */ - -#define inl(y) \ -({ unsigned long _tmp__; \ - asm volatile("inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ - _tmp__; }) - -#define inw(y) \ -({ unsigned short _tmp__; \ - asm volatile(".byte 0x66; inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ - _tmp__; }) - -/* - * only do this if it has not already be defined.. this is a crock for the - * patch kit for right now. Need to clean up all the inx, outx stuff for - * 0.1.5 to use 1 common header file, that has Bruces fast mode inb/outb - * stuff in it. Rgrimes 5/27/93 - */ -#ifndef inb -#define inb(y) \ -({ unsigned char _tmp__; \ - asm volatile("inb %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(y))); \ - _tmp__; }) -#endif - - -#define outl(x, y) \ -{ asm volatile("outl %0, %1" : : "a" (y) , "d" ((unsigned short)(x))); } - - -#define outw(x, y) \ -{asm volatile(".byte 0x66; outl %0, %1" : : "a" ((unsigned short)(y)) , "d" ((unsigned short)(x))); } - - -#define outb(x, y) \ -{ asm volatile("outb %0, %1" : : "a" ((unsigned char)(y)) , "d" ((unsigned short)(x))); } diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h deleted file mode 100644 index 3fe1248..0000000 --- a/sys/i386/include/pmap.h +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 1991 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department and William Jolitz of UUNET Technologies Inc. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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 from hp300 version by Mike Hibler, this version by William - * Jolitz uses a recursive map [a pde points to the page directory] to - * map the page tables using the pagetables themselves. This is done to - * reduce the impact on kernel virtual memory for lots of sparse address - * space, and to reduce the cost of memory to each process. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 - * $Id$ - */ - -#ifndef _PMAP_MACHINE_ -#define _PMAP_MACHINE_ 1 - -/* - * 386 page table entry and page table directory - * W.Jolitz, 8/89 - */ -struct pde -{ -unsigned int - pd_v:1, /* valid bit */ - pd_prot:2, /* access control */ - pd_mbz1:2, /* reserved, must be zero */ - pd_u:1, /* hardware maintained 'used' bit */ - :1, /* not used */ - pd_mbz2:2, /* reserved, must be zero */ - :3, /* reserved for software */ - pd_pfnum:20; /* physical page frame number of pte's*/ -}; - -#define PD_MASK 0xffc00000 /* page directory address bits */ -#define PT_MASK 0x003ff000 /* page table address bits */ -#define PD_SHIFT 22 /* page directory address shift */ -#define PG_SHIFT 12 /* page table address shift */ - -struct pte -{ -unsigned int - pg_v:1, /* valid bit */ - pg_prot:2, /* access control */ - pg_mbz1:2, /* reserved, must be zero */ - pg_u:1, /* hardware maintained 'used' bit */ - pg_m:1, /* hardware maintained modified bit */ - pg_mbz2:2, /* reserved, must be zero */ - pg_w:1, /* software, wired down page */ - :1, /* software (unused) */ - pg_nc:1, /* 'uncacheable page' bit */ - pg_pfnum:20; /* physical page frame number */ -}; - -#define PG_V 0x00000001 -#define PG_RO 0x00000000 -#define PG_RW 0x00000002 -#define PG_u 0x00000004 -#define PG_PROT 0x00000006 /* all protection bits . */ -#define PG_W 0x00000200 -#define PG_N 0x00000800 /* Non-cacheable */ -#define PG_M 0x00000040 -#define PG_U 0x00000020 -#define PG_FRAME 0xfffff000 - -#define PG_NOACC 0 -#define PG_KR 0x00000000 -#define PG_KW 0x00000002 -#define PG_URKR 0x00000004 -#define PG_URKW 0x00000004 -#define PG_UW 0x00000006 - -/* Garbage for current bastardized pager that assumes a hp300 */ -#define PG_NV 0 -#define PG_CI 0 - -/* - * Page Protection Exception bits - */ -#define PGEX_P 0x01 /* Protection violation vs. not present */ -#define PGEX_W 0x02 /* during a Write cycle */ -#define PGEX_U 0x04 /* access from User mode (UPL) */ - -typedef struct pde pd_entry_t; /* page directory entry */ -typedef struct pte pt_entry_t; /* Mach page table entry */ - -/* - * NKPDE controls the virtual space of the kernel, what ever is left is - * given to the user (NUPDE) - */ -#define NKPDE 7 /* number of kernel pde's */ -#define NUPDE (NPTEPG-NKPDE) /* number of user pde's */ -/* - * The *PTDI values control the layout of virtual memory - * - * XXX This works for now, but I am not real happy with it, I'll fix it - * right after I fix locore.s and the magic 28K hole - */ -#define APTDPTDI (NPTEPG-1) /* alt ptd entry that points to APTD */ -#define KPTDI (APTDPTDI-NKPDE)/* start of kernel virtual pde's */ -#define PTDPTDI (KPTDI-1) /* ptd entry that points to ptd! */ -#define UPTDI (PTDPTDI-1) /* ptd entry for u./kernel&user stack */ - -/* - * Address of current and alternate address space page table maps - * and directories. - */ -#ifdef KERNEL -extern struct pte PTmap[], APTmap[], Upte; -extern struct pde PTD[], APTD[], PTDpde, APTDpde, Upde; -extern pt_entry_t *Sysmap; - -extern int IdlePTD; /* physical address of "Idle" state directory */ -#endif - -/* - * virtual address to page table entry and - * to physical address. Likewise for alternate address space. - * Note: these work recursively, thus vtopte of a pte will give - * the corresponding pde that in turn maps it. - */ -#define vtopte(va) (PTmap + i386_btop(va)) -#define kvtopte(va) vtopte(va) -#define ptetov(pt) (i386_ptob(pt - PTmap)) -#define vtophys(va) (i386_ptob(vtopte(va)->pg_pfnum) | ((int)(va) & PGOFSET)) -#define ispt(va) ((va) >= UPT_MIN_ADDRESS && (va) <= KPT_MAX_ADDRESS) - -#define avtopte(va) (APTmap + i386_btop(va)) -#define ptetoav(pt) (i386_ptob(pt - APTmap)) -#define avtophys(va) (i386_ptob(avtopte(va)->pg_pfnum) | ((int)(va) & PGOFSET)) - -/* - * macros to generate page directory/table indicies - */ - -#define pdei(va) (((va)&PD_MASK)>>PD_SHIFT) -#define ptei(va) (((va)&PT_MASK)>>PG_SHIFT) - -/* - * Pmap stuff - */ - -struct pmap { - pd_entry_t *pm_pdir; /* KVA of page directory */ - boolean_t pm_pdchanged; /* pdir changed */ - short pm_dref; /* page directory ref count */ - short pm_count; /* pmap reference count */ - simple_lock_data_t pm_lock; /* lock on pmap */ - struct pmap_statistics pm_stats; /* pmap statistics */ - long pm_ptpages; /* more stats: PT pages */ -}; - -typedef struct pmap *pmap_t; - -#ifdef KERNEL -extern pmap_t kernel_pmap; -#endif - -/* - * Macros for speed - */ -#define PMAP_ACTIVATE(pmapp, pcbp) \ - if ((pmapp) != NULL /*&& (pmapp)->pm_pdchanged */) { \ - (pcbp)->pcb_cr3 = \ - pmap_extract(kernel_pmap, (pmapp)->pm_pdir); \ - if ((pmapp) == &curproc->p_vmspace->vm_pmap) \ - load_cr3((pcbp)->pcb_cr3); \ - (pmapp)->pm_pdchanged = FALSE; \ - } - -#define PMAP_DEACTIVATE(pmapp, pcbp) - -/* - * For each vm_page_t, there is a list of all currently valid virtual - * mappings of that page. An entry is a pv_entry_t, the list is pv_table. - */ -typedef struct pv_entry { - struct pv_entry *pv_next; /* next pv_entry */ - pmap_t pv_pmap; /* pmap where mapping lies */ - vm_offset_t pv_va; /* virtual address for mapping */ - int pv_flags; /* flags */ -} *pv_entry_t; - -#define PV_ENTRY_NULL ((pv_entry_t) 0) - -#define PV_CI 0x01 /* all entries must be cache inhibited */ -#define PV_PTPAGE 0x02 /* entry maps a page table page */ - -#ifdef KERNEL - -pv_entry_t pv_table; /* array of entries, one per page */ - -#define pa_index(pa) atop(pa - vm_first_phys) -#define pa_to_pvh(pa) (&pv_table[pa_index(pa)]) - -#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) - -#endif KERNEL - -#endif _PMAP_MACHINE_ diff --git a/sys/i386/include/proc.h b/sys/i386/include/proc.h deleted file mode 100644 index 0e17164..0000000 --- a/sys/i386/include/proc.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 - * $Id$ - */ - -/* - * Machine-dependent part of the proc structure for hp300. - */ -struct mdproc { - int md_flags; /* machine-dependent flags */ -#ifdef notyet - int *p_regs; /* registers on current frame */ -#endif -}; - -/* md_flags */ -#define MDP_AST 0x0001 /* async trap pending */ diff --git a/sys/i386/include/psl.h b/sys/i386/include/psl.h deleted file mode 100644 index 21de5f7..0000000 --- a/sys/i386/include/psl.h +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)psl.h 5.2 (Berkeley) 1/18/91 - * $Id$ - */ - -/* - * 386 processor status longword. - */ -#define PSL_C 0x00000001 /* carry bit */ -#define PSL_PF 0x00000004 /* parity bit */ -#define PSL_AF 0x00000010 /* bcd carry bit */ -#define PSL_Z 0x00000040 /* zero bit */ -#define PSL_N 0x00000080 /* negative bit */ -#define PSL_T 0x00000100 /* trace enable bit */ -#define PSL_I 0x00000200 /* interrupt enable bit */ -#define PSL_D 0x00000400 /* string instruction direction bit */ -#define PSL_V 0x00000800 /* overflow bit */ -#define PSL_IOPL 0x00003000 /* i/o priviledge level enable */ -#define PSL_NT 0x00004000 /* nested task bit */ -#define PSL_RF 0x00010000 /* restart flag bit */ -#define PSL_VM 0x00020000 /* virtual 8086 mode bit */ - -#define PSL_MBZ 0xfffc7fb7 /* must be zero bits */ -#define PSL_MBO 0x00000002 /* must be one bits */ - -#define PSL_USERSET (PSL_IOPL) -#define PSL_USERCLR (PSL_I|PSL_NT) diff --git a/sys/i386/include/pte.h b/sys/i386/include/pte.h deleted file mode 100644 index a98a357..0000000 --- a/sys/i386/include/pte.h +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)pte.h 5.5 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * 386 page table entry and page table directory - * W.Jolitz, 8/89 - * - * There are two major kinds of pte's: those which have ever existed (and are - * thus either now in core or on the swap device), and those which have - * never existed, but which will be filled on demand at first reference. - * There is a structure describing each. There is also an ancillary - * structure used in page clustering. - */ - -#ifndef LOCORE -struct pde -{ -unsigned int - pd_v:1, /* valid bit */ - pd_prot:2, /* access control */ - pd_mbz1:2, /* reserved, must be zero */ - pd_u:1, /* hardware maintained 'used' bit */ - :1, /* not used */ - pd_mbz2:2, /* reserved, must be zero */ - :3, /* reserved for software */ - pd_pfnum:20; /* physical page frame number of pte's*/ -}; -struct pte -{ -unsigned int - pg_v:1, /* valid bit */ - pg_prot:2, /* access control */ - pg_mbz1:2, /* reserved, must be zero */ - pg_u:1, /* hardware maintained 'used' bit */ - pg_m:1, /* hardware maintained modified bit */ - pg_mbz2:2, /* reserved, must be zero */ - pg_fod:1, /* is fill on demand (=0) */ - :1, /* must write back to swap (unused) */ - pg_nc:1, /* 'uncacheable page' bit */ - pg_pfnum:20; /* physical page frame number */ -}; -struct hpte -{ -unsigned int - pg_high:12, /* special for clustering */ - pg_pfnum:20; -}; -struct fpte -{ -unsigned int - pg_v:1, /* valid bit */ - pg_prot:2, /* access control */ - :5, - pg_fileno:1, /* file mapped from or TEXT or ZERO */ - pg_fod:1, /* is fill on demand (=1) */ - pg_blkno:22; /* file system block number */ -}; -#endif - -#define PD_MASK 0xffc00000 /* page directory address bits */ -#define PD_SHIFT 22 /* page directory address bits */ - -#define PG_V 0x00000001 -#define PG_PROT 0x00000006 /* all protection bits . */ -#define PG_FOD 0x00000200 -#define PG_SWAPM 0x00000400 -#define PG_N 0x00000800 /* Non-cacheable */ -#define PG_M 0x00000040 -#define PG_U 0x00000020 /* not currently used */ -#define PG_FRAME 0xfffff000 - -#define PG_FZERO 0 -#define PG_FTEXT 1 -#define PG_FMAX (PG_FTEXT) - -#define PG_NOACC 0 -#define PG_KR 0x00000000 -#define PG_KW 0x00000002 -#define PG_URKR 0x00000004 -#define PG_URKW 0x00000004 -#define PG_UW 0x00000006 - -/* - * Page Protection Exception bits - */ - -#define PGEX_P 0x01 /* Protection violation vs. not present */ -#define PGEX_W 0x02 /* during a Write cycle */ -#define PGEX_U 0x04 /* access from User mode (UPL) */ - -/* - * Pte related macros - */ -#define dirty(pte) ((pte)->pg_m) - -#ifndef LOCORE -#ifdef KERNEL -/* utilities defined in pmap.c */ -extern struct pte *Sysmap; -#endif -#endif diff --git a/sys/i386/include/reg.h b/sys/i386/include/reg.h deleted file mode 100644 index 11d930d..0000000 --- a/sys/i386/include/reg.h +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)reg.h 5.5 (Berkeley) 1/18/91 - * $Id$ - */ - -/* - * Location of the users' stored - * registers within appropriate frame of 'trap' and 'syscall', relative to - * base of stack frame. - * Normal usage is u.u_ar0[XX] in kernel. - */ - -/* When referenced during a trap/exception, registers are at these offsets */ - -#define tES (0) -#define tDS (1) -#define tEDI (2) -#define tESI (3) -#define tEBP (4) - -#define tEBX (6) -#define tEDX (7) -#define tECX (8) -#define tEAX (9) - -#define tEIP (12) -#define tCS (13) -#define tEFLAGS (14) -#define tESP (15) -#define tSS (16) - -/* During a system call, registers are at these offsets instead of above. */ - -#define sEDI (0) -#define sESI (1) -#define sEBP (2) - -#define sEBX (4) -#define sEDX (5) -#define sECX (6) -#define sEAX (7) -#define sEFLAGS (8) -#define sEIP (9) -#define sCS (10) -#define sESP (11) -#define sSS (12) - -#define PC sEIP -#define SP sESP -#define PS sEFLAGS -#define R0 sEDX -#define R1 sECX -/* - * Registers accessible to ptrace(2) syscall for debugger - */ -#ifdef IPCREG -#define NIPCREG 14 -int ipcreg[NIPCREG] = - { tES,tDS,tEDI,tESI,tEBP,tEBX,tEDX,tECX,tEAX,tEIP,tCS,tEFLAGS,tESP,tSS }; -#endif diff --git a/sys/i386/include/segments.h b/sys/i386/include/segments.h deleted file mode 100644 index bc77569..0000000 --- a/sys/i386/include/segments.h +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * Copyright (c) 1989, 1990 William F. Jolitz - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * 386 Segmentation Data Structures and definitions - * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989 - */ - -/* - * Selectors - */ - -#define ISPL(s) ((s)&3) /* what is the priority level of a selector */ -#define SEL_KPL 0 /* kernel priority level */ -#define SEL_UPL 3 /* user priority level */ -#define ISLDT(s) ((s)&SEL_LDT) /* is it local or global */ -#define SEL_LDT 4 /* local descriptor table */ -#define IDXSEL(s) (((s)>>3) & 0x1fff) /* index of selector */ -#define LSEL(s,r) (((s)<<3) | SEL_LDT | r) /* a local selector */ -#define GSEL(s,r) (((s)<<3) | r) /* a global selector */ - -/* - * Memory and System segment descriptors - */ -struct segment_descriptor { - unsigned sd_lolimit:16 ; /* segment extent (lsb) */ - unsigned sd_lobase:24 ; /* segment base address (lsb) */ - unsigned sd_type:5 ; /* segment type */ - unsigned sd_dpl:2 ; /* segment descriptor priority level */ - unsigned sd_p:1 ; /* segment descriptor present */ - unsigned sd_hilimit:4 ; /* segment extent (msb) */ - unsigned sd_xx:2 ; /* unused */ - unsigned sd_def32:1 ; /* default 32 vs 16 bit size */ - unsigned sd_gran:1 ; /* limit granularity (byte/page units)*/ - unsigned sd_hibase:8 ; /* segment base address (msb) */ -} ; - -/* - * Gate descriptors (e.g. indirect descriptors) - */ -struct gate_descriptor { - unsigned gd_looffset:16 ; /* gate offset (lsb) */ - unsigned gd_selector:16 ; /* gate segment selector */ - unsigned gd_stkcpy:5 ; /* number of stack wds to cpy */ - unsigned gd_xx:3 ; /* unused */ - unsigned gd_type:5 ; /* segment type */ - unsigned gd_dpl:2 ; /* segment descriptor priority level */ - unsigned gd_p:1 ; /* segment descriptor present */ - unsigned gd_hioffset:16 ; /* gate offset (msb) */ -} ; - -/* - * Generic descriptor - */ -union descriptor { - struct segment_descriptor sd; - struct gate_descriptor gd; -}; - - /* system segments and gate types */ -#define SDT_SYSNULL 0 /* system null */ -#define SDT_SYS286TSS 1 /* system 286 TSS available */ -#define SDT_SYSLDT 2 /* system local descriptor table */ -#define SDT_SYS286BSY 3 /* system 286 TSS busy */ -#define SDT_SYS286CGT 4 /* system 286 call gate */ -#define SDT_SYSTASKGT 5 /* system task gate */ -#define SDT_SYS286IGT 6 /* system 286 interrupt gate */ -#define SDT_SYS286TGT 7 /* system 286 trap gate */ -#define SDT_SYSNULL2 8 /* system null again */ -#define SDT_SYS386TSS 9 /* system 386 TSS available */ -#define SDT_SYSNULL3 10 /* system null again */ -#define SDT_SYS386BSY 11 /* system 386 TSS busy */ -#define SDT_SYS386CGT 12 /* system 386 call gate */ -#define SDT_SYSNULL4 13 /* system null again */ -#define SDT_SYS386IGT 14 /* system 386 interrupt gate */ -#define SDT_SYS386TGT 15 /* system 386 trap gate */ - - /* memory segment types */ -#define SDT_MEMRO 16 /* memory read only */ -#define SDT_MEMROA 17 /* memory read only accessed */ -#define SDT_MEMRW 18 /* memory read write */ -#define SDT_MEMRWA 19 /* memory read write accessed */ -#define SDT_MEMROD 20 /* memory read only expand dwn limit */ -#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */ -#define SDT_MEMRWD 22 /* memory read write expand dwn limit */ -#define SDT_MEMRWDA 23 /* memory read write expand dwn limit acessed */ -#define SDT_MEME 24 /* memory execute only */ -#define SDT_MEMEA 25 /* memory execute only accessed */ -#define SDT_MEMER 26 /* memory execute read */ -#define SDT_MEMERA 27 /* memory execute read accessed */ -#define SDT_MEMEC 28 /* memory execute only conforming */ -#define SDT_MEMEAC 29 /* memory execute only accessed conforming */ -#define SDT_MEMERC 30 /* memory execute read conforming */ -#define SDT_MEMERAC 31 /* memory execute read accessed conforming */ - -/* is memory segment descriptor pointer ? */ -#define ISMEMSDP(s) ((s->d_type) >= SDT_MEMRO && (s->d_type) <= SDT_MEMERAC) - -/* is 286 gate descriptor pointer ? */ -#define IS286GDP(s) (((s->d_type) >= SDT_SYS286CGT \ - && (s->d_type) < SDT_SYS286TGT)) - -/* is 386 gate descriptor pointer ? */ -#define IS386GDP(s) (((s->d_type) >= SDT_SYS386CGT \ - && (s->d_type) < SDT_SYS386TGT)) - -/* is gate descriptor pointer ? */ -#define ISGDP(s) (IS286GDP(s) || IS386GDP(s)) - -/* is segment descriptor pointer ? */ -#define ISSDP(s) (ISMEMSDP(s) || !ISGDP(s)) - -/* is system segment descriptor pointer ? */ -#define ISSYSSDP(s) (!ISMEMSDP(s) && !ISGDP(s)) - -/* - * Software definitions are in this convenient format, - * which are translated into inconvenient segment descriptors - * when needed to be used by the 386 hardware - */ - -struct soft_segment_descriptor { - unsigned ssd_base ; /* segment base address */ - unsigned ssd_limit ; /* segment extent */ - unsigned ssd_type:5 ; /* segment type */ - unsigned ssd_dpl:2 ; /* segment descriptor priority level */ - unsigned ssd_p:1 ; /* segment descriptor present */ - unsigned ssd_xx:4 ; /* unused */ - unsigned ssd_xx1:2 ; /* unused */ - unsigned ssd_def32:1 ; /* default 32 vs 16 bit size */ - unsigned ssd_gran:1 ; /* limit granularity (byte/page units)*/ -}; - -extern ssdtosd() ; /* to decode a ssd */ -extern sdtossd() ; /* to encode a sd */ - -/* - * region descriptors, used to load gdt/idt tables before segments yet exist. - */ -struct region_descriptor { - unsigned rd_limit:16; /* segment extent */ - unsigned rd_base:32; /* base address */ -}; - -/* - * Segment Protection Exception code bits - */ - -#define SEGEX_EXT 0x01 /* recursive or externally induced */ -#define SEGEX_IDT 0x02 /* interrupt descriptor table */ -#define SEGEX_TI 0x04 /* local descriptor table */ - /* other bits are affected descriptor index */ -#define SEGEX_IDX(s) ((s)>>3)&0x1fff) - -/* - * Size of IDT table - */ - -#define NIDT 256 -#define NRSVIDT 32 /* reserved entries for cpu exceptions */ diff --git a/sys/i386/include/soundcard.h b/sys/i386/include/soundcard.h deleted file mode 100644 index f853de4..0000000 --- a/sys/i386/include/soundcard.h +++ /dev/null @@ -1,737 +0,0 @@ -#ifndef SOUNDCARD_H -#define SOUNDCARD_H -/* - * Copyright by Hannu Savolainen 1993 - * - * 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 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. - * - * - */ - - /* - * If you make modifications to this file, please contact me before - * distributing the modified version. There is already enough - * divercity in the world. - * - * Regards, - * Hannu Savolainen - * hsavolai@cs.helsinki.fi - */ - -#define SOUND_VERSION 200 - -#include - -/* - * Supported card ID numbers (Should be somewhere else?) - */ - -#define SNDCARD_ADLIB 1 -#define SNDCARD_SB 2 -#define SNDCARD_PAS 3 -#define SNDCARD_GUS 4 -#define SNDCARD_MPU401 5 - -/*********************************** - * IOCTL Commands for /dev/sequencer - */ - -#ifndef _IOWR -/* @(#)ioctlp.h */ - -/* Ioctl's have the command encoded in the lower word, - * and the size of any in or out parameters in the upper - * word. The high 2 bits of the upper word are used - * to encode the in/out status of the parameter; for now - * we restrict parameters to at most 128 bytes. - */ -/* #define IOCTYPE (0xff<<8) */ -#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ -#define IOC_VOID 0x20000000 /* no parameters */ -#define IOC_OUT 0x40000000 /* copy out parameters */ -#define IOC_IN 0x80000000 /* copy in parameters */ -#define IOC_INOUT (IOC_IN|IOC_OUT) -/* the 0x20000000 is so we can distinguish new ioctl's from old */ -#define _IO(x,y) ((int)(IOC_VOID|(x<<8)|y)) -#define _IOR(x,y,t) ((int)(IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) -#define _IOW(x,y,t) ((int)(IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) -/* this should be _IORW, but stdio got there first */ -#define _IOWR(x,y,t) ((int)(IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) -#endif /* !_IOWR */ - -#define SNDCTL_SEQ_RESET _IO ('Q', 0) -#define SNDCTL_SEQ_SYNC _IO ('Q', 1) -#define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info) -#define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer resolution (HZ) */ -#define SNDCTL_SEQ_GETOUTCOUNT _IOR ('Q', 4, int) -#define SNDCTL_SEQ_GETINCOUNT _IOR ('Q', 5, int) -#define SNDCTL_SEQ_PERCMODE _IOW ('Q', 6, int) -#define SNDCTL_FM_LOAD_INSTR _IOW ('Q', 7, struct sbi_instrument) /* Valid for FM only */ -#define SNDCTL_SEQ_TESTMIDI _IOW ('Q', 8, int) -#define SNDCTL_SEQ_RESETSAMPLES _IOW ('Q', 9, int) -#define SNDCTL_SEQ_NRSYNTHS _IOR ('Q',10, int) -#define SNDCTL_SEQ_NRMIDIS _IOR ('Q',11, int) -#define SNDCTL_MIDI_INFO _IOWR('Q',12, struct midi_info) -#define SNDCTL_SEQ_TRESHOLD _IOW ('Q',13, int) -#define SNDCTL_SYNTH_MEMAVL _IOWR('Q',14, int) /* in=dev#, out=memsize */ -#define SNDCTL_FM_4OP_ENABLE _IOW ('Q',15, int) /* in=dev# */ -#define SNDCTL_PMGR_ACCESS _IOWR('Q',16, struct patmgr_info) - -/* - * Sample loading mechanism for internal synthesizers (/dev/sequencer) - * The following patch_info structure has been designed to support - * Gravis UltraSound. It tries to be universal format for uploading - * sample based patches but is propably too limited. - */ - -struct patch_info { - short key; /* Use GUS_PATCH here */ -#define GUS_PATCH 0x04fd -#define OBSOLETE_GUS_PATCH 0x02fd - short device_no; /* Synthesizer number */ - short instr_no; /* Midi pgm# */ - - unsigned long mode; -/* - * The least significant byte has the same format than the GUS .PAT - * files - */ -#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ -#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ -#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ -#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ -#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ -#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ -#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ - /* (use the env_rate/env_offs fields). */ -/* Linux specific bits */ -#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ -#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ -#define WAVE_SCALE 0x00040000 /* The scaling info is valid */ -/* Other bits must be zeroed */ - - long len; /* Size of the wave data in bytes */ - long loop_start, loop_end; /* Byte offsets from the beginning */ - -/* - * The base_freq and base_note fields are used when computing the - * playback speed for a note. The base_note defines the tone frequency - * which is heard if the sample is played using the base_freq as the - * playback speed. - * - * The low_note and high_note fields define the minimum and maximum note - * frequencies for which this sample is valid. It is possible to define - * more than one samples for a instrument number at the same time. The - * low_note and high_note fields are used to select the most suitable one. - * - * The fields base_note, high_note and low_note should contain - * the note frequency multiplied by 1000. For example value for the - * middle A is 440*1000. - */ - - unsigned int base_freq; - unsigned long base_note; - unsigned long high_note; - unsigned long low_note; - int panning; /* -128=left, 127=right */ - int detuning; - -/* New fields introduced in version 1.99.5 */ - - /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ - unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */ - unsigned char env_offset[ 6 ]; /* 255 == 100% */ - - /* - * The tremolo, vibrato and scale info are not supported yet. - * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or - * WAVE_SCALE - */ - - unsigned char tremolo_sweep; - unsigned char tremolo_rate; - unsigned char tremolo_depth; - - unsigned char vibrato_sweep; - unsigned char vibrato_rate; - unsigned char vibrato_depth; - - int scale_frequency; - unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */ - - int volume; - int spare[4]; - char data[0]; /* The waveform data starts here */ - }; - - -/* - * Patch management interface (/dev/sequencer, /dev/patmgr#) - * Don't use these calls if you want to maintain compatibility with - * the future versions of the driver. - */ - -#define PS_NO_PATCHES 0 /* No patch support on device */ -#define PS_MGR_NOT_OK 1 /* Plain patch support (no mgr) */ -#define PS_MGR_OK 2 /* Patch manager supported */ -#define PS_MANAGED 3 /* Patch manager running */ - -#define SNDCTL_PMGR_IFACE _IOWR('P', 1, struct patmgr_info) - -/* - * The patmgr_info is a fixed size structure which is used for two - * different purposes. The intended use is for communication between - * the application using /dev/sequencer and the patch manager daemon - * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)). - * - * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows - * a patch manager daemon to read and write device parameters. This - * ioctl available through /dev/sequencer also. Avoid using it since it's - * extremely hardware dependent. In addition access trough /dev/sequencer - * may confuse the patch manager daemon. - */ - -struct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */ - unsigned long key; /* Don't worry. Reserved for communication - between the patch manager and the driver. */ -#define PM_K_EVENT 1 /* Event from the /dev/sequencer driver */ -#define PM_K_COMMAND 2 /* Request from a application */ -#define PM_K_RESPONSE 3 /* From patmgr to application */ -#define PM_ERROR 4 /* Error returned by the patmgr */ - int device; - int command; - -/* - * Commands 0x000 to 0xfff reserved for patch manager programs - */ -#define PM_GET_DEVTYPE 1 /* Returns type of the patch mgr interface of dev */ -#define PMTYPE_FM2 1 /* 2 OP fm */ -#define PMTYPE_FM4 2 /* Mixed 4 or 2 op FM (OPL-3) */ -#define PMTYPE_WAVE 3 /* Wave table synthesizer (GUS) */ -#define PM_GET_NRPGM 2 /* Returns max # of midi programs in parm1 */ -#define PM_GET_PGMMAP 3 /* Returns map of loaded midi programs in data8 */ -#define PM_GET_PGM_PATCHES 4 /* Return list of patches of a program (parm1) */ -#define PM_GET_PATCH 5 /* Return patch header of patch parm1 */ -#define PM_SET_PATCH 6 /* Set patch header of patch parm1 */ -#define PM_READ_PATCH 7 /* Read patch (wave) data */ -#define PM_WRITE_PATCH 8 /* Write patch (wave) data */ - -/* - * Commands 0x1000 to 0xffff are for communication between the patch manager - * and the client - */ -#define _PM_LOAD_PATCH 0x100 - -/* - * Commands above 0xffff reserved for device specific use - */ - - long parm1; - long parm2; - long parm3; - - union { - unsigned char data8[4000]; - unsigned short data16[2000]; - unsigned long data32[1000]; - struct patch_info patch; - } data; - }; - -/* - * When a patch manager daemon is present, it will be informed by the - * driver when something important happens. For example when the - * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is - * returned. The command field contains the event type: - */ -#define PM_E_OPENED 1 /* /dev/sequencer opened */ -#define PM_E_CLOSED 2 /* /dev/sequencer closed */ -#define PM_E_PATCH_RESET 3 /* SNDCTL_RESETSAMPLES called */ -#define PM_E_PATCH_LOADED 4 /* A patch has been loaded by appl */ - -/* - * /dev/sequencer input events. - * - * The data written to the /dev/sequencer is a stream of events. Events - * are records of 4 or 8 bytes. The first byte defines the size. - * Any number of events can be written with a write call. There - * is a set of macros for sending these events. Use these macros if you - * want to maximize portability of your program. - * - * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. - * (All input events are currently 4 bytes long. Be prepared to support - * 8 byte events also. If you receive any event having first byte >= 0xf0, - * it's a 8 byte event. - * - * The events are documented at the end of this file. - * - * Normal events (4 bytes) - * There is also a 8 byte version of most of the 4 byte events. The - * 8 byte one is recommended. - */ -#define SEQ_NOTEOFF 0 -#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ -#define SEQ_NOTEON 1 -#define SEQ_FMNOTEON SEQ_NOTEON -#define SEQ_WAIT 2 -#define SEQ_PGMCHANGE 3 -#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE -#define SEQ_SYNCTIMER 4 -#define SEQ_MIDIPUTC 5 -#define SEQ_DRUMON 6 /*** OBSOLETE ***/ -#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ -#define SEQ_ECHO 8 /* For synching programs with output */ -#define SEQ_AFTERTOUCH 9 -#define SEQ_CONTROLLER 10 -#define CTRL_PITCH_BENDER 255 -#define CTRL_PITCH_BENDER_RANGE 254 -#define CTRL_EXPRESSION 253 -#define CTRL_MAIN_VOLUME 252 -#define SEQ_BALANCE 11 - -/* - * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as - * input events. - */ - -/* - * Event codes 0xf0 to 0xfc are reserved for future extensions. - */ - -#define SEQ_FULLSIZE 0xfd /* Long events */ -/* - * SEQ_FULLSIZE events are used for loading patches/samples to the - * synthesizer devices. These events are passed directly to the driver - * of the associated synthesizer device. There is no limit to the size - * of the extended events. These events are not queued but executed - * immediately when the write() is called (execution can take several - * seconds of time). - * - * When a SEQ_FULLSIZE message is written to the device, it must - * be written using exactly one write() call. Other events cannot - * be mixed to the same write. - * - * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the - * /dev/sequencer. Don't write other data together with the instrument structure - * Set the key field of the structure to FM_PATCH. The device field is used to - * route the patch to the corresponding device. - * - * For Gravis UltraSound use struct patch_info. Initialize the key field - * to GUS_PATCH. - */ -#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ -#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) */ - -/* - * Extended events for synthesizers (8 bytes) - * - * Format: - * - * b0 = SEQ_EXTENDED - * b1 = command - * b2 = device - * b3-b7 = parameters - * - * Command b3 b4 b5 b6 b7 - * ---------------------------------------------------------------------------- - * SEQ_NOTEON voice note volume 0 0 - * SEQ_NOTEOFF voice note volume 0 0 - * SEQ_PGMCHANGE voice pgm 0 0 0 - * SEQ_DRUMON (voice) drum# volume 0 0 - * SEQ_DRUMOFF (voice) drum# volume 0 0 - */ - -/* - * Record for FM patches - */ - -typedef unsigned char sbi_instr_data[32]; - -struct sbi_instrument { - unsigned short key; /* Initialize to FM_PATCH or OPL3_PATCH */ -#define FM_PATCH 0x01fd -#define OPL3_PATCH 0x03fd - short device; /* Synth# (0-4) */ - int channel; /* Program# to be initialized */ - sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */ - }; - -struct synth_info { /* Read only */ - char name[30]; - int device; /* 0-N. INITIALIZE BEFORE CALLING */ - int synth_type; -#define SYNTH_TYPE_FM 0 -#define SYNTH_TYPE_SAMPLE 1 - - int synth_subtype; -#define FM_TYPE_ADLIB 0x00 -#define FM_TYPE_OPL3 0x01 - -#define SAMPLE_TYPE_GUS 0x10 - - int perc_mode; /* No longer supported */ - int nr_voices; - int nr_drums; /* Obsolete field */ - int instr_bank_size; - unsigned long capabilities; -#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ -#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ - int dummies[19]; /* Reserve space */ - }; - -struct midi_info { - char name[30]; - int device; /* 0-N. INITIALIZE BEFORE CALLING */ - unsigned long capabilities; /* To be defined later */ - int dummies[19]; /* Reserve space */ - }; - -/******************************************** - * IOCTL commands for /dev/dsp and /dev/audio - */ - -#define SNDCTL_DSP_RESET _IO ('P', 0) -#define SNDCTL_DSP_SYNC _IO ('P', 1) -#define SNDCTL_DSP_SPEED _IOWR('P', 2, int) -#define SNDCTL_DSP_STEREO _IOWR('P', 3, int) -#define SNDCTL_DSP_GETBLKSIZE _IOWR('P', 4, int) -#define SNDCTL_DSP_SAMPLESIZE _IOWR('P', 5, int) /* 8, 12 or 16 */ -#define SOUND_PCM_WRITE_CHANNELS _IOWR('P', 6, int) -#define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int) -#define SNDCTL_DSP_POST _IO ('P', 8) - -#define SOUND_PCM_READ_RATE _IOR ('P', 2, int) -#define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int) -#define SOUND_PCM_READ_BITS _IOR ('P', 5, int) -#define SOUND_PCM_READ_FILTER _IOR ('P', 7, int) - -/* Some alias names */ -#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SAMPLESIZE -#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED -#define SOUND_PCM_POST SNDCTL_DSP_POST -#define SOUND_PCM_RESET SNDCTL_DSP_RESET -#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC - -/********************************************* - * IOCTL commands for /dev/mixer - */ - -/* - * Mixer devices - * - * There can be up to 20 different analog mixer channels. The - * SOUND_MIXER_NRDEVICES gives the currently supported maximum. - * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells - * the devices supported by the particular mixer. - */ - -#define SOUND_MIXER_NRDEVICES 12 -#define SOUND_MIXER_VOLUME 0 -#define SOUND_MIXER_BASS 1 -#define SOUND_MIXER_TREBLE 2 -#define SOUND_MIXER_SYNTH 3 -#define SOUND_MIXER_PCM 4 -#define SOUND_MIXER_SPEAKER 5 -#define SOUND_MIXER_LINE 6 -#define SOUND_MIXER_MIC 7 -#define SOUND_MIXER_CD 8 -#define SOUND_MIXER_IMIX 9 /* Recording monitor */ -#define SOUND_MIXER_ALTPCM 10 -#define SOUND_MIXER_RECLEV 11 /* Recording level */ - -/* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */ -/* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */ -#define SOUND_ONOFF_MIN 28 -#define SOUND_ONOFF_MAX 30 -#define SOUND_MIXER_MUTE 28 /* 0 or 1 */ -#define SOUND_MIXER_ENHANCE 29 /* Enhanced stereo (0, 40, 60 or 80) */ -#define SOUND_MIXER_LOUD 30 /* 0 or 1 */ - -/* Note! Number 31 cannot be used since the sign bit is reserved */ - -#define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ - "Mic ", "CD ", "Mix ", "Pcm2 ", "rec"} - -#define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ - "mic", "cd", "mix", "pcm2", "rec"} - -/* Device bitmask identifiers */ - -#define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */ -#define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */ -#define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */ -#define SOUND_MIXER_CAPS 0xfc - #define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */ -#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ - -/* Device mask bits */ - -#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) -#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) -#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) -#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) -#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) -#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) -#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) -#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) -#define SOUND_MASK_CD (1 << SOUND_MIXER_CD) -#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) -#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) -#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) - -#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) -#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) -#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) - -#define MIXER_READ(dev) _IOR('M', dev, int) -#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) -#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) -#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) -#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) -#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) -#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) -#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) -#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) -#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) -#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) -#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) -#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) -#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) -#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) -#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) - -#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) -#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) -#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) -#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) -#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) - -#define MIXER_WRITE(dev) _IOWR('M', dev, int) -#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) -#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) -#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) -#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) -#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) -#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) -#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) -#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) -#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) -#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) -#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) -#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) -#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) -#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) -#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) - -#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) - -/* - * The following mixer ioctl calls are compatible with the BSD driver by - * Steve Haehnichen - * - * Since this interface is entirely SB specific, it will be dropped in the - * near future. - */ - -typedef unsigned char S_BYTE; -typedef unsigned char S_FLAG; -struct stereo_vol -{ - S_BYTE l; /* Left volume */ - S_BYTE r; /* Right volume */ -}; - -#define MIXER_IOCTL_SET_LEVELS _IOW ('s', 20, struct sb_mixer_levels) -#define MIXER_IOCTL_SET_PARAMS _IOW ('s', 21, struct sb_mixer_params) -#define MIXER_IOCTL_READ_LEVELS _IOR ('s', 22, struct sb_mixer_levels) -#define MIXER_IOCTL_READ_PARAMS _IOR ('s', 23, struct sb_mixer_params) -#define MIXER_IOCTL_RESET _IO ('s', 24) - -/* - * Mixer volume levels for MIXER_IOCTL_SET_VOL & MIXER_IOCTL_READ_VOL - */ -struct sb_mixer_levels -{ - struct stereo_vol master; /* Master volume */ - struct stereo_vol voc; /* DSP Voice volume */ - struct stereo_vol fm; /* FM volume */ - struct stereo_vol line; /* Line-in volume */ - struct stereo_vol cd; /* CD audio */ - S_BYTE mic; /* Microphone level */ -}; - -/* - * Mixer parameters for MIXER_IOCTL_SET_PARAMS & MIXER_IOCTL_READ_PARAMS - */ -struct sb_mixer_params -{ - S_BYTE record_source; /* Recording source (See SRC_xxx below) */ - S_FLAG hifreq_filter; /* Filter frequency (hi/low) */ - S_FLAG filter_input; /* ANFI input filter */ - S_FLAG filter_output; /* DNFI output filter */ - S_FLAG dsp_stereo; /* 1 if DSP is in Stereo mode */ -}; - -#define SRC_MIC 1 /* Select Microphone recording source */ -#define SRC_CD 3 /* Select CD recording source */ -#define SRC_LINE 7 /* Use Line-in for recording source */ - -#if !defined(KERNEL) && !defined(INKERNEL) -/* - * Some convenience macros to simplify programming of the - * /dev/sequencer interface - * - * These macros define the API which should be used when possible. - */ - -void seqbuf_dump(); /* This function must be provided by programs */ - -/* Sample seqbuf_dump() implementation: - * - * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes - * - * int seqfd; -- The file descriptor for /dev/sequencer. - * - * void - * seqbuf_dump () - * { - * if (_seqbufptr) - * if (write (seqfd, _seqbuf, _seqbufptr) == -1) - * { - * perror ("write /dev/sequencer"); - * exit (-1); - * } - * _seqbufptr = 0; - * } - */ - -#define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len, _seqbufptr = 0 -#define SEQ_PM_DEFINES struct patmgr_info _pm_info -#define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump() -#define _SEQ_ADVBUF(len) _seqbufptr += len -#define SEQ_DUMPBUF seqbuf_dump -#define PM_LOAD_PATCH(dev, bank, pgm) (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ - _pm_info.device=dev, _pm_info.data.data8[0]=pgm, \ - _pm_info.parm1 = bank, _pm_info.parm2 = 1, \ - ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) -#define PM_LOAD_PATCHES(dev, bank, pgm) (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ - _pm_info.device=dev, memcpy(_pm_info.data.data8, pgm, 128), \ - _pm_info.parm1 = bank, _pm_info.parm2 = 128, \ - ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) - -#define SEQ_START_NOTE(dev, voice, note, vol) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_NOTEON;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (voice);\ - _seqbuf[_seqbufptr+4] = (note);\ - _seqbuf[_seqbufptr+5] = (vol);\ - _seqbuf[_seqbufptr+6] = 0;\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -#define SEQ_STOP_NOTE(dev, voice, note, vol) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_NOTEOFF;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (voice);\ - _seqbuf[_seqbufptr+4] = (note);\ - _seqbuf[_seqbufptr+5] = (vol);\ - _seqbuf[_seqbufptr+6] = 0;\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -#define SEQ_CHN_PRESSURE(dev, voice, pressure) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_AFTERTOUCH;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (voice);\ - _seqbuf[_seqbufptr+4] = (pressure);\ - _seqbuf[_seqbufptr+5] = 0;\ - _seqbuf[_seqbufptr+6] = 0;\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -#define SEQ_PANNING(dev, voice, pos) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_BALANCE;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (voice);\ - (char)_seqbuf[_seqbufptr+4] = (pos);\ - _seqbuf[_seqbufptr+5] = 0;\ - _seqbuf[_seqbufptr+6] = 0;\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -#define SEQ_CONTROL(dev, voice, controller, value) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (voice);\ - _seqbuf[_seqbufptr+4] = (controller);\ - *(short *)&_seqbuf[_seqbufptr+5] = (value);\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -#define SEQ_PITCHBEND(dev, voice, value) SEQ_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) -#define SEQ_BENDER_RANGE(dev, voice, value) SEQ_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) -#define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTRL_EXPRESSION, value) -#define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTRL_MAIN_VOLUME, value) - -#define SEQ_START_TIMER() {_SEQ_NEEDBUF(4);\ - _seqbuf[_seqbufptr] = SEQ_SYNCTIMER;\ - _seqbuf[_seqbufptr+1] = 0;\ - _seqbuf[_seqbufptr+2] = 0;\ - _seqbuf[_seqbufptr+3] = 0;\ - _SEQ_ADVBUF(4);} -#define SEQ_SET_PATCH(dev, voice, patch) {_SEQ_NEEDBUF(8);\ - _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ - _seqbuf[_seqbufptr+1] = SEQ_PGMCHANGE;\ - _seqbuf[_seqbufptr+2] = (dev);\ - _seqbuf[_seqbufptr+3] = (voice);\ - _seqbuf[_seqbufptr+4] = (patch);\ - _seqbuf[_seqbufptr+5] = 0;\ - _seqbuf[_seqbufptr+6] = 0;\ - _seqbuf[_seqbufptr+7] = 0;\ - _SEQ_ADVBUF(8);} - -#define SEQ_WAIT_TIME(ticks) {_SEQ_NEEDBUF(4);\ - *(unsigned long *)&_seqbuf[_seqbufptr] = SEQ_WAIT | ((ticks) << 8);\ - _SEQ_ADVBUF(4);} - -#define SEQ_ECHO_BACK(key) {_SEQ_NEEDBUF(4);\ - *(unsigned long *)&_seqbuf[_seqbufptr] = SEQ_ECHO | ((key) << 8);\ - _SEQ_ADVBUF(4);} - -#define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\ - _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ - _seqbuf[_seqbufptr+1] = (byte);\ - _seqbuf[_seqbufptr+2] = (device);\ - _seqbuf[_seqbufptr+3] = 0;\ - _SEQ_ADVBUF(4);} -#define SEQ_WRPATCH(patch, len) {if (_seqbufptr) seqbuf_dump();\ - if (write(seqfd, (char*)(patch), len)==-1) \ - perror("Write patch: /dev/sequencer");} - -#endif -long soundcard_init(long mem_start); -#endif diff --git a/sys/i386/include/specialreg.h b/sys/i386/include/specialreg.h deleted file mode 100644 index 7538259..0000000 --- a/sys/i386/include/specialreg.h +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)specialreg.h 7.1 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * Bits in 386 special registers: - */ - -#define CR0_PE 0x00000001 /* Protected mode Enable */ -#define CR0_MP 0x00000002 /* "Math" Present (NPX or NPX emulator) */ -#ifdef notused -#define CR0_EM 0x00000004 /* EMulate non-NPX coproc. (trap ESC only) */ -#endif -#define CR0_TS 0x00000008 /* Task Switched (if MP, trap ESC and WAIT) */ -#ifdef notused -#define CR0_ET 0x00000010 /* Extension Type (387 (if set) vs 287) */ -#endif -#define CR0_PG 0x80000000 /* PaGing enable */ - -/* - * Bits in 486 special registers: - */ - -#define CR0_NE 0x00000020 /* Numeric Error enable (EX16 vs IRQ13) */ -#define CR0_WP 0x00010000 /* Write Protect (honor ~PG_W in all modes) */ -#ifdef notyet -#define CR0_AM 0x00040000 /* Alignment Mask (set to enable AC flag) */ -#endif diff --git a/sys/i386/include/stdarg.h b/sys/i386/include/stdarg.h deleted file mode 100644 index 3fdd382..0000000 --- a/sys/i386/include/stdarg.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)stdarg.h 7.2 (Berkeley) 5/4/91 - * $Id$ - */ - -typedef char *va_list; - -#ifdef KERNEL -#define va_arg(ap, type) \ - ((type *)(ap += sizeof(type)))[-1] -#else -#define va_arg(ap, type) \ - ((type *)(ap += sizeof(type) < sizeof(int) ? \ - (abort(), 0) : sizeof(type)))[-1] -#endif - -#define va_end(ap) - -#define __va_promote(type) \ - (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) - -#define va_start(ap, last) \ - (ap = ((char *)&(last) + __va_promote(last))) diff --git a/sys/i386/include/sysarch.h b/sys/i386/include/sysarch.h deleted file mode 100644 index 92abe9c..0000000 --- a/sys/i386/include/sysarch.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Architecture specific syscalls (i386) - * - * $Id$ - */ -#define I386_GET_LDT 0 -#define I386_SET_LDT 1 - -#ifndef KERNEL -int i386_get_ldt __P((int, union descriptor *, int)); -int i386_set_ldt __P((int, union descriptor *, int)); -#endif diff --git a/sys/i386/include/trap.h b/sys/i386/include/trap.h deleted file mode 100644 index 7b19bc7..0000000 --- a/sys/i386/include/trap.h +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)trap.h 5.4 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * Trap type values - * also known in trap.c for name strings - */ - -#define T_RESADFLT 0 /* reserved addressing */ -#define T_PRIVINFLT 1 /* privileged instruction */ -#define T_RESOPFLT 2 /* reserved operand */ -#define T_BPTFLT 3 /* breakpoint instruction */ -#define T_SYSCALL 5 /* system call (kcall) */ -#define T_ARITHTRAP 6 /* arithmetic trap */ -#define T_ASTFLT 7 /* system forced exception */ -#define T_SEGFLT 8 /* segmentation (limit) fault */ -#define T_PROTFLT 9 /* protection fault */ -#define T_TRCTRAP 10 /* trace trap */ -#define T_PAGEFLT 12 /* page fault */ -#define T_TABLEFLT 13 /* page table fault */ -#define T_ALIGNFLT 14 /* alignment fault */ -#define T_KSPNOTVAL 15 /* kernel stack pointer not valid */ -#define T_BUSERR 16 /* bus error */ -#define T_KDBTRAP 17 /* kernel debugger trap */ - -#define T_DIVIDE 18 /* integer divide fault */ -#define T_NMI 19 /* non-maskable trap */ -#define T_OFLOW 20 /* overflow trap */ -#define T_BOUND 21 /* bound instruction fault */ -#define T_DNA 22 /* device not available fault */ -#define T_DOUBLEFLT 23 /* double fault */ -#define T_FPOPFLT 24 /* fp coprocessor operand fetch fault */ -#define T_TSSFLT 25 /* invalid tss fault */ -#define T_SEGNPFLT 26 /* segment not present fault */ -#define T_STKFLT 27 /* stack fault */ -#define T_RESERVED 28 /* reserved fault base */ - -/* definitions for */ -#define ILL_RESAD_FAULT T_RESADFLT -#define ILL_PRIVIN_FAULT T_PRIVINFLT -#define ILL_RESOP_FAULT T_RESOPFLT -#define ILL_ALIGN_FAULT T_ALIGNFLT -#define ILL_FPOP_FAULT T_FPOPFLT /* coprocessor operand fault */ - -/* codes for SIGFPE/ARITHTRAP */ -#define FPE_INTOVF_TRAP 0x1 /* integer overflow */ -#define FPE_INTDIV_TRAP 0x2 /* integer divide by zero */ -#define FPE_FLTDIV_TRAP 0x3 /* floating/decimal divide by zero */ -#define FPE_FLTOVF_TRAP 0x4 /* floating overflow */ -#define FPE_FLTUND_TRAP 0x5 /* floating underflow */ -#define FPE_FPU_NP_TRAP 0x6 /* floating point unit not present */ -#define FPE_SUBRNG_TRAP 0x7 /* subrange out of bounds */ - -/* codes for SIGBUS */ -#define BUS_PAGE_FAULT T_PAGEFLT /* page fault protection base */ -#define BUS_SEGNP_FAULT T_SEGNPFLT /* segment not present */ -#define BUS_STK_FAULT T_STKFLT /* stack segment */ -#define BUS_SEGM_FAULT T_RESERVED /* segment protection base */ - -/* Trap's coming from user mode */ -#define T_USER 0x100 diff --git a/sys/i386/include/tss.h b/sys/i386/include/tss.h deleted file mode 100644 index fec3db5..0000000 --- a/sys/i386/include/tss.h +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)tss.h 5.4 (Berkeley) 1/18/91 - * $Id$ - */ - -/* - * Intel 386 Context Data Type - */ - -struct i386tss { - int tss_link; /* actually 16 bits: top 16 bits must be zero */ - int tss_esp0; /* kernel stack pointer priviledge level 0 */ -#define tss_ksp tss_esp0 - int tss_ss0; /* actually 16 bits: top 16 bits must be zero */ - int tss_esp1; /* kernel stack pointer priviledge level 1 */ - int tss_ss1; /* actually 16 bits: top 16 bits must be zero */ - int tss_esp2; /* kernel stack pointer priviledge level 2 */ - int tss_ss2; /* actually 16 bits: top 16 bits must be zero */ - /* struct ptd *tss_cr3; /* page table directory */ - int tss_cr3; /* page table directory */ -#define tss_ptd tss_cr3 - int tss_eip; /* program counter */ -#define tss_pc tss_eip - int tss_eflags; /* program status longword */ -#define tss_psl tss_eflags - int tss_eax; - int tss_ecx; - int tss_edx; - int tss_ebx; - int tss_esp; /* user stack pointer */ -#define tss_usp tss_esp - int tss_ebp; /* user frame pointer */ -#define tss_fp tss_ebp - int tss_esi; - int tss_edi; - int tss_es; /* actually 16 bits: top 16 bits must be zero */ - int tss_cs; /* actually 16 bits: top 16 bits must be zero */ - int tss_ss; /* actually 16 bits: top 16 bits must be zero */ - int tss_ds; /* actually 16 bits: top 16 bits must be zero */ - int tss_fs; /* actually 16 bits: top 16 bits must be zero */ - int tss_gs; /* actually 16 bits: top 16 bits must be zero */ - int tss_ldt; /* actually 16 bits: top 16 bits must be zero */ - int tss_ioopt; /* options & io offset bitmap: currently zero */ - /* XXX unimplemented .. i/o permission bitmap */ -}; diff --git a/sys/i386/include/types.h b/sys/i386/include/types.h deleted file mode 100644 index 118290c..0000000 --- a/sys/i386/include/types.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)types.h 7.5 (Berkeley) 3/9/91 - * $Id$ - */ - -#ifndef _MACHTYPES_H_ -#define _MACHTYPES_H_ - -typedef struct _physadr { - int r[1]; -} *physadr; - -typedef struct label_t { - int val[6]; -} label_t; - -typedef u_long vm_offset_t; -typedef u_long vm_size_t; - -#endif /* _MACHTYPES_H_ */ diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h deleted file mode 100644 index 700b697..0000000 --- a/sys/i386/include/vmparam.h +++ /dev/null @@ -1,261 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 - * $Id$ - */ - - -/* - * Machine dependent constants for 386. - */ - -/* - * Virtual address space arrangement. On 386, both user and kernel - * share the address space, not unlike the vax. - * USRTEXT is the start of the user text/data space, while USRSTACK - * is the top (end) of the user stack. Immediately above the user stack - * resides the user structure, which is UPAGES long and contains the - * kernel stack. - * - * Immediately after the user structure is the page table map, and then - * kernal address space. - */ -#define USRTEXT 0 -#define USRSTACK 0xFDBFE000 -#define BTOPUSRSTACK (0xFDC00-(UPAGES)) /* btop(USRSTACK) */ -#define LOWPAGES 0 -#define HIGHPAGES UPAGES - -/* - * Virtual memory related constants, all in bytes - */ -#define MAXTSIZ (6*1024*1024) /* max text size */ -#ifndef DFLDSIZ -#define DFLDSIZ (16*1024*1024) /* initial data size limit */ -#endif -#ifndef MAXDSIZ -#define MAXDSIZ (32*1024*1024) /* max data size */ -#endif -#ifndef DFLSSIZ -#define DFLSSIZ (512*1024) /* initial stack size limit */ -#endif -#ifndef MAXSSIZ -#define MAXSSIZ (8*1024*1024) /* max stack size */ -#endif - -/* - * Default sizes of swap allocation chunks (see dmap.h). - * The actual values may be changed in vminit() based on MAXDSIZ. - * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024. - */ -#define DMMIN 32 /* smallest swap allocation */ -#define DMMAX 4096 /* largest potential swap allocation */ -#define DMTEXT 1024 /* swap allocation for text */ - -/* - * Sizes of the system and user portions of the system page table. - */ -#define SYSPTSIZE (2*NPTEPG) -#define USRPTSIZE (2*NPTEPG) - -/* - * Size of the Shared Memory Pages page table. - */ -#ifndef SHMMAXPGS -#define SHMMAXPGS 512 /* XXX until we have more kmap space */ -#endif - -/* - * Size of User Raw I/O map - */ -#define USRIOSIZE 300 - -/* - * The size of the clock loop. - */ -#define LOOPPAGES (maxfree - firstfree) - -/* - * The time for a process to be blocked before being very swappable. - * This is a number of seconds which the system takes as being a non-trivial - * amount of real time. You probably shouldn't change this; - * it is used in subtle ways (fractions and multiples of it are, that is, like - * half of a ``long time'', almost a long time, etc.) - * It is related to human patience and other factors which don't really - * change over time. - */ -#define MAXSLP 20 - -/* - * A swapped in process is given a small amount of core without being bothered - * by the page replacement algorithm. Basically this says that if you are - * swapped in you deserve some resources. We protect the last SAFERSS - * pages against paging and will just swap you out rather than paging you. - * Note that each process has at least UPAGES+CLSIZE pages which are not - * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this - * number just means a swapped in process is given around 25k bytes. - * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81), - * so we loan each swapped in process memory worth 100$, or just admit - * that we don't consider it worthwhile and swap it out to disk which costs - * $30/mb or about $0.75. - * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17 - * on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) } - */ -#define SAFERSS 8 /* nominal ``small'' resident set size - protected against replacement */ - -/* - * DISKRPM is used to estimate the number of paging i/o operations - * which one can expect from a single disk controller. - */ -#define DISKRPM 60 - -/* - * Klustering constants. Klustering is the gathering - * of pages together for pagein/pageout, while clustering - * is the treatment of hardware page size as though it were - * larger than it really is. - * - * KLMAX gives maximum cluster size in CLSIZE page (cluster-page) - * units. Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h. - */ - -#define KLMAX (4/CLSIZE) -#define KLSEQL (2/CLSIZE) /* in klust if vadvise(VA_SEQL) */ -#define KLIN (4/CLSIZE) /* default data/stack in klust */ -#define KLTXT (4/CLSIZE) /* default text in klust */ -#define KLOUT (4/CLSIZE) - -/* - * KLSDIST is the advance or retard of the fifo reclaim for sequential - * processes data space. - */ -#define KLSDIST 3 /* klusters advance/retard for seq. fifo */ - -/* - * Paging thresholds (see vm_sched.c). - * Strategy of 1/19/85: - * lotsfree is 512k bytes, but at most 1/4 of memory - * desfree is 200k bytes, but at most 1/8 of memory - * minfree is 64k bytes, but at most 1/2 of desfree - */ -#define LOTSFREE (512 * 1024) -#define LOTSFREEFRACT 4 -#define DESFREE (200 * 1024) -#define DESFREEFRACT 8 -#define MINFREE (64 * 1024) -#define MINFREEFRACT 2 - -/* - * There are two clock hands, initially separated by HANDSPREAD bytes - * (but at most all of user memory). The amount of time to reclaim - * a page once the pageout process examines it increases with this - * distance and decreases as the scan rate rises. - */ -#define HANDSPREAD (2 * 1024 * 1024) - -/* - * The number of times per second to recompute the desired paging rate - * and poke the pagedaemon. - */ -#define RATETOSCHEDPAGING 4 - -/* - * Believed threshold (in megabytes) for which interleaved - * swapping area is desirable. - */ -#define LOTSOFMEM 2 - -#define mapin(pte, v, pfnum, prot) \ - {(*(int *)(pte) = ((pfnum)<p_addr) - -/* - * Flush MMU TLB - */ - -#ifndef I386_CR3PAT -#define I386_CR3PAT 0x0 -#endif - -#ifdef notyet -#define _cr3() ({u_long rtn; \ - asm (" movl %%cr3,%%eax; movl %%eax,%0 " \ - : "=g" (rtn) \ - : \ - : "ax"); \ - rtn; \ -}) - -#define load_cr3(s) ({ u_long val; \ - val = (s) | I386_CR3PAT; \ - asm ("movl %0,%%eax; movl %%eax,%%cr3" \ - : \ - : "g" (val) \ - : "ax"); \ -}) - -#define tlbflush() ({ u_long val; \ - val = u.u_pcb.pcb_ptd | I386_CR3PAT; \ - asm ("movl %0,%%eax; movl %%eax,%%cr3" \ - : \ - : "g" (val) \ - : "ax"); \ -}) -#endif diff --git a/sys/i386/isa/aha1542.c b/sys/i386/isa/aha1542.c deleted file mode 100644 index 1a1ae56..0000000 --- a/sys/i386/isa/aha1542.c +++ /dev/null @@ -1,1583 +0,0 @@ -/* - * (Mostly) Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * $Id: aha1542.c,v 1.11 1993/10/15 09:43:51 rgrimes Exp $ - */ - -/* - * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - */ - -/* - * a FEW lines in this driver come from a MACH adaptec-disk driver - * so the copyright below is included: - * - * Copyright 1990 by Open Software Foundation, - * Grenoble, FRANCE - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation, and that the name of OSF or Open Software - * Foundation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef MACH /* EITHER CMU OR OSF */ -#include -#include -#include - -#ifdef OSF /* OSF ONLY */ -#include -#include -#include -#include - -#else OSF /* CMU ONLY */ -#include -#include -#endif OSF -#endif MACH /* end of MACH specific */ - -#ifdef __386BSD__ /* 386BSD specific */ -#define isa_dev isa_device -#define dev_unit id_unit -#define dev_addr id_iobase - -#include -#include -#include -#endif __386BSD__ - - -#ifdef __386BSD__ -#include "ddb.h" -#if NDDB > 0 -int Debugger(); -#else NDDB -#define Debugger() panic("should call debugger here (adaptec.c)") -#endif NDDB -#endif __386BSD__ -extern int hz; -extern int delaycount; /* from clock setup code */ - -/************************** board definitions *******************************/ -/* - * I/O Port Interface - */ - -#define AHA_BASE aha_base[unit] -#define AHA_CTRL_STAT_PORT (AHA_BASE + 0x0) /* control & status */ -#define AHA_CMD_DATA_PORT (AHA_BASE + 0x1) /* cmds and datas */ -#define AHA_INTR_PORT (AHA_BASE + 0x2) /* Intr. stat */ - -/* - * AHA_CTRL_STAT bits (write) - */ - -#define AHA_HRST 0x80 /* Hardware reset */ -#define AHA_SRST 0x40 /* Software reset */ -#define AHA_IRST 0x20 /* Interrupt reset */ -#define AHA_SCRST 0x10 /* SCSI bus reset */ - -/* - * AHA_CTRL_STAT bits (read) - */ - -#define AHA_STST 0x80 /* Self test in Progress */ -#define AHA_DIAGF 0x40 /* Diagnostic Failure */ -#define AHA_INIT 0x20 /* Mbx Init required */ -#define AHA_IDLE 0x10 /* Host Adapter Idle */ -#define AHA_CDF 0x08 /* cmd/data out port full */ -#define AHA_DF 0x04 /* Data in port full */ -#define AHA_INVDCMD 0x01 /* Invalid command */ - -/* - * AHA_CMD_DATA bits (write) - */ - -#define AHA_NOP 0x00 /* No operation */ -#define AHA_MBX_INIT 0x01 /* Mbx initialization */ -#define AHA_START_SCSI 0x02 /* start scsi command */ -#define AHA_START_BIOS 0x03 /* start bios command */ -#define AHA_INQUIRE 0x04 /* Adapter Inquiry */ -#define AHA_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */ -#define AHA_SEL_TIMEOUT_SET 0x06 /* set selection time-out */ -#define AHA_BUS_ON_TIME_SET 0x07 /* set bus-on time */ -#define AHA_BUS_OFF_TIME_SET 0x08 /* set bus-off time */ -#define AHA_SPEED_SET 0x09 /* set transfer speed */ -#define AHA_DEV_GET 0x0a /* return installed devices */ -#define AHA_CONF_GET 0x0b /* return configuration data */ -#define AHA_TARGET_EN 0x0c /* enable target mode */ -#define AHA_SETUP_GET 0x0d /* return setup data */ -#define AHA_WRITE_CH2 0x1a /* write channel 2 buffer */ -#define AHA_READ_CH2 0x1b /* read channel 2 buffer */ -#define AHA_WRITE_FIFO 0x1c /* write fifo buffer */ -#define AHA_READ_FIFO 0x1d /* read fifo buffer */ -#define AHA_ECHO 0x1e /* Echo command data */ -#define AHA_EXT_BIOS 0x28 /* return extended bios info */ -#define AHA_MBX_ENABLE 0x29 /* enable mail box interface */ - -struct aha_cmd_buf { - u_char byte[16]; -}; - -/* - * AHA_INTR_PORT bits (read) - */ - -#define AHA_ANY_INTR 0x80 /* Any interrupt */ -#define AHA_SCRD 0x08 /* SCSI reset detected */ -#define AHA_HACC 0x04 /* Command complete */ -#define AHA_MBOA 0x02 /* MBX out empty */ -#define AHA_MBIF 0x01 /* MBX in full */ - -/* - * Mail box defs - */ - -#define AHA_MBX_SIZE 16 /* mail box size */ - -struct aha_mbx { - struct aha_mbx_out { - unsigned char cmd; - unsigned char ccb_addr[3]; - } mbo [AHA_MBX_SIZE]; - struct aha_mbx_in{ - unsigned char stat; - unsigned char ccb_addr[3]; - } mbi[AHA_MBX_SIZE]; -}; - -/* - * mbo.cmd values - */ - -#define AHA_MBO_FREE 0x0 /* MBO entry is free */ -#define AHA_MBO_START 0x1 /* MBO activate entry */ -#define AHA_MBO_ABORT 0x2 /* MBO abort entry */ - -#define AHA_MBI_FREE 0x0 /* MBI entry is free */ -#define AHA_MBI_OK 0x1 /* completed without error */ -#define AHA_MBI_ABORT 0x2 /* aborted ccb */ -#define AHA_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */ -#define AHA_MBI_ERROR 0x4 /* Completed with error */ - -extern struct aha_mbx aha_mbx[]; - -/* FOR OLD VERSIONS OF THE !%$@ this may have to be 16 (yuk) */ -#define AHA_NSEG 17 /* Number of scatter gather segments <= 16 */ - /* allow 64 K i/o (min) */ - -struct aha_ccb { - unsigned char opcode; - unsigned char lun:3; - unsigned char data_in:1; /* must be 0 */ - unsigned char data_out:1; /* must be 0 */ - unsigned char target:3; - unsigned char scsi_cmd_length; - unsigned char req_sense_length; - unsigned char data_length[3]; - unsigned char data_addr[3]; - unsigned char link_addr[3]; - unsigned char link_id; - unsigned char host_stat; - unsigned char target_stat; - unsigned char reserved[2]; - struct scsi_generic scsi_cmd; - struct scsi_sense_data scsi_sense; - struct aha_scat_gath { - unsigned char seg_len[3]; - unsigned char seg_addr[3]; - } scat_gath[AHA_NSEG]; - struct aha_ccb *next; - struct scsi_xfer *xfer; /* the scsi_xfer for this cmd */ - struct aha_mbx_out *mbx; /* pointer to mail box */ - int flags; -#define CCB_FREE 0 -#define CCB_ACTIVE 1 -#define CCB_ABORTED 2 - -}; - - -/* - * opcode fields - */ - -#define AHA_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */ -#define AHA_TARGET_CCB 0x01 /* SCSI Target CCB */ -#define AHA_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scattter gather*/ -#define AHA_RESET_CCB 0x81 /* SCSI Bus reset */ - - -/* - * aha_ccb.host_stat values - */ - -#define AHA_OK 0x00 /* cmd ok */ -#define AHA_LINK_OK 0x0a /* Link cmd ok */ -#define AHA_LINK_IT 0x0b /* Link cmd ok + int */ -#define AHA_SEL_TIMEOUT 0x11 /* Selection time out */ -#define AHA_OVER_UNDER 0x12 /* Data over/under run */ -#define AHA_BUS_FREE 0x13 /* Bus dropped at unexpected time */ -#define AHA_INV_BUS 0x14 /* Invalid bus phase/sequence */ -#define AHA_BAD_MBO 0x15 /* Incorrect MBO cmd */ -#define AHA_BAD_CCB 0x16 /* Incorrect ccb opcode */ -#define AHA_BAD_LINK 0x17 /* Not same values of LUN for links */ -#define AHA_INV_TARGET 0x18 /* Invalid target direction */ -#define AHA_CCB_DUP 0x19 /* Duplicate CCB received */ -#define AHA_INV_CCB 0x1a /* Invalid CCB or segment list */ -#define AHA_ABORTED 42 - - - - -struct aha_setup -{ - u_char sync_neg:1; - u_char parity:1; - u_char :6; - u_char speed; - u_char bus_on; - u_char bus_off; - u_char num_mbx; - u_char mbx[3]; - struct - { - u_char offset:4; - u_char period:3; - u_char valid:1; - }sync[8]; - u_char disc_sts; -}; - -struct aha_config -{ - u_char chan; - u_char intr; - u_char scsi_dev:3; - u_char :5; -}; - -struct aha_inquire -{ - u_char boardid; /* type of board */ - /* 0x20 = BusLogic 545, but it gets - the command wrong, only returns - one byte */ - /* 0x31 = AHA-1540 */ - /* 0x41 = AHA-1540A/1542A/1542B */ - /* 0x42 = AHA-1640 */ - /* 0x43 = AHA-1542C */ - /* 0x44 = AHA-1542CF */ - u_char spec_opts; /* special options ID */ - /* 0x41 = Board is standard model */ - u_char revision_1; /* firmware revision [0-9A-Z] */ - u_char revision_2; /* firmware revision [0-9A-Z] */ -}; - -struct aha_extbios -{ - u_char flags; /* Bit 3 == 1 extended bios enabled */ - u_char mailboxlock; /* mail box lock code to unlock it */ -}; - -#define INT9 0x01 -#define INT10 0x02 -#define INT11 0x04 -#define INT12 0x08 -#define INT14 0x20 -#define INT15 0x40 - -#define CHAN0 0x01 -#define CHAN5 0x20 -#define CHAN6 0x40 -#define CHAN7 0x80 - - -/*********************************** end of board definitions***************/ - - -#ifdef MACH -#define PHYSTOKV(x) phystokv(x) -#define KVTOPHYS(x) kvtophys(x) -#else MACH -#ifdef __386BSD__ -#define KVTOPHYS(x) vtophys(x) -#else __386BSD__ -#endif __386BSD__ -#endif MACH -#define AHA_DMA_PAGES AHA_NSEG - -#define PAGESIZ 4096 -#define INVALIDATE_CACHE {asm volatile( ".byte 0x0F ;.byte 0x08" ); } - - -u_char aha_scratch_buf[256]; -#ifdef MACH -caddr_t aha_base[NAHA]; /* base port for each board */ -#else -short aha_base[NAHA]; /* base port for each board */ -#endif -struct aha_mbx aha_mbx[NAHA]; -struct aha_ccb *aha_ccb_free[NAHA]; -struct aha_ccb aha_ccb[NAHA][AHA_MBX_SIZE]; -struct scsi_xfer aha_scsi_xfer[NAHA]; -struct isa_dev *ahainfo[NAHA]; -struct aha_ccb *aha_get_ccb(); -int aha_int[NAHA]; -int aha_dma[NAHA]; -int aha_scsi_dev[NAHA]; -int aha_initialized[NAHA]; -#ifdef OSF -int aha_attached[NAHA]; -#endif OSF -#ifdef AHADEBUG -int aha_debug = 1; -#endif /*AHADEBUG*/ - -int ahaprobe(), ahaattach(), ahaintr(); -#ifdef MACH -struct isa_driver ahadriver = { ahaprobe, 0, ahaattach, "aha", 0, 0, 0}; -int (*ahaintrs[])() = {ahaintr, 0}; -#endif -#ifdef __386BSD__ -struct isa_driver ahadriver = { ahaprobe, ahaattach, "aha",}; -#endif __386BSD__ -static int ahaunit = 0; - - -#define aha_abortmbx(mbx) \ - (mbx)->cmd = AHA_MBO_ABORT; \ - outb(AHA_CMD_DATA_PORT, AHA_START_SCSI); -#define aha_startmbx(mbx) \ - (mbx)->cmd = AHA_MBO_START; \ - outb(AHA_CMD_DATA_PORT, AHA_START_SCSI); - - - -int aha_scsi_cmd(); -int aha_timeout(); -void ahaminphys(); -long int aha_adapter_info(); - -struct scsi_switch aha_switch = -{ - aha_scsi_cmd, - ahaminphys, - 0, - 0, - aha_adapter_info, - "aha", - 0,0 -}; -#define AHA_CMD_TIMEOUT_FUDGE 200 /* multiplied to get Secs */ -#define AHA_RESET_TIMEOUT 1000000 /* time to wait for reset */ -#define AHA_SCSI_TIMEOUT_FUDGE 20 /* divided by for mSecs */ - - -/***********************************************************************\ -* aha_cmd(unit,icnt, ocnt,wait, retval, opcode, args) * -* Activate Adapter command * -* icnt: number of args (outbound bytes written after opcode) * -* ocnt: number of expected returned bytes * -* wait: number of seconds to wait for response * -* retval: buffer where to place returned bytes * -* opcode: opcode AHA_NOP, AHA_MBX_INIT, AHA_START_SCSI ... * -* args: parameters * -* * -* Performs an adapter command through the ports. Not to be confused * -* with a scsi command, which is read in via the dma * -* One of the adapter commands tells it to read in a scsi command * -\***********************************************************************/ - - -aha_cmd(unit,icnt, ocnt, wait,retval, opcode, args) - -u_char *retval; -unsigned opcode; -u_char args; -{ - unsigned *ic = &opcode; - u_char oc; - register i; - int sts; - - /*******************************************************\ - * multiply the wait argument by a big constant * - * zero defaults to 1 * - \*******************************************************/ - if(!wait) - wait = AHA_CMD_TIMEOUT_FUDGE * delaycount; - else - wait *= AHA_CMD_TIMEOUT_FUDGE * delaycount; - /*******************************************************\ - * Wait for the adapter to go idle, unless it's one of * - * the commands which don't need this * - \*******************************************************/ - if (opcode != AHA_MBX_INIT && opcode != AHA_START_SCSI) - { - i = AHA_CMD_TIMEOUT_FUDGE * delaycount; /* 1 sec?*/ - while (--i) - { - sts = inb(AHA_CTRL_STAT_PORT); - if (sts & AHA_IDLE) - { - break; - } - } - if (!i) - { - printf("aha%d: aha_cmd, host not idle(0x%x)\n", - unit,sts); - return(ENXIO); - } - } - /*******************************************************\ - * Now that it is idle, if we expect output, preflush the* - * queue feeding to us. * - \*******************************************************/ - if (ocnt) - { - while((inb(AHA_CTRL_STAT_PORT)) & AHA_DF) - inb(AHA_CMD_DATA_PORT); - } - - /*******************************************************\ - * Output the command and the number of arguments given * - * for each byte, first check the port is empty. * - \*******************************************************/ - icnt++; /* include the command */ - while (icnt--) - { - sts = inb(AHA_CTRL_STAT_PORT); - for (i=0; i< wait; i++) - { - sts = inb(AHA_CTRL_STAT_PORT); - if (!(sts & AHA_CDF)) - break; - } - if (i >= wait) - { - printf("aha%d: aha_cmd, cmd/data port full\n",unit); - outb(AHA_CTRL_STAT_PORT, AHA_SRST); - return(ENXIO); - } - outb(AHA_CMD_DATA_PORT, (u_char)(*ic++)); - } - /*******************************************************\ - * If we expect input, loop that many times, each time, * - * looking for the data register to have valid data * - \*******************************************************/ - while (ocnt--) - { - sts = inb(AHA_CTRL_STAT_PORT); - for (i=0; i< wait; i++) - { - sts = inb(AHA_CTRL_STAT_PORT); - if (sts & AHA_DF) - break; - } - if (i >= wait) - { - printf("aha%d: aha_cmd, cmd/data port empty %d\n", - unit,ocnt); - return(ENXIO); - } - oc = inb(AHA_CMD_DATA_PORT); - if (retval) - *retval++ = oc; - } - /*******************************************************\ - * Wait for the board to report a finised instruction * - \*******************************************************/ - i=AHA_CMD_TIMEOUT_FUDGE * delaycount; /* 1 sec? */ - while (--i) - { - sts = inb(AHA_INTR_PORT); - if (sts & AHA_HACC) - { - break; - } - } - if (!i) - { - printf("aha%d: aha_cmd, host not finished(0x%x)\n",unit,sts); - return(ENXIO); - } - outb(AHA_CTRL_STAT_PORT, AHA_IRST); - return(0); -} - -/*******************************************************\ -* Check if the device can be found at the port given * -* and if so, set it up ready for further work * -* as an argument, takes the isa_dev structure from * -* autoconf.c * -\*******************************************************/ -ahaprobe(dev) -struct isa_dev *dev; -{ - int unit = ahaunit; -#if defined(OSF) - static ihandler_t aha_handler[NAHA]; - static ihandler_id_t *aha_handler_id[NAHA]; - register ihandler_t *chp = &aha_handler[unit];; -#endif /* defined(OSF) */ - - /***********************************************\ - /***********************************************\ - * find unit and check we have that many defined * - \***********************************************/ - dev->dev_unit = unit; - aha_base[unit] = dev->dev_addr; - if(unit >= NAHA) - { - printf("aha%d: unit number too high\n",unit); - return(0); - } - /***********************************************\ - * Try initialise a unit at this location * - * sets up dma and bus speed, loads aha_int[unit]* - \***********************************************/ - if (aha_init(unit) != 0) - { - return(0); - } - - /***********************************************\ - * If it's there, put in it's interrupt vectors * - \***********************************************/ -#if !defined(OSF) -#if defined MACH - iunit[aha_int[unit]] =unit; - ivect[aha_int[unit]] = ahaintr; - intpri[aha_int[unit]] = dev->dev_spl; - form_pic_mask(); - /*take_dev_irq(dev);*/ -#else -#ifdef __386BSD__ - dev->id_irq = (1 << aha_int[unit]); - dev->id_drq = aha_dma[unit]; -#endif __386BSD__ -#endif -#else /* !defined(OSF) */ - - dev->dev_pic = aha_dma[unit]; - chp->ih_level = dev->dev_pic; - chp->ih_handler = dev->dev_intr[0]; - chp->ih_resolver = i386_resolver; - chp->ih_rdev = dev; - chp->ih_stats.intr_type = INTR_DEVICE; - chp->ih_stats.intr_cnt = 0; - chp->ih_hparam[0].intparam = unit; - if ((aha_handler_id[unit] = handler_add(chp)) != NULL) - handler_enable(aha_handler_id[unit]); - else - panic("Unable to add aha interrupt handler"); -#endif /* !defined(OSF) */ -#ifndef __386BSD__ - printf("port=%x spl=%d\n", dev->dev_addr, dev->dev_spl); -#endif __386BSD__ - ahaunit ++; - return(1); -} - -/***********************************************\ -* Attach all the sub-devices we can find * -\***********************************************/ -ahaattach(dev) -struct isa_dev *dev; -{ - int unit = dev->dev_unit; - - /***********************************************\ - * ask the adapter what subunits are present * - \***********************************************/ - scsi_attachdevs( unit, aha_scsi_dev[unit], &aha_switch); -#if defined(OSF) - aha_attached[unit]=1; -#endif /* defined(OSF) */ - return; -} - -/***********************************************\ -* Return some information to the caller about * -* the adapter and it's capabilities * -\***********************************************/ -long int aha_adapter_info(unit) -int unit; -{ - return(2); /* 2 outstanding requests at a time per device */ -} - -/***********************************************\ -* Catch an interrupt from the adaptor * -\***********************************************/ -ahaintr(unit) -{ - struct aha_ccb *ccb; - unsigned char stat; - register i; - -#ifdef AHADEBUG - if(scsi_debug & PRINTROUTINES) - printf("ahaintr "); -#endif /*AHADEBUG*/ - /***********************************************\ - * First acknowlege the interrupt, Then if it's * - * not telling about a completed operation * - * just return. * - \***********************************************/ - stat = inb(AHA_INTR_PORT); - outb(AHA_CTRL_STAT_PORT, AHA_IRST); -#ifdef AHADEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("int "); -#endif /*AHADEBUG*/ - if (! (stat & AHA_MBIF)) - return(1); -#ifdef AHADEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("b "); -#endif /*AHADEBUG*/ -#if defined(OSF) - if (!aha_attached[unit]) - { - return(1); - } -#endif /* defined(OSF) */ - /***********************************************\ - * If it IS then process the competed operation * - \***********************************************/ - for (i = 0; i < AHA_MBX_SIZE; i++) - { - if (aha_mbx[unit].mbi[i].stat != AHA_MBI_FREE) - { - ccb = (struct aha_ccb *)PHYSTOKV( - (_3btol(aha_mbx[unit].mbi[i].ccb_addr))); - - if((stat = aha_mbx[unit].mbi[i].stat) != AHA_MBI_OK) - { - switch(stat) - { - case AHA_MBI_ABORT: -#ifdef AHADEBUG - if(aha_debug) - printf("abort"); -#endif /*AHADEBUG*/ - ccb->host_stat = AHA_ABORTED; - break; - - case AHA_MBI_UNKNOWN: - ccb = (struct aha_ccb *)0; -#ifdef AHADEBUG - if(aha_debug) - printf("unknown ccb for abort "); -#endif /*AHADEBUG*/ - /* may have missed it */ - /* no such ccb known for abort */ - - case AHA_MBI_ERROR: - break; - - default: - panic("Impossible mbxi status"); - - } -#ifdef AHADEBUG - if( aha_debug && ccb ) - { - u_char *cp; - cp = (u_char *)(&(ccb->scsi_cmd)); - printf("op=%x %x %x %x %x %x\n", - cp[0], cp[1], cp[2], - cp[3], cp[4], cp[5]); - printf("stat %x for mbi[%d]\n" - , aha_mbx[unit].mbi[i].stat, i); - printf("addr = 0x%x\n", ccb); - } -#endif /*AHADEBUG*/ - } - if(ccb) - { - untimeout(aha_timeout,ccb); - aha_done(unit,ccb); - } - aha_mbx[unit].mbi[i].stat = AHA_MBI_FREE; - } - } - return(1); -} - -/***********************************************\ -* A ccb (and hence a mbx-out is put onto the * -* free list. * -\***********************************************/ -aha_free_ccb(unit,ccb, flags) -struct aha_ccb *ccb; -{ - unsigned int opri; - -#ifdef AHADEBUG - if(scsi_debug & PRINTROUTINES) - printf("ccb%d(0x%x)> ",unit,flags); -#endif /*AHADEBUG*/ - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - - ccb->next = aha_ccb_free[unit]; - aha_ccb_free[unit] = ccb; - ccb->flags = CCB_FREE; - /***********************************************\ - * If there were none, wake abybody waiting for * - * one to come free, starting with queued entries* - \***********************************************/ - if (!ccb->next) { - wakeup(&aha_ccb_free[unit]); - } - if (!(flags & SCSI_NOMASK)) - splx(opri); -} - -/***********************************************\ -* Get a free ccb (and hence mbox-out entry) * -\***********************************************/ -struct aha_ccb * -aha_get_ccb(unit,flags) -{ - unsigned opri; - struct aha_ccb *rc; - -#ifdef AHADEBUG - if(scsi_debug & PRINTROUTINES) - printf("next; - rc->flags = CCB_ACTIVE; - } - if (!(flags & SCSI_NOMASK)) - splx(opri); - return(rc); -} - - -/***********************************************\ -* We have a ccb which has been processed by the * -* adaptor, now we look to see how the operation * -* went. Wake up the owner if waiting * -\***********************************************/ -aha_done(unit,ccb) -struct aha_ccb *ccb; -{ - struct scsi_sense_data *s1,*s2; - struct scsi_xfer *xs = ccb->xfer; - -#ifdef AHADEBUG - if(scsi_debug & PRINTROUTINES ) - printf("aha_done "); -#endif /*AHADEBUG*/ - /***********************************************\ - * Otherwise, put the results of the operation * - * into the xfer and call whoever started it * - \***********************************************/ - if(!(xs->flags & INUSE)) - { - printf("aha%d: exiting but not in use!\n",unit); - Debugger(); - } - if ( ( ccb->host_stat != AHA_OK - || ccb->target_stat != SCSI_OK) - && (!(xs->flags & SCSI_ERR_OK))) - { - s1 = (struct scsi_sense_data *)(((char *)(&ccb->scsi_cmd)) - + ccb->scsi_cmd_length); - s2 = &(xs->sense); - - if(ccb->host_stat) - { - switch(ccb->host_stat) - { - case AHA_ABORTED: - case AHA_SEL_TIMEOUT: /* No response */ - xs->error = XS_TIMEOUT; - break; - default: /* Other scsi protocol messes */ - xs->error = XS_DRIVER_STUFFUP; -#ifdef AHADEBUG - if (aha_debug > 1) - { - printf("host_stat%x\n", - ccb->host_stat); - } -#endif /*AHADEBUG*/ - } - - } - else - { - switch(ccb->target_stat) - { - case 0x02: - /* structure copy!!!!!*/ - *s2=*s1; - xs->error = XS_SENSE; - break; - case 0x08: - xs->error = XS_BUSY; - break; - default: -#ifdef AHADEBUG - if (aha_debug > 1) - { - printf("target_stat%x\n", - ccb->target_stat); - } -#endif /*AHADEBUG*/ - xs->error = XS_DRIVER_STUFFUP; - } - } - } - else /* All went correctly OR errors expected */ - { - xs->resid = 0; - } - xs->flags |= ITSDONE; - aha_free_ccb(unit,ccb, xs->flags); - if(xs->when_done) - (*(xs->when_done))(xs->done_arg,xs->done_arg2); -} - - -/***********************************************\ -* Start the board, ready for normal operation * -\***********************************************/ -aha_init(unit) -int unit; -{ - unsigned char ad[3]; - volatile int i,sts; - struct aha_config conf; - struct aha_inquire inquire; - struct aha_extbios extbios; - - /***********************************************\ - * reset board, If it doesn't respond, assume * - * that it's not there.. good for the probe * - \***********************************************/ - - outb(AHA_CTRL_STAT_PORT, AHA_HRST|AHA_SRST); - - for (i=0; i < AHA_RESET_TIMEOUT; i++) - { - sts = inb(AHA_CTRL_STAT_PORT) ; - if ( sts == (AHA_IDLE | AHA_INIT)) - break; - } - if (i >= AHA_RESET_TIMEOUT) - { -#ifdef AHADEBUG - if (aha_debug) - printf("aha_init: No answer from adaptec board\n"); -#endif /*AHADEBUG*/ - return(ENXIO); - } - /* - * Assume we have a board at this stage, do an adapter inquire - * to find out what type of controller it is - */ - aha_cmd(unit, 0, sizeof(inquire), 1 ,&inquire, AHA_INQUIRE); -#ifdef AHADEBUG - printf("aha%d: inquire %x, %x, %x, %x\n", - unit, - inquire.boardid, inquire.spec_opts, - inquire.revision_1, inquire.revision_2); -#endif /* AHADEBUG */ - /* - * XXX The Buslogic 545S gets the AHA_INQUIRE command wrong, - * they only return one byte which causes us to print an error, - * so if the boardid comes back as 0x20, tell the user why they - * get the "cmd/data port empty" message - */ - if (inquire.boardid == 0x20) { - /* looks like a Buslogic 545 */ - printf ("aha%d: above cmd/data port empty do to Buslogic 545\n", - unit); - } - /* - * If we are on a 1542C or 1542CF find out if the extended bios - * is enabled, if it is disable it, or else it will screw us up later - */ - if ((inquire.boardid == 0x43) || (inquire.boardid == 0x44)) { - aha_cmd(unit, 0, sizeof(extbios), 0, &extbios, AHA_EXT_BIOS); -#ifdef AHADEBUG - printf("aha%d: extended bios flags %x\n", unit, extbios.flags); -#endif /* AHADEBUG */ - if (extbios.flags & 0x8) { - printf("aha%d: disabling bios enhanced features\n"); - aha_cmd(unit, 2, 0, 0, 0, AHA_MBX_ENABLE, - 0, extbios.mailboxlock); - } - } - /***********************************************\ - * Setup dma channel from jumpers and save int * - * level * - \***********************************************/ -#ifdef __386BSD__ - printf("aha%d: reading board settings, ",unit); -#define PRNT(x) printf(x) -#else __386BSD__ - printf("aha%d:",unit); -#define PRNT(x) printf(x) -#endif __386BSD__ - DELAY(10000); /* for Bustek 545 */ - aha_cmd(unit,0, sizeof(conf), 0 ,&conf, AHA_CONF_GET); - switch(conf.chan) - { - case CHAN0: - outb(0x0b, 0x0c); - outb(0x0a, 0x00); - aha_dma[unit] = 0; - PRNT("dma=0 "); - break; - case CHAN5: - outb(0xd6, 0xc1); - outb(0xd4, 0x01); - aha_dma[unit] = 5; - PRNT("dma=5 "); - break; - case CHAN6: - outb(0xd6, 0xc2); - outb(0xd4, 0x02); - aha_dma[unit] = 6; - PRNT("dma=6 "); - break; - case CHAN7: - outb(0xd6, 0xc3); - outb(0xd4, 0x03); - aha_dma[unit] = 7; - PRNT("dma=7 "); - break; - default: - printf("illegal dma jumper setting\n"); - return(EIO); - } - switch(conf.intr) - { - case INT9: - aha_int[unit] = 9; - PRNT("int=9 "); - break; - case INT10: - aha_int[unit] = 10; - PRNT("int=10 "); - break; - case INT11: - aha_int[unit] = 11; - PRNT("int=11 "); - break; - case INT12: - aha_int[unit] = 12; - PRNT("int=12 "); - break; - case INT14: - aha_int[unit] = 14; - PRNT("int=14 "); - break; - case INT15: - aha_int[unit] = 15; - PRNT("int=15 "); - break; - default: - printf("illegal int jumper setting\n"); - return(EIO); - } - /* who are we on the scsi bus */ - aha_scsi_dev[unit] = conf.scsi_dev; - - - /***********************************************\ - * Initialize memory transfer speed * - \***********************************************/ -/* - * XXX This code seems to BREAK more boards than it makes - * work right, we are just going to NOP this here... - */ -#if 0 - if(!(aha_set_bus_speed(unit))) - { - return(EIO); - } -#else - printf ("\n"); -#endif - - - /***********************************************\ - * Initialize mail box * - \***********************************************/ - - lto3b(KVTOPHYS(&aha_mbx[unit]), ad); - - aha_cmd(unit,4, 0, 0, 0, AHA_MBX_INIT, - AHA_MBX_SIZE, - ad[0], - ad[1], - ad[2]); - - - /***********************************************\ - * link the ccb's with the mbox-out entries and * - * into a free-list * - \***********************************************/ - for (i=0; i < AHA_MBX_SIZE; i++) { - aha_ccb[unit][i].next = aha_ccb_free[unit]; - aha_ccb_free[unit] = &aha_ccb[unit][i]; - aha_ccb_free[unit]->flags = CCB_FREE; - aha_ccb_free[unit]->mbx = &aha_mbx[unit].mbo[i]; - lto3b(KVTOPHYS(aha_ccb_free[unit]), aha_mbx[unit].mbo[i].ccb_addr); - } - - /***********************************************\ - * Note that we are going and return (to probe) * - \***********************************************/ - aha_initialized[unit]++; - return(0); -} - - - - - -void ahaminphys(bp) -struct buf *bp; -{ -#ifdef MACH -#if !defined(OSF) - bp->b_flags |= B_NPAGES; /* can support scat/gather */ -#endif /* !defined(OSF) */ -#endif MACH -/* aha seems to explode with 17 segs (64k may require 17 segs) */ -/* on old boards so use a max of 16 segs if you have problems here*/ - if(bp->b_bcount > ((AHA_NSEG - 1) * PAGESIZ)) - { - bp->b_bcount = ((AHA_NSEG - 1) * PAGESIZ); - } -} - -/***********************************************\ -* start a scsi operation given the command and * -* the data address. Also needs the unit, target * -* and lu * -\***********************************************/ -int aha_scsi_cmd(xs) -struct scsi_xfer *xs; -{ - struct scsi_sense_data *s1,*s2; - struct aha_ccb *ccb; - struct aha_scat_gath *sg; - int seg; /* scatter gather seg being worked on */ - int i = 0; - int rc = 0; - int thiskv; - int thisphys,nextphys; - int unit =xs->adapter; - int bytes_this_seg,bytes_this_page,datalen,flags; - struct iovec *iovp; - int s; - -#ifdef AHADEBUG - if(scsi_debug & PRINTROUTINES) - printf("aha_scsi_cmd "); -#endif /*AHADEBUG*/ - /***********************************************\ - * get a ccb (mbox-out) to use. If the transfer * - * is from a buf (possibly from interrupt time) * - * then we can't allow it to sleep * - \***********************************************/ - flags = xs->flags; - if(!(flags & INUSE)) - { - printf("aha%d: not in use!\n",unit); - Debugger(); - xs->flags |= INUSE; - } - if(flags & ITSDONE) - { - printf("aha%d: Already done! check device retry code\n",unit); - Debugger(); - xs->flags &= ~ITSDONE; - } - if(xs->bp) flags |= (SCSI_NOSLEEP); /* just to be sure */ - if (!(ccb = aha_get_ccb(unit,flags))) - { - xs->error = XS_DRIVER_STUFFUP; - return(TRY_AGAIN_LATER); - } - - if (ccb->mbx->cmd != AHA_MBO_FREE) - printf("aha%d: MBO not free\n",unit); - - /***********************************************\ - * Put all the arguments for the xfer in the ccb * - \***********************************************/ - ccb->xfer = xs; - if(flags & SCSI_RESET) - { - ccb->opcode = AHA_RESET_CCB; - } - else - { - /* can't use S/G if zero length */ - ccb->opcode = (xs->datalen? - AHA_INIT_SCAT_GATH_CCB - :AHA_INITIATOR_CCB); - } - ccb->target = xs->targ;; - ccb->data_out = 0; - ccb->data_in = 0; - ccb->lun = xs->lu; - ccb->scsi_cmd_length = xs->cmdlen; - ccb->req_sense_length = sizeof(ccb->scsi_sense); - - if((xs->datalen) && (!(flags & SCSI_RESET))) - { /* can use S/G only if not zero length */ - lto3b(KVTOPHYS(ccb->scat_gath), ccb->data_addr ); - sg = ccb->scat_gath ; - seg = 0; - if(flags & SCSI_DATA_UIO) - { - iovp = ((struct uio *)xs->data)->uio_iov; - datalen = ((struct uio *)xs->data)->uio_iovcnt; - while ((datalen) && (seg < AHA_NSEG)) - { - lto3b(iovp->iov_base,&(sg->seg_addr)); - lto3b(iovp->iov_len,&(sg->seg_len)); -#ifdef AHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x@0x%x)" - ,iovp->iov_len - ,iovp->iov_base); -#endif /*AHADEBUG*/ - sg++; - iovp++; - seg++; - datalen--; - } - } - else - { - /***********************************************\ - * Set up the scatter gather block * - \***********************************************/ - -#ifdef AHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("%d @0x%x:- ",xs->datalen,xs->data); -#endif /*AHADEBUG*/ - datalen = xs->datalen; - thiskv = (int)xs->data; - thisphys = KVTOPHYS(thiskv); - - while ((datalen) && (seg < AHA_NSEG)) - { - bytes_this_seg = 0; - - /* put in the base address */ - lto3b(thisphys,&(sg->seg_addr)); - -#ifdef AHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("0x%x",thisphys); -#endif /*AHADEBUG*/ - - /* do it at least once */ - nextphys = thisphys; - while ((datalen) && (thisphys == nextphys)) - /***************************************\ - * This page is contiguous (physically) * - * with the the last, just extend the * - * length * - \***************************************/ - { - /** how far to the end of the page ***/ - nextphys = (thisphys & (~(PAGESIZ - 1))) - + PAGESIZ; - bytes_this_page = nextphys - thisphys; - /**** or the data ****/ - bytes_this_page = min(bytes_this_page - ,datalen); - bytes_this_seg += bytes_this_page; - datalen -= bytes_this_page; - - /**** get more ready for the next page ****/ - thiskv = (thiskv & (~(PAGESIZ - 1))) - + PAGESIZ; - if(datalen) - thisphys = KVTOPHYS(thiskv); - } - /***************************************\ - * next page isn't contiguous, finish the seg* - \***************************************/ -#ifdef AHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x)",bytes_this_seg); -#endif /*AHADEBUG*/ - lto3b(bytes_this_seg,&(sg->seg_len)); - sg++; - seg++; - } - } - lto3b(seg * sizeof(struct aha_scat_gath),ccb->data_length); -#ifdef AHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("\n"); -#endif /*AHADEBUG*/ - if (datalen) - { /* there's still data, must have run out of segs! */ - printf("aha%d: aha_scsi_cmd, more than %d DMA segs\n", - unit,AHA_NSEG); - xs->error = XS_DRIVER_STUFFUP; - aha_free_ccb(unit,ccb,flags); - return(HAD_ERROR); - } - - } - else - { /* No data xfer, use non S/G values */ - lto3b(0, ccb->data_addr ); - lto3b(0,ccb->data_length); - } - lto3b(0, ccb->link_addr ); - /***********************************************\ - * Put the scsi command in the ccb and start it * - \***********************************************/ - if(!(flags & SCSI_RESET)) - bcopy(xs->cmd, &ccb->scsi_cmd, ccb->scsi_cmd_length); -#ifdef AHADEBUG - if(scsi_debug & SHOWCOMMANDS) - { - u_char *b = (u_char *)&ccb->scsi_cmd; - if(!(flags & SCSI_RESET)) - { - int i = 0; - printf("aha%d:%d:%d-" - ,unit - ,ccb->target - ,ccb->lun ); - while(i < ccb->scsi_cmd_length ) - { - if(i) printf(","); - printf("%x",b[i++]); - } - } - else - { - printf("aha%d:%d:%d-RESET- " - ,unit - ,ccb->target - ,ccb->lun - ); - } - } -#endif /*AHADEBUG*/ - if (!(flags & SCSI_NOMASK)) - { - s= splbio(); /* stop instant timeouts */ - timeout(aha_timeout,ccb,(xs->timeout * hz) / 1000); - aha_startmbx(ccb->mbx); - /***********************************************\ - * Usually return SUCCESSFULLY QUEUED * - \***********************************************/ - splx(s); -#ifdef AHADEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("sent "); -#endif /*AHADEBUG*/ - return(SUCCESSFULLY_QUEUED); - } - aha_startmbx(ccb->mbx); -#ifdef AHADEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("cmd_sent, waiting "); -#endif /*AHADEBUG*/ - /***********************************************\ - * If we can't use interrupts, poll on completion* - \***********************************************/ - { - int done = 0; - int count = delaycount * xs->timeout / AHA_SCSI_TIMEOUT_FUDGE; - while((!done) && count) - { - i=0; - while ( (!done) && iflags & SCSI_SILENT)) - printf("aha%d: cmd fail\n",unit); - aha_abortmbx(ccb->mbx); - count = delaycount * 2000 / AHA_SCSI_TIMEOUT_FUDGE; - while((!done) && count) - { - i=0; - while ( (!done) && imbx->cmd = AHA_MBO_FREE; - } - aha_free_ccb(unit,ccb,flags); - ahaintr(unit); - xs->error = XS_DRIVER_STUFFUP; - return(HAD_ERROR); - } - ahaintr(unit); - if(xs->error) return(HAD_ERROR); - return(COMPLETE); - - } -} -/***************************************************************\ -* try each speed in turn, when we find one that works, use * -* the NEXT one for a safety margin, unless that doesn't exist * -* or doesn't work. returns the nSEC value of the time used * -* or 0 if it could get a working speed ( or the NEXT speed * -* failed) * -\***************************************************************/ - -int aha_set_bus_speed(unit) -int unit; -{ - int speed; - int retval,retval2; - -#ifdef EISA - speed = 0; /* start at the fastest */ -#else EISA - speed = 1; /* 100 ns can crash some ISA busses (!?!) */ -#endif EISA - while (1) - { - retval = aha_bus_speed_check(unit,speed); - if(retval == HAD_ERROR) - { - printf("no working bus speed!!!\n"); - return(0); - } - if(retval == 0) - { - speed++; - } - else /* Go one slower to be safe */ - { /* unless eisa at 100 ns.. trust it */ - if(speed != 0) - { - speed++; - } - printf("%d nSEC ok, using ",retval); - retval2 = aha_bus_speed_check(unit,speed); - if(retval2 == HAD_ERROR) /* retval is slowest already */ - { - printf("marginal "); - retval2 = retval; - } - if(retval2) - { - printf("%d nSEC\n",retval2); - return(retval2); - } - else - { - printf(".. slower failed, abort\n",retval); - return(0); - } - - } - } -} - -/***************************************************************\ -* Set the DMA speed to the Nth speed and try an xfer. If it * -* fails return 0, if it succeeds return the nSec value selected * -* If there is no such speed return HAD_ERROR. * -\***************************************************************/ -static struct bus_speed -{ - char arg; - int nsecs; -}aha_bus_speeds[] = -{ - {0x88,100}, - {0x99,150}, - {0xaa,200}, - {0xbb,250}, - {0xcc,300}, - {0xdd,350}, - {0xee,400}, - {0xff,450} -}; -static char aha_test_string[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz!@"; - -int aha_bus_speed_check(unit,speed) -int unit,speed; -{ - int numspeeds = sizeof(aha_bus_speeds)/sizeof(struct bus_speed); - u_char ad[3]; - - /*******************************************************\ - * Check we have such an entry * - \*******************************************************/ - if(speed >= numspeeds) return(HAD_ERROR); /* illegal speed */ - - /*******************************************************\ - * Set the dma-speed * - \*******************************************************/ - aha_cmd(unit,1, 0, 0, 0, AHA_SPEED_SET,aha_bus_speeds[speed].arg); - - /*******************************************************\ - * put the test data into the buffer and calculate * - * it's address. Read it onto the board * - \*******************************************************/ - strcpy(aha_scratch_buf,aha_test_string); - lto3b(KVTOPHYS(aha_scratch_buf),ad); - - aha_cmd(unit,3, 0, 0, 0, AHA_WRITE_FIFO, ad[0], ad[1], ad[2]); - - /*******************************************************\ - * clear the buffer then copy the contents back from the * - * board. * - \*******************************************************/ - bzero(aha_scratch_buf,54); /* 54 bytes transfered by test */ - - aha_cmd(unit,3, 0, 0, 0, AHA_READ_FIFO, ad[0], ad[1], ad[2]); - - /*******************************************************\ - * Compare the original data and the final data and * - * return the correct value depending upon the result * - \*******************************************************/ - if(strcmp(aha_test_string,aha_scratch_buf)) - { /* copy failed.. assume too fast */ - return(0); - } - else - { /* copy succeded assume speed ok */ - return(aha_bus_speeds[speed].nsecs); - } -} - - - -aha_timeout(struct aha_ccb *ccb) -{ - int unit; - int s = splbio(); - - unit = ccb->xfer->adapter; - printf("aha%d: device %d timed out ",unit ,ccb->xfer->targ); - - /***************************************\ - * If The ccb's mbx is not free, then * - * the board has gone south * - \***************************************/ - if(ccb->mbx->cmd != AHA_MBO_FREE) - { - printf("aha%d: not taking commands!\n",unit); - Debugger(); - } - /***************************************\ - * If it has been through before, then * - * a previous abort has failed, don't * - * try abort again * - \***************************************/ - if(ccb->flags == CCB_ABORTED) /* abort timed out */ - { - printf(" AGAIN\n"); - ccb->xfer->retries = 0; /* I MEAN IT ! */ - ccb->host_stat = AHA_ABORTED; - aha_done(unit,ccb); - } - else /* abort the operation that has timed out */ - { - printf("\n"); - aha_abortmbx(ccb->mbx); - /* 2 secs for the abort */ - timeout(aha_timeout,ccb,2 * hz); - ccb->flags = CCB_ABORTED; - } - splx(s); -} diff --git a/sys/i386/isa/aha1742.c b/sys/i386/isa/aha1742.c deleted file mode 100644 index 1e3e154..0000000 --- a/sys/i386/isa/aha1742.c +++ /dev/null @@ -1,1322 +0,0 @@ -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * commenced: Sun Sep 27 18:14:01 PDT 1992 - * - * $Id: aha1742.c,v 1.9 1993/08/28 03:07:40 rgrimes Exp $ - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef MACH /* EITHER CMU OR OSF */ -#include -#include -#include - -#ifdef OSF /* OSF ONLY */ -#include -#include -#include -#include - -#else OSF /* CMU ONLY */ -#include -#include -#endif OSF -#endif MACH /* end of MACH specific */ - -#ifdef __386BSD__ /* 386BSD specific */ -#define isa_dev isa_device -#define dev_unit id_unit -#define dev_addr id_iobase - -#include -#include -#include -#include -#endif __386BSD__ - -/* */ - -#ifdef __386BSD__ -#include "ddb.h" -#if NDDB > 0 -int Debugger(); -#else NDDB -#define Debugger() panic("should call debugger here (adaptec.c)") -#endif NDDB -#endif __386BSD__ - -#ifdef MACH -int Debugger(); -#endif MACH - -typedef unsigned long int physaddr; -extern int hz; - -#ifdef MACH -extern physaddr kvtophys(); -#define PHYSTOKV(x) phystokv(x) -#define KVTOPHYS(x) kvtophys(x) -#endif MACH - -#ifdef __386BSD__ -#define KVTOPHYS(x) vtophys(x) -#endif __386BSD__ - -extern int delaycount; /* from clock setup code */ -#define NUM_CONCURRENT 16 /* number of concurrent ops per board */ -#define AHB_NSEG 33 /* number of dma segments supported */ -#define FUDGE(X) (X>>1) /* our loops are slower than spinwait() */ -/* */ -/***********************************************************************\ -* AHA1740 standard EISA Host ID regs (Offset from slot base) * -\***********************************************************************/ -#define HID0 0xC80 /* 0,1: msb of ID2, 3-7: ID1 */ -#define HID1 0xC81 /* 0-4: ID3, 4-7: LSB ID2 */ -#define HID2 0xC82 /* product, 0=174[20] 1 = 1744 */ -#define HID3 0xC83 /* firmware revision */ - -#define CHAR1(B1,B2) (((B1>>2) & 0x1F) | '@') -#define CHAR2(B1,B2) (((B1<<3) & 0x18) | ((B2>>5) & 0x7)|'@') -#define CHAR3(B1,B2) ((B2 & 0x1F) | '@') - -/* AHA1740 EISA board control registers (Offset from slot base) */ -#define EBCTRL 0xC84 -#define CDEN 0x01 -/***********************************************************************\ -* AHA1740 EISA board mode registers (Offset from slot base) * -\***********************************************************************/ -#define PORTADDR 0xCC0 -#define PORTADDR_ENHANCED 0x80 -#define BIOSADDR 0xCC1 -#define INTDEF 0xCC2 -#define SCSIDEF 0xCC3 -#define BUSDEF 0xCC4 -#define RESV0 0xCC5 -#define RESV1 0xCC6 -#define RESV2 0xCC7 -/**** bit definitions for INTDEF ****/ -#define INT9 0x00 -#define INT10 0x01 -#define INT11 0x02 -#define INT12 0x03 -#define INT14 0x05 -#define INT15 0x06 -#define INTHIGH 0x08 /* int high=ACTIVE (else edge) */ -#define INTEN 0x10 -/**** bit definitions for SCSIDEF ****/ -#define HSCSIID 0x0F /* our SCSI ID */ -#define RSTPWR 0x10 /* reset scsi bus on power up or reset */ -/**** bit definitions for BUSDEF ****/ -#define B0uS 0x00 /* give up bus immediatly */ -#define B4uS 0x01 /* delay 4uSec. */ -#define B8uS 0x02 -/***********************************************************************\ -* AHA1740 ENHANCED mode mailbox control regs (Offset from slot base) * -\***********************************************************************/ -#define MBOXOUT0 0xCD0 -#define MBOXOUT1 0xCD1 -#define MBOXOUT2 0xCD2 -#define MBOXOUT3 0xCD3 - -#define ATTN 0xCD4 -#define G2CNTRL 0xCD5 -#define G2INTST 0xCD6 -#define G2STAT 0xCD7 - -#define MBOXIN0 0xCD8 -#define MBOXIN1 0xCD9 -#define MBOXIN2 0xCDA -#define MBOXIN3 0xCDB - -#define G2STAT2 0xCDC - -/*******************************************************\ -* Bit definitions for the 5 control/status registers * -\*******************************************************/ -#define ATTN_TARGET 0x0F -#define ATTN_OPCODE 0xF0 -#define OP_IMMED 0x10 -#define AHB_TARG_RESET 0x80 -#define OP_START_ECB 0x40 -#define OP_ABORT_ECB 0x50 - -#define G2CNTRL_SET_HOST_READY 0x20 -#define G2CNTRL_CLEAR_EISA_INT 0x40 -#define G2CNTRL_HARD_RESET 0x80 - -#define G2INTST_TARGET 0x0F -#define G2INTST_INT_STAT 0xF0 -#define AHB_ECB_OK 0x10 -#define AHB_ECB_RECOVERED 0x50 -#define AHB_HW_ERR 0x70 -#define AHB_IMMED_OK 0xA0 -#define AHB_ECB_ERR 0xC0 -#define AHB_ASN 0xD0 /* for target mode */ -#define AHB_IMMED_ERR 0xE0 - -#define G2STAT_BUSY 0x01 -#define G2STAT_INT_PEND 0x02 -#define G2STAT_MBOX_EMPTY 0x04 - -#define G2STAT2_HOST_READY 0x01 -/* */ - -struct ahb_dma_seg -{ - physaddr addr; - long len; -}; - -struct ahb_ecb_status -{ - u_short status; -# define ST_DON 0x0001 -# define ST_DU 0x0002 -# define ST_QF 0x0008 -# define ST_SC 0x0010 -# define ST_DO 0x0020 -# define ST_CH 0x0040 -# define ST_INT 0x0080 -# define ST_ASA 0x0100 -# define ST_SNS 0x0200 -# define ST_INI 0x0800 -# define ST_ME 0x1000 -# define ST_ECA 0x4000 - u_char ha_status; -# define HS_OK 0x00 -# define HS_CMD_ABORTED_HOST 0x04 -# define HS_CMD_ABORTED_ADAPTER 0x05 -# define HS_TIMED_OUT 0x11 -# define HS_HARDWARE_ERR 0x20 -# define HS_SCSI_RESET_ADAPTER 0x22 -# define HS_SCSI_RESET_INCOMING 0x23 - u_char targ_status; -# define TS_OK 0x00 -# define TS_CHECK_CONDITION 0x02 -# define TS_BUSY 0x08 - u_long resid_count; - u_long resid_addr; - u_short addit_status; - u_char sense_len; - u_char unused[9]; - u_char cdb[6]; -}; - -/* */ - -struct ecb -{ - u_char opcode; -# define ECB_SCSI_OP 0x01 - u_char :4; - u_char options:3; - u_char :1; - short opt1; -# define ECB_CNE 0x0001 -# define ECB_DI 0x0080 -# define ECB_SES 0x0400 -# define ECB_S_G 0x1000 -# define ECB_DSB 0x4000 -# define ECB_ARS 0x8000 - short opt2; -# define ECB_LUN 0x0007 -# define ECB_TAG 0x0008 -# define ECB_TT 0x0030 -# define ECB_ND 0x0040 -# define ECB_DAT 0x0100 -# define ECB_DIR 0x0200 -# define ECB_ST 0x0400 -# define ECB_CHK 0x0800 -# define ECB_REC 0x4000 -# define ECB_NRB 0x8000 - u_short unused1; - physaddr data; - u_long datalen; - physaddr status; - physaddr chain; - short unused2; - short unused3; - physaddr sense; - u_char senselen; - u_char cdblen; - short cksum; - u_char cdb[12]; - /*-----------------end of hardware supported fields----------------*/ - struct ecb *next; /* in free list */ - struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ - int flags; -#define ECB_FREE 0 -#define ECB_ACTIVE 1 -#define ECB_ABORTED 2 -#define ECB_IMMED 4 -#define ECB_IMMED_FAIL 8 - struct ahb_dma_seg ahb_dma[AHB_NSEG]; - struct ahb_ecb_status ecb_status; - struct scsi_sense_data ecb_sense; -}; - -/* */ - -struct ahb_data -{ - int flags; -#define AHB_INIT 0x01; - int baseport; - struct ecb ecbs[NUM_CONCURRENT]; - struct ecb *free_ecb; - int our_id; /* our scsi id */ - int vect; - struct ecb *immed_ecb; /* an outstanding immediete command */ -} ahb_data[NAHB]; - -int ahbprobe(); -int ahb_attach(); -int ahbintr(); -int ahb_scsi_cmd(); -int ahb_timeout(); -struct ecb *cheat; -void ahbminphys(); -long int ahb_adapter_info(); - -#ifdef MACH -struct isa_driver ahbdriver = { ahbprobe, 0, ahb_attach, "ahb", 0, 0, 0}; -int (*ahbintrs[])() = {ahbintr, 0}; -#endif MACH - -#ifdef __386BSD__ -struct isa_driver ahbdriver = { ahbprobe, ahb_attach, "ahb"}; -#endif __386BSD__ - -#define MAX_SLOTS 8 -static ahb_slot = 0; /* slot last board was found in */ -static ahb_unit = 0; -int ahb_debug = 0; -#define AHB_SHOWECBS 0x01 -#define AHB_SHOWINTS 0x02 -#define AHB_SHOWCMDS 0x04 -#define AHB_SHOWMISC 0x08 -#define FAIL 1 -#define SUCCESS 0 -#define PAGESIZ 4096 - -struct scsi_switch ahb_switch = -{ - ahb_scsi_cmd, - ahbminphys, - 0, - 0, - ahb_adapter_info, - "ahb", - 0,0 -}; - -/* */ -/***********************************************************************\ -* Function to send a command out through a mailbox * -\***********************************************************************/ -ahb_send_mbox( int unit - ,int opcode - ,int target - ,struct ecb *ecb) -{ - int port = ahb_data[unit].baseport; - int spincount = FUDGE(delaycount) * 1; /* 1ms should be enough */ - int s = splbio(); - int stport = port + G2STAT; - - while( ((inb(stport) & (G2STAT_BUSY | G2STAT_MBOX_EMPTY)) - != (G2STAT_MBOX_EMPTY)) - && (spincount--)); - if(spincount == -1) - { - printf("ahb%d: board not responding\n",unit); - Debugger(); - } - - outl(port + MBOXOUT0,KVTOPHYS(ecb)); /* don't know this will work */ - outb(port + ATTN, opcode|target); - - splx(s); -} - -/***********************************************************************\ -* Function to poll for command completion when in poll mode * -\***********************************************************************/ -ahb_poll(int unit ,int wait) /* in msec */ -{ - int port = ahb_data[unit].baseport; - int spincount = FUDGE(delaycount) * wait; /* in msec */ - int stport = port + G2STAT; -int start = spincount; - -retry: - while( (spincount--) && (!(inb(stport) & G2STAT_INT_PEND))); - if(spincount == -1) - { - printf("ahb%d: board not responding\n",unit); - return(EIO); - } -if ((int)cheat != PHYSTOKV(inl(port + MBOXIN0))) -{ - printf("discarding %x ",inl(port + MBOXIN0)); - outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT); - spinwait(50); - goto retry; -}/* don't know this will work */ - ahbintr(unit); - return(0); -} -/***********************************************************************\ -* Function to send an immediate type command to the adapter * -\***********************************************************************/ -ahb_send_immed( int unit - ,int target - ,u_long cmd) -{ - int port = ahb_data[unit].baseport; - int spincount = FUDGE(delaycount) * 1; /* 1ms should be enough */ - int s = splbio(); - int stport = port + G2STAT; - - while( ((inb(stport) & (G2STAT_BUSY | G2STAT_MBOX_EMPTY)) - != (G2STAT_MBOX_EMPTY)) - && (spincount--)); - if(spincount == -1) - { - printf("ahb%d: board not responding\n",unit); - Debugger(); - } - - outl(port + MBOXOUT0,cmd); /* don't know this will work */ - outb(port + G2CNTRL, G2CNTRL_SET_HOST_READY); - outb(port + ATTN, OP_IMMED | target); - splx(s); -} - -/* */ - -/*******************************************************\ -* Check the slots looking for a board we recognise * -* If we find one, note it's address (slot) and call * -* the actual probe routine to check it out. * -\*******************************************************/ -ahbprobe(dev) -struct isa_dev *dev; -{ - int port; - u_char byte1,byte2,byte3; - ahb_slot++; - while (ahb_slot<8) - { - port = 0x1000 * ahb_slot; - byte1 = inb(port + HID0); - byte2 = inb(port + HID1); - byte3 = inb(port + HID2); - if(byte1 == 0xff) - { - ahb_slot++; - continue; - } - if ((CHAR1(byte1,byte2) == 'A') - && (CHAR2(byte1,byte2) == 'D') - && (CHAR3(byte1,byte2) == 'P') - && ((byte3 == 0 ) || (byte3 == 1))) - { - dev->dev_addr = port; - return(ahbprobe1(dev)); - } - ahb_slot++; - } - return(0); -} -/*******************************************************\ -* Check if the device can be found at the port given * -* and if so, set it up ready for further work * -* as an argument, takes the isa_dev structure from * -* autoconf.c * -\*******************************************************/ -ahbprobe1(dev) -struct isa_dev *dev; -{ - /***********************************************\ - * find unit and check we have that many defined * - \***********************************************/ - int unit = ahb_unit; -#if defined(OSF) - static ihandler_t ahb_handler[NAHB]; - static ihandler_id_t *ahb_handler_id[NAHB]; - register ihandler_t *chp = &ahb_handler[unit];; -#endif /* defined(OSF) */ - - dev->dev_unit = unit; - ahb_data[unit].baseport = dev->dev_addr; - if(unit >= NAHB) - { - printf("ahb: unit number (%d) too high\n",unit); - return(0); - } - /***********************************************\ - * Try initialise a unit at this location * - * sets up dma and bus speed, loads ahb_data[unit].vect* - \***********************************************/ - if (ahb_init(unit) != 0) - { - return(0); - } - - /***********************************************\ - * If it's there, put in it's interrupt vectors * - \***********************************************/ -#ifdef MACH - dev->dev_pic = ahb_data[unit].vect; -#if defined(OSF) /* OSF */ - chp->ih_level = dev->dev_pic; - chp->ih_handler = dev->dev_intr[0]; - chp->ih_resolver = i386_resolver; - chp->ih_rdev = dev; - chp->ih_stats.intr_type = INTR_DEVICE; - chp->ih_stats.intr_cnt = 0; - chp->ih_hparam[0].intparam = unit; - if ((ahb_handler_id[unit] = handler_add(chp)) != NULL) - handler_enable(ahb_handler_id[unit]); - else - panic("Unable to add ahb interrupt handler"); -#else /* CMU */ - take_dev_irq(dev); -#endif /* !defined(OSF) */ - printf("port=%x spl=%d\n", dev->dev_addr, dev->dev_spl); -#endif MACH -#ifdef __386BSD__ /* 386BSD */ - dev->id_irq = (1 << ahb_data[unit].vect); - dev->id_drq = -1; /* use EISA dma */ -#endif __386BSD__ - - ahb_unit++; - return(1); -} - -/***********************************************\ -* Attach all the sub-devices we can find * -\***********************************************/ -ahb_attach(dev) -struct isa_dev *dev; -{ - int unit = dev->dev_unit; - - /***********************************************\ - * ask the adapter what subunits are present * - \***********************************************/ - scsi_attachdevs( unit, ahb_data[unit].our_id, &ahb_switch); -#if defined(OSF) - ahb_attached[unit]=1; -#endif /* defined(OSF) */ - return; -} - -/***********************************************\ -* Return some information to the caller about * -* the adapter and it's capabilities * -\***********************************************/ -long int ahb_adapter_info(unit) -int unit; -{ - return(2); /* 2 outstanding requests at a time per device */ -} - -/***********************************************\ -* Catch an interrupt from the adaptor * -\***********************************************/ -ahbintr(unit) -{ - struct ecb *ecb; - unsigned char stat; - register i; - u_char ahbstat; - int target; - long int mboxval; - - int port = ahb_data[unit].baseport; - -#ifdef AHBDEBUG - if(scsi_debug & PRINTROUTINES) - printf("ahbintr "); -#endif /*AHBDEBUG*/ - -#if defined(OSF) - if (!ahb_attached[unit]) - { - return(1); - } -#endif /* defined(OSF) */ - while(inb(port + G2STAT) & G2STAT_INT_PEND) - { - /***********************************************\ - * First get all the information and then * - * acknowlege the interrupt * - \***********************************************/ - ahbstat = inb(port + G2INTST); - target = ahbstat & G2INTST_TARGET; - stat = ahbstat & G2INTST_INT_STAT; - mboxval = inl(port + MBOXIN0);/* don't know this will work */ - outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT); -#ifdef AHBDEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("status = 0x%x ",stat); -#endif /*AHBDEBUG*/ - /***********************************************\ - * Process the completed operation * - \***********************************************/ - - if(stat == AHB_ECB_OK) /* common case is fast */ - { - ecb = (struct ecb *)PHYSTOKV(mboxval); - } - else - { - switch(stat) - { - case AHB_IMMED_OK: - ecb = ahb_data[unit].immed_ecb; - ahb_data[unit].immed_ecb = 0; - break; - case AHB_IMMED_ERR: - ecb = ahb_data[unit].immed_ecb; - ecb->flags |= ECB_IMMED_FAIL; - ahb_data[unit].immed_ecb = 0; - break; - case AHB_ASN: /* for target mode */ - printf("ahb%d: Unexpected ASN interrupt(%x)\n", - unit, mboxval); - ecb = 0; - break; - case AHB_HW_ERR: - printf("ahb%d: Hardware error interrupt(%x)\n", - unit, mboxval); - ecb = 0; - break; - case AHB_ECB_RECOVERED: - ecb = (struct ecb *)PHYSTOKV(mboxval); - break; - case AHB_ECB_ERR: - ecb = (struct ecb *)PHYSTOKV(mboxval); - break; - default: - printf(" Unknown return from ahb%d(%x)\n",unit,ahbstat); - ecb=0; - } - } - if(ecb) - { -#ifdef AHBDEBUG - if(ahb_debug & AHB_SHOWCMDS ) - { - ahb_show_scsi_cmd(ecb->xs); - } - if((ahb_debug & AHB_SHOWECBS) && ecb) - printf("",ecb); -#endif /*AHBDEBUG*/ - untimeout(ahb_timeout,ecb); - ahb_done(unit,ecb,((stat == AHB_ECB_OK)?SUCCESS:FAIL)); - } - } - return(1); -} - -/***********************************************\ -* We have a ecb which has been processed by the * -* adaptor, now we look to see how the operation * -* went. * -\***********************************************/ -ahb_done(unit,ecb,state) -int unit,state; -struct ecb *ecb; -{ - struct ahb_ecb_status *stat = &ecb->ecb_status; - struct scsi_sense_data *s1,*s2; - struct scsi_xfer *xs = ecb->xs; - -#ifdef AHBDEBUG - if(scsi_debug & (PRINTROUTINES | TRACEINTERRUPTS)) - printf("ahb_done "); -#endif /*AHBDEBUG*/ - /***********************************************\ - * Otherwise, put the results of the operation * - * into the xfer and call whoever started it * - \***********************************************/ - if(ecb->flags & ECB_IMMED) - { - if(ecb->flags & ECB_IMMED_FAIL) - { - xs->error = XS_DRIVER_STUFFUP; - } - goto done; - } - if ( (state == SUCCESS) || (xs->flags & SCSI_ERR_OK)) - { /* All went correctly OR errors expected */ - xs->resid = 0; - xs->error = 0; - } - else - { - - s1 = &(ecb->ecb_sense); - s2 = &(xs->sense); - - if(stat->ha_status) - { - switch(stat->ha_status) - { - case HS_SCSI_RESET_ADAPTER: - break; - case HS_SCSI_RESET_INCOMING: - break; - case HS_CMD_ABORTED_HOST: /* No response */ - case HS_CMD_ABORTED_ADAPTER: /* No response */ - break; - case HS_TIMED_OUT: /* No response */ -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) - { - printf("timeout reported back\n"); - } -#endif /*AHBDEBUG*/ - xs->error = XS_TIMEOUT; - break; - default: /* Other scsi protocol messes */ - xs->error = XS_DRIVER_STUFFUP; -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) - { - printf("unexpected ha_status: %x\n", - stat->ha_status); - } -#endif /*AHBDEBUG*/ - } - - } - else - { - switch(stat->targ_status) - { - case TS_CHECK_CONDITION: - /* structure copy!!!!!*/ - *s2=*s1; - xs->error = XS_SENSE; - break; - case TS_BUSY: - xs->error = XS_BUSY; - break; - default: -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) - { - printf("unexpected targ_status: %x\n", - stat->targ_status); - } -#endif /*AHBDEBUG*/ - xs->error = XS_DRIVER_STUFFUP; - } - } - } -done: xs->flags |= ITSDONE; - ahb_free_ecb(unit,ecb, xs->flags); - if(xs->when_done) - (*(xs->when_done))(xs->done_arg,xs->done_arg2); -} - -/***********************************************\ -* A ecb (and hence a mbx-out is put onto the * -* free list. * -\***********************************************/ -ahb_free_ecb(unit,ecb, flags) -struct ecb *ecb; -{ - unsigned int opri; - -#ifdef AHBDEBUG - if(scsi_debug & PRINTROUTINES) - printf("ecb%d(0x%x)> ",unit,flags); -#endif /*AHBDEBUG*/ - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - - ecb->next = ahb_data[unit].free_ecb; - ahb_data[unit].free_ecb = ecb; - ecb->flags = ECB_FREE; - /***********************************************\ - * If there were none, wake abybody waiting for * - * one to come free, starting with queued entries* - \***********************************************/ - if (!ecb->next) { - wakeup(&ahb_data[unit].free_ecb); - } - if (!(flags & SCSI_NOMASK)) - splx(opri); -} - -/***********************************************\ -* Get a free ecb (and hence mbox-out entry) * -\***********************************************/ -struct ecb * -ahb_get_ecb(unit,flags) -{ - unsigned opri; - struct ecb *rc; - -#ifdef AHBDEBUG - if(scsi_debug & PRINTROUTINES) - printf("next; - rc->flags = ECB_ACTIVE; - } - if (!(flags & SCSI_NOMASK)) - splx(opri); - return(rc); -} - - - -/***********************************************\ -* Start the board, ready for normal operation * -\***********************************************/ -ahb_init(unit) -int unit; -{ - int port = ahb_data[unit].baseport; - int intdef; - int spincount = FUDGE(delaycount) * 1000; /* 1 sec enough? */ - int i; - int stport = port + G2STAT; -#define NO_NO 1 -#ifdef NO_NO - /***********************************************\ - * reset board, If it doesn't respond, assume * - * that it's not there.. good for the probe * - \***********************************************/ - outb(port + EBCTRL,CDEN); /* enable full card */ - outb(port + PORTADDR,PORTADDR_ENHANCED); - - outb(port + G2CNTRL,G2CNTRL_HARD_RESET); - spinwait(1); - outb(port + G2CNTRL,0); - spinwait(10); - while( ((inb(stport) & G2STAT_BUSY )) - && (spincount--)); - if(spincount == -1) - { -#ifdef AHBDEBUG - if (ahb_debug & AHB_SHOWMISC) - printf("ahb_init: No answer from bt742a board\n"); -#endif /*AHBDEBUG*/ - return(ENXIO); - } - i = inb(port + MBOXIN0) & 0xff; - if(i) - { - printf("self test failed, val = 0x%x\n",i); - return(EIO); - } -#endif - while( inb(stport) & G2STAT_INT_PEND) - { - printf("."); - outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT); - spinwait(10); - } - outb(port + EBCTRL,CDEN); /* enable full card */ - outb(port + PORTADDR,PORTADDR_ENHANCED); - /***********************************************\ - * Assume we have a board at this stage * - * setup dma channel from jumpers and save int * - * level * - \***********************************************/ -#ifdef __386BSD__ - printf("ahb%d: reading board settings, ",unit); -#else __386BSD__ - printf("ahb%d:",unit); -#endif __386BSD__ - - intdef = inb(port + INTDEF); - switch(intdef & 0x07) - { - case INT9: - ahb_data[unit].vect = 9; - break; - case INT10: - ahb_data[unit].vect = 10; - break; - case INT11: - ahb_data[unit].vect = 11; - break; - case INT12: - ahb_data[unit].vect = 12; - break; - case INT14: - ahb_data[unit].vect = 14; - break; - case INT15: - ahb_data[unit].vect = 15; - break; - default: - printf("illegal int setting\n"); - return(EIO); - } -#ifdef __386BSD__ - printf("int=%d\n",ahb_data[unit].vect); -#else __386BSD__ - printf("int=%d ",ahb_data[unit].vect); -#endif __386BSD__ - - outb(port + INTDEF ,(intdef | INTEN)); /* make sure we can interrupt */ - /* who are we on the scsi bus */ - ahb_data[unit].our_id = (inb(port + SCSIDEF) & HSCSIID); - - /***********************************************\ - * link up all our ECBs into a free list * - \***********************************************/ - for (i=0; i < NUM_CONCURRENT; i++) - { - ahb_data[unit].ecbs[i].next = ahb_data[unit].free_ecb; - ahb_data[unit].free_ecb = &ahb_data[unit].ecbs[i]; - ahb_data[unit].free_ecb->flags = ECB_FREE; - } - - /***********************************************\ - * Note that we are going and return (to probe) * - \***********************************************/ - ahb_data[unit].flags |= AHB_INIT; - return( 0 ); -} - - -#ifndef min -#define min(x,y) (x < y ? x : y) -#endif min - - -void ahbminphys(bp) -struct buf *bp; -{ -#ifdef MACH -#if !defined(OSF) - bp->b_flags |= B_NPAGES; /* can support scat/gather */ -#endif /* defined(OSF) */ -#endif MACH - if(bp->b_bcount > ((AHB_NSEG-1) * PAGESIZ)) - { - bp->b_bcount = ((AHB_NSEG-1) * PAGESIZ); - } -} - -/***********************************************\ -* start a scsi operation given the command and * -* the data address. Also needs the unit, target * -* and lu * -\***********************************************/ -int ahb_scsi_cmd(xs) -struct scsi_xfer *xs; -{ - struct scsi_sense_data *s1,*s2; - struct ecb *ecb; - struct ahb_dma_seg *sg; - int seg; /* scatter gather seg being worked on */ - int i = 0; - int rc = 0; - int thiskv; - physaddr thisphys,nextphys; - int unit =xs->adapter; - int bytes_this_seg,bytes_this_page,datalen,flags; - struct iovec *iovp; - int s; -#ifdef AHBDEBUG - if(scsi_debug & PRINTROUTINES) - printf("ahb_scsi_cmd "); -#endif /*AHBDEBUG*/ - /***********************************************\ - * get a ecb (mbox-out) to use. If the transfer * - * is from a buf (possibly from interrupt time) * - * then we can't allow it to sleep * - \***********************************************/ - flags = xs->flags; - if(xs->bp) flags |= (SCSI_NOSLEEP); /* just to be sure */ - if(flags & ITSDONE) - { - printf("ahb%d: Already done?",unit); - xs->flags &= ~ITSDONE; - } - if(!(flags & INUSE)) - { - printf("ahb%d: Not in use?",unit); - xs->flags |= INUSE; - } - if (!(ecb = ahb_get_ecb(unit,flags))) - { - xs->error = XS_DRIVER_STUFFUP; - return(TRY_AGAIN_LATER); - } - -cheat = ecb; -#ifdef AHBDEBUG - if(ahb_debug & AHB_SHOWECBS) - printf("",ecb); - if(scsi_debug & SHOWCOMMANDS) - { - ahb_show_scsi_cmd(xs); - } -#endif /*AHBDEBUG*/ - ecb->xs = xs; - /***********************************************\ - * If it's a reset, we need to do an 'immediate' * - * command, and store it's ccb for later * - * if there is already an immediate waiting, * - * then WE must wait * - \***********************************************/ - if(flags & SCSI_RESET) - { - ecb->flags |= ECB_IMMED; - if(ahb_data[unit].immed_ecb) - { - return(TRY_AGAIN_LATER); - } - ahb_data[unit].immed_ecb = ecb; - if (!(flags & SCSI_NOMASK)) - { - s = splbio(); - ahb_send_immed(unit,xs->targ,AHB_TARG_RESET); - timeout(ahb_timeout,ecb,(xs->timeout * hz)/1000); - splx(s); - return(SUCCESSFULLY_QUEUED); - } - else - { - ahb_send_immed(unit,xs->targ,AHB_TARG_RESET); - /***********************************************\ - * If we can't use interrupts, poll on completion* - \***********************************************/ -#ifdef AHBDEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("wait "); -#endif /*AHBDEBUG*/ - if( ahb_poll(unit,xs->timeout)) - { - ahb_free_ecb(unit,ecb,flags); - xs->error = XS_TIMEOUT; - return(HAD_ERROR); - } - return(COMPLETE); - } - } - /***********************************************\ - * Put all the arguments for the xfer in the ecb * - \***********************************************/ - ecb->opcode = ECB_SCSI_OP; - ecb->opt1 = ECB_SES|ECB_DSB|ECB_ARS; - if(xs->datalen) - { - ecb->opt1 |= ECB_S_G; - } - ecb->opt2 = xs->lu | ECB_NRB; - ecb->cdblen = xs->cmdlen; - ecb->sense = KVTOPHYS(&(ecb->ecb_sense)); - ecb->senselen = sizeof(ecb->ecb_sense); - ecb->status = KVTOPHYS(&(ecb->ecb_status)); - - if(xs->datalen) - { /* should use S/G only if not zero length */ - ecb->data = KVTOPHYS(ecb->ahb_dma); - sg = ecb->ahb_dma ; - seg = 0; - if(flags & SCSI_DATA_UIO) - { - iovp = ((struct uio *)xs->data)->uio_iov; - datalen = ((struct uio *)xs->data)->uio_iovcnt; - xs->datalen = 0; - while ((datalen) && (seg < AHB_NSEG)) - { - sg->addr = (physaddr)iovp->iov_base; - xs->datalen += sg->len = iovp->iov_len; -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x@0x%x)" - ,iovp->iov_len - ,iovp->iov_base); -#endif /*AHBDEBUG*/ - sg++; - iovp++; - seg++; - datalen--; - } - } - else - { - /***********************************************\ - * Set up the scatter gather block * - \***********************************************/ - -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("%d @0x%x:- ",xs->datalen,xs->data); -#endif /*AHBDEBUG*/ - datalen = xs->datalen; - thiskv = (int)xs->data; - thisphys = KVTOPHYS(thiskv); - - while ((datalen) && (seg < AHB_NSEG)) - { - bytes_this_seg = 0; - - /* put in the base address */ - sg->addr = thisphys; - -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("0x%x",thisphys); -#endif /*AHBDEBUG*/ - - /* do it at least once */ - nextphys = thisphys; - while ((datalen) && (thisphys == nextphys)) - /*********************************************\ - * This page is contiguous (physically) with * - * the the last, just extend the length * - \*********************************************/ - { - /* how far to the end of the page */ - nextphys= (thisphys & (~(PAGESIZ - 1))) - + PAGESIZ; - bytes_this_page = nextphys - thisphys; - /**** or the data ****/ - bytes_this_page = min(bytes_this_page - ,datalen); - bytes_this_seg += bytes_this_page; - datalen -= bytes_this_page; - - /* get more ready for the next page */ - thiskv = (thiskv & (~(PAGESIZ - 1))) - + PAGESIZ; - if(datalen) - thisphys = KVTOPHYS(thiskv); - } - /********************************************\ - * next page isn't contiguous, finish the seg * - \********************************************/ -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x)",bytes_this_seg); -#endif /*AHBDEBUG*/ - sg->len = bytes_this_seg; - sg++; - seg++; - } - } /*end of iov/kv decision */ - ecb->datalen = seg * sizeof(struct ahb_dma_seg); -#ifdef AHBDEBUG - if(scsi_debug & SHOWSCATGATH) - printf("\n"); -#endif /*AHBDEBUG*/ - if (datalen) - { /* there's still data, must have run out of segs! */ - printf("ahb_scsi_cmd%d: more than %d DMA segs\n", - unit,AHB_NSEG); - xs->error = XS_DRIVER_STUFFUP; - ahb_free_ecb(unit,ecb,flags); - return(HAD_ERROR); - } - - } - else - { /* No data xfer, use non S/G values */ - ecb->data = (physaddr)0; - ecb->datalen = 0; - } - ecb->chain = (physaddr)0; - /***********************************************\ - * Put the scsi command in the ecb and start it * - \***********************************************/ - bcopy(xs->cmd, ecb->cdb, xs->cmdlen); - /***********************************************\ - * Usually return SUCCESSFULLY QUEUED * - \***********************************************/ - if (!(flags & SCSI_NOMASK)) - { - s = splbio(); - ahb_send_mbox(unit,OP_START_ECB,xs->targ,ecb); - timeout(ahb_timeout,ecb,(xs->timeout * hz)/1000); - splx(s); -#ifdef AHBDEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("cmd_sent "); -#endif /*AHBDEBUG*/ - return(SUCCESSFULLY_QUEUED); - } - /***********************************************\ - * If we can't use interrupts, poll on completion* - \***********************************************/ - ahb_send_mbox(unit,OP_START_ECB,xs->targ,ecb); -#ifdef AHBDEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("cmd_wait "); -#endif /*AHBDEBUG*/ - do - { - if(ahb_poll(unit,xs->timeout)) - { - if (!(xs->flags & SCSI_SILENT)) printf("cmd fail\n"); - ahb_send_mbox(unit,OP_ABORT_ECB,xs->targ,ecb); - if(ahb_poll(unit,2000)) - { - printf("abort failed in wait\n"); - ahb_free_ecb(unit,ecb,flags); - } - xs->error = XS_DRIVER_STUFFUP; - return(HAD_ERROR); - } - } while (!(xs->flags & ITSDONE));/* something (?) else finished */ - if(xs->error) - { - return(HAD_ERROR); - } - return(COMPLETE); -} - - -ahb_timeout(struct ecb *ecb) -{ - int unit; - int s = splbio(); - - unit = ecb->xs->adapter; - printf("ahb%d:%d device timed out\n",unit - ,ecb->xs->targ); -#ifdef AHBDEBUG - if(ahb_debug & AHB_SHOWECBS) - ahb_print_active_ecb(unit); -#endif /*AHBDEBUG*/ - - /***************************************\ - * If it's immediate, don't try abort it * - \***************************************/ - if(ecb->flags & ECB_IMMED) - { - ecb->xs->retries = 0; /* I MEAN IT ! */ - ecb->flags |= ECB_IMMED_FAIL; - ahb_done(unit,ecb,FAIL); - splx(s); - return; - } - /***************************************\ - * If it has been through before, then * - * a previous abort has failed, don't * - * try abort again * - \***************************************/ - if(ecb->flags == ECB_ABORTED) /* abort timed out */ - { - printf("AGAIN"); - ecb->xs->retries = 0; /* I MEAN IT ! */ - ecb->ecb_status.ha_status = HS_CMD_ABORTED_HOST; - ahb_done(unit,ecb,FAIL); - } - else /* abort the operation that has timed out */ - { - printf("\n"); - ahb_send_mbox(unit,OP_ABORT_ECB,ecb->xs->targ,ecb); - /* 2 secs for the abort */ - timeout(ahb_timeout,ecb,2 * hz); - ecb->flags = ECB_ABORTED; - } - splx(s); -} - -#ifdef AHBDEBUG -ahb_show_scsi_cmd(struct scsi_xfer *xs) -{ - u_char *b = (u_char *)xs->cmd; - int i = 0; - if(!(xs->flags & SCSI_RESET)) - { - printf("ahb%d:%d:%d-" - ,xs->adapter - ,xs->targ - ,xs->lu); - while(i < xs->cmdlen ) - { - if(i) printf(","); - printf("%x",b[i++]); - } - printf("-\n"); - } - else - { - printf("ahb%d:%d:%d-RESET-\n" - ,xs->adapter - ,xs->targ - ,xs->lu - ); - } -} -ahb_print_ecb(ecb) -struct ecb *ecb; -{ - printf("ecb:%x op:%x cmdlen:%d senlen:%d\n" - ,ecb - ,ecb->opcode - ,ecb->cdblen - ,ecb->senselen); - printf(" datlen:%d hstat:%x tstat:%x flags:%x\n" - ,ecb->datalen - ,ecb->ecb_status.ha_status - ,ecb->ecb_status.targ_status - ,ecb->flags); - ahb_show_scsi_cmd(ecb->xs); -} - -ahb_print_active_ecb(int unit) -{ - struct ecb *ecb = ahb_data[unit].ecbs; - int i = NUM_CONCURRENT; - - while(i--) - { - if(ecb->flags != ECB_FREE) - { - ahb_print_ecb(ecb); - } - ecb++; - } -} -#endif /*AHBDEBUG */ diff --git a/sys/i386/isa/bt742a.c b/sys/i386/isa/bt742a.c deleted file mode 100644 index 0e25091..0000000 --- a/sys/i386/isa/bt742a.c +++ /dev/null @@ -1,1617 +0,0 @@ -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * $Id: bt742a.c,v 1.7 1993/08/28 03:07:42 rgrimes Exp $ - */ - -/* - * bt742a SCSI driver - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef MACH /* EITHER CMU OR OSF */ -#include -#include -#include - -#ifdef OSF /* OSF ONLY */ -#include -#include -#include -#include - -#else OSF /* CMU ONLY */ -#include -#include -#endif OSF -#endif MACH /* end of MACH specific */ - -#ifdef __386BSD__ /* 386BSD specific */ -#define isa_dev isa_device -#define dev_unit id_unit -#define dev_addr id_iobase - -#include -#include -#include -#endif __386BSD__ - - -#ifdef __386BSD__ -#include "ddb.h" -#if NDDB > 0 -int Debugger(); -#else NDDB -#define Debugger() panic("should call debugger here (bt742a.c)") -#endif NDDB -#endif __386BSD__ - -#ifdef MACH -int Debugger(); -#endif MACH - -extern int hz; -extern int delaycount; /* from clock setup code */ -typedef unsigned long int physaddr; - -/* - * I/O Port Interface - */ - -#define BT_BASE bt_base[unit] -#define BT_CTRL_STAT_PORT (BT_BASE + 0x0) /* control & status */ -#define BT_CMD_DATA_PORT (BT_BASE + 0x1) /* cmds and datas */ -#define BT_INTR_PORT (BT_BASE + 0x2) /* Intr. stat */ - -/* - * BT_CTRL_STAT bits (write) - */ - -#define BT_HRST 0x80 /* Hardware reset */ -#define BT_SRST 0x40 /* Software reset */ -#define BT_IRST 0x20 /* Interrupt reset */ -#define BT_SCRST 0x10 /* SCSI bus reset */ - -/* - * BT_CTRL_STAT bits (read) - */ - -#define BT_STST 0x80 /* Self test in Progress */ -#define BT_DIAGF 0x40 /* Diagnostic Failure */ -#define BT_INIT 0x20 /* Mbx Init required */ -#define BT_IDLE 0x10 /* Host Adapter Idle */ -#define BT_CDF 0x08 /* cmd/data out port full */ -#define BT_DF 0x04 /* Data in port full */ -#define BT_INVDCMD 0x01 /* Invalid command */ - -/* - * BT_CMD_DATA bits (write) - */ - -#define BT_NOP 0x00 /* No operation */ -#define BT_MBX_INIT 0x01 /* Mbx initialization */ -#define BT_START_SCSI 0x02 /* start scsi command */ -#define BT_START_BIOS 0x03 /* start bios command */ -#define BT_INQUIRE 0x04 /* Adapter Inquiry */ -#define BT_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */ -#define BT_SEL_TIMEOUT_SET 0x06 /* set selection time-out */ -#define BT_BUS_ON_TIME_SET 0x07 /* set bus-on time */ -#define BT_BUS_OFF_TIME_SET 0x08 /* set bus-off time */ -#define BT_SPEED_SET 0x09 /* set transfer speed */ -#define BT_DEV_GET 0x0a /* return installed devices */ -#define BT_CONF_GET 0x0b /* return configuration data */ -#define BT_TARGET_EN 0x0c /* enable target mode */ -#define BT_SETUP_GET 0x0d /* return setup data */ -#define BT_WRITE_CH2 0x1a /* write channel 2 buffer */ -#define BT_READ_CH2 0x1b /* read channel 2 buffer */ -#define BT_WRITE_FIFO 0x1c /* write fifo buffer */ -#define BT_READ_FIFO 0x1d /* read fifo buffer */ -#define BT_ECHO 0x1e /* Echo command data */ -#define BT_MBX_INIT_EXTENDED 0x81 /* Mbx initialization */ -#define BT_INQUIRE_EXTENDED 0x8D /* Adapter Setup Inquiry */ - -/* Follows command appeared at FirmWare 3.31 */ -#define BT_ROUND_ROBIN 0x8f /* Enable/Disable(default) round robin */ -#define BT_DISABLE 0x00 /* Parameter value for Disable */ -#define BT_ENABLE 0x01 /* Parameter value for Enable */ - -struct bt_cmd_buf { - u_char byte[16]; -}; - -/* - * BT_INTR_PORT bits (read) - */ - -#define BT_ANY_INTR 0x80 /* Any interrupt */ -#define BT_SCRD 0x08 /* SCSI reset detected */ -#define BT_HACC 0x04 /* Command complete */ -#define BT_MBOA 0x02 /* MBX out empty */ -#define BT_MBIF 0x01 /* MBX in full */ - -/* - * Mail box defs - */ - -#define BT_MBX_SIZE 255 /* mail box size (MAX 255 MBxs) */ -#define BT_CCB_SIZE 32 /* store up to 32CCBs at any one time */ - /* in bt742a H/W ( Not MAX ? ) */ - -#define bt_nextmbx( wmb, mbx, mbio ) \ - if ( (wmb) == &((mbx)->mbio[BT_MBX_SIZE - 1 ]) ) { \ - (wmb) = &((mbx)->mbio[0]); \ - } else { \ - (wmb)++; \ - } - - -typedef struct bt_mbx_out { - physaddr ccb_addr; - unsigned char dummy[3]; - unsigned char cmd; -} BT_MBO; - -typedef struct bt_mbx_in{ - physaddr ccb_addr; - unsigned char btstat; - unsigned char sdstat; - unsigned char dummy; - unsigned char stat; -} BT_MBI; - -struct bt_mbx -{ - BT_MBO mbo[BT_MBX_SIZE]; - BT_MBI mbi[BT_MBX_SIZE]; - BT_MBO *tmbo; /* Target Mail Box out */ - BT_MBI *tmbi; /* Target Mail Box in */ -}; - -/* - * mbo.cmd values - */ - -#define BT_MBO_FREE 0x0 /* MBO entry is free */ -#define BT_MBO_START 0x1 /* MBO activate entry */ -#define BT_MBO_ABORT 0x2 /* MBO abort entry */ - -#define BT_MBI_FREE 0x0 /* MBI entry is free */ -#define BT_MBI_OK 0x1 /* completed without error */ -#define BT_MBI_ABORT 0x2 /* aborted ccb */ -#define BT_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */ -#define BT_MBI_ERROR 0x4 /* Completed with error */ - -extern struct bt_mbx bt_mbx[]; - -#if defined(BIG_DMA) -/* #define BT_NSEG 8192 /* Number of scatter gather segments - to much vm */ -#define BT_NSEG 512 -#else -#define BT_NSEG 33 -#endif /* BIG_DMA */ -struct bt_scat_gath - { - unsigned long seg_len; - physaddr seg_addr; - }; - -struct bt_ccb { - unsigned char opcode; - unsigned char :3,data_in:1,data_out:1,:3; - unsigned char scsi_cmd_length; - unsigned char req_sense_length; - /*------------------------------------longword boundary */ - unsigned long data_length; - /*------------------------------------longword boundary */ - physaddr data_addr; - /*------------------------------------longword boundary */ - unsigned char dummy[2]; - unsigned char host_stat; - unsigned char target_stat; - /*------------------------------------longword boundary */ - unsigned char target; - unsigned char lun; - unsigned char scsi_cmd[12]; /* 12 bytes (bytes only)*/ - unsigned char dummy2[1]; - unsigned char link_id; - /*------------------------------------4 longword boundary */ - physaddr link_addr; - /*------------------------------------longword boundary */ - physaddr sense_ptr; - /*------------------------------------longword boundary */ - struct scsi_sense_data scsi_sense; - /*------------------------------------longword boundary */ - struct bt_scat_gath scat_gath[BT_NSEG]; - /*------------------------------------longword boundary */ - struct bt_ccb *next; - /*------------------------------------longword boundary */ - struct scsi_xfer *xfer; /* the scsi_xfer for this cmd */ - /*------------------------------------longword boundary */ - struct bt_mbx_out *mbx; /* pointer to mail box */ - /*------------------------------------longword boundary */ - int flags; -#define CCB_FREE 0 -#define CCB_ACTIVE 1 -#define CCB_ABORTED 2 -}; - -/* - * opcode fields - */ - -#define BT_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */ -#define BT_TARGET_CCB 0x01 /* SCSI Target CCB */ -#define BT_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scattter gather*/ -#define BT_RESET_CCB 0x81 /* SCSI Bus reset */ - - -/* - * bt_ccb.host_stat values - */ - -#define BT_OK 0x00 /* cmd ok */ -#define BT_LINK_OK 0x0a /* Link cmd ok */ -#define BT_LINK_IT 0x0b /* Link cmd ok + int */ -#define BT_SEL_TIMEOUT 0x11 /* Selection time out */ -#define BT_OVER_UNDER 0x12 /* Data over/under run */ -#define BT_BUS_FREE 0x13 /* Bus dropped at unexpected time */ -#define BT_INV_BUS 0x14 /* Invalid bus phase/sequence */ -#define BT_BAD_MBO 0x15 /* Incorrect MBO cmd */ -#define BT_BAD_CCB 0x16 /* Incorrect ccb opcode */ -#define BT_BAD_LINK 0x17 /* Not same values of LUN for links */ -#define BT_INV_TARGET 0x18 /* Invalid target direction */ -#define BT_CCB_DUP 0x19 /* Duplicate CCB received */ -#define BT_INV_CCB 0x1a /* Invalid CCB or segment list */ -#define BT_ABORTED 42 /* pseudo value from driver */ - -struct bt_boardID -{ - u_char board_type; - u_char custom_feture; - char firm_revision; - u_char firm_version; -}; - -struct bt_setup -{ - u_char sync_neg:1; - u_char parity:1; - u_char :6; - u_char speed; - u_char bus_on; - u_char bus_off; - u_char num_mbx; - u_char mbx[3]; - struct { - u_char offset:4; - u_char period:3; - u_char valid:1; - }sync[8]; - u_char disc_sts; -}; - -struct bt_config -{ - u_char chan; - u_char intr; - u_char scsi_dev:3; - u_char :5; -}; - -#define INT9 0x01 -#define INT10 0x02 -#define INT11 0x04 -#define INT12 0x08 -#define INT14 0x20 -#define INT15 0x40 - -#define EISADMA 0x00 -#define CHAN0 0x01 -#define CHAN5 0x20 -#define CHAN6 0x40 -#define CHAN7 0x80 - - - - -#ifdef MACH -extern physaddr kvtophys(); -#define PHYSTOKV(x) phystokv(x) -#define KVTOPHYS(x) kvtophys(x) -#endif MACH - -#ifdef __386BSD__ -#define KVTOPHYS(x) vtophys(x) -#endif __386BSD__ - - - -#define PAGESIZ 4096 -#define INVALIDATE_CACHE {asm volatile( ".byte 0x0F ;.byte 0x08" ); } - - -u_char bt_scratch_buf[256]; -#ifdef MACH -caddr_t bt_base[NBT]; /* base port for each board */ -#else MACH -short bt_base[NBT]; /* base port for each board */ -#endif MACH -struct bt_mbx bt_mbx[NBT]; -struct bt_ccb *bt_ccb_free[NBT]; -struct bt_ccb bt_ccb[NBT][BT_CCB_SIZE]; -struct scsi_xfer bt_scsi_xfer[NBT]; -struct isa_dev *btinfo[NBT]; -struct bt_ccb *bt_get_ccb(); -int bt_int[NBT]; -int bt_dma[NBT]; -int bt_scsi_dev[NBT]; -int bt_initialized[NBT]; -#if defined(OSF) -int bt_attached[NBT]; -#endif /* defined(OSF) */ - -/***********debug values *************/ -#define BT_SHOWCCBS 0x01 -#define BT_SHOWINTS 0x02 -#define BT_SHOWCMDS 0x04 -#define BT_SHOWMISC 0x08 -int bt_debug = 0; - - -int btprobe(), btattach(); -int btintr(); - -#ifdef MACH -struct isa_driver btdriver = { btprobe, 0, btattach, "bt", 0, 0, 0}; -int (*btintrs[])() = {btintr, 0}; -#endif MACH - -#ifdef __386BSD__ -struct isa_driver btdriver = { btprobe, btattach, "bt"}; -#endif __386BSD__ - -static int btunit = 0; - -int bt_scsi_cmd(); -int bt_timeout(); -void btminphys(); -long int bt_adapter_info(); - -struct scsi_switch bt_switch = -{ - bt_scsi_cmd, - btminphys, - 0, - 0, - bt_adapter_info, - "bt", - 0,0 -}; -#define BT_CMD_TIMEOUT_FUDGE 200 /* multiplied to get Secs */ -#define BT_RESET_TIMEOUT 1000000 -#define BT_SCSI_TIMEOUT_FUDGE 20 /* divided by for mSecs */ - - -/***********************************************************************\ -* bt_cmd(unit,icnt, ocnt,wait, retval, opcode, args) * -* Activate Adapter command * -* icnt: number of args (outbound bytes written after opcode) * -* ocnt: number of expected returned bytes * -* wait: number of seconds to wait for response * -* retval: buffer where to place returned bytes * -* opcode: opcode BT_NOP, BT_MBX_INIT, BT_START_SCSI ... * -* args: parameters * -* * -* Performs an adapter command through the ports. Not to be confused * -* with a scsi command, which is read in via the dma * -* One of the adapter commands tells it to read in a scsi command * -\***********************************************************************/ -bt_cmd(unit,icnt, ocnt, wait,retval, opcode, args) - -u_char *retval; -unsigned opcode; -u_char args; -{ - unsigned *ic = &opcode; - u_char oc; - register i; - int sts; - - /*******************************************************\ - * multiply the wait argument by a big constant * - * zero defaults to 1 * - \*******************************************************/ - if(!wait) - wait = BT_CMD_TIMEOUT_FUDGE * delaycount; - else - wait *= BT_CMD_TIMEOUT_FUDGE * delaycount; - /*******************************************************\ - * Wait for the adapter to go idle, unless it's one of * - * the commands which don't need this * - \*******************************************************/ - if (opcode != BT_MBX_INIT && opcode != BT_START_SCSI) - { - i = BT_CMD_TIMEOUT_FUDGE * delaycount; /* 1 sec?*/ - while (--i) - { - sts = inb(BT_CTRL_STAT_PORT); - if (sts & BT_IDLE) - { - break; - } - } - if (!i) - { - printf("bt%d: bt_cmd, host not idle(0x%x)\n",unit,sts); - return(ENXIO); - } - } - /*******************************************************\ - * Now that it is idle, if we expect output, preflush the* - * queue feeding to us. * - \*******************************************************/ - if (ocnt) - { - while((inb(BT_CTRL_STAT_PORT)) & BT_DF) - inb(BT_CMD_DATA_PORT); - } - - /*******************************************************\ - * Output the command and the number of arguments given * - * for each byte, first check the port is empty. * - \*******************************************************/ - icnt++; /* include the command */ - while (icnt--) - { - sts = inb(BT_CTRL_STAT_PORT); - for (i=0; i< wait; i++) - { - sts = inb(BT_CTRL_STAT_PORT); - if (!(sts & BT_CDF)) - break; - } - if (i >= wait) - { - printf("bt%d: bt_cmd, cmd/data port full\n",unit); - outb(BT_CTRL_STAT_PORT, BT_SRST); - return(ENXIO); - } - outb(BT_CMD_DATA_PORT, (u_char)(*ic++)); - } - /*******************************************************\ - * If we expect input, loop that many times, each time, * - * looking for the data register to have valid data * - \*******************************************************/ - while (ocnt--) - { - sts = inb(BT_CTRL_STAT_PORT); - for (i=0; i< wait; i++) - { - sts = inb(BT_CTRL_STAT_PORT); - if (sts & BT_DF) - break; - } - if (i >= wait) - { - printf("bt%d: bt_cmd, cmd/data port empty %d\n", - unit,ocnt); - return(ENXIO); - } - oc = inb(BT_CMD_DATA_PORT); - if (retval) - *retval++ = oc; - } - /*******************************************************\ - * Wait for the board to report a finised instruction * - \*******************************************************/ - i=BT_CMD_TIMEOUT_FUDGE * delaycount; /* 1 sec? */ - while (--i) - { - sts = inb(BT_INTR_PORT); - if (sts & BT_HACC) - { - break; - } - } - if (!i) - { - printf("bt%d: bt_cmd, host not finished(0x%x)\n",unit,sts); - return(ENXIO); - } - outb(BT_CTRL_STAT_PORT, BT_IRST); - return(0); -} - -/*******************************************************\ -* Check if the device can be found at the port given * -* and if so, set it up ready for further work * -* as an argument, takes the isa_dev structure from * -* autoconf.c * -\*******************************************************/ - -btprobe(dev) -struct isa_dev *dev; -{ - /***********************************************\ - * find unit and check we have that many defined * - \***********************************************/ - int unit = btunit; -#if defined(OSF) - static ihandler_t bt_handler[NBT]; - static ihandler_id_t *bt_handler_id[NBT]; - register ihandler_t *chp = &bt_handler[unit];; -#endif /* defined(OSF) */ - - dev->dev_unit = unit; - bt_base[unit] = dev->dev_addr; - if(unit >= NBT) - { - printf("bt%d: unit number too high\n",unit); - return(0); - } - /***********************************************\ - * Try initialise a unit at this location * - * sets up dma and bus speed, loads bt_int[unit]* - \***********************************************/ - if (bt_init(unit) != 0) - { - return(0); - } - - /***********************************************\ - * If it's there, put in it's interrupt vectors * - \***********************************************/ -#ifdef MACH - dev->dev_pic = bt_int[unit]; -#if defined(OSF) /* OSF */ - chp->ih_level = dev->dev_pic; - chp->ih_handler = dev->dev_intr[0]; - chp->ih_resolver = i386_resolver; - chp->ih_rdev = dev; - chp->ih_stats.intr_type = INTR_DEVICE; - chp->ih_stats.intr_cnt = 0; - chp->ih_hparam[0].intparam = unit; - if ((bt_handler_id[unit] = handler_add(chp)) != NULL) - handler_enable(bt_handler_id[unit]); - else - panic("Unable to add bt interrupt handler"); -#else /* CMU */ - take_dev_irq(dev); -#endif /* !defined(OSF) */ - printf("port=%x spl=%d\n", dev->dev_addr, dev->dev_spl); -#endif MACH -#ifdef __386BSD__ /* 386BSD */ - dev->id_irq = (1 << bt_int[unit]); - dev->id_drq = bt_dma[unit]; -#endif __386BSD__ - - btunit++; - return(1); -} - -/***********************************************\ -* Attach all the sub-devices we can find * -\***********************************************/ -btattach(dev) -struct isa_dev *dev; -{ - int unit = dev->dev_unit; - - - /***********************************************\ - * ask the adapter what subunits are present * - \***********************************************/ - scsi_attachdevs( unit, bt_scsi_dev[unit], &bt_switch); -#if defined(OSF) - bt_attached[unit]=1; -#endif /* defined(OSF) */ - return; -} - -/***********************************************\ -* Return some information to the caller about * -* the adapter and it's capabilities * -\***********************************************/ -long int bt_adapter_info(unit) -int unit; -{ - return(2); /* 2 outstanding requests at a time per device */ -} - -/***********************************************\ -* Catch an interrupt from the adaptor * -\***********************************************/ -btintr(unit) -{ - BT_MBI *wmbi; - struct bt_mbx *wmbx; - struct bt_ccb *ccb; - unsigned char stat; - int i,wait; - int found = 0; - -#ifdef UTEST - if(scsi_debug & PRINTROUTINES) - printf("btintr "); -#endif - /***********************************************\ - * First acknowlege the interrupt, Then if it's * - * not telling about a completed operation * - * just return. * - \***********************************************/ - stat = inb(BT_INTR_PORT); - - /* Mail Box out empty ? */ - if ( stat & BT_MBOA ) { - printf("bt%d: Available Free mbo post\n",unit); - /* Disable MBO available interrupt */ - outb(BT_CMD_DATA_PORT,BT_MBO_INTR_EN); - wait = BT_CMD_TIMEOUT_FUDGE * delaycount; - for (i=0; i< wait; i++) - { - if (!(inb(BT_CTRL_STAT_PORT) & BT_CDF)) - break; - } - if (i >= wait) - { - printf("bt%d: bt_intr, cmd/data port full\n",unit); - outb(BT_CTRL_STAT_PORT, BT_SRST); - return 1; - } - outb(BT_CMD_DATA_PORT, 0x00); /* Disable */ - wakeup(&bt_mbx[unit]); - outb(BT_CTRL_STAT_PORT, BT_IRST); - return 1; - } - if (! (stat & BT_MBIF)) { - outb(BT_CTRL_STAT_PORT, BT_IRST); - return 1; - } -#if defined(OSF) - if (!bt_attached[unit]) - { - return(1); - } -#endif /* defined(OSF) */ - /***********************************************\ - * If it IS then process the competed operation * - \***********************************************/ - wmbx = &bt_mbx[unit]; - wmbi = wmbx->tmbi; -AGAIN: - while ( wmbi->stat != BT_MBI_FREE ) { - found++; - ccb = (struct bt_ccb *)PHYSTOKV((wmbi->ccb_addr)); - if((stat = wmbi->stat) != BT_MBI_OK) - { - switch(stat) - { - case BT_MBI_ABORT: -#ifdef UTEST - if(bt_debug & BT_SHOWMISC) - printf("abort "); -#endif - ccb->host_stat = BT_ABORTED; - break; - - case BT_MBI_UNKNOWN: - ccb = (struct bt_ccb *)0; -#ifdef UTEST - if(bt_debug & BT_SHOWMISC) - printf("unknown ccb for abort"); -#endif - break; - - case BT_MBI_ERROR: - break; - - default: - panic("Impossible mbxi status"); - - } -#ifdef UTEST - if((bt_debug & BT_SHOWCMDS ) && ccb) - { - u_char *cp; - cp = ccb->scsi_cmd; - printf("op=%x %x %x %x %x %x\n", - cp[0], cp[1], cp[2], - cp[3], cp[4], cp[5]); - printf("stat %x for mbi addr = 0x%08x\n" - , wmbi->stat, wmbi ); - printf("addr = 0x%x\n", ccb); - } -#endif - } - wmbi->stat = BT_MBI_FREE; - if(ccb) - { - untimeout(bt_timeout,ccb); - bt_done(unit,ccb); - } - - /* Set the IN mail Box pointer for next */ - bt_nextmbx( wmbi, wmbx, mbi ); - } - if ( !found ) { - for ( i = 0; i < BT_MBX_SIZE; i++) { - if ( wmbi->stat != BT_MBI_FREE ) { - found ++; - break; - } - bt_nextmbx( wmbi, wmbx, mbi ); - } - if ( !found ) { - printf("bt%d: mbi at 0x%08x should be found, stat=%02x..resync\n", - unit, wmbi, stat ); - } else { - found = 0; - goto AGAIN; - } - } - wmbx->tmbi = wmbi; - outb(BT_CTRL_STAT_PORT, BT_IRST); - return(1); -} - -/***********************************************\ -* A ccb (and hence a mbx-out is put onto the * -* free list. * -\***********************************************/ -bt_free_ccb(unit,ccb, flags) -struct bt_ccb *ccb; -{ - unsigned int opri; - -#ifdef UTEST - if(scsi_debug & PRINTROUTINES) - printf("ccb%d(0x%x)> ",unit,flags); -#endif - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - - ccb->next = bt_ccb_free[unit]; - bt_ccb_free[unit] = ccb; - ccb->flags = CCB_FREE; - /***********************************************\ - * If there were none, wake abybody waiting for * - * one to come free, starting with queued entries* - \***********************************************/ - if (!ccb->next) { - wakeup(&bt_ccb_free[unit]); - } - if (!(flags & SCSI_NOMASK)) - splx(opri); -} - -/***********************************************\ -* Get a free ccb * -\***********************************************/ -struct bt_ccb * -bt_get_ccb(unit,flags) -{ - unsigned opri; - struct bt_ccb *rc; - struct bt_mbx *wmbx; /* Mail Box pointer specified unit */ - BT_MBO *wmbo; /* Out Mail Box pointer */ - -#ifdef UTEST - if(scsi_debug & PRINTROUTINES) - printf("next; - rc->flags = CCB_ACTIVE; -#ifdef HE - /* Get the Target OUT mail Box pointer */ - wmbx = &bt_mbx[unit]; - wmbo = wmbx->tmbo; - while ( wmbo->cmd != BT_MBO_FREE ) { - /* Enable MBO available interrupt */ - outb(BT_CMD_DATA_PORT,BT_MBO_INTR_EN); - printf("Wait free mbo.."); /* AMURAI */ - sleep( wmbx, PRIBIO); - printf("Got free mbo\n"); /* AMURAI */ - } - - /* Link CCB to the Mail Box */ - rc->mbx = wmbo; - wmbo->ccb_addr = KVTOPHYS(rc); - - /* Set the OUT mail Box pointer for next */ - bt_nextmbx( wmbo, wmbx, mbo ); - wmbx->tmbo = wmbo; -#endif - } - if (!(flags & SCSI_NOMASK)) - splx(opri); - - return(rc); -} -/***********************************************\ -* Get a MBO and then Send it * -\***********************************************/ -BT_MBO *bt_send_mbo( int unit, - int flags, - int cmd, - struct bt_ccb *ccb ) -{ - unsigned opri; - BT_MBO *wmbo; /* Mail Box Out pointer */ - struct bt_mbx *wmbx; /* Mail Box pointer specified unit */ - int i, wait; - - wmbx = &bt_mbx[unit]; - - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - - /* Get the Target OUT mail Box pointer and move to Next */ - wmbo = wmbx->tmbo; - wmbx->tmbo = ( wmbo == &( wmbx->mbo[BT_MBX_SIZE - 1 ] ) ? - &(wmbx->mbo[0]) : wmbo + 1 ); - - /* - * Check the outmail box is free or not - * Note: Under the normal operation, it shuld NOT happen to wait. - */ - while ( wmbo->cmd != BT_MBO_FREE ) { - - wait = BT_CMD_TIMEOUT_FUDGE * delaycount; - /* Enable MBO available interrupt */ - outb(BT_CMD_DATA_PORT,BT_MBO_INTR_EN); - for (i=0; i< wait; i++) - { - if (!(inb(BT_CTRL_STAT_PORT) & BT_CDF)) - break; - } - if (i >= wait) - { - printf("bt%d: bt_send_mbo, cmd/data port full\n",unit); - outb(BT_CTRL_STAT_PORT, BT_SRST); - return( (BT_MBO *)0 ); - } - outb(BT_CMD_DATA_PORT, 0x01); /* Enable */ - sleep( wmbx, PRIBIO); - } - - /* Link CCB to the Mail Box */ - wmbo->ccb_addr = KVTOPHYS(ccb); - ccb->mbx = wmbo; - wmbo->cmd = cmd; - - /* Send it ! */ - outb(BT_CMD_DATA_PORT, BT_START_SCSI); - - if (!(flags & SCSI_NOMASK)) - splx(opri); - - return(wmbo); -} -/***********************************************\ -* We have a ccb which has been processed by the * -* adaptor, now we look to see how the operation * -* went. Wake up the owner if waiting * -\***********************************************/ -bt_done(unit,ccb) -struct bt_ccb *ccb; -{ - struct scsi_sense_data *s1,*s2; - struct scsi_xfer *xs = ccb->xfer; - -#ifdef UTEST - if(scsi_debug & (PRINTROUTINES | TRACEINTERRUPTS)) - printf("bt_done "); -#endif - /***********************************************\ - * Otherwise, put the results of the operation * - * into the xfer and call whoever started it * - \***********************************************/ - if ( ( ccb->host_stat != BT_OK - || ccb->target_stat != SCSI_OK) - && (!(xs->flags & SCSI_ERR_OK))) - { - - s1 = &(ccb->scsi_sense); - s2 = &(xs->sense); - - if(ccb->host_stat) - { - switch(ccb->host_stat) - { - case BT_ABORTED: /* No response */ - case BT_SEL_TIMEOUT: /* No response */ -#ifdef UTEST - if (bt_debug & BT_SHOWMISC) - { - printf("timeout reported back\n"); - } -#endif - xs->error = XS_TIMEOUT; - break; - default: /* Other scsi protocol messes */ - xs->error = XS_DRIVER_STUFFUP; -#ifdef UTEST - if (bt_debug & BT_SHOWMISC) - { - printf("unexpected host_stat: %x\n", - ccb->host_stat); - } -#endif - } - - } - else - { - switch(ccb->target_stat) - { - case 0x02: - /* structure copy!!!!!*/ - *s2=*s1; - xs->error = XS_SENSE; - break; - case 0x08: - xs->error = XS_BUSY; - break; - default: -#ifdef UTEST - if (bt_debug & BT_SHOWMISC) - { - printf("unexpected target_stat: %x\n", - ccb->target_stat); - } -#endif - xs->error = XS_DRIVER_STUFFUP; - } - } - } - else /* All went correctly OR errors expected */ - { - xs->resid = 0; - } - xs->flags |= ITSDONE; - bt_free_ccb(unit,ccb, xs->flags); - if(xs->when_done) - (*(xs->when_done))(xs->done_arg,xs->done_arg2); -} - -/***********************************************\ -* Start the board, ready for normal operation * -\***********************************************/ -bt_init(unit) -int unit; -{ - unsigned char ad[4]; - volatile int i,sts; - struct bt_config conf; - - /***********************************************\ - * reset board, If it doesn't respond, assume * - * that it's not there.. good for the probe * - \***********************************************/ - - outb(BT_CTRL_STAT_PORT, BT_HRST|BT_SRST); - - for (i=0; i < BT_RESET_TIMEOUT; i++) - { - sts = inb(BT_CTRL_STAT_PORT) ; - if ( sts == (BT_IDLE | BT_INIT)) - break; - } - if (i >= BT_RESET_TIMEOUT) - { -#ifdef UTEST - if (bt_debug & BT_SHOWMISC) - printf("bt_init: No answer from bt742a board\n"); -#endif - return(ENXIO); - } - - /***********************************************\ - * Assume we have a board at this stage * - * setup dma channel from jumpers and save int * - * level * - \***********************************************/ -#ifdef __386BSD__ - printf("bt%d: reading board settings, ",unit); -#else __386BSD__ - printf("bt%d:",unit); -#endif __386BSD__ - - bt_cmd(unit,0, sizeof(conf), 0 ,&conf, BT_CONF_GET); - switch(conf.chan) - { - case EISADMA: - bt_dma[unit] = -1; - break; - case CHAN0: - outb(0x0b, 0x0c); - outb(0x0a, 0x00); - bt_dma[unit] = 0; - break; - case CHAN5: - outb(0xd6, 0xc1); - outb(0xd4, 0x01); - bt_dma[unit] = 5; - break; - case CHAN6: - outb(0xd6, 0xc2); - outb(0xd4, 0x02); - bt_dma[unit] = 6; - break; - case CHAN7: - outb(0xd6, 0xc3); - outb(0xd4, 0x03); - bt_dma[unit] = 7; - break; - default: - printf("illegal dma setting %x\n",conf.chan); - return(EIO); - } - if (bt_dma[unit] == -1) - printf("eisa dma, "); - else - printf("dma=%d, ",bt_dma[unit]); - - switch(conf.intr) - { - case INT9: - bt_int[unit] = 9; - break; - case INT10: - bt_int[unit] = 10; - break; - case INT11: - bt_int[unit] = 11; - break; - case INT12: - bt_int[unit] = 12; - break; - case INT14: - bt_int[unit] = 14; - break; - case INT15: - bt_int[unit] = 15; - break; - default: - printf("illegal int setting\n"); - return(EIO); - } -#ifdef __386BSD__ - printf("int=%d\n",bt_int[unit]); -#else - printf("int=%d ",bt_int[unit]); -#endif __386BSD__ - - /* who are we on the scsi bus */ - bt_scsi_dev[unit] = conf.scsi_dev; - /***********************************************\ - * Initialize mail box * - \***********************************************/ - *((physaddr *)ad) = KVTOPHYS(&bt_mbx[unit]); - bt_cmd(unit,5, 0, 0, 0, BT_MBX_INIT_EXTENDED - , BT_MBX_SIZE - , ad[0] - , ad[1] - , ad[2] - , ad[3]); - - /***********************************************\ - * Set Pointer chain null for just in case * - * Link the ccb's into a free-list W/O mbox * - * Initilize Mail Box stat to Free * - \***********************************************/ - if ( bt_ccb_free[unit] != (struct bt_ccb *)0 ) { - printf("bt%d: bt_ccb_free is NOT initialized but init here\n", - unit); - bt_ccb_free[unit] = (struct bt_ccb *)0; - } - for (i=0; i < BT_CCB_SIZE; i++) { - bt_ccb[unit][i].next = bt_ccb_free[unit]; - bt_ccb_free[unit] = &bt_ccb[unit][i]; - bt_ccb_free[unit]->flags = CCB_FREE; - } - for (i=0; i < BT_MBX_SIZE; i++) { - bt_mbx[unit].mbo[i].cmd = BT_MBO_FREE; - bt_mbx[unit].mbi[i].stat = BT_MBI_FREE; - } - - /***********************************************\ - * Set up Initial mail box for round-robin * - \***********************************************/ - bt_mbx[unit].tmbo = &bt_mbx[unit].mbo[0]; - bt_mbx[unit].tmbi = &bt_mbx[unit].mbi[0]; - bt_inquire_setup_information( unit ); - - /* Enable round-robin scheme - appeared at FirmWare 3.31 */ - bt_cmd(unit, 1, 0, 0, 0, BT_ROUND_ROBIN, BT_ENABLE ); - - /***********************************************\ - * Note that we are going and return (to probe) * - \***********************************************/ - bt_initialized[unit]++; - return( 0 ); -} -bt_inquire_setup_information( unit ) -int unit; -{ - struct bt_setup setup; - struct bt_boardID bID; - int i; - - /* Inquire Board ID to Bt742 for FirmWare Version */ - bt_cmd(unit, 0, sizeof(bID), 0, &bID, BT_INQUIRE ); - printf("bt%d: version %c.%c, ", - unit, bID.firm_revision, bID.firm_version ); - - /* Ask setup information to Bt742 */ - bt_cmd(unit, 1, sizeof(setup), 0, &setup, BT_SETUP_GET, sizeof(setup) ); - - if ( setup.sync_neg ) { - printf("sync, "); - } else { - printf("async, "); - } - - if ( setup.parity ) { - printf("parity, "); - } else { - printf("no parity, "); - } - - printf("%d mbxs, %d ccbs\n", setup.num_mbx, - sizeof(bt_ccb)/(sizeof(struct bt_ccb) * NBT) ); - - for ( i = 0; i < 8; i++ ) { - if( !setup.sync[i].offset && - !setup.sync[i].period && - !setup.sync[i].valid ) - continue; - - printf("bt%d: dev%02d Offset=%d,Transfer period=%d, Synchronous? %s", - unit, i, - setup.sync[i].offset, setup.sync[i].period, - setup.sync[i].valid ? "Yes" : "No" ); - } - -} - - -#ifndef min -#define min(x,y) (x < y ? x : y) -#endif min - - -void btminphys(bp) -struct buf *bp; -{ -#ifdef MACH -#if !defined(OSF) - bp->b_flags |= B_NPAGES; /* can support scat/gather */ -#endif /* defined(OSF) */ -#endif MACH - if(bp->b_bcount > ((BT_NSEG-1) * PAGESIZ)) - { - bp->b_bcount = ((BT_NSEG-1) * PAGESIZ); - } -} - -/***********************************************\ -* start a scsi operation given the command and * -* the data address. Also needs the unit, target * -* and lu * -\***********************************************/ -int bt_scsi_cmd(xs) -struct scsi_xfer *xs; -{ - struct scsi_sense_data *s1,*s2; - struct bt_ccb *ccb; - struct bt_scat_gath *sg; - int seg; /* scatter gather seg being worked on */ - int i = 0; - int rc = 0; - int thiskv; - physaddr thisphys,nextphys; - int unit =xs->adapter; - int bytes_this_seg,bytes_this_page,datalen,flags; - struct iovec *iovp; - BT_MBO *mbo; - -#ifdef UTEST - if(scsi_debug & PRINTROUTINES) - printf("bt_scsi_cmd "); -#endif - /***********************************************\ - * get a ccb (mbox-out) to use. If the transfer * - * is from a buf (possibly from interrupt time) * - * then we can't allow it to sleep * - \***********************************************/ - flags = xs->flags; - if(xs->bp) flags |= (SCSI_NOSLEEP); /* just to be sure */ - if(flags & ITSDONE) - { - printf("bt%d: Already done?\n",unit); - xs->flags &= ~ITSDONE; - } - if(!(flags & INUSE)) - { - printf("bt%d: Not in use?\n",unit); - xs->flags |= INUSE; - } - if (!(ccb = bt_get_ccb(unit,flags))) - { - xs->error = XS_DRIVER_STUFFUP; - return(TRY_AGAIN_LATER); - } -#ifdef UTEST - if(bt_debug & BT_SHOWCCBS) - printf("",ccb); -#endif - /***********************************************\ - * Put all the arguments for the xfer in the ccb * - \***********************************************/ - ccb->xfer = xs; - if(flags & SCSI_RESET) - { - ccb->opcode = BT_RESET_CCB; - } - else - { - /* can't use S/G if zero length */ - ccb->opcode = (xs->datalen? - BT_INIT_SCAT_GATH_CCB - :BT_INITIATOR_CCB); - } - ccb->target = xs->targ;; - ccb->data_out = 0; - ccb->data_in = 0; - ccb->lun = xs->lu; - ccb->scsi_cmd_length = xs->cmdlen; - ccb->sense_ptr = KVTOPHYS(&(ccb->scsi_sense)); - ccb->req_sense_length = sizeof(ccb->scsi_sense); - - if((xs->datalen) && (!(flags & SCSI_RESET))) - { /* can use S/G only if not zero length */ - ccb->data_addr = KVTOPHYS(ccb->scat_gath); - sg = ccb->scat_gath ; - seg = 0; - if(flags & SCSI_DATA_UIO) - { - iovp = ((struct uio *)xs->data)->uio_iov; - datalen = ((struct uio *)xs->data)->uio_iovcnt; - xs->datalen = 0; - while ((datalen) && (seg < BT_NSEG)) - { - sg->seg_addr = (physaddr)iovp->iov_base; - xs->datalen += sg->seg_len = iovp->iov_len; -#ifdef UTEST - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x@0x%x)" - ,iovp->iov_len - ,iovp->iov_base); -#endif - sg++; - iovp++; - seg++; - datalen--; - } - } - else - { - /***********************************************\ - * Set up the scatter gather block * - \***********************************************/ - -#ifdef UTEST - if(scsi_debug & SHOWSCATGATH) - printf("%d @0x%x:- ",xs->datalen,xs->data); -#endif - datalen = xs->datalen; - thiskv = (int)xs->data; - thisphys = KVTOPHYS(thiskv); - - while ((datalen) && (seg < BT_NSEG)) - { - bytes_this_seg = 0; - - /* put in the base address */ - sg->seg_addr = thisphys; - -#ifdef UTEST - if(scsi_debug & SHOWSCATGATH) - printf("0x%x",thisphys); -#endif - - /* do it at least once */ - nextphys = thisphys; - while ((datalen) && (thisphys == nextphys)) - /*********************************************\ - * This page is contiguous (physically) with * - * the the last, just extend the length * - \*********************************************/ - { - /* how far to the end of the page */ - nextphys= (thisphys & (~(PAGESIZ - 1))) - + PAGESIZ; - bytes_this_page = nextphys - thisphys; - /**** or the data ****/ - bytes_this_page = min(bytes_this_page - ,datalen); - bytes_this_seg += bytes_this_page; - datalen -= bytes_this_page; - - /* get more ready for the next page */ - thiskv = (thiskv & (~(PAGESIZ - 1))) - + PAGESIZ; - if(datalen) - thisphys = KVTOPHYS(thiskv); - } - /********************************************\ - * next page isn't contiguous, finish the seg * - \********************************************/ -#ifdef UTEST - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x)",bytes_this_seg); -#endif - sg->seg_len = bytes_this_seg; - sg++; - seg++; - } - } /*end of iov/kv decision */ - ccb->data_length = seg * sizeof(struct bt_scat_gath); -#ifdef UTEST - if(scsi_debug & SHOWSCATGATH) - printf("\n"); -#endif - if (datalen) - { /* there's still data, must have run out of segs! */ - printf("bt%d: bt_scsi_cmd, more than %d DMA segs\n", - unit,BT_NSEG); - xs->error = XS_DRIVER_STUFFUP; - bt_free_ccb(unit,ccb,flags); - return(HAD_ERROR); - } - - } - else - { /* No data xfer, use non S/G values */ - ccb->data_addr = (physaddr)0; - ccb->data_length = 0; - } - ccb->link_id = 0; - ccb->link_addr = (physaddr)0; - /***********************************************\ - * Put the scsi command in the ccb and start it * - \***********************************************/ - if(!(flags & SCSI_RESET)) - { - bcopy(xs->cmd, ccb->scsi_cmd, ccb->scsi_cmd_length); - } -#ifdef UTEST - if(scsi_debug & SHOWCOMMANDS) - { - u_char *b = ccb->scsi_cmd; - if(!(flags & SCSI_RESET)) - { - int i = 0; - printf("bt%d:%d:%d-" - ,unit - ,ccb->target - ,ccb->lun); - while(i < ccb->scsi_cmd_length ) - { - if(i) printf(","); - printf("%x",b[i++]); - } - printf("-\n"); - } - else - { - printf("bt%d:%d:%d-RESET- " - ,unit - ,ccb->target - ,ccb->lun - ); - } - } -#endif - if ( bt_send_mbo( unit, flags, BT_MBO_START, ccb ) == (BT_MBO *)0 ) - { - xs->error = XS_DRIVER_STUFFUP; - bt_free_ccb(unit,ccb,flags); - return(TRY_AGAIN_LATER); - } - /***********************************************\ - * Usually return SUCCESSFULLY QUEUED * - \***********************************************/ -#ifdef UTEST - if(scsi_debug & TRACEINTERRUPTS) - printf("cmd_sent "); -#endif - if (!(flags & SCSI_NOMASK)) - { - timeout(bt_timeout,ccb,(xs->timeout * hz) / 1000); - return(SUCCESSFULLY_QUEUED); - } else - /***********************************************\ - * If we can't use interrupts, poll on completion* - \***********************************************/ - { - int done = 0; - int count = delaycount * xs->timeout / BT_SCSI_TIMEOUT_FUDGE; - struct bt_mbx *wmbx = &bt_mbx[unit]; - BT_MBI *wmbi = wmbx->tmbi; - unsigned char stat; -#ifdef UTEST - if(scsi_debug & TRACEINTERRUPTS) - printf("wait "); -#endif - while((!done) && count) - { - stat = inb(BT_INTR_PORT) & (BT_ANY_INTR | BT_MBIF ); - if ( !( stat & BT_ANY_INTR ) || - ( wmbi->stat == BT_MBI_FREE )|| - (PHYSTOKV(wmbi->ccb_addr) - != (int)ccb ) ) { - count--; - continue; - } - wmbi->stat = BT_MBI_FREE; - bt_done(unit,ccb); - done ++; - outb(BT_CTRL_STAT_PORT, BT_IRST); - /* Set the IN mail Box pointer for next */ - bt_nextmbx( wmbi, wmbx, mbi ); - wmbx->tmbi = wmbi; - } - if (!count && !done) - { -#ifdef UTEST - if (!(xs->flags & SCSI_SILENT)) - printf("cmd fail\n"); -#endif - bt_send_mbo( unit, flags, BT_MBO_ABORT, ccb ); - count = delaycount * 2000 / BT_SCSI_TIMEOUT_FUDGE; - while((!done) && count) - { - if ( !( stat & BT_ANY_INTR ) || - ( wmbi->stat == BT_MBI_FREE )|| - ( PHYSTOKV(wmbi->ccb_addr ) - != (int)ccb ) ) { - count--; - continue; - } - wmbi->stat = BT_MBI_FREE; - bt_done(unit,ccb); - done ++; - outb(BT_CTRL_STAT_PORT, BT_IRST); - /* Set the IN mail Box pointer for next */ - bt_nextmbx( wmbi, wmbx, mbi ); - wmbx->tmbi = wmbi; - } - if(!count && !done) - { - printf("bt%d: abort failed in wait\n", unit); - ccb->mbx->cmd = BT_MBO_FREE; - } - bt_free_ccb(unit,ccb,flags); - xs->error = XS_DRIVER_STUFFUP; - return(HAD_ERROR); - } - if(xs->error) return(HAD_ERROR); - return(COMPLETE); - } -} - - -bt_timeout(struct bt_ccb *ccb) -{ - int unit; - int s = splbio(); - - unit = ccb->xfer->adapter; - printf("bt%d: %d device timed out\n",unit - ,ccb->xfer->targ); -#ifdef UTEST - if(bt_debug & BT_SHOWCCBS) - bt_print_active_ccbs(unit); -#endif - - /***************************************\ - * If The ccb's mbx is not free, then * - * the board has gone Far East ? * - \***************************************/ - if((struct bt_ccb *)PHYSTOKV(ccb->mbx->ccb_addr)==ccb && - ccb->mbx->cmd != BT_MBO_FREE ) - { - printf("bt%d: not taking commands!\n" - ,unit); - Debugger(); - } - /***************************************\ - * If it has been through before, then * - * a previous abort has failed, don't * - * try abort again * - \***************************************/ - if(ccb->flags == CCB_ABORTED) /* abort timed out */ - { - printf("bt%d: Abort Operation has timed out\n",unit); - ccb->xfer->retries = 0; /* I MEAN IT ! */ - ccb->host_stat = BT_ABORTED; - bt_done(unit,ccb); - } - else /* abort the operation that has timed out */ - { - printf("bt%d: Try to abort\n",unit); - bt_send_mbo( unit, ~SCSI_NOMASK, - BT_MBO_ABORT, ccb ); - /* 2 secs for the abort */ - timeout(bt_timeout,ccb,2 * hz); - ccb->flags = CCB_ABORTED; - } - splx(s); -} - -#ifdef UTEST -bt_print_ccb(ccb) -struct bt_ccb *ccb; -{ - printf("ccb:%x op:%x cmdlen:%d senlen:%d\n" - ,ccb - ,ccb->opcode - ,ccb->scsi_cmd_length - ,ccb->req_sense_length); - printf(" datlen:%d hstat:%x tstat:%x flags:%x\n" - ,ccb->data_length - ,ccb->host_stat - ,ccb->target_stat - ,ccb->flags); -} - -bt_print_active_ccbs(int unit) -{ - struct bt_ccb *ccb; - ccb = &(bt_ccb[unit][0]); - int i = BT_CCB_SIZE; - - while(i--) - { - if(ccb->flags != CCB_FREE) - bt_print_ccb(ccb); - ccb++; - } -} -#endif /*UTEST*/ diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c deleted file mode 100644 index 53497c8..0000000 --- a/sys/i386/isa/clock.c +++ /dev/null @@ -1,252 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz and Don Ahn. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id$ - */ - -/* - * Primitive clock interrupt routines. - */ -#include "param.h" -#include "systm.h" -#include "time.h" -#include "kernel.h" -#include "machine/segments.h" -#include "i386/isa/icu.h" -#include "i386/isa/isa.h" -#include "i386/isa/rtc.h" -#include "i386/isa/timerreg.h" - -#define DAYST 119 -#define DAYEN 303 - -/* X-tals being what they are, it's nice to be able to fudge this one... */ -/* Note, the name changed here from XTALSPEED to TIMER_FREQ rgrimes 4/26/93 */ -#ifndef TIMER_FREQ -#define TIMER_FREQ 1193182 /* XXX - should be in isa.h */ -#endif - -startrtclock() { - int s; - - findcpuspeed(); /* use the clock (while it's free) - to find the cpu speed */ - /* initialize 8253 clock */ - outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT); - - /* Correct rounding will buy us a better precision in timekeeping */ - outb (IO_TIMER1, (TIMER_FREQ+hz/2)/hz); - outb (IO_TIMER1, ((TIMER_FREQ+hz/2)/hz)/256); - - /* initialize brain-dead battery powered clock */ - outb (IO_RTC, RTC_STATUSA); - outb (IO_RTC+1, 0x26); - outb (IO_RTC, RTC_STATUSB); - outb (IO_RTC+1, 2); - - outb (IO_RTC, RTC_DIAG); - if (s = inb (IO_RTC+1)) - printf("RTC BIOS diagnostic error %b\n", s, RTCDG_BITS); - outb (IO_RTC, RTC_DIAG); - outb (IO_RTC+1, 0); -} - -unsigned int delaycount; /* calibrated loop variable (1 millisecond) */ - -#define FIRST_GUESS 0x2000 -findcpuspeed() -{ - unsigned char low; - unsigned int remainder; - - /* Put counter in count down mode */ - outb(IO_TIMER1+3, 0x34); - outb(IO_TIMER1, 0xff); - outb(IO_TIMER1, 0xff); - delaycount = FIRST_GUESS; - spinwait(1); - /* Read the value left in the counter */ - low = inb(IO_TIMER1); /* least siginifcant */ - remainder = inb(IO_TIMER1); /* most significant */ - remainder = (remainder<<8) + low ; - /* Formula for delaycount is : - * (loopcount * timer clock speed)/ (counter ticks * 1000) - */ - delaycount = (FIRST_GUESS * (TIMER_FREQ/1000)) / (0xffff-remainder); -} - - -/* convert 2 digit BCD number */ -bcd(i) -int i; -{ - return ((i/16)*10 + (i%16)); -} - -/* convert years to seconds (from 1970) */ -unsigned long -ytos(y) -int y; -{ - int i; - unsigned long ret; - - ret = 0; - for(i = 1970; i < y; i++) { - if (i % 4) ret += 365*24*60*60; - else ret += 366*24*60*60; - } - return ret; -} - -/* convert months to seconds */ -unsigned long -mtos(m,leap) -int m,leap; -{ - int i; - unsigned long ret; - - ret = 0; - for(i=1;i= DAYST) && ( yd <= DAYEN)) { - sec -= 60*60; - } - sec += tz.tz_minuteswest * 60; - - time.tv_sec = sec; -} - -#ifdef garbage -/* - * Initialze the time of day register, based on the time base which is, e.g. - * from a filesystem. - */ -test_inittodr(base) - time_t base; -{ - - outb(IO_RTC,9); /* year */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,8); /* month */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,7); /* day */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,4); /* hour */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,2); /* minutes */ - printf("%d ",bcd(inb(IO_RTC+1))); - outb(IO_RTC,0); /* seconds */ - printf("%d\n",bcd(inb(IO_RTC+1))); - - time.tv_sec = base; -} -#endif - -/* - * Restart the clock. - */ -resettodr() -{ -} - -/* - * Wire clock interrupt in. - */ -#define V(s) __CONCAT(V, s) -extern V(clk)(); -enablertclock() { - setidt(ICU_OFFSET+0, &V(clk), SDT_SYS386IGT, SEL_KPL); - INTREN(IRQ0); -} - -/* - * Delay for some number of milliseconds. - */ -void -spinwait(millisecs) - int millisecs; -{ - DELAY(1000 * millisecs); -} diff --git a/sys/i386/isa/fd.c b/sys/i386/isa/fd.c deleted file mode 100644 index c287ef1..0000000 --- a/sys/i386/isa/fd.c +++ /dev/null @@ -1,977 +0,0 @@ -/*#define DEBUG 1*/ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Don Ahn. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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: @(#)fd.c 7.4 (Berkeley) 5/25/91 - * $Id: fd.c,v 1.5 1993/09/15 23:27:45 rgrimes Exp $ - * - */ - -#include "fd.h" -#if NFD > 0 - -#include "param.h" -#include "dkbad.h" -#include "systm.h" -#include "conf.h" -#include "file.h" -#include "ioctl.h" -#include "disklabel.h" -#include "buf.h" -#include "uio.h" -#include "syslog.h" -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/fdreg.h" -#include "i386/isa/icu.h" -#include "i386/isa/rtc.h" -#undef NFD -#define NFD 2 - -#define FDUNIT(s) ((s>>3)&1) -#define FDTYPE(s) ((s)&7) - -#define b_cylin b_resid -#define FDBLK 512 -#define NUMTYPES 4 - -struct fd_type { - int sectrac; /* sectors per track */ - int secsize; /* size code for sectors */ - int datalen; /* data len when secsize = 0 */ - int gap; /* gap len between sectors */ - int tracks; /* total num of tracks */ - int size; /* size of disk in sectors */ - int steptrac; /* steps per cylinder */ - int trans; /* transfer speed code */ - int heads; /* number of heads */ -}; - -struct fd_type fd_types[NUMTYPES] = -{ - { 18,2,0xFF,0x1B,80,2880,1,0,2 }, /* 1.44 meg HD 3.5in floppy */ - { 15,2,0xFF,0x1B,80,2400,1,0,2 }, /* 1.2 meg HD floppy */ - { 9,2,0xFF,0x23,40,720,2,1,2 }, /* 360k floppy in 1.2meg drive */ - { 9,2,0xFF,0x2A,40,720,1,1,2 }, /* 360k floppy in DD drive */ -}; - -#define DRVS_PER_CTLR 2 -/***********************************************************************\ -* Per controller structure. * -\***********************************************************************/ -struct fdc_data -{ - int fdcu; /* our unit number */ - int baseport; - int dmachan; - int flags; -#define FDC_ATTACHED 0x01 - struct fd_data *fd; - int fdu; /* the active drive */ - struct buf head; /* Head of buf chain */ - struct buf rhead; /* Raw head of buf chain */ - int state; - int retry; - int status[7]; /* copy of the registers */ -}fdc_data[(NFD+1)/DRVS_PER_CTLR]; - -/***********************************************************************\ -* Per drive structure. * -* N per controller (presently 2) (DRVS_PER_CTLR) * -\***********************************************************************/ -struct fd_data { - struct fdc_data *fdc; - int fdu; /* this unit number */ - int fdsu; /* this units number on this controller */ - int type; /* Drive type (HD, DD */ - struct fd_type *ft; /* pointer to the type descriptor */ - int flags; -#define FD_OPEN 0x01 /* it's open */ -#define FD_ACTIVE 0x02 /* it's active */ -#define FD_MOTOR 0x04 /* motor should be on */ -#define FD_MOTOR_WAIT 0x08 /* motor coming up */ - int skip; - int hddrv; - int track; /* where we think the head is */ -} fd_data[NFD]; - -/***********************************************************************\ -* Throughout this file the following conventions will be used: * -* fd is a pointer to the fd_data struct for the drive in question * -* fdc is a pointer to the fdc_data struct for the controller * -* fdu is the floppy drive unit number * -* fdcu is the floppy controller unit number * -* fdsu is the floppy drive unit number on that controller. (sub-unit) * -\***********************************************************************/ -typedef int fdu_t; -typedef int fdcu_t; -typedef int fdsu_t; -typedef struct fd_data *fd_p; -typedef struct fdc_data *fdc_p; - -#define DEVIDLE 0 -#define FINDWORK 1 -#define DOSEEK 2 -#define SEEKCOMPLETE 3 -#define IOCOMPLETE 4 -#define RECALCOMPLETE 5 -#define STARTRECAL 6 -#define RESETCTLR 7 -#define SEEKWAIT 8 -#define RECALWAIT 9 -#define MOTORWAIT 10 -#define IOTIMEDOUT 11 - -#ifdef DEBUG -char *fdstates[] = -{ -"DEVIDLE", -"FINDWORK", -"DOSEEK", -"SEEKCOMPLETE", -"IOCOMPLETE", -"RECALCOMPLETE", -"STARTRECAL", -"RESETCTLR", -"SEEKWAIT", -"RECALWAIT", -"MOTORWAIT", -"IOTIMEDOUT" -}; - - -int fd_debug = 1; -#define TRACE0(arg) if(fd_debug) printf(arg) -#define TRACE1(arg1,arg2) if(fd_debug) printf(arg1,arg2) -#else DEBUG -#define TRACE0(arg) -#define TRACE1(arg1,arg2) -#endif DEBUG - -extern int hz; -/* state needed for current transfer */ - -/****************************************************************************/ -/* autoconfiguration stuff */ -/****************************************************************************/ -int fdprobe(), fdattach(), fd_turnoff(); - -struct isa_driver fddriver = { - fdprobe, fdattach, "fd", -}; - -/* - * probe for existance of controller - */ -fdprobe(dev) -struct isa_device *dev; -{ - fdcu_t fdcu = dev->id_unit; - if(fdc_data[fdcu].flags & FDC_ATTACHED) - { - printf("fdc: same unit (%d) used multiple times\n",fdcu); - return 0; - } - - fdc_data[fdcu].baseport = dev->id_iobase; - - /* see if it can handle a command */ - if (out_fdc(fdcu,NE7CMD_SPECIFY) < 0) - { - return(0); - } - out_fdc(fdcu,0xDF); - out_fdc(fdcu,2); - return (IO_FDCSIZE); -} - -/* - * wire controller into system, look for floppy units - */ -fdattach(dev) -struct isa_device *dev; -{ - unsigned fdt,st0, cyl; - int hdr; - fdu_t fdu; - fdcu_t fdcu = dev->id_unit; - fdc_p fdc = fdc_data + fdcu; - fd_p fd; - int fdsu; - - fdc->fdcu = fdcu; - fdc->flags |= FDC_ATTACHED; - fdc->dmachan = dev->id_drq; - fdc->state = DEVIDLE; - - fdt = rtcin(RTC_FDISKETTE); - hdr = 0; - - /* check for each floppy drive */ - for (fdu = (fdcu * DRVS_PER_CTLR),fdsu = 0; - ((fdu < NFD) && (fdsu < DRVS_PER_CTLR)); - fdu++,fdsu++) - { - /* is there a unit? */ - if ((fdt & 0xf0) == RTCFDT_NONE) { -#define NO_TYPE NUMTYPES - fd_data[fdu].type = NO_TYPE; - continue; - } - -#ifdef notyet - /* select it */ - fd_turnon1(fdu); - spinwait(1000); /* 1 sec */ - out_fdc(fdcu,NE7CMD_RECAL); /* Recalibrate Function */ - out_fdc(fdcu,fdsu); - spinwait(1000); /* 1 sec */ - - /* anything responding */ - out_fdc(fdcu,NE7CMD_SENSEI); - st0 = in_fdc(fdcu); - cyl = in_fdc(fdcu); - if (st0 & 0xd0) - continue; - -#endif - fd_data[fdu].track = -2; - fd_data[fdu].fdc = fdc; - fd_data[fdu].fdsu = fdsu; - printf("fd%d: unit %d type ", fdcu, fdu); - - if ((fdt & 0xf0) == RTCFDT_12M) { - printf("1.2MB 5.25in\n"); - fd_data[fdu].type = 1; - fd_data[fdu].ft = fd_types + 1; - - } - if ((fdt & 0xf0) == RTCFDT_144M) { - printf("1.44MB 3.5in\n"); - fd_data[fdu].type = 0; - fd_data[fdu].ft = fd_types + 0; - } - - fdt <<= 4; - fd_turnoff(fdu); - hdr = 1; - } - - /* Set transfer to 500kbps */ - outb(fdc->baseport+fdctl,0); /*XXX*/ -} - -int -fdsize(dev) -dev_t dev; -{ - return(0); -} - -/****************************************************************************/ -/* fdstrategy */ -/****************************************************************************/ -fdstrategy(bp) - register struct buf *bp; /* IO operation to perform */ -{ - register struct buf *dp,*dp0,*dp1; - long nblocks,blknum; - int s; - fdcu_t fdcu; - fdu_t fdu; - fdc_p fdc; - fd_p fd; - - fdu = FDUNIT(minor(bp->b_dev)); - fd = &fd_data[fdu]; - fdc = fd->fdc; - fdcu = fdc->fdcu; - /*type = FDTYPE(minor(bp->b_dev));*/ - - if ((fdu >= NFD) || (bp->b_blkno < 0)) { - printf("fdstrat: fdu = %d, blkno = %d, bcount = %d\n", - fdu, bp->b_blkno, bp->b_bcount); - pg("fd:error in fdstrategy"); - bp->b_error = EINVAL; - bp->b_flags |= B_ERROR; - goto bad; - } - /* - * Set up block calculations. - */ - blknum = (unsigned long) bp->b_blkno * DEV_BSIZE/FDBLK; - nblocks = fd->ft->size; - if (blknum + (bp->b_bcount / FDBLK) > nblocks) { - if (blknum == nblocks) { - bp->b_resid = bp->b_bcount; - } else { - bp->b_error = ENOSPC; - bp->b_flags |= B_ERROR; - } - goto bad; - } - bp->b_cylin = blknum / (fd->ft->sectrac * fd->ft->heads); - dp = &(fdc->head); - s = splbio(); - disksort(dp, bp); - untimeout(fd_turnoff,fdu); /* a good idea */ - fdstart(fdcu); - splx(s); - return; - -bad: - biodone(bp); -} - -/****************************************************************************/ -/* motor control stuff */ -/* remember to not deselect the drive we're working on */ -/****************************************************************************/ -set_motor(fdcu, fdu, reset) - fdcu_t fdcu; - fdu_t fdu; - int reset; -{ - int m0,m1; - int selunit; - fd_p fd; - if(fd = fdc_data[fdcu].fd)/* yes an assign! */ - { - selunit = fd->fdsu; - } - else - { - selunit = 0; - } - m0 = fd_data[fdcu * DRVS_PER_CTLR + 0].flags & FD_MOTOR; - m1 = fd_data[fdcu * DRVS_PER_CTLR + 1].flags & FD_MOTOR; - outb(fdc_data[fdcu].baseport+fdout, - selunit - | (reset ? 0 : (FDO_FRST|FDO_FDMAEN)) - | (m0 ? FDO_MOEN0 : 0) - | (m1 ? FDO_MOEN1 : 0)); - TRACE1("[0x%x->fdout]",( - selunit - | (reset ? 0 : (FDO_FRST|FDO_FDMAEN)) - | (m0 ? FDO_MOEN0 : 0) - | (m1 ? FDO_MOEN1 : 0))); -} - -fd_turnoff(fdu) - fdu_t fdu; -{ - int s; - - fd_p fd = fd_data + fdu; - s = splbio(); - fd->flags &= ~FD_MOTOR; - set_motor(fd->fdc->fdcu,fd->fdsu,0); - splx(s); -} - -fd_motor_on(fdu) - fdu_t fdu; -{ - int s; - - fd_p fd = fd_data + fdu; - s = splbio(); - fd->flags &= ~FD_MOTOR_WAIT; - if((fd->fdc->fd == fd) && (fd->fdc->state == MOTORWAIT)) - { - fdintr(fd->fdc->fdcu); - } - splx(s); -} - -fd_turnon(fdu) - fdu_t fdu; -{ - fd_p fd = fd_data + fdu; - if(!(fd->flags & FD_MOTOR)) - { - fd_turnon1(fdu); - fd->flags |= FD_MOTOR_WAIT; - timeout(fd_motor_on,fdu,hz); /* in 1 sec its ok */ - } -} - -fd_turnon1(fdu) - fdu_t fdu; -{ - fd_p fd = fd_data + fdu; - fd->flags |= FD_MOTOR; - set_motor(fd->fdc->fdcu,fd->fdsu,0); -} - -/****************************************************************************/ -/* fdc in/out */ -/****************************************************************************/ -int -in_fdc(fdcu) - fdcu_t fdcu; -{ - int baseport = fdc_data[fdcu].baseport; - int i, j = 100000; - while ((i = inb(baseport+fdsts) & (NE7_DIO|NE7_RQM)) - != (NE7_DIO|NE7_RQM) && j-- > 0) - if (i == NE7_RQM) return -1; - if (j <= 0) - return(-1); -#ifdef DEBUG - i = inb(baseport+fddata); - TRACE1("[fddata->0x%x]",(unsigned char)i); - return(i); -#else - return inb(baseport+fddata); -#endif -} - -out_fdc(fdcu, x) - fdcu_t fdcu; - int x; -{ - int baseport = fdc_data[fdcu].baseport; - int i; - - /* Check that the direction bit is set */ - i = 100000; - while ((inb(baseport+fdsts) & NE7_DIO) && i-- > 0); - if (i <= 0) return (-1); /* Floppy timed out */ - - /* Check that the floppy controller is ready for a command */ - i = 100000; - while ((inb(baseport+fdsts) & NE7_RQM) == 0 && i-- > 0); - if (i <= 0) return (-1); /* Floppy timed out */ - - /* Send the command and return */ - outb(baseport+fddata,x); - TRACE1("[0x%x->fddata]",x); - return (0); -} - -/****************************************************************************/ -/* fdopen/fdclose */ -/****************************************************************************/ -Fdopen(dev, flags) - dev_t dev; - int flags; -{ - fdu_t fdu = FDUNIT(minor(dev)); - /*int type = FDTYPE(minor(dev));*/ - int s; - - /* check bounds */ - if (fdu >= NFD || fd_data[fdu].type == NO_TYPE) return(ENXIO); - /*if (type >= NUMTYPES) return(ENXIO);*/ - fd_data[fdu].flags |= FD_OPEN; - - return 0; -} - -fdclose(dev, flags) - dev_t dev; -{ - fdu_t fdu = FDUNIT(minor(dev)); - fd_data[fdu].flags &= ~FD_OPEN; - return(0); -} - - -/***************************************************************\ -* fdstart * -* We have just queued something.. if the controller is not busy * -* then simulate the case where it has just finished a command * -* So that it (the interrupt routine) looks on the queue for more* -* work to do and picks up what we just added. * -* If the controller is already busy, we need do nothing, as it * -* will pick up our work when the present work completes * -\***************************************************************/ -fdstart(fdcu) - fdcu_t fdcu; -{ - register struct buf *dp,*bp; - int s; - fdu_t fdu; - - s = splbio(); - if(fdc_data[fdcu].state == DEVIDLE) - { - fdintr(fdcu); - } - splx(s); -} - -fd_timeout(fdcu) - fdcu_t fdcu; -{ - fdu_t fdu = fdc_data[fdcu].fdu; - int st0, st3, cyl; - struct buf *dp,*bp; - int s; - - dp = &fdc_data[fdcu].head; - s = splbio(); - bp = dp->b_actf; - - out_fdc(fdcu,NE7CMD_SENSED); - out_fdc(fdcu,fd_data[fdu].hddrv); - st3 = in_fdc(fdcu); - - out_fdc(fdcu,NE7CMD_SENSEI); - st0 = in_fdc(fdcu); - cyl = in_fdc(fdcu); - printf("fd%d: Operation timeout ST0 %b cyl %d ST3 %b\n", - fdu, - st0, - NE7_ST0BITS, - cyl, - st3, - NE7_ST3BITS); - - if (bp) - { - retrier(fdcu); - fdc_data[fdcu].status[0] = 0xc0; - fdc_data[fdcu].state = IOTIMEDOUT; - if( fdc_data[fdcu].retry < 6) - fdc_data[fdcu].retry = 6; - } - else - { - fdc_data[fdcu].fd = (fd_p) 0; - fdc_data[fdcu].fdu = -1; - fdc_data[fdcu].state = DEVIDLE; - } - fdintr(fdcu); - splx(s); -} - -/* just ensure it has the right spl */ -fd_pseudointr(fdcu) - fdcu_t fdcu; -{ - int s; - s = splbio(); - fdintr(fdcu); - splx(s); -} - -/***********************************************************************\ -* fdintr * -* keep calling the state machine until it returns a 0 * -* ALWAYS called at SPLBIO * -\***********************************************************************/ -fdintr(fdcu) - fdcu_t fdcu; -{ - fdc_p fdc = fdc_data + fdcu; - while(fdstate(fdcu, fdc)); -} - -/***********************************************************************\ -* The controller state machine. * -* if it returns a non zero value, it should be called again immediatly * -\***********************************************************************/ -int fdstate(fdcu, fdc) - fdcu_t fdcu; - fdc_p fdc; -{ - int read,head,trac,sec,i,s,sectrac,cyl,st0; - unsigned long blknum; - fdu_t fdu = fdc->fdu; - fd_p fd; - register struct buf *dp,*bp; - - dp = &(fdc->head); - bp = dp->b_actf; - if(!bp) - { - /***********************************************\ - * nothing left for this controller to do * - * Force into the IDLE state, * - \***********************************************/ - fdc->state = DEVIDLE; - if(fdc->fd) - { - printf("unexpected valid fd pointer (fdu = %d)\n" - ,fdc->fdu); - fdc->fd = (fd_p) 0; - fdc->fdu = -1; - } - TRACE1("[fdc%d IDLE]",fdcu); - return(0); - } - fdu = FDUNIT(minor(bp->b_dev)); - fd = fd_data + fdu; - if (fdc->fd && (fd != fdc->fd)) - { - printf("confused fd pointers\n"); - } - read = bp->b_flags & B_READ; - TRACE1("fd%d",fdu); - TRACE1("[%s]",fdstates[fdc->state]); - TRACE1("(0x%x)",fd->flags); - untimeout(fd_turnoff, fdu); - timeout(fd_turnoff,fdu,4 * hz); - switch (fdc->state) - { - case DEVIDLE: - case FINDWORK: /* we have found new work */ - fdc->retry = 0; - fd->skip = 0; - fdc->fd = fd; - fdc->fdu = fdu; - /*******************************************************\ - * If the next drive has a motor startup pending, then * - * it will start up in it's own good time * - \*******************************************************/ - if(fd->flags & FD_MOTOR_WAIT) - { - fdc->state = MOTORWAIT; - return(0); /* come back later */ - } - /*******************************************************\ - * Maybe if it's not starting, it SHOULD be starting * - \*******************************************************/ - if (!(fd->flags & FD_MOTOR)) - { - fdc->state = MOTORWAIT; - fd_turnon(fdu); - return(0); - } - else /* at least make sure we are selected */ - { - set_motor(fdcu,fd->fdsu,0); - } - fdc->state = DOSEEK; - break; - case DOSEEK: - if (bp->b_cylin == fd->track) - { - fdc->state = SEEKCOMPLETE; - break; - } - out_fdc(fdcu,NE7CMD_SEEK); /* Seek function */ - out_fdc(fdcu,fd->fdsu); /* Drive number */ - out_fdc(fdcu,bp->b_cylin * fd->ft->steptrac); - fd->track = -2; - fdc->state = SEEKWAIT; - timeout(fd_timeout,fdcu,2 * hz); - return(0); /* will return later */ - case SEEKWAIT: - untimeout(fd_timeout,fdcu); - /* allow heads to settle */ - timeout(fd_pseudointr,fdcu,hz/50); - fdc->state = SEEKCOMPLETE; - return(0); /* will return later */ - break; - - case SEEKCOMPLETE : /* SEEK DONE, START DMA */ - /* Make sure seek really happened*/ - if(fd->track == -2) - { - int descyl = bp->b_cylin * fd->ft->steptrac; - out_fdc(fdcu,NE7CMD_SENSEI); - i = in_fdc(fdcu); - cyl = in_fdc(fdcu); - if (cyl != descyl) - { - printf("fd%d: Seek to cyl %d failed; am at cyl %d (ST0 = 0x%x)\n", fdu, - descyl, cyl, i, NE7_ST0BITS); - return(retrier(fdcu)); - } - } - - fd->track = bp->b_cylin; - isa_dmastart(bp->b_flags, bp->b_un.b_addr+fd->skip, - FDBLK, fdc->dmachan); - blknum = (unsigned long)bp->b_blkno*DEV_BSIZE/FDBLK - + fd->skip/FDBLK; - sectrac = fd->ft->sectrac; - sec = blknum % (sectrac * fd->ft->heads); - head = sec / sectrac; - sec = sec % sectrac + 1; -/*XXX*/ fd->hddrv = ((head&1)<<2)+fdu; - - if (read) - { - out_fdc(fdcu,NE7CMD_READ); /* READ */ - } - else - { - out_fdc(fdcu,NE7CMD_WRITE); /* WRITE */ - } - out_fdc(fdcu,head << 2 | fdu); /* head & unit */ - out_fdc(fdcu,fd->track); /* track */ - out_fdc(fdcu,head); - out_fdc(fdcu,sec); /* sector XXX +1? */ - out_fdc(fdcu,fd->ft->secsize); /* sector size */ - out_fdc(fdcu,sectrac); /* sectors/track */ - out_fdc(fdcu,fd->ft->gap); /* gap size */ - out_fdc(fdcu,fd->ft->datalen); /* data length */ - fdc->state = IOCOMPLETE; - timeout(fd_timeout,fdcu,2 * hz); - return(0); /* will return later */ - case IOCOMPLETE: /* IO DONE, post-analyze */ - untimeout(fd_timeout,fdcu); - for(i=0;i<7;i++) - { - fdc->status[i] = in_fdc(fdcu); - } - case IOTIMEDOUT: /*XXX*/ - isa_dmadone(bp->b_flags, bp->b_un.b_addr+fd->skip, - FDBLK, fdc->dmachan); - if (fdc->status[0]&0xF8) - { - return(retrier(fdcu)); - } - /* All OK */ - fd->skip += FDBLK; - if (fd->skip < bp->b_bcount) - { - /* set up next transfer */ - blknum = (unsigned long)bp->b_blkno*DEV_BSIZE/FDBLK - + fd->skip/FDBLK; - bp->b_cylin = (blknum / (fd->ft->sectrac * fd->ft->heads)); - fdc->state = DOSEEK; - } - else - { - /* ALL DONE */ - fd->skip = 0; - bp->b_resid = 0; - dp->b_actf = bp->av_forw; - biodone(bp); - fdc->fd = (fd_p) 0; - fdc->fdu = -1; - fdc->state = FINDWORK; - } - return(1); - case RESETCTLR: - /* Try a reset, keep motor on */ - set_motor(fdcu,fd->fdsu,1); - DELAY(100); - set_motor(fdcu,fd->fdsu,0); - outb(fdc->baseport+fdctl,fd->ft->trans); - TRACE1("[0x%x->fdctl]",fd->ft->trans); - fdc->retry++; - fdc->state = STARTRECAL; - break; - case STARTRECAL: - out_fdc(fdcu,NE7CMD_SPECIFY); /* specify command */ - out_fdc(fdcu,0xDF); - out_fdc(fdcu,2); - out_fdc(fdcu,NE7CMD_RECAL); /* Recalibrate Function */ - out_fdc(fdcu,fdu); - fdc->state = RECALWAIT; - return(0); /* will return later */ - case RECALWAIT: - /* allow heads to settle */ - timeout(fd_pseudointr,fdcu,hz/30); - fdc->state = RECALCOMPLETE; - return(0); /* will return later */ - case RECALCOMPLETE: - out_fdc(fdcu,NE7CMD_SENSEI); - st0 = in_fdc(fdcu); - cyl = in_fdc(fdcu); - if (cyl != 0) - { - printf("fd%d: recal failed ST0 %b cyl %d\n", fdu, - st0, NE7_ST0BITS, cyl); - return(retrier(fdcu)); - } - fd->track = 0; - /* Seek (probably) necessary */ - fdc->state = DOSEEK; - return(1); /* will return immediatly */ - case MOTORWAIT: - if(fd->flags & FD_MOTOR_WAIT) - { - return(0); /* time's not up yet */ - } - fdc->state = DOSEEK; - return(1); /* will return immediatly */ - default: - printf("Unexpected FD int->"); - out_fdc(fdcu,NE7CMD_SENSEI); - st0 = in_fdc(fdcu); - cyl = in_fdc(fdcu); - printf("ST0 = %lx, PCN = %lx\n",i,sec); - out_fdc(fdcu,0x4A); - out_fdc(fdcu,fd->fdsu); - for(i=0;i<7;i++) { - fdc->status[i] = in_fdc(fdcu); - } - printf("intr status :%lx %lx %lx %lx %lx %lx %lx ", - fdc->status[0], - fdc->status[1], - fdc->status[2], - fdc->status[3], - fdc->status[4], - fdc->status[5], - fdc->status[6] ); - return(0); - } - return(1); /* Come back immediatly to new state */ -} - -retrier(fdcu) - fdcu_t fdcu; -{ - fdc_p fdc = fdc_data + fdcu; - register struct buf *dp,*bp; - - dp = &(fdc->head); - bp = dp->b_actf; - - switch(fdc->retry) - { - case 0: case 1: case 2: - fdc->state = SEEKCOMPLETE; - break; - case 3: case 4: case 5: - fdc->state = STARTRECAL; - break; - case 6: - fdc->state = RESETCTLR; - break; - case 7: - break; - default: - { - diskerr(bp, "fd", "hard error", LOG_PRINTF, - fdc->fd->skip, (struct disklabel *)NULL); - printf(" (ST0 %b ", fdc->status[0], NE7_ST0BITS); - printf(" ST1 %b ", fdc->status[1], NE7_ST1BITS); - printf(" ST2 %b ", fdc->status[2], NE7_ST2BITS); - printf("cyl %d hd %d sec %d)\n", - fdc->status[3], fdc->status[4], fdc->status[5]); - } - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - bp->b_resid = bp->b_bcount - fdc->fd->skip; - dp->b_actf = bp->av_forw; - fdc->fd->skip = 0; - biodone(bp); - fdc->state = FINDWORK; - fdc->fd = (fd_p) 0; - fdc->fdu = -1; - /* XXX abort current command, if any. */ - return(1); - } - fdc->retry++; - return(1); -} - -/* - * fdioctl() from jc@irbs.UUCP (John Capo) - * i386/i386/conf.c needs to have fdioctl() declared and remove the line that - * defines fdioctl to be enxio. - * - * TODO: Reformat. - * Think about allocating buffer off stack. - * Don't pass uncast 0's and NULL's to read/write/setdisklabel(). - * Watch out for NetBSD's different *disklabel() interface. - */ - -int -fdioctl (dev, cmd, addr, flag) -dev_t dev; -int cmd; -caddr_t addr; -int flag; -{ - struct fd_type *fdt; - struct disklabel *dl; - char buffer[DEV_BSIZE]; - int error; - - error = 0; - - switch (cmd) - { - case DIOCGDINFO: - bzero(buffer, sizeof (buffer)); - dl = (struct disklabel *)buffer; - dl->d_secsize = FDBLK; - fdt = fd_data[FDUNIT(minor(dev))].ft; - dl->d_secpercyl = fdt->size / fdt->tracks; - dl->d_type = DTYPE_FLOPPY; - - if (readdisklabel(dev, fdstrategy, dl, NULL, 0, 0) == NULL) - error = 0; - else - error = EINVAL; - - *(struct disklabel *)addr = *dl; - break; - - case DIOCSDINFO: - - if ((flag & FWRITE) == 0) - error = EBADF; - - break; - - case DIOCWLABEL: - if ((flag & FWRITE) == 0) - error = EBADF; - - break; - - case DIOCWDINFO: - if ((flag & FWRITE) == 0) - { - error = EBADF; - break; - } - - dl = (struct disklabel *)addr; - - if (error = setdisklabel ((struct disklabel *)buffer, dl, 0, NULL)) - break; - - error = writedisklabel(dev, fdstrategy, (struct disklabel *)buffer, NULL); - break; - - default: - error = EINVAL; - break; - } - return (error); -} - -#endif diff --git a/sys/i386/isa/fdreg.h b/sys/i386/isa/fdreg.h deleted file mode 100644 index 84dbf75..0000000 --- a/sys/i386/isa/fdreg.h +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)fdreg.h 7.1 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * AT floppy controller registers and bitfields - */ - -/* uses NEC765 controller */ -#include "../i386/isa/ic/nec765.h" - -/* registers */ -#define fdout 2 /* Digital Output Register (W) */ -#define FDO_FDSEL 0x03 /* floppy device select */ -#define FDO_FRST 0x04 /* floppy controller reset */ -#define FDO_FDMAEN 0x08 /* enable floppy DMA and Interrupt */ -#define FDO_MOEN0 0x10 /* motor enable drive 0 */ -#define FDO_MOEN1 0x20 /* motor enable drive 1 */ -#define FDO_MOEN2 0x30 /* motor enable drive 2 */ -#define FDO_MOEN3 0x40 /* motor enable drive 3 */ - -#define fdsts 4 /* NEC 765 Main Status Register (R) */ -#define fddata 5 /* NEC 765 Data Register (R/W) */ - -#define fdctl 7 /* Control Register (W) */ -#define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */ -#define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */ -#define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */ -#define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */ - -#define fdin 7 /* Digital Input Register (R) */ -#define FDI_DCHG 0x80 /* diskette has been changed */ - - diff --git a/sys/i386/isa/ic/i8042.h b/sys/i386/isa/ic/i8042.h deleted file mode 100644 index 84ee90f..0000000 --- a/sys/i386/isa/ic/i8042.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * $Id$ - */ - -#define KBSTATP 0x64 /* kbd controller status port (I) */ -#define KBS_DIB 0x01 /* kbd data in buffer */ -#define KBS_IBF 0x02 /* kbd input buffer low */ -#define KBS_WARM 0x04 /* kbd input buffer low */ -#define KBS_OCMD 0x08 /* kbd output buffer has command */ -#define KBS_NOSEC 0x10 /* kbd security lock not engaged */ -#define KBS_TERR 0x20 /* kbd transmission error */ -#define KBS_RERR 0x40 /* kbd receive error */ -#define KBS_PERR 0x80 /* kbd parity error */ - -#define KBCMDP 0x64 /* kbd controller port (O) */ -#define KBDATAP 0x60 /* kbd data port (I) */ -#define KBOUTP 0x60 /* kbd data port (O) */ - -#define K_LDCMDBYTE 0x60 - -#define KC8_TRANS 0x40 /* convert to old scan codes */ -#define KC8_OLDPC 0x20 /* old 9bit codes instead of new 11bit */ -#define KC8_DISABLE 0x10 /* disable keyboard */ -#define KC8_IGNSEC 0x08 /* ignore security lock */ -#define KC8_CPU 0x04 /* exit from protected mode reset */ -#define KC8_IEN 0x01 /* enable interrupt */ -#define CMDBYTE (KC8_TRANS|KC8_IGNSEC|KC8_CPU|KC8_IEN) diff --git a/sys/i386/isa/ic/i8237.h b/sys/i386/isa/ic/i8237.h deleted file mode 100644 index 2199e73..0000000 --- a/sys/i386/isa/ic/i8237.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Intel 8237 DMA Controller - * - * $Id$ - */ - -#define DMA37MD_SINGLE 0x40 /* single pass mode */ -#define DMA37MD_CASCADE 0xc0 /* cascade mode */ -#define DMA37MD_WRITE 0x04 /* read the device, write memory operation */ -#define DMA37MD_READ 0x08 /* write the device, read memory operation */ - diff --git a/sys/i386/isa/ic/i82586.h b/sys/i386/isa/ic/i82586.h deleted file mode 100644 index 577313d..0000000 --- a/sys/i386/isa/ic/i82586.h +++ /dev/null @@ -1,325 +0,0 @@ -/*- - * Copyright (c) 1992, University of Vermont and State Agricultural College. - * Copyright (c) 1992, Garrett A. Wollman. - * 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 University of - * Vermont and State Agricultural College and Garrett A. Wollman. - * 4. Neither the name of the University nor the name of the author - * 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 UNIVERSITY OR 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. - * - * $Id$ - */ - -/* - * Intel 82586 Ethernet chip - * Register, bit, and structure definitions. - * - * Written by GAW with reference to the Clarkson Packet Driver code for this - * chip written by Russ Nelson and others. - */ - -struct ie_en_addr { - u_char data[6]; -}; - -/* - * This is the master configuration block. It tells the hardware where all - * the rest of the stuff is. - */ -struct ie_sys_conf_ptr { - u_short mbz; /* must be zero */ - u_char ie_bus_use; /* true if 8-bit only */ - u_char mbz2[5]; /* must be zero */ - caddr_t ie_iscp_ptr; /* 24-bit physaddr of ISCP */ -}; - -/* - * Note that this is wired in hardware; the SCP is always located here, no - * matter what. - */ -#define IE_SCP_ADDR 0xfffff4 - -/* - * The tells the hardware where all the rest of the stuff is, too. - * FIXME: some of these should be re-commented after we figure out their - * REAL function. - */ -struct ie_int_sys_conf_ptr { - u_char ie_busy; /* zeroed after init */ - u_char mbz; - u_short ie_scb_offset; /* 16-bit physaddr of next struct */ - caddr_t ie_base; /* 24-bit physaddr for all 16-bit vars */ -}; - -/* - * This FINALLY tells the hardware what to do and where to put it. - */ -struct ie_sys_ctl_block { - u_short ie_status; /* status word */ - u_short ie_command; /* command word */ - u_short ie_command_list; /* 16-pointer to command block list */ - u_short ie_recv_list; /* 16-pointer to receive frame list */ - u_short ie_err_crc; /* CRC errors */ - u_short ie_err_align; /* Alignment errors */ - u_short ie_err_resource; /* Resource errors */ - u_short ie_err_overrun; /* Overrun errors */ -}; - -/* Command values */ -#define IE_RU_COMMAND 0x0070 /* mask for RU command */ -#define IE_RU_NOP 0 /* for completeness */ -#define IE_RU_START 0x0010 /* start receive unit command */ -#define IE_RU_ENABLE 0x0020 /* enable receiver command */ -#define IE_RU_DISABLE 0x0030 /* disable receiver command */ -#define IE_RU_ABORT 0x0040 /* abort current receive operation */ - -#define IE_CU_COMMAND 0x0700 /* mask for CU command */ -#define IE_CU_NOP 0 /* included for completeness */ -#define IE_CU_START 0x0100 /* do-command command */ -#define IE_CU_RESUME 0x0200 /* resume a suspended cmd list */ -#define IE_CU_STOP 0x0300 /* SUSPEND was already taken */ -#define IE_CU_ABORT 0x0400 /* abort current command */ - -#define IE_ACK_COMMAND 0xf000 /* mask for ACK command */ -#define IE_ACK_CX 0x8000 /* ack IE_ST_DONE */ -#define IE_ACK_FR 0x4000 /* ack IE_ST_RECV */ -#define IE_ACK_CNA 0x2000 /* ack IE_ST_ALLDONE */ -#define IE_ACK_RNR 0x1000 /* ack IE_ST_RNR */ - -#define IE_ACTION_COMMAND(x) (((x) & IE_CU_COMMAND) == IE_CU_START) - /* is this command an action command? */ - -/* Status values */ -#define IE_ST_WHENCE 0xf000 /* mask for cause of interrupt */ -#define IE_ST_DONE 0x8000 /* command with I bit completed */ -#define IE_ST_RECV 0x4000 /* frame received */ -#define IE_ST_ALLDONE 0x2000 /* all commands completed */ -#define IE_ST_RNR 0x1000 /* receive not ready */ - -#define IE_CU_STATUS 0x700 /* mask for command unit status */ -#define IE_CU_ACTIVE 0x200 /* command unit is active */ -#define IE_CU_SUSPEND 0x100 /* command unit is suspended */ - -#define IE_RU_STATUS 0x70 /* mask for receiver unit status */ -#define IE_RU_SUSPEND 0x10 /* receiver is suspended */ -#define IE_RU_NOSPACE 0x20 /* receiver has no resources */ -#define IE_RU_READY 0x40 /* reveiver is ready */ - -/* - * This is filled in partially by the chip, partially by us. - */ -struct ie_recv_frame_desc { - u_short ie_fd_status; /* status for this frame */ - u_short ie_fd_last; /* end of frame list flag */ - u_short ie_fd_next; /* 16-pointer to next RFD */ - u_short ie_fd_buf_desc; /* 16-pointer to list of buffer desc's */ - struct ie_en_addr dest; /* destination ether */ - struct ie_en_addr src; /* source ether */ - u_short ie_length; /* 802 length/Ether type */ - u_short mbz; /* must be zero */ -}; - -#define IE_FD_LAST 0x8000 /* last rfd in list */ -#define IE_FD_SUSP 0x4000 /* suspend RU after receipt */ - -#define IE_FD_COMPLETE 0x8000 /* frame is complete */ -#define IE_FD_BUSY 0x4000 /* frame is busy */ -#define IE_FD_OK 0x2000 /* frame is bad */ -#define IE_FD_RNR 0x0200 /* receiver out of resources here */ - -/* - * linked list of buffers... - */ -struct ie_recv_buf_desc { - u_short ie_rbd_actual; /* status for this buffer */ - u_short ie_rbd_next; /* 16-pointer to next RBD */ - caddr_t ie_rbd_buffer; /* 24-pointer to buffer for this RBD */ - u_short ie_rbd_length; /* length of the buffer */ - u_short mbz; /* must be zero */ -}; - -#define IE_RBD_LAST 0x8000 /* last buffer */ -#define IE_RBD_USED 0x4000 /* this buffer has data */ -/* - * All commands share this in common. - */ -struct ie_cmd_common { - u_short ie_cmd_status; /* status of this command */ - u_short ie_cmd_cmd; /* command word */ - u_short ie_cmd_link; /* link to next command */ -}; - -#define IE_STAT_COMPL 0x8000 /* command is completed */ -#define IE_STAT_BUSY 0x4000 /* command is running now */ -#define IE_STAT_OK 0x2000 /* command completed successfully */ - -#define IE_CMD_NOP 0x0000 /* NOP */ -#define IE_CMD_IASETUP 0x0001 /* initial address setup */ -#define IE_CMD_CONFIG 0x0002 /* configure command */ -#define IE_CMD_MCAST 0x0003 /* multicast setup command */ -#define IE_CMD_XMIT 0x0004 /* transmit command */ -#define IE_CMD_TDR 0x0005 /* time-domain reflectometer command */ -#define IE_CMD_DUMP 0x0006 /* dump command */ -#define IE_CMD_DIAGNOSE 0x0007 /* diagnostics command */ - -#define IE_CMD_LAST 0x8000 /* this is the last command in the list */ -#define IE_CMD_SUSPEND 0x4000 /* suspend CU after this command */ -#define IE_CMD_INTR 0x2000 /* post an interrupt after completion */ - -/* - * This is the command to transmit a frame. - */ -struct ie_xmit_cmd { - struct ie_cmd_common com; /* common part */ -#define ie_xmit_status com.ie_cmd_status - - u_short ie_xmit_desc; /* 16-pointer to buffer descriptor */ - struct ie_en_addr ie_xmit_addr; /* destination address */ - - u_short ie_xmit_length; /* 802.3 length/Ether type field */ -}; - -#define IE_XS_MAXCOLL 0x000f /* number of collisions during transmit */ -#define IE_XS_EXCMAX 0x0020 /* exceeded maximum number of collisions */ -#define IE_XS_SQE 0x0040 /* SQE positive */ -#define IE_XS_DEFERRED 0x0080 /* transmission deferred */ -#define IE_XS_UNDERRUN 0x0100 /* DMA underrun */ -#define IE_XS_LOSTCTS 0x0200 /* Lost CTS */ -#define IE_XS_NOCARRIER 0x0400 /* No Carrier */ -#define IE_XS_LATECOLL 0x0800 /* Late collision */ - -/* - * This is a buffer descriptor for a frame to be transmitted. - */ - -struct ie_xmit_buf { - u_short ie_xmit_flags; /* see below */ - u_short ie_xmit_next; /* 16-pointer to next desc. */ - caddr_t ie_xmit_buf; /* 24-pointer to the actual buffer */ -}; - -#define IE_XMIT_LAST 0x8000 /* this TBD is the last one */ -/* The rest of the `flags' word is actually the length. */ - -/* - * Multicast setup command. - */ - -#define MAXMCAST 50 /* must fit in transmit buffer */ - -struct ie_mcast_cmd { - struct ie_cmd_common com; /* common part */ -#define ie_mcast_status com.ie_cmd_status - - u_short ie_mcast_bytes; /* size (in bytes) of multicast addresses */ - struct ie_en_addr ie_mcast_addrs[MAXMCAST + 1]; /* space for them */ -}; - -/* - * Time Domain Reflectometer command. - */ - -struct ie_tdr_cmd { - struct ie_cmd_common com; /* common part */ -#define ie_tdr_status com.ie_cmd_status - - u_short ie_tdr_time; /* error bits and time */ -}; - -#define IE_TDR_SUCCESS 0x8000 /* TDR succeeded without error */ -#define IE_TDR_XCVR 0x4000 /* detected a transceiver problem */ -#define IE_TDR_OPEN 0x2000 /* detected an open */ -#define IE_TDR_SHORT 0x1000 /* TDR detected a short */ -#define IE_TDR_TIME 0x07ff /* mask for reflection time */ - -/* - * Initial Address Setup command - */ -struct ie_iasetup_cmd { - struct ie_cmd_common com; -#define ie_iasetup_status com.ie_cmd_status - - struct ie_en_addr ie_address; -}; - -/* - * Configuration command - */ -struct ie_config_cmd { - struct ie_cmd_common com; /* common part */ -#define ie_config_status com.ie_cmd_status - - u_char ie_config_count; /* byte count (0x0c) */ - u_char ie_fifo; /* fifo (8) */ - u_char ie_save_bad; /* save bad frames (0x40) */ - u_char ie_addr_len; /* address length (0x2e) (AL-LOC == 1) */ - u_char ie_priority; /* priority and backoff (0x0) */ - u_char ie_ifs; /* inter-frame spacing (0x60) */ - u_char ie_slot_low; /* slot time, LSB (0x0) */ - u_char ie_slot_high; /* slot time, MSN, and retries (0xf2) */ - u_char ie_promisc; /* 1 if promiscuous, else 0 */ - u_char ie_crs_cdt; /* CSMA/CD parameters (0x0) */ - u_char ie_min_len; /* min frame length (0x40) */ - u_char ie_junk; /* stuff for 82596 (0xff) */ -}; - -/* - * Here are a few useful functions. We could have done these as macros, - * but since we have the inline facility, it makes sense to use that - * instead. - */ -inline void -ie_setup_config(volatile struct ie_config_cmd *cmd, - int promiscuous, int manchester) { - cmd->ie_config_count = 0x0c; - cmd->ie_fifo = 8; - cmd->ie_save_bad = 0x40; - cmd->ie_addr_len = 0x2e; - cmd->ie_priority = 0; - cmd->ie_ifs = 0x60; - cmd->ie_slot_low = 0; - cmd->ie_slot_high = 0xf2; - cmd->ie_promisc = !!promiscuous | manchester << 2; - cmd->ie_crs_cdt = 0; - cmd->ie_min_len = 64; - cmd->ie_junk = 0xff; -} - -inline caddr_t -Align(caddr_t ptr) { - unsigned long l = (unsigned long)ptr; - l = (l + 3) & ~3L; - return (caddr_t)l; -} - -inline void -ie_ack(volatile struct ie_sys_ctl_block *scb, - u_int mask, int unit, - void (*ca)(int)) { - scb->ie_command = scb->ie_status & mask; - (*ca)(unit); -} diff --git a/sys/i386/isa/ic/nec765.h b/sys/i386/isa/ic/nec765.h deleted file mode 100644 index 1895db7..0000000 --- a/sys/i386/isa/ic/nec765.h +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)nec765.h 7.1 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * Nec 765 floppy disc controller definitions - */ - -/* Main status register */ -#define NE7_DAB 0x01 /* Diskette drive A is seeking, thus busy */ -#define NE7_DBB 0x02 /* Diskette drive B is seeking, thus busy */ -#define NE7_CB 0x10 /* Diskette Controller Busy */ -#define NE7_NDM 0x20 /* Diskette Controller in Non Dma Mode */ -#define NE7_DIO 0x40 /* Diskette Controller Data register I/O */ -#define NE7_RQM 0x80 /* Diskette Controller ReQuest for Master */ - -/* Status register ST0 */ -#define NE7_ST0BITS "\020\010invld\007abnrml\006seek_cmplt\005drv_chck\004drive_rdy\003top_head" - -/* Status register ST1 */ -#define NE7_ST1BITS "\020\010end_of_cyl\006bad_crc\005data_overrun\003sec_not_fnd\002write_protect\001no_am" - -/* Status register ST2 */ -#define NE7_ST2BITS "\020\007ctrl_mrk\006bad_crc\005wrong_cyl\004scn_eq\003scn_not_fnd\002bad_cyl\001no_dam" - -/* Status register ST3 */ -#define NE7_ST3BITS "\020\010fault\007write_protect\006drdy\005tk0\004two_side\003side_sel\002" - -/* Commands */ -#define NE7CMD_SPECIFY 3 /* specify drive parameters - requires unit - parameters byte */ -#define NE7CMD_SENSED 4 /* sense drive - requires unit select byte */ -#define NE7CMD_WRITE 0xc5 /* write - requires eight additional bytes */ -#define NE7CMD_READ 0xe6 /* read - requires eight additional bytes */ -#define NE7CMD_FORMAT 0x4c /* format - requires five additional bytes */ -#define NE7CMD_RECAL 7 /* recalibrate drive - requires - unit select byte */ -#define NE7CMD_SENSEI 8 /* sense controller interrupt status */ -#define NE7CMD_SEEK 15 /* seek drive - requires unit select byte - and new cyl byte */ diff --git a/sys/i386/isa/ic/ns16450.h b/sys/i386/isa/ic/ns16450.h deleted file mode 100644 index aa6280d..0000000 --- a/sys/i386/isa/ic/ns16450.h +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ns16450.h 7.1 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * NS16450 UART registers - */ - -#define com_data 0 /* data register (R/W) */ -#define com_dlbl 0 /* divisor latch low (W) */ -#define com_dlbh 1 /* divisor latch high (W) */ -#define com_ier 1 /* interrupt enable (W) */ -#define com_iir 2 /* interrupt identification (R) */ -#define com_lctl 3 /* line control register (R/W) */ -#define com_cfcr 3 /* line control register (R/W) */ -#define com_mcr 4 /* modem control register (R/W) */ -#define com_lsr 5 /* line status register (R/W) */ -#define com_msr 6 /* modem status register (R/W) */ diff --git a/sys/i386/isa/ic/ns16550.h b/sys/i386/isa/ic/ns16550.h deleted file mode 100644 index ff59757..0000000 --- a/sys/i386/isa/ic/ns16550.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ns16550.h 7.1 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * NS16550 UART registers - */ - -#define com_data 0 /* data register (R/W) */ -#define com_dlbl 0 /* divisor latch low (W) */ -#define com_dlbh 1 /* divisor latch high (W) */ -#define com_ier 1 /* interrupt enable (W) */ -#define com_iir 2 /* interrupt identification (R) */ -#define com_fifo 2 /* FIFO control (W) */ -#define com_lctl 3 /* line control register (R/W) */ -#define com_cfcr 3 /* line control register (R/W) */ -#define com_mcr 4 /* modem control register (R/W) */ -#define com_lsr 5 /* line status register (R/W) */ -#define com_msr 6 /* modem status register (R/W) */ diff --git a/sys/i386/isa/icu.h b/sys/i386/isa/icu.h deleted file mode 100644 index 488ad3e..0000000 --- a/sys/i386/isa/icu.h +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)icu.h 5.6 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * AT/386 Interrupt Control constants - * W. Jolitz 8/89 - */ - -#ifndef __ICU__ -#define __ICU__ - -#ifndef LOCORE - -/* - * Interrupt "level" mechanism variables, masks, and macros - */ -extern unsigned imen; /* interrupt mask enable */ -extern unsigned cpl; /* current priority level mask */ - -extern unsigned highmask; /* group of interrupts masked with splhigh() */ -extern unsigned ttymask; /* group of interrupts masked with spltty() */ -extern unsigned biomask; /* group of interrupts masked with splbio() */ -extern unsigned netmask; /* group of interrupts masked with splimp() */ - -#define INTREN(s) (imen &= ~(s), SET_ICUS()) -#define INTRDIS(s) (imen |= (s), SET_ICUS()) -#define INTRMASK(msk,s) (msk |= (s)) -#if 0 -#define SET_ICUS() (outb(IO_ICU1 + 1, imen), outb(IU_ICU2 + 1, imen >> 8)) -#else -/* - * XXX - IO_ICU* are defined in isa.h, not icu.h, and nothing much bothers to - * include isa.h, while too many things include icu.h. - */ -#define SET_ICUS() (outb(0x21, imen), outb(0xa1, imen >> 8)) -#endif - -#endif - -/* - * Interrupt enable bits -- in order of priority - */ -#define IRQ0 0x0001 /* highest priority - timer */ -#define IRQ1 0x0002 -#define IRQ_SLAVE 0x0004 -#define IRQ8 0x0100 -#define IRQ9 0x0200 -#define IRQ2 IRQ9 -#define IRQ10 0x0400 -#define IRQ11 0x0800 -#define IRQ12 0x1000 -#define IRQ13 0x2000 -#define IRQ14 0x4000 -#define IRQ15 0x8000 -#define IRQ3 0x0008 -#define IRQ4 0x0010 -#define IRQ5 0x0020 -#define IRQ6 0x0040 -#define IRQ7 0x0080 /* lowest - parallel printer */ - -/* - * Interrupt Control offset into Interrupt descriptor table (IDT) - */ -#define ICU_OFFSET 32 /* 0-31 are processor exceptions */ -#define ICU_LEN 16 /* 32-47 are ISA interrupts */ - -#endif __ICU__ diff --git a/sys/i386/isa/icu.s b/sys/i386/isa/icu.s deleted file mode 100644 index 22cec58..0000000 --- a/sys/i386/isa/icu.s +++ /dev/null @@ -1,377 +0,0 @@ -/*- - * Copyright (c) 1989, 1990 William F. Jolitz. - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)icu.s 7.2 (Berkeley) 5/21/91 - * - * $Id$ - */ - -/* - * AT/386 - * Vector interrupt control section - */ - -/* - * XXX - this file is now misnamed. All spls are now soft and the only thing - * related to the hardware icu is that the bit numbering is the same in the - * soft priority masks as in the hard ones. - */ - -#include "sio.h" -#define HIGHMASK 0xffff -#define SOFTCLOCKMASK 0x8000 - - .data - .globl _cpl -_cpl: .long 0xffff # current priority (all off) - .globl _imen -_imen: .long 0xffff # interrupt mask enable (all off) -/* .globl _highmask */ -_highmask: .long HIGHMASK - .globl _ttymask -_ttymask: .long 0 - .globl _biomask -_biomask: .long 0 - .globl _netmask -_netmask: .long 0 - .globl _ipending -_ipending: .long 0 -vec: - .long vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7 - .long vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15 - -#define GENSPL(name, mask, event) \ - .globl _spl/**/name ; \ - ALIGN_TEXT ; \ -_spl/**/name: ; \ - COUNT_EVENT(_intrcnt_spl, event) ; \ - movl _cpl,%eax ; \ - movl %eax,%edx ; \ - orl mask,%edx ; \ - movl %edx,_cpl ; \ - SHOW_CPL ; \ - ret - -#define FASTSPL(mask) \ - movl mask,_cpl ; \ - SHOW_CPL - -#define FASTSPL_VARMASK(varmask) \ - movl varmask,%eax ; \ - movl %eax,_cpl ; \ - SHOW_CPL - - .text - - ALIGN_TEXT -unpend_v: - COUNT_EVENT(_intrcnt_spl, 0) - bsfl %eax,%eax # slow, but not worth optimizing - btrl %eax,_ipending - jnc unpend_v_next # some intr cleared the in-memory bit - SHOW_IPENDING - movl Vresume(,%eax,4),%eax - testl %eax,%eax - je noresume - jmp %eax - - ALIGN_TEXT -/* - * XXX - must be some fastintr, need to register those too. - */ -noresume: -#if NSIO > 0 - call _softsio1 -#endif -unpend_v_next: - movl _cpl,%eax - movl %eax,%edx - notl %eax - andl _ipending,%eax - je none_to_unpend - jmp unpend_v - -/* - * Handle return from interrupt after device handler finishes - */ - ALIGN_TEXT -doreti: - COUNT_EVENT(_intrcnt_spl, 1) - addl $4,%esp # discard unit arg - popl %eax # get previous priority -/* - * Now interrupt frame is a trap frame! - * - * XXX - setting up the interrupt frame to be almost a stack frame is mostly - * a waste of time. - */ - movl %eax,_cpl - SHOW_CPL - movl %eax,%edx - notl %eax - andl _ipending,%eax - jne unpend_v -none_to_unpend: - testl %edx,%edx # returning to zero priority? - jne 1f # nope, going to non-zero priority - movl _netisr,%eax - testl %eax,%eax # check for softint s/traps - jne 2f # there are some - jmp test_resched # XXX - schedule jumps better - COUNT_EVENT(_intrcnt_spl, 2) # XXX - - ALIGN_TEXT # XXX -1: # XXX - COUNT_EVENT(_intrcnt_spl, 3) - popl %es - popl %ds - popal - addl $8,%esp - iret - -#include "../net/netisr.h" - -#define DONET(s, c, event) ; \ - .globl c ; \ - btrl $s,_netisr ; \ - jnc 1f ; \ - COUNT_EVENT(_intrcnt_spl, event) ; \ - call c ; \ -1: - - ALIGN_TEXT -2: - COUNT_EVENT(_intrcnt_spl, 4) -/* - * XXX - might need extra locking while testing reg copy of netisr, but - * interrupt routines setting it would not cause any new problems (since we - * don't loop, fresh bits will not be processed until the next doreti or spl0). - */ - testl $~((1 << NETISR_SCLK) | (1 << NETISR_AST)),%eax - je test_ASTs # no net stuff, just temporary AST's - FASTSPL_VARMASK(_netmask) - DONET(NETISR_RAW, _rawintr, 5) - -#ifdef INET - DONET(NETISR_IP, _ipintr, 6) -#endif /* INET */ - -#ifdef IMP - DONET(NETISR_IMP, _impintr, 7) -#endif /* IMP */ - -#ifdef NS - DONET(NETISR_NS, _nsintr, 8) -#endif /* NS */ - -#ifdef ISO - DONET(NETISR_ISO, _clnlintr, 9) -#endif /* ISO */ - - FASTSPL($0) -test_ASTs: - btrl $NETISR_SCLK,_netisr - jnc test_resched - COUNT_EVENT(_intrcnt_spl, 10) - FASTSPL($SOFTCLOCKMASK) -/* - * Back to an interrupt frame for a moment. - */ - pushl $0 # previous cpl (probably not used) - pushl $0x7f # dummy unit number - call _softclock - addl $8,%esp # discard dummies - FASTSPL($0) -test_resched: -#ifdef notused1 - btrl $NETISR_AST,_netisr - jnc 2f -#endif -#ifdef notused2 - cmpl $0,_want_resched - je 2f -#endif - cmpl $0,_astpending # XXX - put it back in netisr to - je 2f # reduce the number of tests - testb $SEL_RPL_MASK,TRAPF_CS_OFF(%esp) - # to non-kernel (i.e., user)? - je 2f # nope, leave - COUNT_EVENT(_intrcnt_spl, 11) - movl $0,_astpending - call _trap -2: - COUNT_EVENT(_intrcnt_spl, 12) - popl %es - popl %ds - popal - addl $8,%esp - iret - -/* - * Interrupt priority mechanism - * -- soft splXX masks with group mechanism (cpl) - * -- h/w masks for currently active or unused interrupts (imen) - * -- ipending = active interrupts currently masked by cpl - */ - - GENSPL(bio, _biomask, 13) - GENSPL(clock, $HIGHMASK, 14) /* splclock == splhigh ex for count */ - GENSPL(high, $HIGHMASK, 15) - GENSPL(imp, _netmask, 16) /* splimp == splnet except for count */ - GENSPL(net, _netmask, 17) - GENSPL(softclock, $SOFTCLOCKMASK, 18) - GENSPL(tty, _ttymask, 19) - - .globl _splnone - .globl _spl0 - ALIGN_TEXT -_splnone: -_spl0: - COUNT_EVENT(_intrcnt_spl, 20) -in_spl0: - movl _cpl,%eax - pushl %eax # save old priority - testl $(1 << NETISR_RAW) | (1 << NETISR_IP),_netisr - je over_net_stuff_for_spl0 - movl _netmask,%eax # mask off those network devices - movl %eax,_cpl # set new priority - SHOW_CPL -/* - * XXX - what about other net intrs? - */ - DONET(NETISR_RAW, _rawintr, 21) - -#ifdef INET - DONET(NETISR_IP, _ipintr, 22) -#endif /* INET */ - -#ifdef IMP - DONET(NETISR_IMP, _impintr, 23) -#endif /* IMP */ - -#ifdef NS - DONET(NETISR_NS, _nsintr, 24) -#endif /* NS */ - -#ifdef ISO - DONET(NETISR_ISO, _clnlintr, 25) -#endif /* ISO */ - -over_net_stuff_for_spl0: - movl $0,_cpl # set new priority - SHOW_CPL - movl _ipending,%eax - testl %eax,%eax - jne unpend_V - popl %eax # return old priority - ret - - .globl _splx - ALIGN_TEXT -_splx: - COUNT_EVENT(_intrcnt_spl, 26) - movl 4(%esp),%eax # new priority - testl %eax,%eax - je in_spl0 # going to "zero level" is special - COUNT_EVENT(_intrcnt_spl, 27) - movl _cpl,%edx # save old priority - movl %eax,_cpl # set new priority - SHOW_CPL - notl %eax - andl _ipending,%eax - jne unpend_V_result_edx - movl %edx,%eax # return old priority - ret - - ALIGN_TEXT -unpend_V_result_edx: - pushl %edx -unpend_V: - COUNT_EVENT(_intrcnt_spl, 28) - bsfl %eax,%eax - btrl %eax,_ipending - jnc unpend_V_next - SHOW_IPENDING - movl Vresume(,%eax,4),%edx - testl %edx,%edx - je noresumeV -/* - * We would prefer to call the intr handler directly here but that doesn't - * work for badly behaved handlers that want the interrupt frame. Also, - * there's a problem determining the unit number. We should change the - * interface so that the unit number is not determined at config time. - */ - jmp *vec(,%eax,4) - - ALIGN_TEXT -/* - * XXX - must be some fastintr, need to register those too. - */ -noresumeV: -#if NSIO > 0 - call _softsio1 -#endif -unpend_V_next: - movl _cpl,%eax - notl %eax - andl _ipending,%eax - jne unpend_V - popl %eax - ret - -#define BUILD_VEC(irq_num) \ - ALIGN_TEXT ; \ -vec/**/irq_num: ; \ - int $ICU_OFFSET + (irq_num) ; \ - popl %eax ; \ - ret - - BUILD_VEC(0) - BUILD_VEC(1) - BUILD_VEC(2) - BUILD_VEC(3) - BUILD_VEC(4) - BUILD_VEC(5) - BUILD_VEC(6) - BUILD_VEC(7) - BUILD_VEC(8) - BUILD_VEC(9) - BUILD_VEC(10) - BUILD_VEC(11) - BUILD_VEC(12) - BUILD_VEC(13) - BUILD_VEC(14) - BUILD_VEC(15) diff --git a/sys/i386/isa/if_ed.c b/sys/i386/isa/if_ed.c deleted file mode 100644 index 91eb929..0000000 --- a/sys/i386/isa/if_ed.c +++ /dev/null @@ -1,2375 +0,0 @@ -/* - * Device driver for National Semiconductor DS8390/WD83C690 based ethernet - * adapters. By David Greenman, 29-April-1993 - * - * 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. - * - * Currently supports the Western Digital/SMC 8003 and 8013 series, - * the 3Com 3c503, the NE1000 and NE2000, and a variety of similar - * clones. - * - * Thanks to Charles Hannum for proving to me with example code that the - * NE1000/2000 support could be added with minimal impact. Without - * this, I wouldn't have proceeded in this direction. - * - */ - -/* - * $Id: if_ed.c,v 2.11 1993/10/23 04:21:03 davidg Exp davidg $ - */ - -/* - * Modification history - * - * Revision 2.11 1993/10/23 04:21:03 davidg - * Novell probe changed to be invasive because of too many complaints - * about some clone boards not being reset properly and thus not - * found on a warmboot. Yuck. - * - * Revision 2.10 1993/10/23 04:07:12 davidg - * increment output errors if the device times out (done via watchdog) - * - * Revision 2.9 1993/10/23 04:01:45 davidg - * increment input error counter if a packet with a bad length is - * detected. - * - * Revision 2.8 1993/10/15 10:59:56 davidg - * increase maximum time to wait for transmit DMA to complete to 120us. - * call ed_reset() if the time limit is reached instead of trying - * to abort the remote DMA. - * - * Revision 2.7 1993/10/15 10:49:10 davidg - * minor change to way the mbuf pointer temp variable is assigned in - * ed_start (slightly improves code readability) - * - * Revision 2.6 93/10/02 01:12:20 davidg - * use ETHER_ADDR_LEN in NE probe rather than '6'. - * - * Revision 2.5 93/09/30 17:44:14 davidg - * patch from vak@zebub.msk.su (Serge V.Vakulenko) to work around - * a hardware bug in cheap WD clone boards where the PROM checksum - * byte is always zero - * - * Revision 2.4 93/09/29 21:24:30 davidg - * Added software NIC reset in NE probe to work around a problem - * with some NE boards where the 8390 doesn't reset properly on - * power-up. Remove initialization of IMR/ISR in the NE probe - * because this is inherent in the reset. - * - * Revision 2.3 93/09/29 15:10:16 davidg - * credit Charles Hannum - * - * Revision 2.2 93/09/29 13:23:25 davidg - * added no multi-buffer override for 3c503 - * - * Revision 2.1 93/09/29 12:32:12 davidg - * changed multi-buffer count for 16bit 3c503's from 5 to 2 after - * noticing that the transmitter becomes idle because of so many - * packets to load. - * - * Revision 2.0 93/09/29 00:00:19 davidg - * many changes, rewrites, additions, etc. Now supports the - * NE1000, NE2000, WD8003, WD8013, 3C503, 16bit 3C503, and - * a variety of similar clones. 16bit 3c503 now does multi - * transmit buffers. Nearly every part of the driver has - * changed in some way since rev 1.30. - * - * Revision 1.1 93/06/14 22:21:24 davidg - * Beta release of device driver for SMC/WD80x3 and 3C503 ethernet boards. - * - */ - -#include "ed.h" -#if NED > 0 -/* bpfilter included here in case it is needed in future net includes */ -#include "bpfilter.h" - -#include "param.h" -#include "systm.h" -#include "errno.h" -#include "ioctl.h" -#include "mbuf.h" -#include "socket.h" -#include "syslog.h" - -#include "net/if.h" -#include "net/if_dl.h" -#include "net/if_types.h" -#include "net/netisr.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 - -#ifdef NS -#include "netns/ns.h" -#include "netns/ns_if.h" -#endif - -#if NBPFILTER > 0 -#include "net/bpf.h" -#include "net/bpfdesc.h" -#endif - -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/icu.h" -#include "i386/isa/if_edreg.h" - -#include "i386/include/pio.h" - -/* For backwards compatibility */ -#ifndef IFF_ALTPHYS -#define IFF_ALTPHYS IFF_LLC0 -#endif - -/* - * ed_softc: per line info and status - */ -struct ed_softc { - struct arpcom arpcom; /* ethernet common */ - - char *type_str; /* pointer to type string */ - u_char vendor; /* interface vendor */ - u_char type; /* interface type code */ - - u_short asic_addr; /* ASIC I/O bus address */ - u_short nic_addr; /* NIC (DS8390) I/O bus address */ - -/* - * The following 'proto' variable is part of a work-around for 8013EBT asics - * being write-only. It's sort of a prototype/shadow of the real thing. - */ - u_char wd_laar_proto; - u_char isa16bit; /* width of access to card 0=8 or 1=16 */ - - caddr_t bpf; /* BPF "magic cookie" */ - caddr_t mem_start; /* NIC memory start address */ - caddr_t mem_end; /* NIC memory end address */ - u_long mem_size; /* total NIC memory size */ - caddr_t mem_ring; /* start of RX ring-buffer (in NIC mem) */ - - u_char mem_shared; /* NIC memory is shared with host */ - u_char xmit_busy; /* transmitter is busy */ - u_char txb_cnt; /* number of transmit buffers */ - u_char txb_inuse; /* number of TX buffers currently in-use*/ - - u_char txb_new; /* pointer to where new buffer will be added */ - u_char txb_next_tx; /* pointer to next buffer ready to xmit */ - u_short txb_len[8]; /* buffered xmit buffer lengths */ - u_char tx_page_start; /* first page of TX buffer area */ - u_char rec_page_start; /* first page of RX ring-buffer */ - u_char rec_page_stop; /* last page of RX ring-buffer */ - u_char next_packet; /* pointer to next unread RX packet */ -} ed_softc[NED]; - -int ed_attach(), ed_init(), edintr(), ed_ioctl(), ed_probe(), - ed_start(), ed_reset(), ed_watchdog(); - -static void ed_stop(); - -static inline void ed_rint(); -static inline void ed_xmit(); -static inline char *ed_ring_copy(); - -void ed_pio_readmem(), ed_pio_writemem(); -u_short ed_pio_write_mbufs(); - -extern int ether_output(); - -struct trailer_header { - u_short ether_type; - u_short ether_residual; -}; - -struct isa_driver eddriver = { - ed_probe, - ed_attach, - "ed" -}; -/* - * Interrupt conversion table for WD/SMC ASIC - * (IRQ* are defined in icu.h) - */ -static unsigned short ed_intr_mask[] = { - IRQ9, - IRQ3, - IRQ5, - IRQ7, - IRQ10, - IRQ11, - IRQ15, - IRQ4 -}; - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 -#define ETHER_HDR_SIZE 14 - -/* - * Determine if the device is present - * - * on entry: - * a pointer to an isa_device struct - * on exit: - * NULL if device not found - * or # of i/o addresses used (if found) - */ -int -ed_probe(isa_dev) - struct isa_device *isa_dev; -{ - struct ed_softc *sc = &ed_softc[isa_dev->id_unit]; - int nports; - - if (nports = ed_probe_WD80x3(isa_dev)) - return (nports); - - if (nports = ed_probe_3Com(isa_dev)) - return (nports); - - if (nports = ed_probe_Novell(isa_dev)) - return (nports); -} - -/* - * Generic probe routine for testing for the existance of a DS8390. - * Must be called after the NIC has just been reset. This routine - * works by looking at certain register values that are gauranteed - * to be initialized a certain way after power-up or reset. Seems - * not to currently work on the 83C690. - * - * Specifically: - * - * Register reset bits set bits - * Command Register (CR) TXP, STA RD2, STP - * Interrupt Status (ISR) RST - * Interrupt Mask (IMR) All bits - * Data Control (DCR) LAS - * Transmit Config. (TCR) LB1, LB0 - * - * We only look at the CR and ISR registers, however, because looking at - * the others would require changing register pages (which would be - * intrusive if this isn't an 8390). - * - * Return 1 if 8390 was found, 0 if not. - */ - -int -ed_probe_generic8390(sc) - struct ed_softc *sc; -{ - if ((inb(sc->nic_addr + ED_P0_CR) & - (ED_CR_RD2|ED_CR_TXP|ED_CR_STA|ED_CR_STP)) != - (ED_CR_RD2|ED_CR_STP)) - return (0); - if ((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST) - return (0); - - return(1); -} - -/* - * Probe and vendor-specific initialization routine for SMC/WD80x3 boards - */ -int -ed_probe_WD80x3(isa_dev) - struct isa_device *isa_dev; -{ - struct ed_softc *sc = &ed_softc[isa_dev->id_unit]; - int i; - u_int memsize; - u_char iptr, isa16bit, sum; - - sc->asic_addr = isa_dev->id_iobase; - sc->nic_addr = sc->asic_addr + ED_WD_NIC_OFFSET; - - /* - * Attempt to do a checksum over the station address PROM. - * If it fails, it's probably not a SMC/WD board. There - * is a problem with this, though: some clone WD boards - * don't pass the checksum test. Danpex boards for one. - */ - for (sum = 0, i = 0; i < 8; ++i) - sum += inb(sc->asic_addr + ED_WD_PROM + i); - - if (sum != ED_WD_ROM_CHECKSUM_TOTAL) { - /* - * Checksum is invalid. This often happens with cheap - * WD8003E clones. In this case, the checksum byte - * (the eighth byte) seems to always be zero. - */ - if (inb(sc->asic_addr + ED_WD_CARD_ID) != ED_TYPE_WD8003E || - inb(sc->asic_addr + ED_WD_PROM + 7) != 0) - return(0); - } - - /* reset card to force it into a known state. */ - outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST); - DELAY(100); - outb(sc->asic_addr + ED_WD_MSR, inb(sc->asic_addr + ED_WD_MSR) & ~ED_WD_MSR_RST); - /* wait in the case this card is reading it's EEROM */ - DELAY(5000); - - sc->vendor = ED_VENDOR_WD_SMC; - sc->type = inb(sc->asic_addr + ED_WD_CARD_ID); - - /* - * Set initial values for width/size. - */ - switch (sc->type) { - case ED_TYPE_WD8003S: - sc->type_str = "WD8003S"; - memsize = 8192; - isa16bit = 0; - break; - case ED_TYPE_WD8003E: - sc->type_str = "WD8003E"; - memsize = 8192; - isa16bit = 0; - break; - case ED_TYPE_WD8013EBT: - sc->type_str = "WD8013EBT"; - memsize = 16384; - isa16bit = 1; - break; - case ED_TYPE_WD8013EP: /* also WD8003EP */ - if (inb(sc->asic_addr + ED_WD_ICR) - & ED_WD_ICR_16BIT) { - isa16bit = 1; - memsize = 16384; - sc->type_str = "WD8013EP"; - } else { - isa16bit = 0; - memsize = 8192; - sc->type_str = "WD8003EP"; - } - break; - case ED_TYPE_WD8013WC: - sc->type_str = "WD8013WC"; - memsize = 16384; - isa16bit = 1; - break; - case ED_TYPE_WD8013EBP: - sc->type_str = "WD8013EBP"; - memsize = 16384; - isa16bit = 1; - break; - case ED_TYPE_WD8013EPC: - sc->type_str = "WD8013EPC"; - memsize = 16384; - isa16bit = 1; - break; - default: - sc->type_str = ""; - memsize = 8192; - isa16bit = 0; - break; - } - /* - * Make some adjustments to initial values depending on what is - * found in the ICR. - */ - if (isa16bit && (sc->type != ED_TYPE_WD8013EBT) - && ((inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) { - isa16bit = 0; - memsize = 8192; - } - -#if ED_DEBUG - printf("type=%s isa16bit=%d memsize=%d id_msize=%d\n", - sc->type_str,isa16bit,memsize,isa_dev->id_msize); - for (i=0; i<8; i++) - printf("%x -> %x\n", i, inb(sc->asic_addr + i)); -#endif - /* - * Allow the user to override the autoconfiguration - */ - if (isa_dev->id_msize) - memsize = isa_dev->id_msize; - /* - * (note that if the user specifies both of the following flags - * that '8bit' mode intentionally has precedence) - */ - if (isa_dev->id_flags & ED_FLAGS_FORCE_16BIT_MODE) - isa16bit = 1; - if (isa_dev->id_flags & ED_FLAGS_FORCE_8BIT_MODE) - isa16bit = 0; - - /* - * Check 83C584 interrupt configuration register if this board has one - * XXX - we could also check the IO address register. But why - * bother...if we get past this, it *has* to be correct. - */ - if (sc->type & ED_WD_SOFTCONFIG) { - /* - * Assemble together the encoded interrupt number. - */ - iptr = (inb(isa_dev->id_iobase + ED_WD_ICR) & ED_WD_ICR_IR2) | - ((inb(isa_dev->id_iobase + ED_WD_IRR) & - (ED_WD_IRR_IR0 | ED_WD_IRR_IR1)) >> 5); - /* - * Translate it using translation table, and check for correctness. - */ - if (ed_intr_mask[iptr] != isa_dev->id_irq) { - printf("ed%d: kernel configured irq %d doesn't match board configured irq %d\n", - isa_dev->id_unit, ffs(isa_dev->id_irq) - 1, ffs(ed_intr_mask[iptr]) - 1); - return(0); - } - /* - * Enable the interrupt. - */ - outb(isa_dev->id_iobase + ED_WD_IRR, - inb(isa_dev->id_iobase + ED_WD_IRR) | ED_WD_IRR_IEN); - } - - sc->isa16bit = isa16bit; - -#ifdef notyet /* XXX - I'm not sure if PIO mode is even possible on WD/SMC boards */ - /* - * The following allows the WD/SMC boards to be used in Programmed I/O - * mode - without mapping the NIC memory shared. ...Not the prefered - * way, but it might be the only way. - */ - if (isa_dev->id_flags & ED_FLAGS_FORCE_PIO) { - sc->mem_shared = 0; - isa_dev->id_maddr = 0; - } else { - sc->mem_shared = 1; - } -#else - sc->mem_shared = 1; -#endif - isa_dev->id_msize = memsize; - - sc->mem_start = (caddr_t)isa_dev->id_maddr; - - /* - * allocate one xmit buffer if < 16k, two buffers otherwise - */ - if ((memsize < 16384) || (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING)) { - sc->mem_ring = sc->mem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE); - sc->txb_cnt = 1; - sc->rec_page_start = ED_TXBUF_SIZE; - } else { - sc->mem_ring = sc->mem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE * 2); - sc->txb_cnt = 2; - sc->rec_page_start = ED_TXBUF_SIZE * 2; - } - sc->mem_size = memsize; - sc->mem_end = sc->mem_start + memsize; - sc->rec_page_stop = memsize / ED_PAGE_SIZE; - sc->tx_page_start = ED_WD_PAGE_OFFSET; - - /* - * Get station address from on-board ROM - */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->arpcom.ac_enaddr[i] = inb(sc->asic_addr + ED_WD_PROM + i); - - if (sc->mem_shared) { - /* - * Set address and enable interface shared memory. - */ - outb(sc->asic_addr + ED_WD_MSR, ((kvtop(sc->mem_start) >> 13) & - ED_WD_MSR_ADDR) | ED_WD_MSR_MENB); - - /* - * Set upper address bits and 8/16 bit access to shared memory - */ - if (isa16bit) { - outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto = - ED_WD_LAAR_L16EN | ED_WD_LAAR_M16EN | - ((kvtop(sc->mem_start) >> 19) & ED_WD_LAAR_ADDRHI))); - } else { - if ((sc->type & ED_WD_SOFTCONFIG) || (sc->type == ED_TYPE_WD8013EBT)) { - outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto = - ((kvtop(sc->mem_start) >> 19) & ED_WD_LAAR_ADDRHI))); - } - } - - /* - * Now zero memory and verify that it is clear - */ - bzero(sc->mem_start, memsize); - - for (i = 0; i < memsize; ++i) - if (sc->mem_start[i]) { - printf("ed%d: failed to clear shared memory at %x - check configuration\n", - isa_dev->id_unit, kvtop(sc->mem_start + i)); - - /* - * Disable 16 bit access to shared memory - */ - if (isa16bit) - outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto &= - ~ED_WD_LAAR_M16EN)); - - return(0); - } - - /* - * Disable 16bit access to shared memory - we leave it disabled so - * that 1) machines reboot properly when the board is set - * 16 bit mode and there are conflicting 8bit devices/ROMS - * in the same 128k address space as this boards shared - * memory. and 2) so that other 8 bit devices with shared - * memory can be used in this 128k region, too. - */ - if (isa16bit) - outb(sc->asic_addr + ED_WD_LAAR, (sc->wd_laar_proto &= - ~ED_WD_LAAR_M16EN)); - - } - - return (ED_WD_IO_PORTS); -} - -/* - * Probe and vendor-specific initialization routine for 3Com 3c503 boards - */ -int -ed_probe_3Com(isa_dev) - struct isa_device *isa_dev; -{ - struct ed_softc *sc = &ed_softc[isa_dev->id_unit]; - int i; - u_int memsize; - u_char isa16bit, sum; - - sc->asic_addr = isa_dev->id_iobase + ED_3COM_ASIC_OFFSET; - sc->nic_addr = isa_dev->id_iobase + ED_3COM_NIC_OFFSET; - - /* - * Verify that the kernel configured I/O address matches the board - * configured address - */ - switch (inb(sc->asic_addr + ED_3COM_BCFR)) { - case ED_3COM_BCFR_300: - if (isa_dev->id_iobase != 0x300) - return(0); - break; - case ED_3COM_BCFR_310: - if (isa_dev->id_iobase != 0x310) - return(0); - break; - case ED_3COM_BCFR_330: - if (isa_dev->id_iobase != 0x330) - return(0); - break; - case ED_3COM_BCFR_350: - if (isa_dev->id_iobase != 0x350) - return(0); - break; - case ED_3COM_BCFR_250: - if (isa_dev->id_iobase != 0x250) - return(0); - break; - case ED_3COM_BCFR_280: - if (isa_dev->id_iobase != 0x280) - return(0); - break; - case ED_3COM_BCFR_2A0: - if (isa_dev->id_iobase != 0x2a0) - return(0); - break; - case ED_3COM_BCFR_2E0: - if (isa_dev->id_iobase != 0x2e0) - return(0); - break; - default: - return(0); - } - - /* - * Verify that the kernel shared memory address matches the - * board configured address. - */ - switch (inb(sc->asic_addr + ED_3COM_PCFR)) { - case ED_3COM_PCFR_DC000: - if (kvtop(isa_dev->id_maddr) != 0xdc000) - return(0); - break; - case ED_3COM_PCFR_D8000: - if (kvtop(isa_dev->id_maddr) != 0xd8000) - return(0); - break; - case ED_3COM_PCFR_CC000: - if (kvtop(isa_dev->id_maddr) != 0xcc000) - return(0); - break; - case ED_3COM_PCFR_C8000: - if (kvtop(isa_dev->id_maddr) != 0xc8000) - return(0); - break; - default: - return(0); - } - - - /* - * Reset NIC and ASIC. Enable on-board transceiver throughout reset - * sequence because it'll lock up if the cable isn't connected - * if we don't. - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_RST | ED_3COM_CR_XSEL); - - /* - * Wait for a while, then un-reset it - */ - DELAY(50); - /* - * The 3Com ASIC defaults to rather strange settings for the CR after - * a reset - it's important to set it again after the following - * outb (this is done when we map the PROM below). - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL); - - /* - * Wait a bit for the NIC to recover from the reset - */ - DELAY(5000); - - sc->vendor = ED_VENDOR_3COM; - sc->type_str = "3c503"; - - sc->mem_shared = 1; - - /* - * Hmmm...a 16bit 3Com board has 16k of memory, but only an 8k - * window to it. - */ - memsize = 8192; - - /* - * Get station address from on-board ROM - */ - /* - * First, map ethernet address PROM over the top of where the NIC - * registers normally appear. - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_EALO | ED_3COM_CR_XSEL); - - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->arpcom.ac_enaddr[i] = inb(sc->nic_addr + i); - - /* - * Unmap PROM - select NIC registers. The proper setting of the - * tranceiver is set in ed_init so that the attach code - * is given a chance to set the default based on a compile-time - * config option - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL); - - /* - * Determine if this is an 8bit or 16bit board - */ - - /* - * select page 0 registers - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP); - - /* - * Attempt to clear WTS bit. If it doesn't clear, then this is a - * 16bit board. - */ - outb(sc->nic_addr + ED_P0_DCR, 0); - - /* - * select page 2 registers - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_2|ED_CR_RD2|ED_CR_STP); - - /* - * The 3c503 forces the WTS bit to a one if this is a 16bit board - */ - if (inb(sc->nic_addr + ED_P2_DCR) & ED_DCR_WTS) - isa16bit = 1; - else - isa16bit = 0; - - /* - * select page 0 registers - */ - outb(sc->nic_addr + ED_P2_CR, ED_CR_RD2|ED_CR_STP); - - sc->mem_start = (caddr_t)isa_dev->id_maddr; - sc->mem_size = memsize; - sc->mem_end = sc->mem_start + memsize; - - /* - * We have an entire 8k window to put the transmit buffers on the - * 16bit boards. But since the 16bit 3c503's shared memory - * is only fast enough to overlap the loading of one full-size - * packet, trying to load more than 2 buffers can actually - * leave the transmitter idle during the load. So 2 seems - * the best value. (Although a mix of variable-sized packets - * might change this assumption. Nonetheless, we optimize for - * linear transfers of same-size packets.) - */ - if (isa16bit) { - if (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING) - sc->txb_cnt = 1; - else - sc->txb_cnt = 2; - - sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_16BIT; - sc->rec_page_start = ED_3COM_RX_PAGE_OFFSET_16BIT; - sc->rec_page_stop = memsize / ED_PAGE_SIZE + - ED_3COM_RX_PAGE_OFFSET_16BIT; - sc->mem_ring = sc->mem_start; - } else { - sc->txb_cnt = 1; - sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_8BIT; - sc->rec_page_start = ED_TXBUF_SIZE + ED_3COM_TX_PAGE_OFFSET_8BIT; - sc->rec_page_stop = memsize / ED_PAGE_SIZE + - ED_3COM_TX_PAGE_OFFSET_8BIT; - sc->mem_ring = sc->mem_start + (ED_PAGE_SIZE * ED_TXBUF_SIZE); - } - - sc->isa16bit = isa16bit; - - /* - * Initialize GA page start/stop registers. Probably only needed - * if doing DMA, but what the hell. - */ - outb(sc->asic_addr + ED_3COM_PSTR, sc->rec_page_start); - outb(sc->asic_addr + ED_3COM_PSPR, sc->rec_page_stop); - - /* - * Set IRQ. 3c503 only allows a choice of irq 2-5. - */ - switch (isa_dev->id_irq) { - case IRQ2: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ2); - break; - case IRQ3: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ3); - break; - case IRQ4: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ4); - break; - case IRQ5: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ5); - break; - default: - printf("ed%d: Invalid irq configuration (%d) must be 2-5 for 3c503\n", - isa_dev->id_unit, ffs(isa_dev->id_irq) - 1); - return(0); - } - - /* - * Initialize GA configuration register. Set bank and enable shared mem. - */ - outb(sc->asic_addr + ED_3COM_GACFR, ED_3COM_GACFR_RSEL | - ED_3COM_GACFR_MBS0); - - /* - * Initialize "Vector Pointer" registers. These gawd-awful things - * are compared to 20 bits of the address on ISA, and if they - * match, the shared memory is disabled. We set them to - * 0xffff0...allegedly the reset vector. - */ - outb(sc->asic_addr + ED_3COM_VPTR2, 0xff); - outb(sc->asic_addr + ED_3COM_VPTR1, 0xff); - outb(sc->asic_addr + ED_3COM_VPTR0, 0x00); - - /* - * Zero memory and verify that it is clear - */ - bzero(sc->mem_start, memsize); - - for (i = 0; i < memsize; ++i) - if (sc->mem_start[i]) { - printf("ed%d: failed to clear shared memory at %x - check configuration\n", - isa_dev->id_unit, kvtop(sc->mem_start + i)); - return(0); - } - - isa_dev->id_msize = memsize; - return(ED_3COM_IO_PORTS); -} - -/* - * Probe and vendor-specific initialization routine for NE1000/2000 boards - */ -int -ed_probe_Novell(isa_dev) - struct isa_device *isa_dev; -{ - struct ed_softc *sc = &ed_softc[isa_dev->id_unit]; - u_int memsize, n; - u_char romdata[16], isa16bit = 0, tmp; - static char test_pattern[32] = "THIS is A memory TEST pattern"; - char test_buffer[32]; - - sc->asic_addr = isa_dev->id_iobase + ED_NOVELL_ASIC_OFFSET; - sc->nic_addr = isa_dev->id_iobase + ED_NOVELL_NIC_OFFSET; - - /* XXX - do Novell-specific probe here */ - - /* Reset the board */ - tmp = inb(sc->asic_addr + ED_NOVELL_RESET); - -#if 0 - /* - * This total and completely screwy thing is to work around braindamage - * in some NE compatible boards. Why it works, I have *no* idea. - * It appears that the boards watch the ISA bus for an outb, and - * will lock up the ISA bus if they see an inb first. Weird. - */ - outb(0x84, 0); -#endif - - /* - * I don't know if this is necessary; probably cruft leftover from - * Clarkson packet driver code. Doesn't do a thing on the boards - * I've tested. -DG [note that a outb(0x84, 0) seems to work - * here, and is non-invasive...but some boards don't seem to reset - * and I don't have complete documentation on what the 'right' - * thing to do is...so we do the invasive thing for now. Yuck.] - */ - outb(sc->asic_addr + ED_NOVELL_RESET, tmp); - DELAY(5000); - - /* - * This is needed because some NE clones apparently don't reset the - * NIC properly (or the NIC chip doesn't reset fully on power-up) - * XXX - this makes the probe invasive! ...Done against my better - * judgement. -DLG - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP); - - DELAY(5000); - - /* Make sure that we really have an 8390 based board */ - if (!ed_probe_generic8390(sc)) - return(0); - - sc->vendor = ED_VENDOR_NOVELL; - sc->mem_shared = 0; - isa_dev->id_maddr = 0; - - /* - * Test the ability to read and write to the NIC memory. This has - * the side affect of determining if this is an NE1000 or an NE2000. - */ - - /* - * This prevents packets from being stored in the NIC memory when - * the readmem routine turns on the start bit in the CR. - */ - outb(sc->nic_addr + ED_P0_RCR, ED_RCR_MON); - - /* Temporarily initialize DCR for byte operations */ - outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1|ED_DCR_LS); - - outb(sc->nic_addr + ED_P0_PSTART, 8192 / ED_PAGE_SIZE); - outb(sc->nic_addr + ED_P0_PSTOP, 16384 / ED_PAGE_SIZE); - - sc->isa16bit = 0; - - /* - * Write a test pattern in byte mode. If this fails, then there - * probably isn't any memory at 8k - which likely means - * that the board is an NE2000. - */ - ed_pio_writemem(sc, test_pattern, 8192, sizeof(test_pattern)); - ed_pio_readmem(sc, 8192, test_buffer, sizeof(test_pattern)); - - if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) { - /* not an NE1000 - try NE2000 */ - - outb(sc->nic_addr + ED_P0_DCR, - ED_DCR_WTS|ED_DCR_FT1|ED_DCR_LS); - outb(sc->nic_addr + ED_P0_PSTART, 16384 / ED_PAGE_SIZE); - outb(sc->nic_addr + ED_P0_PSTOP, 32768 / ED_PAGE_SIZE); - - sc->isa16bit = 1; - /* - * Write a test pattern in word mode. If this also fails, then - * we don't know what this board is. - */ - ed_pio_writemem(sc, test_pattern, 16384, sizeof(test_pattern)); - ed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern)); - - if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) - return(0); /* not an NE2000 either */ - - sc->type = ED_TYPE_NE2000; - sc->type_str = "NE2000"; - } else { - sc->type = ED_TYPE_NE1000; - sc->type_str = "NE1000"; - } - - /* 8k of memory plus an additional 8k if 16bit */ - memsize = 8192 + sc->isa16bit * 8192; - -#if 0 /* probably not useful - NE boards only come two ways */ - /* allow kernel config file overrides */ - if (isa_dev->id_msize) - memsize = isa_dev->id_msize; -#endif - - sc->mem_size = memsize; - - /* NIC memory doesn't start at zero on an NE board */ - /* The start address is tied to the bus width */ - sc->mem_start = (char *) 8192 + sc->isa16bit * 8192; - sc->mem_end = sc->mem_start + memsize; - sc->tx_page_start = memsize / ED_PAGE_SIZE; - - /* - * Use one xmit buffer if < 16k, two buffers otherwise (if not told - * otherwise). - */ - if ((memsize < 16384) || (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING)) - sc->txb_cnt = 1; - else - sc->txb_cnt = 2; - - sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE; - sc->rec_page_stop = sc->tx_page_start + memsize / ED_PAGE_SIZE; - - sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE; - - ed_pio_readmem(sc, 0, romdata, 16); - for (n = 0; n < ETHER_ADDR_LEN; n++) - sc->arpcom.ac_enaddr[n] = romdata[n*(sc->isa16bit+1)]; - - /* clear any pending interrupts that might have occurred above */ - outb(sc->nic_addr + ED_P0_ISR, 0xff); - - return(ED_NOVELL_IO_PORTS); -} - -/* - * Install interface into kernel networking data structures - */ -int -ed_attach(isa_dev) - struct isa_device *isa_dev; -{ - struct ed_softc *sc = &ed_softc[isa_dev->id_unit]; - struct ifnet *ifp = &sc->arpcom.ac_if; - struct ifaddr *ifa; - struct sockaddr_dl *sdl; - - /* - * Set interface to stopped condition (reset) - */ - ed_stop(isa_dev->id_unit); - - /* - * Initialize ifnet structure - */ - ifp->if_unit = isa_dev->id_unit; - ifp->if_name = "ed" ; - ifp->if_mtu = ETHERMTU; - ifp->if_init = ed_init; - ifp->if_output = ether_output; - ifp->if_start = ed_start; - ifp->if_ioctl = ed_ioctl; - ifp->if_reset = ed_reset; - ifp->if_watchdog = ed_watchdog; - - /* - * Set default state for ALTPHYS flag (used to disable the tranceiver - * for AUI operation), based on compile-time config option. - */ - if (isa_dev->id_flags & ED_FLAGS_DISABLE_TRANCEIVER) - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS - | IFF_ALTPHYS); - else - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS); - - /* - * Attach the interface - */ - if_attach(ifp); - - /* - * Search down the ifa address list looking for the AF_LINK type entry - */ - ifa = ifp->if_addrlist; - while ((ifa != 0) && (ifa->ifa_addr != 0) && - (ifa->ifa_addr->sa_family != AF_LINK)) - ifa = ifa->ifa_next; - /* - * If we find an AF_LINK type entry we fill in the hardware address. - * This is useful for netstat(1) to keep track of which interface - * is which. - */ - if ((ifa != 0) && (ifa->ifa_addr != 0)) { - /* - * Fill in the link-level address for this interface - */ - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDR_LEN; - sdl->sdl_slen = 0; - bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); - } - - /* - * Print additional info when attached - */ - printf("ed%d: address %s, ", isa_dev->id_unit, - ether_sprintf(sc->arpcom.ac_enaddr)); - - if (sc->type_str && (*sc->type_str != 0)) - printf("type %s ", sc->type_str); - else - printf("type unknown (0x%x) ", sc->type); - - printf("%s ",sc->isa16bit ? "(16 bit)" : "(8 bit)"); - - printf("%s\n", ((sc->vendor == ED_VENDOR_3COM) && - (ifp->if_flags & IFF_ALTPHYS)) ? "tranceiver disabled" : ""); - - /* - * If BPF is in the kernel, call the attach for it - */ -#if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - -} - -/* - * Reset interface. - */ -int -ed_reset(unit) - int unit; -{ - int s; - - s = splnet(); - - /* - * Stop interface and re-initialize. - */ - ed_stop(unit); - ed_init(unit); - - (void) splx(s); -} - -/* - * Take interface offline. - */ -void -ed_stop(unit) - int unit; -{ - struct ed_softc *sc = &ed_softc[unit]; - int n = 5000; - - /* - * Stop everything on the interface, and select page 0 registers. - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP); - - /* - * Wait for interface to enter stopped state, but limit # of checks - * to 'n' (about 5ms). It shouldn't even take 5us on modern - * DS8390's, but just in case it's an old one. - */ - while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RST) == 0) && --n); - -} - -/* - * Device timeout/watchdog routine. Entered if the device neglects to - * generate an interrupt after a transmit has been started on it. - */ -int -ed_watchdog(unit) - int unit; -{ - struct ed_softc *sc = &ed_softc[unit]; - - log(LOG_ERR, "ed%d: device timeout\n", unit); - ++sc->arpcom.ac_if.if_oerrors; - - ed_reset(unit); -} - -/* - * Initialize device. - */ -ed_init(unit) - int unit; -{ - struct ed_softc *sc = &ed_softc[unit]; - struct ifnet *ifp = &sc->arpcom.ac_if; - int i, s; - u_char command; - - - /* address not known */ - if (ifp->if_addrlist == (struct ifaddr *)0) return; - - /* - * Initialize the NIC in the exact order outlined in the NS manual. - * This init procedure is "mandatory"...don't change what or when - * things happen. - */ - s = splnet(); - - /* reset transmitter flags */ - sc->xmit_busy = 0; - sc->arpcom.ac_if.if_timer = 0; - - sc->txb_inuse = 0; - sc->txb_new = 0; - sc->txb_next_tx = 0; - - /* This variable is used below - don't move this assignment */ - sc->next_packet = sc->rec_page_start + 1; - - /* - * Set interface for page 0, Remote DMA complete, Stopped - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STP); - - if (sc->isa16bit) { - /* - * Set FIFO threshold to 8, No auto-init Remote DMA, - * byte order=80x86, word-wide DMA xfers, - */ - outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1|ED_DCR_WTS|ED_DCR_LS); - } else { - /* - * Same as above, but byte-wide DMA xfers - */ - outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1|ED_DCR_LS); - } - - /* - * Clear Remote Byte Count Registers - */ - outb(sc->nic_addr + ED_P0_RBCR0, 0); - outb(sc->nic_addr + ED_P0_RBCR1, 0); - - /* - * Enable reception of broadcast packets - */ - outb(sc->nic_addr + ED_P0_RCR, ED_RCR_AB); - - /* - * Place NIC in internal loopback mode - */ - outb(sc->nic_addr + ED_P0_TCR, ED_TCR_LB0); - - /* - * Initialize transmit/receive (ring-buffer) Page Start - */ - outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start); - outb(sc->nic_addr + ED_P0_PSTART, sc->rec_page_start); - - /* - * Initialize Receiver (ring-buffer) Page Stop and Boundry - */ - outb(sc->nic_addr + ED_P0_PSTOP, sc->rec_page_stop); - outb(sc->nic_addr + ED_P0_BNRY, sc->rec_page_start); - - /* - * Clear all interrupts. A '1' in each bit position clears the - * corresponding flag. - */ - outb(sc->nic_addr + ED_P0_ISR, 0xff); - - /* - * Enable the following interrupts: receive/transmit complete, - * receive/transmit error, and Receiver OverWrite. - * - * Counter overflow and Remote DMA complete are *not* enabled. - */ - outb(sc->nic_addr + ED_P0_IMR, - ED_IMR_PRXE|ED_IMR_PTXE|ED_IMR_RXEE|ED_IMR_TXEE|ED_IMR_OVWE); - - /* - * Program Command Register for page 1 - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STP); - - /* - * Copy out our station address - */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - outb(sc->nic_addr + ED_P1_PAR0 + i, sc->arpcom.ac_enaddr[i]); - -#if NBPFILTER > 0 - /* - * Initialize multicast address hashing registers to accept - * all multicasts (only used when in promiscuous mode) - */ - for (i = 0; i < 8; ++i) - outb(sc->nic_addr + ED_P1_MAR0 + i, 0xff); -#endif - - /* - * Set Current Page pointer to next_packet (initialized above) - */ - outb(sc->nic_addr + ED_P1_CURR, sc->next_packet); - - /* - * Set Command Register for page 0, Remote DMA complete, - * and interface Start. - */ - outb(sc->nic_addr + ED_P1_CR, ED_CR_RD2|ED_CR_STA); - - /* - * Take interface out of loopback - */ - outb(sc->nic_addr + ED_P0_TCR, 0); - - /* - * If this is a 3Com board, the tranceiver must be software enabled - * (there is no settable hardware default). - */ - if (sc->vendor == ED_VENDOR_3COM) { - if (ifp->if_flags & IFF_ALTPHYS) { - outb(sc->asic_addr + ED_3COM_CR, 0); - } else { - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL); - } - } - - /* - * Set 'running' flag, and clear output active flag. - */ - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - - /* - * ...and attempt to start output - */ - ed_start(ifp); - - (void) splx(s); -} - -/* - * This routine actually starts the transmission on the interface - */ -static inline void ed_xmit(ifp) - struct ifnet *ifp; -{ - struct ed_softc *sc = &ed_softc[ifp->if_unit]; - unsigned short len; - - len = sc->txb_len[sc->txb_next_tx]; - - /* - * Set NIC for page 0 register access - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - /* - * Set TX buffer start page - */ - outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start + - sc->txb_next_tx * ED_TXBUF_SIZE); - - /* - * Set TX length - */ - outb(sc->nic_addr + ED_P0_TBCR0, len); - outb(sc->nic_addr + ED_P0_TBCR1, len >> 8); - - /* - * Set page 0, Remote DMA complete, Transmit Packet, and *Start* - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_TXP|ED_CR_STA); - - sc->xmit_busy = 1; - - /* - * Point to next transmit buffer slot and wrap if necessary. - */ - sc->txb_next_tx++; - if (sc->txb_next_tx == sc->txb_cnt) - sc->txb_next_tx = 0; - - /* - * Set a timer just in case we never hear from the board again - */ - ifp->if_timer = 2; -} - -/* - * Start output on interface. - * We make two assumptions here: - * 1) that the current priority is set to splnet _before_ this code - * is called *and* is returned to the appropriate priority after - * return - * 2) that the IFF_OACTIVE flag is checked before this code is called - * (i.e. that the output part of the interface is idle) - */ -int -ed_start(ifp) - struct ifnet *ifp; -{ - struct ed_softc *sc = &ed_softc[ifp->if_unit]; - struct mbuf *m0, *m; - caddr_t buffer; - int len; - -outloop: - /* - * First, see if there are buffered packets and an idle - * transmitter - should never happen at this point. - */ - if (sc->txb_inuse && (sc->xmit_busy == 0)) { - printf("ed: packets buffers, but transmitter idle\n"); - ed_xmit(ifp); - } - - /* - * See if there is room to put another packet in the buffer. - */ - if (sc->txb_inuse == sc->txb_cnt) { - /* - * No room. Indicate this to the outside world - * and exit. - */ - ifp->if_flags |= IFF_OACTIVE; - return; - } - - IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m); - if (m == 0) { - /* - * We are using the !OACTIVE flag to indicate to the outside - * world that we can accept an additional packet rather than - * that the transmitter is _actually_ active. Indeed, the - * transmitter may be active, but if we haven't filled all - * the buffers with data then we still want to accept more. - */ - ifp->if_flags &= ~IFF_OACTIVE; - return; - } - - /* - * Copy the mbuf chain into the transmit buffer - */ - - m0 = m; - - /* txb_new points to next open buffer slot */ - buffer = sc->mem_start + (sc->txb_new * ED_TXBUF_SIZE * ED_PAGE_SIZE); - - if (sc->mem_shared) { - /* - * Special case setup for 16 bit boards... - */ - if (sc->isa16bit) { - switch (sc->vendor) { - /* - * For 16bit 3Com boards (which have 16k of memory), - * we have the xmit buffers in a different page - * of memory ('page 0') - so change pages. - */ - case ED_VENDOR_3COM: - outb(sc->asic_addr + ED_3COM_GACFR, - ED_3COM_GACFR_RSEL); - break; - /* - * Enable 16bit access to shared memory on WD/SMC boards - * Don't update wd_laar_proto because we want to restore the - * previous state (because an arp reply in the input code - * may cause a call-back to ed_start) - * XXX - the call-back to 'start' is a bug, IMHO. - */ - case ED_VENDOR_WD_SMC: - outb(sc->asic_addr + ED_WD_LAAR, - (sc->wd_laar_proto | ED_WD_LAAR_M16EN)); - } - } - - for (len = 0; m != 0; m = m->m_next) { - bcopy(mtod(m, caddr_t), buffer, m->m_len); - buffer += m->m_len; - len += m->m_len; - } - - /* - * Restore previous shared memory access - */ - if (sc->isa16bit) { - switch (sc->vendor) { - case ED_VENDOR_3COM: - outb(sc->asic_addr + ED_3COM_GACFR, - ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0); - break; - case ED_VENDOR_WD_SMC: - outb(sc->asic_addr + ED_WD_LAAR, sc->wd_laar_proto); - break; - } - } - } else { - len = ed_pio_write_mbufs(sc, m, buffer); - } - - sc->txb_len[sc->txb_new] = MAX(len, ETHER_MIN_LEN); - - sc->txb_inuse++; - - /* - * Point to next buffer slot and wrap if necessary. - */ - sc->txb_new++; - if (sc->txb_new == sc->txb_cnt) - sc->txb_new = 0; - - if (sc->xmit_busy == 0) - ed_xmit(ifp); - /* - * If there is BPF support in the configuration, tap off here. - * The following has support for converting trailer packets - * back to normal. - * XXX - support for trailer packets in BPF should be moved into - * the bpf code proper to avoid code duplication in all of - * the drivers. - */ -#if NBPFILTER > 0 - if (sc->bpf) { - u_short etype; - int off, datasize, resid; - struct ether_header *eh; - struct trailer_header trailer_header; - char ether_packet[ETHER_MAX_LEN]; - char *ep; - - ep = ether_packet; - - /* - * We handle trailers below: - * Copy ether header first, then residual data, - * then data. Put all this in a temporary buffer - * 'ether_packet' and send off to bpf. Since the - * system has generated this packet, we assume - * that all of the offsets in the packet are - * correct; if they're not, the system will almost - * certainly crash in m_copydata. - * We make no assumptions about how the data is - * arranged in the mbuf chain (i.e. how much - * data is in each mbuf, if mbuf clusters are - * used, etc.), which is why we use m_copydata - * to get the ether header rather than assume - * that this is located in the first mbuf. - */ - /* copy ether header */ - m_copydata(m0, 0, sizeof(struct ether_header), ep); - eh = (struct ether_header *) ep; - ep += sizeof(struct ether_header); - etype = ntohs(eh->ether_type); - if (etype >= ETHERTYPE_TRAIL && - etype < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) { - datasize = ((etype - ETHERTYPE_TRAIL) << 9); - off = datasize + sizeof(struct ether_header); - - /* copy trailer_header into a data structure */ - m_copydata(m0, off, sizeof(struct trailer_header), - &trailer_header.ether_type); - - /* copy residual data */ - m_copydata(m0, off+sizeof(struct trailer_header), - resid = ntohs(trailer_header.ether_residual) - - sizeof(struct trailer_header), ep); - ep += resid; - - /* copy data */ - m_copydata(m0, sizeof(struct ether_header), - datasize, ep); - ep += datasize; - - /* restore original ether packet type */ - eh->ether_type = trailer_header.ether_type; - - bpf_tap(sc->bpf, ether_packet, ep - ether_packet); - } else - bpf_mtap(sc->bpf, m0); - } -#endif - - m_freem(m0); - - /* - * Loop back to the top to possibly buffer more packets - */ - goto outloop; -} - -/* - * Ethernet interface receiver interrupt. - */ -static inline void -ed_rint(unit) - int unit; -{ - register struct ed_softc *sc = &ed_softc[unit]; - u_char boundry, current; - u_short len; - struct ed_ring packet_hdr; - char *packet_ptr; - - /* - * Set NIC to page 1 registers to get 'current' pointer - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STA); - - /* - * 'sc->next_packet' is the logical beginning of the ring-buffer - i.e. - * it points to where new data has been buffered. The 'CURR' - * (current) register points to the logical end of the ring-buffer - * - i.e. it points to where additional new data will be added. - * We loop here until the logical beginning equals the logical - * end (or in other words, until the ring-buffer is empty). - */ - while (sc->next_packet != inb(sc->nic_addr + ED_P1_CURR)) { - - /* get pointer to this buffer's header structure */ - packet_ptr = sc->mem_ring + - (sc->next_packet - sc->rec_page_start) * ED_PAGE_SIZE; - - /* - * The byte count includes the FCS - Frame Check Sequence (a - * 32 bit CRC). - */ - if (sc->mem_shared) - packet_hdr = *(struct ed_ring *)packet_ptr; - else - ed_pio_readmem(sc, packet_ptr, (char *) &packet_hdr, - sizeof(packet_hdr)); - len = packet_hdr.count; - if ((len >= ETHER_MIN_LEN) && (len <= ETHER_MAX_LEN)) { - /* - * Go get packet. len - 4 removes CRC from length. - */ - ed_get_packet(sc, packet_ptr + 4, len - 4); - ++sc->arpcom.ac_if.if_ipackets; - } else { - /* - * Really BAD...probably indicates that the ring pointers - * are corrupted. Also seen on early rev chips under - * high load - the byte order of the length gets switched. - */ - log(LOG_ERR, - "ed%d: NIC memory corrupt - invalid packet length %d\n", - unit, len); - ++sc->arpcom.ac_if.if_ierrors; - ed_reset(unit); - return; - } - - /* - * Update next packet pointer - */ - sc->next_packet = packet_hdr.next_packet; - - /* - * Update NIC boundry pointer - being careful to keep it - * one buffer behind. (as recommended by NS databook) - */ - boundry = sc->next_packet - 1; - if (boundry < sc->rec_page_start) - boundry = sc->rec_page_stop - 1; - - /* - * Set NIC to page 0 registers to update boundry register - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - outb(sc->nic_addr + ED_P0_BNRY, boundry); - - /* - * Set NIC to page 1 registers before looping to top (prepare to - * get 'CURR' current pointer) - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STA); - } -} - -/* - * Ethernet interface interrupt processor - */ -int -edintr(unit) - int unit; -{ - struct ed_softc *sc = &ed_softc[unit]; - u_char isr; - - /* - * Set NIC to page 0 registers - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - /* - * loop until there are no more new interrupts - */ - while (isr = inb(sc->nic_addr + ED_P0_ISR)) { - - /* - * reset all the bits that we are 'acknowledging' - * by writing a '1' to each bit position that was set - * (writing a '1' *clears* the bit) - */ - outb(sc->nic_addr + ED_P0_ISR, isr); - - /* - * Handle transmitter interrupts. Handle these first - * because the receiver will reset the board under - * some conditions. - */ - if (isr & (ED_ISR_PTX|ED_ISR_TXE)) { - u_char collisions = inb(sc->nic_addr + ED_P0_NCR); - - /* - * Check for transmit error. If a TX completed with an - * error, we end up throwing the packet away. Really - * the only error that is possible is excessive - * collisions, and in this case it is best to allow the - * automatic mechanisms of TCP to backoff the flow. Of - * course, with UDP we're screwed, but this is expected - * when a network is heavily loaded. - */ - if (isr & ED_ISR_TXE) { - - /* - * Excessive collisions (16) - */ - if ((inb(sc->nic_addr + ED_P0_TSR) & ED_TSR_ABT) - && (collisions == 0)) { - /* - * When collisions total 16, the - * P0_NCR will indicate 0, and the - * TSR_ABT is set. - */ - collisions = 16; - } - - /* - * update output errors counter - */ - ++sc->arpcom.ac_if.if_oerrors; - } else { - /* - * Update total number of successfully - * transmitted packets. - */ - ++sc->arpcom.ac_if.if_opackets; - } - - /* - * reset tx busy and output active flags - */ - sc->xmit_busy = 0; - sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - - /* - * clear watchdog timer - */ - sc->arpcom.ac_if.if_timer = 0; - - /* - * Add in total number of collisions on last - * transmission. - */ - sc->arpcom.ac_if.if_collisions += collisions; - - /* - * Decrement buffer in-use count if not zero (can only - * be zero if a transmitter interrupt occured while - * not actually transmitting). - * If data is ready to transmit, start it transmitting, - * otherwise defer until after handling receiver - */ - if (sc->txb_inuse && --sc->txb_inuse) - ed_xmit(&sc->arpcom.ac_if); - } - - /* - * Handle receiver interrupts - */ - if (isr & (ED_ISR_PRX|ED_ISR_RXE|ED_ISR_OVW)) { - /* - * Overwrite warning. In order to make sure that a lockup - * of the local DMA hasn't occurred, we reset and - * re-init the NIC. The NSC manual suggests only a - * partial reset/re-init is necessary - but some - * chips seem to want more. The DMA lockup has been - * seen only with early rev chips - Methinks this - * bug was fixed in later revs. -DG - */ - if (isr & ED_ISR_OVW) { - ++sc->arpcom.ac_if.if_ierrors; -#ifdef DIAGNOSTIC - log(LOG_WARNING, - "ed%d: warning - receiver ring buffer overrun\n", - unit); -#endif - /* - * Stop/reset/re-init NIC - */ - ed_reset(unit); - } else { - - /* - * Receiver Error. One or more of: CRC error, frame - * alignment error FIFO overrun, or missed packet. - */ - if (isr & ED_ISR_RXE) { - ++sc->arpcom.ac_if.if_ierrors; -#ifdef ED_DEBUG - printf("ed%d: receive error %x\n", unit, - inb(sc->nic_addr + ED_P0_RSR)); -#endif - } - - /* - * Go get the packet(s) - * XXX - Doing this on an error is dubious - * because there shouldn't be any data to - * get (we've configured the interface to - * not accept packets with errors). - */ - - /* - * Enable 16bit access to shared memory first - * on WD/SMC boards. - */ - if (sc->isa16bit && - (sc->vendor == ED_VENDOR_WD_SMC)) { - - outb(sc->asic_addr + ED_WD_LAAR, - (sc->wd_laar_proto |= - ED_WD_LAAR_M16EN)); - } - - ed_rint (unit); - - /* disable 16bit access */ - if (sc->isa16bit && - (sc->vendor == ED_VENDOR_WD_SMC)) { - - outb(sc->asic_addr + ED_WD_LAAR, - (sc->wd_laar_proto &= - ~ED_WD_LAAR_M16EN)); - } - } - } - - /* - * If it looks like the transmitter can take more data, - * attempt to start output on the interface. - * This is done after handling the receiver to - * give the receiver priority. - */ - if ((sc->arpcom.ac_if.if_flags & IFF_OACTIVE) == 0) - ed_start(&sc->arpcom.ac_if); - - /* - * return NIC CR to standard state: page 0, remote DMA complete, - * start (toggling the TXP bit off, even if was just set - * in the transmit routine, is *okay* - it is 'edge' - * triggered from low to high) - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - /* - * If the Network Talley Counters overflow, read them to - * reset them. It appears that old 8390's won't - * clear the ISR flag otherwise - resulting in an - * infinite loop. - */ - if (isr & ED_ISR_CNT) { - (void) inb(sc->nic_addr + ED_P0_CNTR0); - (void) inb(sc->nic_addr + ED_P0_CNTR1); - (void) inb(sc->nic_addr + ED_P0_CNTR2); - } - } -} - -/* - * Process an ioctl request. This code needs some work - it looks - * pretty ugly. - */ -int -ed_ioctl(ifp, command, data) - register struct ifnet *ifp; - int command; - caddr_t data; -{ - register struct ifaddr *ifa = (struct ifaddr *)data; - struct ed_softc *sc = &ed_softc[ifp->if_unit]; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splnet(); - - switch (command) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - ed_init(ifp->if_unit); /* before arpwhohas */ - /* - * See if another station has *our* IP address. - * i.e.: There is an address conflict! If a - * conflict exists, a message is sent to the - * console. - */ - ((struct arpcom *)ifp)->ac_ipaddr = - IA_SIN(ifa)->sin_addr; - arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - /* - * XXX - This code is probably wrong - */ - case AF_NS: - { - register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->arpcom.ac_enaddr); - else { - /* - * - */ - bcopy((caddr_t)ina->x_host.c_host, - (caddr_t)sc->arpcom.ac_enaddr, - sizeof(sc->arpcom.ac_enaddr)); - } - /* - * Set new address - */ - ed_init(ifp->if_unit); - break; - } -#endif - default: - ed_init(ifp->if_unit); - break; - } - break; - - case SIOCSIFFLAGS: - /* - * If interface is marked down and it is running, then stop it - */ - if (((ifp->if_flags & IFF_UP) == 0) && - (ifp->if_flags & IFF_RUNNING)) { - ed_stop(ifp->if_unit); - ifp->if_flags &= ~IFF_RUNNING; - } else { - /* - * If interface is marked up and it is stopped, then start it - */ - if ((ifp->if_flags & IFF_UP) && - ((ifp->if_flags & IFF_RUNNING) == 0)) - ed_init(ifp->if_unit); - } -#if NBPFILTER > 0 - if (ifp->if_flags & IFF_PROMISC) { - /* - * Set promiscuous mode on interface. - * XXX - for multicasts to work, we would need to - * write 1's in all bits of multicast - * hashing array. For now we assume that - * this was done in ed_init(). - */ - outb(sc->nic_addr + ED_P0_RCR, - ED_RCR_PRO|ED_RCR_AM|ED_RCR_AB); - } else { - /* - * XXX - for multicasts to work, we would need to - * rewrite the multicast hashing array with the - * proper hash (would have been destroyed above). - */ - outb(sc->nic_addr + ED_P0_RCR, ED_RCR_AB); - } -#endif - /* - * An unfortunate hack to provide the (required) software control - * of the tranceiver for 3Com boards. The ALTPHYS flag disables - * the tranceiver if set. - */ - if (sc->vendor == ED_VENDOR_3COM) { - if (ifp->if_flags & IFF_ALTPHYS) { - outb(sc->asic_addr + ED_3COM_CR, 0); - } else { - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL); - } - } - - break; - - default: - error = EINVAL; - } - (void) splx(s); - return (error); -} - -/* - * Macro to calculate a new address within shared memory when given an offset - * from an address, taking into account ring-wrap. - */ -#define ringoffset(sc, start, off, type) \ - ((type)( ((caddr_t)(start)+(off) >= (sc)->mem_end) ? \ - (((caddr_t)(start)+(off))) - (sc)->mem_end \ - + (sc)->mem_ring: \ - ((caddr_t)(start)+(off)) )) - -/* - * Retreive packet from shared memory and send to the next level up via - * ether_input(). If there is a BPF listener, give a copy to BPF, too. - */ -ed_get_packet(sc, buf, len) - struct ed_softc *sc; - char *buf; - u_short len; -{ - struct ether_header *eh; - struct mbuf *m, *head, *ed_ring_to_mbuf(); - u_short off; - int resid; - u_short etype; - struct trailer_header trailer_header; - - /* Allocate a header mbuf */ - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - goto bad; - m->m_pkthdr.rcvif = &sc->arpcom.ac_if; - m->m_pkthdr.len = len; - m->m_len = 0; - head = m; - - /* The following sillines is to make NFS happy */ -#define EROUND ((sizeof(struct ether_header) + 3) & ~3) -#define EOFF (EROUND - sizeof(struct ether_header)) - - /* - * The following assumes there is room for - * the ether header in the header mbuf - */ - head->m_data += EOFF; - eh = mtod(head, struct ether_header *); - - if (sc->mem_shared) - bcopy(buf, mtod(head, caddr_t), sizeof(struct ether_header)); - else - ed_pio_readmem(sc, buf, mtod(head, caddr_t), - sizeof(struct ether_header)); - buf += sizeof(struct ether_header); - head->m_len += sizeof(struct ether_header); - len -= sizeof(struct ether_header); - - etype = ntohs((u_short)eh->ether_type); - - /* - * Deal with trailer protocol: - * If trailer protocol, calculate the datasize as 'off', - * which is also the offset to the trailer header. - * Set resid to the amount of packet data following the - * trailer header. - * Finally, copy residual data into mbuf chain. - */ - if (etype >= ETHERTYPE_TRAIL && - etype < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) { - - off = (etype - ETHERTYPE_TRAIL) << 9; - if ((off + sizeof(struct trailer_header)) > len) - goto bad; /* insanity */ - - /* - * If we have shared memory, we can get info directly from the - * stored packet, otherwise we must get a local copy - * of the trailer header using PIO. - */ - if (sc->mem_shared) { - eh->ether_type = *ringoffset(sc, buf, off, u_short *); - resid = ntohs(*ringoffset(sc, buf, off+2, u_short *)); - } else { - struct trailer_header trailer_header; - ed_pio_readmem(sc, - ringoffset(sc, buf, off, caddr_t), - (char *) &trailer_header, - sizeof(trailer_header)); - eh->ether_type = trailer_header.ether_type; - resid = trailer_header.ether_residual; - } - - if ((off + resid) > len) goto bad; /* insanity */ - - resid -= sizeof(struct trailer_header); - if (resid < 0) goto bad; /* insanity */ - - m = ed_ring_to_mbuf(sc, ringoffset(sc, buf, off+4, char *), head, resid); - if (m == 0) goto bad; - - len = off; - head->m_pkthdr.len -= 4; /* subtract trailer header */ - } - - /* - * Pull packet off interface. Or if this was a trailer packet, - * the data portion is appended. - */ - m = ed_ring_to_mbuf(sc, buf, m, len); - if (m == 0) goto bad; - -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to bpf. - */ - if (sc->bpf) { - bpf_mtap(sc->bpf, head); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - * - * XXX This test does not support multicasts. - */ - if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC) && - bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0 && - bcmp(eh->ether_dhost, etherbroadcastaddr, - sizeof(eh->ether_dhost)) != 0) { - - m_freem(head); - return; - } - } -#endif - - /* - * Fix up data start offset in mbuf to point past ether header - */ - m_adj(head, sizeof(struct ether_header)); - - /* - * silly ether_input routine needs 'type' in host byte order - */ - eh->ether_type = ntohs(eh->ether_type); - - ether_input(&sc->arpcom.ac_if, eh, head); - return; - -bad: if (head) - m_freem(head); - return; -} - -/* - * Supporting routines - */ - -/* - * Given a NIC memory source address and a host memory destination - * address, copy 'amount' from NIC to host using Programmed I/O. - * The 'amount' is rounded up to a word - okay as long as mbufs - * are word sized. - * This routine is currently Novell-specific. - */ -void -ed_pio_readmem(sc,src,dst,amount) - struct ed_softc *sc; - unsigned short src; - unsigned char *dst; - unsigned short amount; -{ - unsigned short tmp_amount; - - /* select page 0 registers */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - /* round up to a word */ - tmp_amount = amount; - if (amount & 1) ++amount; - - /* set up DMA byte count */ - outb(sc->nic_addr + ED_P0_RBCR0, amount); - outb(sc->nic_addr + ED_P0_RBCR1, amount>>8); - - /* set up source address in NIC mem */ - outb(sc->nic_addr + ED_P0_RSAR0, src); - outb(sc->nic_addr + ED_P0_RSAR1, src>>8); - - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD0 | ED_CR_STA); - - if (sc->isa16bit) { - insw(sc->asic_addr + ED_NOVELL_DATA, dst, amount/2); - } else - insb(sc->asic_addr + ED_NOVELL_DATA, dst, amount); - -} - -/* - * Stripped down routine for writing a linear buffer to NIC memory. - * Only used in the probe routine to test the memory. 'len' must - * be even. - */ -void -ed_pio_writemem(sc,src,dst,len) - struct ed_softc *sc; - char *src; - unsigned short dst; - unsigned short len; -{ - int maxwait=100; /* about 120us */ - - /* select page 0 registers */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - /* reset remote DMA complete flag */ - outb(sc->nic_addr + ED_P0_ISR, ED_ISR_RDC); - - /* set up DMA byte count */ - outb(sc->nic_addr + ED_P0_RBCR0, len); - outb(sc->nic_addr + ED_P0_RBCR1, len>>8); - - /* set up destination address in NIC mem */ - outb(sc->nic_addr + ED_P0_RSAR0, dst); - outb(sc->nic_addr + ED_P0_RSAR1, dst>>8); - - /* set remote DMA write */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD1 | ED_CR_STA); - - if (sc->isa16bit) - outsw(sc->asic_addr + ED_NOVELL_DATA, src, len/2); - else - outsb(sc->asic_addr + ED_NOVELL_DATA, src, len); - /* - * Wait for remote DMA complete. This is necessary because on the - * transmit side, data is handled internally by the NIC in bursts - * and we can't start another remote DMA until this one completes. - * Not waiting causes really bad things to happen - like the NIC - * irrecoverably jamming the ISA bus. - */ - while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait); -} - -/* - * Write an mbuf chain to the destination NIC memory address using - * programmed I/O. - */ -u_short -ed_pio_write_mbufs(sc,m,dst) - struct ed_softc *sc; - struct mbuf *m; - unsigned short dst; -{ - unsigned short len, mb_offset; - struct mbuf *mp; - unsigned char residual[2]; - int maxwait=100; /* about 120us */ - - /* First, count up the total number of bytes to copy */ - for (len = 0, mp = m; mp; mp = mp->m_next) - len += mp->m_len; - - /* select page 0 registers */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2|ED_CR_STA); - - /* reset remote DMA complete flag */ - outb(sc->nic_addr + ED_P0_ISR, ED_ISR_RDC); - - /* set up DMA byte count */ - outb(sc->nic_addr + ED_P0_RBCR0, len); - outb(sc->nic_addr + ED_P0_RBCR1, len>>8); - - /* set up destination address in NIC mem */ - outb(sc->nic_addr + ED_P0_RSAR0, dst); - outb(sc->nic_addr + ED_P0_RSAR1, dst>>8); - - /* set remote DMA write */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD1 | ED_CR_STA); - - mb_offset = 0; - /* - * Transfer the mbuf chain to the NIC memory. - * The following code isn't too pretty. The problem is that we can only - * transfer words to the board, and if an mbuf has an odd number - * of bytes in it, this is a problem. It's not a simple matter of - * just removing a byte from the next mbuf (adjusting data++ and - * len--) because this will hose-over the mbuf chain which might - * be needed later for BPF. Instead, we maintain an offset - * (mb_offset) which let's us skip over the first byte in the - * following mbuf. - */ - while (m) { - if (m->m_len - mb_offset) { - if (sc->isa16bit) { - if ((m->m_len - mb_offset) > 1) - outsw(sc->asic_addr + ED_NOVELL_DATA, - mtod(m, caddr_t) + mb_offset, - (m->m_len - mb_offset) / 2); - - /* - * if odd number of bytes, get the odd byte from - * the next mbuf with data - */ - if ((m->m_len - mb_offset) & 1) { - /* first the last byte in current mbuf */ - residual[0] = *(mtod(m, caddr_t) - + m->m_len - 1); - - /* advance past any empty mbufs */ - while (m->m_next && (m->m_next->m_len == 0)) - m = m->m_next; - - if (m->m_next) { - /* remove first byte in next mbuf */ - residual[1] = *(mtod(m->m_next, caddr_t)); - mb_offset = 1; - } - - outw(sc->asic_addr + ED_NOVELL_DATA, - *((unsigned short *) residual)); - } else - mb_offset = 0; - } else - outsb(sc->asic_addr + ED_NOVELL_DATA, m->m_data, m->m_len); - - } - m = m->m_next; - } - - /* - * Wait for remote DMA complete. This is necessary because on the - * transmit side, data is handled internally by the NIC in bursts - * and we can't start another remote DMA until this one completes. - * Not waiting causes really bad things to happen - like the NIC - * irrecoverably jamming the ISA bus. - */ - while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait); - - if (!maxwait) { - log(LOG_WARNING, "ed%d: remote transmit DMA failed to complete\n", - sc->arpcom.ac_if.if_unit); - ed_reset(sc->arpcom.ac_if.if_unit); - } - - return(len); -} - -/* - * Given a source and destination address, copy 'amount' of a packet from - * the ring buffer into a linear destination buffer. Takes into account - * ring-wrap. - */ -static inline char * -ed_ring_copy(sc,src,dst,amount) - struct ed_softc *sc; - char *src; - char *dst; - u_short amount; -{ - u_short tmp_amount; - - /* does copy wrap to lower addr in ring buffer? */ - if (src + amount > sc->mem_end) { - tmp_amount = sc->mem_end - src; - - /* copy amount up to end of NIC memory */ - if (sc->mem_shared) - bcopy(src,dst,tmp_amount); - else - ed_pio_readmem(sc,src,dst,tmp_amount); - - amount -= tmp_amount; - src = sc->mem_ring; - dst += tmp_amount; - } - - if (sc->mem_shared) - bcopy(src, dst, amount); - else - ed_pio_readmem(sc, src, dst, amount); - - return(src + amount); -} - -/* - * Copy data from receive buffer to end of mbuf chain - * allocate additional mbufs as needed. return pointer - * to last mbuf in chain. - * sc = ed info (softc) - * src = pointer in ed ring buffer - * dst = pointer to last mbuf in mbuf chain to copy to - * amount = amount of data to copy - */ -struct mbuf * -ed_ring_to_mbuf(sc,src,dst,total_len) - struct ed_softc *sc; - char *src; - struct mbuf *dst; - u_short total_len; -{ - register struct mbuf *m = dst; - - while (total_len) { - register u_short amount = min(total_len, M_TRAILINGSPACE(m)); - - if (amount == 0) { /* no more data in this mbuf, alloc another */ - /* - * If there is enough data for an mbuf cluster, attempt - * to allocate one of those, otherwise, a regular - * mbuf will do. - * Note that a regular mbuf is always required, even if - * we get a cluster - getting a cluster does not - * allocate any mbufs, and one is needed to assign - * the cluster to. The mbuf that has a cluster - * extension can not be used to contain data - only - * the cluster can contain data. - */ - dst = m; - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return (0); - - if (total_len >= MINCLSIZE) - MCLGET(m, M_DONTWAIT); - - m->m_len = 0; - dst->m_next = m; - amount = min(total_len, M_TRAILINGSPACE(m)); - } - - src = ed_ring_copy(sc, src, mtod(m, caddr_t) + m->m_len, amount); - - m->m_len += amount; - total_len -= amount; - - } - return (m); -} -#endif diff --git a/sys/i386/isa/if_edreg.h b/sys/i386/isa/if_edreg.h deleted file mode 100644 index 9b7a43f..0000000 --- a/sys/i386/isa/if_edreg.h +++ /dev/null @@ -1,903 +0,0 @@ -/* - * National Semiconductor DS8390 NIC register definitions - * - * $Id: if_edreg.h,v 2.0 93/09/29 00:37:15 davidg Exp Locker: davidg $ - * - * Modification history - * - * $Log: if_edreg.h,v $ - * Revision 2.0 93/09/29 00:37:15 davidg - * changed double buffering flag to multi buffering - * made changes/additions for 3c503 multi-buffering - * ...companion to Rev. 2.0 of 'ed' driver. - * - * Revision 1.6 93/09/28 17:20:03 davidg - * first cut at PIO (e.g. NE1000/2000) support - * - * Revision 1.5 93/08/25 20:38:34 davidg - * added define for card type WD8013WC (10BaseT) - * - * Revision 1.4 93/08/14 20:07:55 davidg - * fix board type definition for 8013EP - * - * Revision 1.3 93/07/20 15:25:25 davidg - * added config flags for forcing 8/16bit mode and disabling double - * xmit buffers. - * - * Revision 1.2 93/06/23 03:03:05 davidg - * added some additional definitions for the 83C584 bus interface - * chip (SMC/WD boards) - * - * Revision 1.1 93/06/23 03:01:07 davidg - * Initial revision - * - */ - -/* - * Page 0 register offsets - */ -#define ED_P0_CR 0x00 /* Command Register */ - -#define ED_P0_CLDA0 0x01 /* Current Local DMA Addr low (read) */ -#define ED_P0_PSTART 0x01 /* Page Start register (write) */ - -#define ED_P0_CLDA1 0x02 /* Current Local DMA Addr high (read) */ -#define ED_P0_PSTOP 0x02 /* Page Stop register (write) */ - -#define ED_P0_BNRY 0x03 /* Boundary Pointer */ - -#define ED_P0_TSR 0x04 /* Transmit Status Register (read) */ -#define ED_P0_TPSR 0x04 /* Transmit Page Start (write) */ - -#define ED_P0_NCR 0x05 /* Number of Collisions Reg (read) */ -#define ED_P0_TBCR0 0x05 /* Transmit Byte count, low (write) */ - -#define ED_P0_FIFO 0x06 /* FIFO register (read) */ -#define ED_P0_TBCR1 0x06 /* Transmit Byte count, high (write) */ - -#define ED_P0_ISR 0x07 /* Interrupt Status Register */ - -#define ED_P0_CRDA0 0x08 /* Current Remote DMA Addr low (read) */ -#define ED_P0_RSAR0 0x08 /* Remote Start Address low (write) */ - -#define ED_P0_CRDA1 0x09 /* Current Remote DMA Addr high (read) */ -#define ED_P0_RSAR1 0x09 /* Remote Start Address high (write) */ - -#define ED_P0_RBCR0 0x0a /* Remote Byte Count low (write) */ - -#define ED_P0_RBCR1 0x0b /* Remote Byte Count high (write) */ - -#define ED_P0_RSR 0x0c /* Receive Status (read) */ -#define ED_P0_RCR 0x0c /* Receive Configuration Reg (write) */ - -#define ED_P0_CNTR0 0x0d /* frame alignment error counter (read) */ -#define ED_P0_TCR 0x0d /* Transmit Configuration Reg (write) */ - -#define ED_P0_CNTR1 0x0e /* CRC error counter (read) */ -#define ED_P0_DCR 0x0e /* Data Configuration Reg (write) */ - -#define ED_P0_CNTR2 0x0f /* missed packet counter (read) */ -#define ED_P0_IMR 0x0f /* Interrupt Mask Register (write) */ - -/* - * Page 1 register offsets - */ -#define ED_P1_CR 0x00 /* Command Register */ -#define ED_P1_PAR0 0x01 /* Physical Address Register 0 */ -#define ED_P1_PAR1 0x02 /* Physical Address Register 1 */ -#define ED_P1_PAR2 0x03 /* Physical Address Register 2 */ -#define ED_P1_PAR3 0x04 /* Physical Address Register 3 */ -#define ED_P1_PAR4 0x05 /* Physical Address Register 4 */ -#define ED_P1_PAR5 0x06 /* Physical Address Register 5 */ -#define ED_P1_CURR 0x07 /* Current RX ring-buffer page */ -#define ED_P1_MAR0 0x08 /* Multicast Address Register 0 */ -#define ED_P1_MAR1 0x09 /* Multicast Address Register 1 */ -#define ED_P1_MAR2 0x0a /* Multicast Address Register 2 */ -#define ED_P1_MAR3 0x0b /* Multicast Address Register 3 */ -#define ED_P1_MAR4 0x0c /* Multicast Address Register 4 */ -#define ED_P1_MAR5 0x0d /* Multicast Address Register 5 */ -#define ED_P1_MAR6 0x0e /* Multicast Address Register 6 */ -#define ED_P1_MAR7 0x0f /* Multicast Address Register 7 */ - -/* - * Page 2 register offsets - */ -#define ED_P2_CR 0x00 /* Command Register */ -#define ED_P2_PSTART 0x01 /* Page Start (read) */ -#define ED_P2_CLDA0 0x01 /* Current Local DMA Addr 0 (write) */ -#define ED_P2_PSTOP 0x02 /* Page Stop (read) */ -#define ED_P2_CLDA1 0x02 /* Current Local DMA Addr 1 (write) */ -#define ED_P2_RNPP 0x03 /* Remote Next Packet Pointer */ -#define ED_P2_TPSR 0x04 /* Transmit Page Start (read) */ -#define ED_P2_LNPP 0x05 /* Local Next Packet Pointer */ -#define ED_P2_ACU 0x06 /* Address Counter Upper */ -#define ED_P2_ACL 0x07 /* Address Counter Lower */ -#define ED_P2_RCR 0x0c /* Receive Configuration Register (read) */ -#define ED_P2_TCR 0x0d /* Transmit Configuration Register (read) */ -#define ED_P2_DCR 0x0e /* Data Configuration Register (read) */ -#define ED_P2_IMR 0x0f /* Interrupt Mask Register (read) */ - -/* - * Command Register (CR) definitions - */ - -/* - * STP: SToP. Software reset command. Takes the controller offline. No - * packets will be received or transmitted. Any reception or - * transmission in progress will continue to completion before - * entering reset state. To exit this state, the STP bit must - * reset and the STA bit must be set. The software reset has - * executed only when indicated by the RST bit in the ISR being - * set. - */ -#define ED_CR_STP 0x01 - -/* - * STA: STArt. This bit is used to activate the NIC after either power-up, - * or when the NIC has been put in reset mode by software command - * or error. - */ -#define ED_CR_STA 0x02 - -/* - * TXP: Transmit Packet. This bit must be set to indicate transmission of - * a packet. TXP is internally reset either after the transmission is - * completed or aborted. This bit should be set only after the Transmit - * Byte Count and Transmit Page Start register have been programmed. - */ -#define ED_CR_TXP 0x04 - -/* - * RD0, RD1, RD2: Remote DMA Command. These three bits control the operation - * of the remote DMA channel. RD2 can be set to abort any remote DMA - * command in progress. The Remote Byte Count registers should be cleared - * when a remote DMA has been aborted. The Remote Start Addresses are not - * restored to the starting address if the remote DMA is aborted. - * - * RD2 RD1 RD0 function - * 0 0 0 not allowed - * 0 0 1 remote read - * 0 1 0 remote write - * 0 1 1 send packet - * 1 X X abort - */ -#define ED_CR_RD0 0x08 -#define ED_CR_RD1 0x10 -#define ED_CR_RD2 0x20 - -/* - * PS0, PS1: Page Select. The two bits select which register set or 'page' to - * access. - * - * PS1 PS0 page - * 0 0 0 - * 0 1 1 - * 1 0 2 - * 1 1 reserved - */ -#define ED_CR_PS0 0x40 -#define ED_CR_PS1 0x80 -/* bit encoded aliases */ -#define ED_CR_PAGE_0 0x00 /* (for consistency) */ -#define ED_CR_PAGE_1 0x40 -#define ED_CR_PAGE_2 0x80 - -/* - * Interrupt Status Register (ISR) definitions - */ - -/* - * PRX: Packet Received. Indicates packet received with no errors. - */ -#define ED_ISR_PRX 0x01 - -/* - * PTX: Packet Transmitted. Indicates packet transmitted with no errors. - */ -#define ED_ISR_PTX 0x02 - -/* - * RXE: Receive Error. Indicates that a packet was received with one or more - * the following errors: CRC error, frame alignment error, FIFO overrun, - * missed packet. - */ -#define ED_ISR_RXE 0x04 - -/* - * TXE: Transmission Error. Indicates that an attempt to transmit a packet - * resulted in one or more of the following errors: excessive - * collisions, FIFO underrun. - */ -#define ED_ISR_TXE 0x08 - -/* - * OVW: OverWrite. Indicates a receive ring-buffer overrun. Incoming network - * would exceed (has exceeded?) the boundry pointer, resulting in data - * that was previously received and not yet read from the buffer to be - * overwritten. - */ -#define ED_ISR_OVW 0x10 - -/* - * CNT: Counter Overflow. Set when the MSB of one or more of the Network Talley - * Counters has been set. - */ -#define ED_ISR_CNT 0x20 - -/* - * RDC: Remote Data Complete. Indicates that a Remote DMA operation has completed. - */ -#define ED_ISR_RDC 0x40 - -/* - * RST: Reset status. Set when the NIC enters the reset state and cleared when a - * Start Command is issued to the CR. This bit is also set when a receive - * ring-buffer overrun (OverWrite) occurs and is cleared when one or more - * packets have been removed from the ring. This is a read-only bit. - */ -#define ED_ISR_RST 0x80 - -/* - * Interrupt Mask Register (IMR) definitions - */ - -/* - * PRXE: Packet Received interrupt Enable. If set, a received packet will cause - * an interrupt. - */ -#define ED_IMR_PRXE 0x01 - -/* - * PTXE: Packet Transmit interrupt Enable. If set, an interrupt is generated when - * a packet transmission completes. - */ -#define ED_IMR_PTXE 0x02 - -/* - * RXEE: Receive Error interrupt Enable. If set, an interrupt will occur whenever a - * packet is received with an error. - */ -#define ED_IMR_RXEE 0x04 - -/* - * TXEE: Transmit Error interrupt Enable. If set, an interrupt will occur whenever - * a transmission results in an error. - */ -#define ED_IMR_TXEE 0x08 - -/* - * OVWE: OverWrite error interrupt Enable. If set, an interrupt is generated whenever - * the receive ring-buffer is overrun. i.e. when the boundry pointer is exceeded. - */ -#define ED_IMR_OVWE 0x10 - -/* - * CNTE: Counter overflow interrupt Enable. If set, an interrupt is generated whenever - * the MSB of one or more of the Network Statistics counters has been set. - */ -#define ED_IMR_CNTE 0x20 - -/* - * RDCE: Remote DMA Complete interrupt Enable. If set, an interrupt is generated - * when a remote DMA transfer has completed. - */ -#define ED_IMR_RDCE 0x40 - -/* - * bit 7 is unused/reserved - */ - -/* - * Data Configuration Register (DCR) definitions - */ - -/* - * WTS: Word Transfer Select. WTS establishes byte or word transfers for - * both remote and local DMA transfers - */ -#define ED_DCR_WTS 0x01 - -/* - * BOS: Byte Order Select. BOS sets the byte order for the host. - * Should be 0 for 80x86, and 1 for 68000 series processors - */ -#define ED_DCR_BOS 0x02 - -/* - * LAS: Long Address Select. When LAS is 1, the contents of the remote - * DMA registers RSAR0 and RSAR1 are used to provide A16-A31 - */ -#define ED_DCR_LAS 0x04 - -/* - * LS: Loopback Select. When 0, loopback mode is selected. Bits D1 and D2 - * of the TCR must also be programmed for loopback operation. - * When 1, normal operation is selected. - */ -#define ED_DCR_LS 0x08 - -/* - * AR: Auto-initialize Remote. When 0, data must be removed from ring-buffer - * under program control. When 1, remote DMA is automatically initiated - * and the boundry pointer is automatically updated - */ -#define ED_DCR_AR 0x10 - -/* - * FT0, FT1: Fifo Threshold select. - * FT1 FT0 Word-width Byte-width - * 0 0 1 word 2 bytes - * 0 1 2 words 4 bytes - * 1 0 4 words 8 bytes - * 1 1 8 words 12 bytes - * - * During transmission, the FIFO threshold indicates the number of bytes - * or words that the FIFO has filled from the local DMA before BREQ is - * asserted. The transmission threshold is 16 bytes minus the receiver - * threshold. - */ -#define ED_DCR_FT0 0x20 -#define ED_DCR_FT1 0x40 - -/* - * bit 7 (0x80) is unused/reserved - */ - -/* - * Transmit Configuration Register (TCR) definitions - */ - -/* - * CRC: Inhibit CRC. If 0, CRC will be appended by the transmitter, if 0, CRC - * is not appended by the transmitter. - */ -#define ED_TCR_CRC 0x01 - -/* - * LB0, LB1: Loopback control. These two bits set the type of loopback that is - * to be performed. - * - * LB1 LB0 mode - * 0 0 0 - normal operation (DCR_LS = 0) - * 0 1 1 - internal loopback (DCR_LS = 0) - * 1 0 2 - external loopback (DCR_LS = 1) - * 1 1 3 - external loopback (DCR_LS = 0) - */ -#define ED_TCR_LB0 0x02 -#define ED_TCR_LB1 0x04 - -/* - * ATD: Auto Transmit Disable. Clear for normal operation. When set, allows - * another station to disable the NIC's transmitter by transmitting to - * a multicast address hashing to bit 62. Reception of a multicast address - * hashing to bit 63 enables the transmitter. - */ -#define ED_TCR_ATD 0x08 - -/* - * OFST: Collision Offset enable. This bit when set modifies the backoff - * algorithm to allow prioritization of nodes. - */ -#define ED_TCR_OFST 0x10 - -/* - * bits 5, 6, and 7 are unused/reserved - */ - -/* - * Transmit Status Register (TSR) definitions - */ - -/* - * PTX: Packet Transmitted. Indicates successful transmission of packet. - */ -#define ED_TSR_PTX 0x01 - -/* - * bit 1 (0x02) is unused/reserved - */ - -/* - * COL: Transmit Collided. Indicates that the transmission collided at least - * once with another station on the network. - */ -#define ED_TSR_COL 0x04 - -/* - * ABT: Transmit aborted. Indicates that the transmission was aborted due to - * excessive collisions. - */ -#define ED_TSR_ABT 0x08 - -/* - * CRS: Carrier Sense Lost. Indicates that carrier was lost during the - * transmission of the packet. (Transmission is not aborted because - * of a loss of carrier) - */ -#define ED_TSR_CRS 0x10 - -/* - * FU: FIFO Underrun. Indicates that the NIC wasn't able to access bus/ - * transmission memory before the FIFO emptied. Transmission of the - * packet was aborted. - */ -#define ED_TSR_FU 0x20 - -/* - * CDH: CD Heartbeat. Indicates that the collision detection circuitry - * isn't working correctly during a collision heartbeat test. - */ -#define ED_TSR_CDH 0x40 - -/* - * OWC: Out of Window Collision: Indicates that a collision occurred after - * a slot time (51.2us). The transmission is rescheduled just as in - * normal collisions. - */ -#define ED_TSR_OWC 0x80 - -/* - * Receiver Configuration Register (RCR) definitions - */ - -/* - * SEP: Save Errored Packets. If 0, error packets are discarded. If set to 1, - * packets with CRC and frame errors are not discarded. - */ -#define ED_RCR_SEP 0x01 - -/* - * AR: Accept Runt packet. If 0, packet with less than 64 byte are discarded. - * If set to 1, packets with less than 64 byte are not discarded. - */ -#define ED_RCR_AR 0x02 - -/* - * AB: Accept Broadcast. If set, packets sent to the broadcast address will be - * accepted. - */ -#define ED_RCR_AB 0x04 - -/* - * AM: Accept Multicast. If set, packets sent to a multicast address are checked - * for a match in the hashing array. If clear, multicast packets are ignored. - */ -#define ED_RCR_AM 0x08 - -/* - * PRO: Promiscuous Physical. If set, all packets with a physical addresses are - * accepted. If clear, a physical destination address must match this - * station's address. Note: for full promiscuous mode, RCR_AB and RCR_AM - * must also be set. In addition, the multicast hashing array must be set - * to all 1's so that all multicast addresses are accepted. - */ -#define ED_RCR_PRO 0x10 - -/* - * MON: Monitor Mode. If set, packets will be checked for good CRC and framing, - * but are not stored in the ring-buffer. If clear, packets are stored (normal - * operation). - */ -#define ED_RCR_MON 0x20 - -/* - * bits 6 and 7 are unused/reserved. - */ - -/* - * Receiver Status Register (RSR) definitions - */ - -/* - * PRX: Packet Received without error. - */ -#define ED_RSR_PRX 0x01 - -/* - * CRC: CRC error. Indicates that a packet has a CRC error. Also set for frame - * alignment errors. - */ -#define ED_RSR_CRC 0x02 - -/* - * FAE: Frame Alignment Error. Indicates that the incoming packet did not end on - * a byte boundry and the CRC did not match at the last byte boundry. - */ -#define ED_RSR_FAE 0x04 - -/* - * FO: FIFO Overrun. Indicates that the FIFO was not serviced (during local DMA) - * causing it to overrun. Reception of the packet is aborted. - */ -#define ED_RSR_FO 0x08 - -/* - * MPA: Missed Packet. Indicates that the received packet couldn't be stored in - * the ring-buffer because of insufficient buffer space (exceeding the - * boundry pointer), or because the transfer to the ring-buffer was inhibited - * by RCR_MON - monitor mode. - */ -#define ED_RSR_MPA 0x10 - -/* - * PHY: Physical address. If 0, the packet received was sent to a physical address. - * If 1, the packet was accepted because of a multicast/broadcast address - * match. - */ -#define ED_RSR_PHY 0x20 - -/* - * DIS: Receiver Disabled. Set to indicate that the receiver has enetered monitor - * mode. Cleared when the receiver exits monitor mode. - */ -#define ED_RSR_DIS 0x40 - -/* - * DFR: Deferring. Set to indicate a 'jabber' condition. The CRS and COL inputs - * are active, and the transceiver has set the CD line as a result of the - * jabber. - */ -#define ED_RSR_DFR 0x80 - -/* - * receive ring discriptor - * - * The National Semiconductor DS8390 Network interface controller uses - * the following receive ring headers. The way this works is that the - * memory on the interface card is chopped up into 256 bytes blocks. - * A contiguous portion of those blocks are marked for receive packets - * by setting start and end block #'s in the NIC. For each packet that - * is put into the receive ring, one of these headers (4 bytes each) is - * tacked onto the front. - */ -struct ed_ring { - struct edr_status { /* received packet status */ - u_char rs_prx:1, /* packet received intack */ - rs_crc:1, /* crc error */ - rs_fae:1, /* frame alignment error */ - rs_fo:1, /* fifo overrun */ - rs_mpa:1, /* packet received intack */ - rs_phy:1, /* packet received intack */ - rs_dis:1, /* packet received intack */ - rs_dfr:1; /* packet received intack */ - } ed_rcv_status; /* received packet status */ - u_char next_packet; /* pointer to next packet */ - u_short count; /* bytes in packet (length + 4) */ -}; - -/* - * Common constants - */ -#define ED_PAGE_SIZE 256 /* Size of RAM pages in bytes */ -#define ED_TXBUF_SIZE 6 /* Size of TX buffer in pages */ - -/* - * Vendor types - */ -#define ED_VENDOR_WD_SMC 0x00 /* Western Digital/SMC */ -#define ED_VENDOR_3COM 0x01 /* 3Com */ -#define ED_VENDOR_NOVELL 0x02 /* Novell */ - -/* - * Compile-time config flags - */ -/* - * this sets the default for enabling/disablng the tranceiver - */ -#define ED_FLAGS_DISABLE_TRANCEIVER 0x0001 - -/* - * This forces the board to be used in 8/16bit mode even if it - * autoconfigs differently - */ -#define ED_FLAGS_FORCE_8BIT_MODE 0x0002 -#define ED_FLAGS_FORCE_16BIT_MODE 0x0004 - -/* - * This disables the use of double transmit buffers. - */ -#define ED_FLAGS_NO_MULTI_BUFFERING 0x0008 - -/* - * This forces all operations with the NIC memory to use Programmed - * I/O (i.e. not via shared memory) - */ -#define ED_FLAGS_FORCE_PIO 0x0010 - -/* - * Definitions for Western digital/SMC WD80x3 series ASIC - */ -/* - * Memory Select Register (MSR) - */ -#define ED_WD_MSR 0 - -#define ED_WD_MSR_ADDR 0x3f /* Memory decode bits 18-13 */ -#define ED_WD_MSR_MENB 0x40 /* Memory enable */ -#define ED_WD_MSR_RST 0x80 /* Reset board */ - -/* - * Interface Configuration Register (ICR) - */ -#define ED_WD_ICR 1 - -#define ED_WD_ICR_16BIT 0x01 /* 16-bit interface */ -#define ED_WD_ICR_OAR 0x02 /* select register. 0=BIO 1=EAR */ -#define ED_WD_ICR_IR2 0x04 /* high order bit of encoded IRQ */ -#define ED_WD_ICR_MSZ 0x08 /* memory size (0=8k 1=32k) */ -#define ED_WD_ICR_RLA 0x10 /* recall LAN address */ -#define ED_WD_ICR_RX7 0x20 /* recall all but i/o and LAN address */ -#define ED_WD_ICR_RIO 0x40 /* recall i/o address */ -#define ED_WD_ICR_STO 0x80 /* store to non-volatile memory */ - -/* - * IO Address Register (IAR) - */ -#define ED_WD_IAR 2 - -/* - * EEROM Address Register - */ -#define ED_WD_EAR 3 - -/* - * Interrupt Request Register (IRR) - */ -#define ED_WD_IRR 4 - -#define ED_WD_IRR_0WS 0x01 /* use 0 wait-states on 8 bit bus */ -#define ED_WD_IRR_OUT1 0x02 /* WD83C584 pin 1 output */ -#define ED_WD_IRR_OUT2 0x04 /* WD83C584 pin 2 output */ -#define ED_WD_IRR_OUT3 0x08 /* WD83C584 pin 3 output */ -#define ED_WD_IRR_FLASH 0x10 /* Flash RAM is in the ROM socket */ - -/* - * The three bit of the encoded IRQ are decoded as follows: - * - * IR2 IR1 IR0 IRQ - * 0 0 0 2/9 - * 0 0 1 3 - * 0 1 0 5 - * 0 1 1 7 - * 1 0 0 10 - * 1 0 1 11 - * 1 1 0 15 - * 1 1 1 4 - */ -#define ED_WD_IRR_IR0 0x20 /* bit 0 of encoded IRQ */ -#define ED_WD_IRR_IR1 0x40 /* bit 1 of encoded IRQ */ -#define ED_WD_IRR_IEN 0x80 /* Interrupt enable */ - -/* - * LA Address Register (LAAR) - */ -#define ED_WD_LAAR 5 - -#define ED_WD_LAAR_ADDRHI 0x1f /* bits 23-19 of RAM address */ -#define ED_WD_LAAR_0WS16 0x20 /* enable 0 wait-states on 16 bit bus */ -#define ED_WD_LAAR_L16EN 0x40 /* enable 16-bit operation */ -#define ED_WD_LAAR_M16EN 0x80 /* enable 16-bit memory access */ - -/* i/o base offset to station address/card-ID PROM */ -#define ED_WD_PROM 8 - -/* i/o base offset to CARD ID */ -#define ED_WD_CARD_ID ED_WD_PROM+6 - -/* Board type codes in card ID */ -#define ED_TYPE_WD8003S 0x02 -#define ED_TYPE_WD8003E 0x03 -#define ED_TYPE_WD8013EBT 0x05 -#define ED_TYPE_WD8013EP 0x27 -#define ED_TYPE_WD8013WC 0x28 -#define ED_TYPE_WD8013EBP 0x2c -#define ED_TYPE_WD8013EPC 0x29 - -/* Bit definitions in card ID */ -#define ED_WD_REV_MASK 0x1f /* Revision mask */ -#define ED_WD_SOFTCONFIG 0x20 /* Soft config */ -#define ED_WD_LARGERAM 0x40 /* Large RAM */ -#define ED_MICROCHANEL 0x80 /* Microchannel bus (vs. isa) */ - -/* - * Checksum total. All 8 bytes in station address PROM will add up to this - */ -#define ED_WD_ROM_CHECKSUM_TOTAL 0xFF - -#define ED_WD_NIC_OFFSET 0x10 /* I/O base offset to NIC */ -#define ED_WD_ASIC_OFFSET 0 /* I/O base offset to ASIC */ -#define ED_WD_IO_PORTS 32 /* # of i/o addresses used */ - -#define ED_WD_PAGE_OFFSET 0 /* page offset for NIC access to mem */ - -/* - * Definitions for 3Com 3c503 - */ -#define ED_3COM_NIC_OFFSET 0 -#define ED_3COM_ASIC_OFFSET 0x400 /* offset to nic i/o regs */ - -/* - * XXX - The I/O address range is fragmented in the 3c503; this is the - * number of regs at iobase. - */ -#define ED_3COM_IO_PORTS 16 /* # of i/o addresses used */ - -/* tx memory starts in second bank on 8bit cards */ -#define ED_3COM_TX_PAGE_OFFSET_8BIT 0x20 - -/* tx memory starts in first bank on 16bit cards */ -#define ED_3COM_TX_PAGE_OFFSET_16BIT 0x0 - -/* ...and rx memory starts in second bank */ -#define ED_3COM_RX_PAGE_OFFSET_16BIT 0x20 - - -/* - * Page Start Register. Must match PSTART in NIC - */ -#define ED_3COM_PSTR 0 - -/* - * Page Stop Register. Must match PSTOP in NIC - */ -#define ED_3COM_PSPR 1 - -/* - * Drq Timer Register. Determines number of bytes to be transfered during - * a DMA burst. - */ -#define ED_3COM_DQTR 2 - -/* - * Base Configuration Register. Read-only register which contains the - * board-configured I/O base address of the adapter. Bit encoded. - */ -#define ED_3COM_BCFR 3 - -#define ED_3COM_BCFR_2E0 0x01 -#define ED_3COM_BCFR_2A0 0x02 -#define ED_3COM_BCFR_280 0x04 -#define ED_3COM_BCFR_250 0x08 -#define ED_3COM_BCFR_350 0x10 -#define ED_3COM_BCFR_330 0x20 -#define ED_3COM_BCFR_310 0x40 -#define ED_3COM_BCFR_300 0x80 - -/* - * EPROM Configuration Register. Read-only register which contains the - * board-configured memory base address. Bit encoded. - */ -#define ED_3COM_PCFR 4 - -#define ED_3COM_PCFR_C8000 0x10 -#define ED_3COM_PCFR_CC000 0x20 -#define ED_3COM_PCFR_D8000 0x40 -#define ED_3COM_PCFR_DC000 0x80 - -/* - * GA Configuration Register. Gate-Array Configuration Register. - */ -#define ED_3COM_GACFR 5 - -/* - * mbs2 mbs1 mbs0 start address - * 0 0 0 0x0000 - * 0 0 1 0x2000 - * 0 1 0 0x4000 - * 0 1 1 0x6000 - * - * Note that with adapters with only 8K, the setting for 0x2000 must - * always be used. - */ -#define ED_3COM_GACFR_MBS0 0x01 -#define ED_3COM_GACFR_MBS1 0x02 -#define ED_3COM_GACFR_MBS2 0x04 - -#define ED_3COM_GACFR_RSEL 0x08 /* enable shared memory */ -#define ED_3COM_GACFR_TEST 0x10 /* for GA testing */ -#define ED_3COM_GACFR_OWS 0x20 /* select 0WS access to GA */ -#define ED_3COM_GACFR_TCM 0x40 /* Mask DMA interrupts */ -#define ED_3COM_GACFR_NIM 0x80 /* Mask NIC interrupts */ - -/* - * Control Register. Miscellaneous control functions. - */ -#define ED_3COM_CR 6 - -#define ED_3COM_CR_RST 0x01 /* Reset GA and NIC */ -#define ED_3COM_CR_XSEL 0x02 /* Transceiver select. BNC=1(def) AUI=0 */ -#define ED_3COM_CR_EALO 0x04 /* window EA PROM 0-15 to I/O base */ -#define ED_3COM_CR_EAHI 0x08 /* window EA PROM 16-31 to I/O base */ -#define ED_3COM_CR_SHARE 0x10 /* select interrupt sharing option */ -#define ED_3COM_CR_DBSEL 0x20 /* Double buffer select */ -#define ED_3COM_CR_DDIR 0x40 /* DMA direction select */ -#define ED_3COM_CR_START 0x80 /* Start DMA controller */ - -/* - * Status Register. Miscellaneous status information. - */ -#define ED_3COM_STREG 7 - -#define ED_3COM_STREG_REV 0x07 /* GA revision */ -#define ED_3COM_STREG_DIP 0x08 /* DMA in progress */ -#define ED_3COM_STREG_DTC 0x10 /* DMA terminal count */ -#define ED_3COM_STREG_OFLW 0x20 /* Overflow */ -#define ED_3COM_STREG_UFLW 0x40 /* Underflow */ -#define ED_3COM_STREG_DPRDY 0x80 /* Data port ready */ - -/* - * Interrupt/DMA Configuration Register - */ -#define ED_3COM_IDCFR 8 - -#define ED_3COM_IDCFR_DRQ0 0x01 /* DMA request 1 select */ -#define ED_3COM_IDCFR_DRQ1 0x02 /* DMA request 2 select */ -#define ED_3COM_IDCFR_DRQ2 0x04 /* DMA request 3 select */ -#define ED_3COM_IDCFR_UNUSED 0x08 /* not used */ -#define ED_3COM_IDCFR_IRQ2 0x10 /* Interrupt request 2 select */ -#define ED_3COM_IDCFR_IRQ3 0x20 /* Interrupt request 3 select */ -#define ED_3COM_IDCFR_IRQ4 0x40 /* Interrupt request 4 select */ -#define ED_3COM_IDCFR_IRQ5 0x80 /* Interrupt request 5 select */ - -/* - * DMA Address Register MSB - */ -#define ED_3COM_DAMSB 9 - -/* - * DMA Address Register LSB - */ -#define ED_3COM_DALSB 0x0a - -/* - * Vector Pointer Register 2 - */ -#define ED_3COM_VPTR2 0x0b - -/* - * Vector Pointer Register 1 - */ -#define ED_3COM_VPTR1 0x0c - -/* - * Vector Pointer Register 0 - */ -#define ED_3COM_VPTR0 0x0d - -/* - * Register File Access MSB - */ -#define ED_3COM_RFMSB 0x0e - -/* - * Register File Access LSB - */ -#define ED_3COM_RFLSB 0x0f - -/* - * Definitions for Novell NE1000/2000 boards - */ - -/* - * Board type codes - */ -#define ED_TYPE_NE1000 0x01 -#define ED_TYPE_NE2000 0x02 - -/* - * Register offsets/total - */ -#define ED_NOVELL_NIC_OFFSET 0x00 -#define ED_NOVELL_ASIC_OFFSET 0x10 -#define ED_NOVELL_IO_PORTS 32 - -/* - * Remote DMA data register; for reading or writing to the NIC mem - * via programmed I/O (offset from ASIC base) - */ -#define ED_NOVELL_DATA 0x00 - -/* - * Reset register; reading from this register causes a board reset - */ -#define ED_NOVELL_RESET 0x0f diff --git a/sys/i386/isa/if_ie.c b/sys/i386/isa/if_ie.c deleted file mode 100644 index 2a68b1c..0000000 --- a/sys/i386/isa/if_ie.c +++ /dev/null @@ -1,1799 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, University of Vermont and State - * Agricultural College. - * Copyright (c) 1992, 1993, Garrett A. Wollman. - * - * Portions: - * Copyright (c) 1990, 1991, William F. Jolitz - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * Vermont and State Agricultural College and Garrett A. Wollman, - * by William F. Jolitz, by the University of California, - * Berkeley, by Larwence Berkeley Laboratory, and its contributors. - * 4. Neither the names of the Universities nor the names of the authors - * 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 UNIVERSITY OR AUTHORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id$ - */ - -/* - * Intel 82586 Ethernet chip - * Register, bit, and structure definitions. - * - * Written by GAW with reference to the Clarkson Packet Driver code for this - * chip written by Russ Nelson and others. - * - * BPF support code stolen directly from hpdev/if_le.c, supplied with - * tcpdump. - */ - -/* - * The i82586 is a very versatile chip, found in many implementations. - * Programming this chip is mostly the same, but certain details differ - * from card to card. This driver is written so that different cards - * can be automatically detected at run-time. Currently, only the - * AT&T EN100/StarLAN 10 series are supported. - */ - -/* -Mode of operation: - -We run the 82586 in a standard Ethernet mode. We keep NFRAMES received -frame descriptors around for the receiver to use, and NBUFFS associated -receive buffer descriptors, both in a circular list. Whenever a frame is -received, we rotate both lists as necessary. (The 586 treats both lists -as a simple queue.) We also keep a transmit command around so that packets -can be sent off quickly. - -We configure the adapter in AL-LOC = 1 mode, which means that the -Ethernet/802.3 MAC header is placed at the beginning of the receive buffer -rather than being split off into various fields in the RFD. This also -means that we must include this header in the transmit buffer as well. - -By convention, all transmit commands, and only transmit commands, shall -have the I (IE_CMD_INTR) bit set in the command. This way, when an -interrupt arrives at ieintr(), it is immediately possible to tell -what precisely caused it. ANY OTHER command-sending routines should -run at splimp(), and should post an acknowledgement to every interrupt -they generate. - -The 82586 has a 24-bit address space internally, and the adaptor's -memory is located at the top of this region. However, the value we are -given in configuration is normally the *bottom* of the adaptor RAM. So, -we must go through a few gyrations to come up with a kernel virtual address -which represents the actual beginning of the 586 address space. First, -we autosize the RAM by running through several possible sizes and trying -to initialize the adapter under the assumption that the selected size -is correct. Then, knowing the correct RAM size, we set up our pointers -in ie_softc[unit]. `iomem' represents the computed base of the 586 -address space. `iomembot' represents the actual configured base -of adapter RAM. Finally, `iosize' represents the calculated size -of 586 RAM. Then, when laying out commands, we use the interval -[iomembot, iomembot + iosize); to make 24-pointers, we subtract -iomem, and to make 16-pointers, we subtract iomem and and with 0xffff. - -*/ - -#include "ie.h" -#if NIE > 0 - -#include "param.h" -#include "systm.h" -#include "mbuf.h" -#include "buf.h" -#include "protosw.h" -#include "socket.h" -#include "ioctl.h" -#include "errno.h" -#include "syslog.h" - -#include "net/if.h" -#include "net/if_types.h" -#include "net/if_dl.h" -#include "net/netisr.h" -#include "net/route.h" - -#include "bpfilter.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 - -#ifdef NS -#include "netns/ns.h" -#include "netns/ns_if.h" -#endif - -#include "i386/isa/isa.h" -/*#include "machine/cpufunc.h"*/ -#include "i386/isa/isa_device.h" -#include "i386/isa/ic/i82586.h" -#include "i386/isa/if_iereg.h" -#include "i386/isa/icu.h" - -#include "vm/vm.h" - -#if NBPFILTER > 0 -#include "net/bpf.h" -#include "net/bpfdesc.h" -#endif - -#if (NBPFILTER > 0) || defined(MULTICAST) -#define FILTER -static struct mbuf *last_not_for_us; -#endif - -#ifdef DEBUG -#define IED_RINT 1 -#define IED_TINT 2 -#define IED_RNR 4 -#define IED_CNA 8 -#define IED_READFRAME 16 -int ie_debug = IED_RNR; -#endif - -#ifndef ETHERMINLEN -#define ETHERMINLEN 60 -#endif - -#define IE_BUF_LEN 1512 /* length of transmit buffer */ - -/* Forward declaration */ -struct ie_softc; - -int ieprobe(struct isa_device *dvp); -int ieattach(struct isa_device *dvp); -int ieinit(int unit); -int ieioctl(struct ifnet *ifp, int command, void *data); -int iestart(struct ifnet *ifp); -static void sl_reset_586(int unit); -static void sl_chan_attn(int unit); -int iereset(int unit, int dummy); -static void ie_readframe(int unit, struct ie_softc *ie, int bufno); -static void ie_drop_packet_buffer(int unit, struct ie_softc *ie); -static void sl_read_ether(int unit, unsigned char addr[6]); -static void find_ie_mem_size(int unit); -static int command_and_wait(int unit, int command, void volatile *pcmd, int); -static int ierint(int unit, struct ie_softc *ie); -static int ietint(int unit, struct ie_softc *ie); -static int iernr(int unit, struct ie_softc *ie); -static void start_receiver(int unit); -static int ieget(int, struct ie_softc *, struct mbuf **, - struct ether_header *, int *); -static caddr_t setup_rfa(caddr_t ptr, struct ie_softc *ie); -static int mc_setup(int, caddr_t, volatile struct ie_sys_ctl_block *); -#ifdef MULTICAST -static void ie_mc_reset(int unit); -#endif - -#ifdef DEBUG -void print_rbd(volatile struct ie_recv_buf_desc *rbd); - -int in_ierint = 0; -int in_ietint = 0; -#endif - -/* - * This tells the autoconf code how to set us up. - */ -struct isa_driver iedriver = { - ieprobe, ieattach, "ie", -}; - -enum ie_hardware { - IE_STARLAN10, - IE_EN100, - IE_SLFIBER, - IE_UNKNOWN -}; - -const char *ie_hardware_names[] = { - "StarLAN 10", - "EN100", - "StarLAN Fiber", - "Unknown" -}; - -/* -sizeof(iscp) == 1+1+2+4 == 8 -sizeof(scb) == 2+2+2+2+2+2+2+2 == 16 -NFRAMES * sizeof(rfd) == NFRAMES*(2+2+2+2+6+6+2+2) == NFRAMES*24 == 384 -sizeof(xmit_cmd) == 2+2+2+2+6+2 == 18 -sizeof(transmit buffer) == 1512 -sizeof(transmit buffer desc) == 8 ------ -1946 - -NBUFFS * sizeof(rbd) == NBUFFS*(2+2+4+2+2) == NBUFFS*12 -NBUFFS * IE_RBUF_SIZE == NBUFFS*256 - -NBUFFS should be (16384 - 1946) / (256 + 12) == 14438 / 268 == 53 - -With NBUFFS == 48, this leaves us 1574 bytes for another command or -more buffers. Another transmit command would be 18+8+1512 == 1538 ----just barely fits! - -Obviously all these would have to be reduced for smaller memory sizes. -With a larger memory, it would be possible to roughly double the number of -both transmit and receive buffers. -*/ - -#define NFRAMES 16 /* number of frames to allow for receive */ -#define NBUFFS 48 /* number of buffers to allocate */ -#define IE_RBUF_SIZE 256 /* size of each buffer, MUST BE POWER OF TWO */ - -/* - * Ethernet status, per interface. - */ -struct ie_softc { - struct arpcom arpcom; - void (*ie_reset_586)(int); - void (*ie_chan_attn)(int); - enum ie_hardware hard_type; - int hard_vers; - - u_short port; - caddr_t iomem; - caddr_t iomembot; - unsigned iosize; - - int want_mcsetup; - int promisc; - volatile struct ie_int_sys_conf_ptr *iscp; - volatile struct ie_sys_ctl_block *scb; - volatile struct ie_recv_frame_desc *rframes[NFRAMES]; - volatile struct ie_recv_buf_desc *rbuffs[NBUFFS]; - volatile char *cbuffs[NBUFFS]; - int rfhead, rftail, rbhead, rbtail; - - volatile struct ie_xmit_cmd *xmit_cmds[2]; - volatile struct ie_xmit_buf *xmit_buffs[2]; - int xmit_count; - u_char *xmit_cbuffs[2]; - - struct ie_en_addr mcast_addrs[MAXMCAST + 1]; - int mcast_count; - -#if NBPFILTER > 0 - caddr_t ie_bpf; -#endif - -} ie_softc[NIE]; - -#define MK_24(base, ptr) ((caddr_t)((u_long)ptr - (u_long)base)) -#define MK_16(base, ptr) ((u_short)(u_long)MK_24(base, ptr)) - -#define PORT ie_softc[unit].port -#define MEM ie_softc[unit].iomem - - -int ieprobe(dvp) - struct isa_device *dvp; -{ - int unit = dvp->id_unit; - u_char c; - - ie_softc[unit].port = dvp->id_iobase; - ie_softc[unit].iomembot = dvp->id_maddr; - ie_softc[unit].iomem = 0; - - c = inb(PORT + IEATT_REVISION); - switch(SL_BOARD(c)) { - case SL10_BOARD: - ie_softc[unit].hard_type = IE_STARLAN10; - ie_softc[unit].ie_reset_586 = sl_reset_586; - ie_softc[unit].ie_chan_attn = sl_chan_attn; - break; - case EN100_BOARD: - ie_softc[unit].hard_type = IE_EN100; - ie_softc[unit].ie_reset_586 = sl_reset_586; - ie_softc[unit].ie_chan_attn = sl_chan_attn; - break; - case SLFIBER_BOARD: - ie_softc[unit].hard_type = IE_SLFIBER; - ie_softc[unit].ie_reset_586 = sl_reset_586; - ie_softc[unit].ie_chan_attn = sl_chan_attn; - break; - - /* - * Anything else is not recognized or cannot be used. - */ - default: - return 0; - } - - ie_softc[unit].hard_vers = SL_REV(c); - - /* - * Divine memory size on-board the card. Ususally 16k. - */ - find_ie_mem_size(unit); - - if(!ie_softc[unit].iosize) { - return 0; - } - - dvp->id_msize = ie_softc[unit].iosize; - - switch(ie_softc[unit].hard_type) { - case IE_EN100: - case IE_STARLAN10: - case IE_SLFIBER: - sl_read_ether(unit, ie_softc[unit].arpcom.ac_enaddr); - break; - - default: - printf("ie%d: unknown AT&T board type code %d\n", unit, - ie_softc[unit].hard_type); - return 0; - } - - return 1; -} - -/* - * Taken almost exactly from Bill's if_is.c, then modified beyond recognition. - */ -int -ieattach(dvp) - struct isa_device *dvp; -{ - int unit = dvp->id_unit; - struct ie_softc *ie = &ie_softc[unit]; - struct ifnet *ifp = &ie->arpcom.ac_if; - - ifp->if_unit = unit; - ifp->if_name = iedriver.name; - ifp->if_mtu = ETHERMTU; - printf("<%s R%d> ethernet address %s", - ie_hardware_names[ie_softc[unit].hard_type], - ie_softc[unit].hard_vers + 1, - ether_sprintf(ie->arpcom.ac_enaddr)); - - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; -#ifdef MULTICAST - ifp->if_flags |= IFF_MULTICAST; -#endif /* MULTICAST */ - - ifp->if_init = ieinit; - ifp->if_output = ether_output; - ifp->if_start = iestart; - ifp->if_ioctl = ieioctl; - ifp->if_reset = iereset; - ifp->if_type = IFT_ETHER; - ifp->if_addrlen = 6; - ifp->if_hdrlen = 14; - -#if NBPFILTER > 0 - printf("\n"); - bpfattach(&ie_softc[unit].ie_bpf, ifp, DLT_EN10MB, - sizeof(struct ether_header)); -#endif - - if_attach(ifp); - { - struct ifaddr *ifa = ifp->if_addrlist; - struct sockaddr_dl *sdl; - while(ifa && ifa->ifa_addr && ifa->ifa_addr->sa_family != AF_LINK) - ifa = ifa->ifa_next; - - if(!ifa || !ifa->ifa_addr) return; - - /* Provide our ether address to the higher layers */ - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = 6; - sdl->sdl_slen = 0; - bcopy(ie->arpcom.ac_enaddr, LLADDR(sdl), 6); - } -} - -/* - * What to do upon receipt of an interrupt. - */ -int ieintr(unit) - int unit; -{ - register struct ie_softc *ie = &ie_softc[unit]; - register u_short status; - - status = ie->scb->ie_status; - -loop: - if(status & (IE_ST_RECV | IE_ST_RNR)) { -#ifdef DEBUG - in_ierint++; - if(ie_debug & IED_RINT) - printf("ie%d: rint\n", unit); -#endif - ierint(unit, ie); -#ifdef DEBUG - in_ierint--; -#endif - } - - if(status & IE_ST_DONE) { -#ifdef DEBUG - in_ietint++; - if(ie_debug & IED_TINT) - printf("ie%d: tint\n", unit); -#endif - ietint(unit, ie); -#ifdef DEBUG - in_ietint--; -#endif - } - - if(status & IE_ST_RNR) { -#ifdef DEBUG - if(ie_debug & IED_RNR) - printf("ie%d: rnr\n", unit); -#endif - iernr(unit, ie); - } - -#ifdef DEBUG - if((status & IE_ST_ALLDONE) - && (ie_debug & IED_CNA)) - printf("ie%d: cna\n", unit); -#endif - - /* Don't ack interrupts which we didn't receive */ - ie_ack(ie->scb, IE_ST_WHENCE & status, unit, ie->ie_chan_attn); - - if((status = ie->scb->ie_status) & IE_ST_WHENCE) - goto loop; - - return unit; -} - -/* - * Process a received-frame interrupt. - */ -static int ierint(unit, ie) - int unit; - struct ie_softc *ie; -{ - int i, status; - static int timesthru = 1024; - - i = ie->rfhead; - while(1) { - status = ie->rframes[i]->ie_fd_status; - - if((status & IE_FD_COMPLETE) && (status & IE_FD_OK)) { - ie->arpcom.ac_if.if_ipackets++; - if(!--timesthru) { - ie->arpcom.ac_if.if_ierrors += ie->scb->ie_err_crc + ie->scb->ie_err_align + - ie->scb->ie_err_resource + ie->scb->ie_err_overrun; - ie->scb->ie_err_crc = 0; - ie->scb->ie_err_align = 0; - ie->scb->ie_err_resource = 0; - ie->scb->ie_err_overrun = 0; - timesthru = 1024; - } - ie_readframe(unit, ie, i); - } else { - if(status & IE_FD_RNR) { - if(!(ie->scb->ie_status & IE_RU_READY)) { - ie->rframes[0]->ie_fd_next = MK_16(MEM, ie->rbuffs[0]); - ie->scb->ie_recv_list = MK_16(MEM, ie->rframes[0]); - command_and_wait(unit, IE_RU_START, 0, 0); - } - } - break; - } - i = (i + 1) % NFRAMES; - } - return 0; -} - -/* - * Process a command-complete interrupt. These are only generated by - * the transmission of frames. This routine is deceptively simple, since - * most of the real work is done by iestart(). - */ -static int ietint(unit, ie) - int unit; - struct ie_softc *ie; -{ - int status; - int i; - - ie->arpcom.ac_if.if_timer = 0; - ie->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - - for(i = 0; i < ie->xmit_count; i++) { - status = ie->xmit_cmds[i]->ie_xmit_status; - - if(status & IE_XS_LATECOLL) { - printf("ie%d: late collision\n", unit); - ie->arpcom.ac_if.if_collisions++; - ie->arpcom.ac_if.if_oerrors++; - } else if(status & IE_XS_NOCARRIER) { - printf("ie%d: no carrier\n", unit); - ie->arpcom.ac_if.if_oerrors++; - } else if(status & IE_XS_LOSTCTS) { - printf("ie%d: lost CTS\n", unit); - ie->arpcom.ac_if.if_oerrors++; - } else if(status & IE_XS_UNDERRUN) { - printf("ie%d: DMA underrun\n", unit); - ie->arpcom.ac_if.if_oerrors++; - } else if(status & IE_XS_EXCMAX) { - printf("ie%d: too many collisions\n", unit); - ie->arpcom.ac_if.if_collisions += 16; - ie->arpcom.ac_if.if_oerrors++; - } else { - ie->arpcom.ac_if.if_opackets++; - ie->arpcom.ac_if.if_collisions += status & IE_XS_MAXCOLL; - } - } - ie->xmit_count = 0; - - /* - * If multicast addresses were added or deleted while we were transmitting, - * ie_mc_reset() set the want_mcsetup flag indicating that we should do it. - */ - if(ie->want_mcsetup) { - mc_setup(unit, (caddr_t)ie->xmit_cbuffs[0], ie->scb); - ie->want_mcsetup = 0; - } - - /* Wish I knew why this seems to be necessary... */ - ie->xmit_cmds[0]->ie_xmit_status |= IE_STAT_COMPL; - - iestart(&ie->arpcom.ac_if); - return 0; /* shouldn't be necessary */ -} - -/* - * Process a receiver-not-ready interrupt. I believe that we get these - * when there aren't enough buffers to go around. For now (FIXME), we - * just restart the receiver, and hope everything's ok. - */ -static int iernr(unit, ie) - int unit; - struct ie_softc *ie; -{ -#ifdef doesnt_work - setup_rfa((caddr_t)ie->rframes[0], ie); - - ie->scb->ie_recv_list = MK_16(MEM, ie_softc[unit].rframes[0]); - command_and_wait(unit, IE_RU_START, 0, 0); -#else - /* This doesn't work either, but it doesn't hang either. */ - command_and_wait(unit, IE_RU_DISABLE, 0, 0); /* just in case */ - setup_rfa((caddr_t)ie->rframes[0], ie); /* ignore cast-qual */ - - ie->scb->ie_recv_list = MK_16(MEM, ie_softc[unit].rframes[0]); - command_and_wait(unit, IE_RU_START, 0, 0); /* was ENABLE */ - -#endif - ie_ack(ie->scb, IE_ST_WHENCE, unit, ie->ie_chan_attn); - - ie->arpcom.ac_if.if_ierrors++; - return 0; -} - -#ifdef FILTER -/* - * Compare two Ether/802 addresses for equality, inlined and - * unrolled for speed. I'd love to have an inline assembler - * version of this... - */ -static inline int ether_equal(u_char *one, u_char *two) { - if(one[0] != two[0]) return 0; - if(one[1] != two[1]) return 0; - if(one[2] != two[2]) return 0; - if(one[3] != two[3]) return 0; - if(one[4] != two[4]) return 0; - if(one[5] != two[5]) return 0; - return 1; -} - -/* - * Check for a valid address. to_bpf is filled in with one of the following: - * 0 -> BPF doesn't get this packet - * 1 -> BPF does get this packet - * 2 -> BPF does get this packet, but we don't - * Return value is true if the packet is for us, and false otherwise. - * - * This routine is a mess, but it's also critical that it be as fast - * as possible. It could be made cleaner if we can assume that the - * only client which will fiddle with IFF_PROMISC is BPF. This is - * probably a good assumption, but we do not make it here. (Yet.) - */ -static inline int check_eh(struct ie_softc *ie, - struct ether_header *eh, - int *to_bpf) { - int i; - - switch(ie->promisc) { - case IFF_ALLMULTI: - /* - * Receiving all multicasts, but no unicasts except those destined for us. - */ -#if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); /* BPF gets this packet if anybody cares */ -#endif - if(eh->ether_dhost[0] & 1) { - return 1; - } - if(ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr)) return 1; - return 0; - - case IFF_PROMISC: - /* - * Receiving all packets. These need to be passed on to BPF. - */ -#if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); -#endif - /* If for us, accept and hand up to BPF */ - if(ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr)) return 1; - -#if NBPFILTER > 0 - if(*to_bpf) *to_bpf = 2; /* we don't need to see it */ -#endif - -#ifdef MULTICAST - /* - * Not a multicast, so BPF wants to see it but we don't. - */ - if(!(eh->ether_dhost[0] & 1)) return 1; - - /* - * If it's one of our multicast groups, accept it and pass it - * up. - */ - for(i = 0; i < ie->mcast_count; i++) { - if(ether_equal(eh->ether_dhost, (u_char *)&ie->mcast_addrs[i])) { -#if NBPFILTER > 0 - if(*to_bpf) *to_bpf = 1; -#endif - return 1; - } - } -#endif /* MULTICAST */ - return 1; - - case IFF_ALLMULTI | IFF_PROMISC: - /* - * Acting as a multicast router, and BPF running at the same time. - * Whew! (Hope this is a fast machine...) - */ -#if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); -#endif - /* We want to see multicasts. */ - if(eh->ether_dhost[0] & 1) return 1; - - /* We want to see our own packets */ - if(ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr)) return 1; - - /* Anything else goes to BPF but nothing else. */ -#if NBPFILTER > 0 - if(*to_bpf) *to_bpf = 2; -#endif - return 1; - - default: - /* - * Only accept unicast packets destined for us, or multicasts - * for groups that we belong to. For now, we assume that the - * '586 will only return packets that we asked it for. This - * isn't strictly true (it uses hashing for the multicast filter), - * but it will do in this case, and we want to get out of here - * as quickly as possible. - */ -#if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); -#endif - return 1; - } - return 0; -} -#endif /* FILTER */ - -/* - * We want to isolate the bits that have meaning... This assumes that - * IE_RBUF_SIZE is an even power of two. If somehow the act_len exceeds - * the size of the buffer, then we are screwed anyway. - */ -static inline int ie_buflen(struct ie_softc *ie, int head) { - return (ie->rbuffs[head]->ie_rbd_actual - & (IE_RBUF_SIZE | (IE_RBUF_SIZE - 1))); -} - -static inline int ie_packet_len(int unit, struct ie_softc *ie) { - int i; - int head = ie->rbhead; - int acc = 0; - - do { - if(!(ie->rbuffs[ie->rbhead]->ie_rbd_actual & IE_RBD_USED)) { -#ifdef DEBUG - print_rbd(ie->rbuffs[ie->rbhead]); -#endif - log(LOG_ERR, "ie%d: receive descriptors out of sync at %d\n", - unit, ie->rbhead); - iereset(unit, 0); - return -1; - } - - i = ie->rbuffs[head]->ie_rbd_actual & IE_RBD_LAST; - - acc += ie_buflen(ie, head); - head = (head + 1) % NBUFFS; - } while(!i); - - return acc; -} - -/* - * Read data off the interface, and turn it into an mbuf chain. - * - * This code is DRAMATICALLY different from the previous version; this - * version tries to allocate the entire mbuf chain up front, given the - * length of the data available. This enables us to allocate mbuf - * clusters in many situations where before we would have had a long - * chain of partially-full mbufs. This should help to speed up the - * operation considerably. (Provided that it works, of course.) - */ -static inline int ieget(unit, ie, mp, ehp, to_bpf) - int unit; - struct ie_softc *ie; - struct mbuf **mp; - struct ether_header *ehp; - int *to_bpf; -{ - struct mbuf *m, *top, **mymp; - int i; - int offset; - int totlen, resid; - int thismboff; - int head; - - totlen = ie_packet_len(unit, ie); - if(totlen <= 0) return -1; - - i = ie->rbhead; - - /* - * Snarf the Ethernet header. - */ - bcopy((caddr_t)ie->cbuffs[i], (caddr_t)ehp, sizeof *ehp); - /* ignore cast-qual warning here */ - - /* - * As quickly as possible, check if this packet is for us. - * If not, don't waste a single cycle copying the rest of the - * packet in. - * This is only a consideration when FILTER is defined; i.e., when - * we are either running BPF or doing multicasting. - */ -#ifdef FILTER - if(!check_eh(ie, ehp, to_bpf)) { - ie_drop_packet_buffer(unit, ie); - ie->arpcom.ac_if.if_ierrors--; /* just this case, it's not an error */ - return -1; - } -#endif - totlen -= (offset = sizeof *ehp); - - MGETHDR(*mp, M_DONTWAIT, MT_DATA); - if(!*mp) { - ie_drop_packet_buffer(unit, ie); - return -1; - } - - m = *mp; - m->m_pkthdr.rcvif = &ie->arpcom.ac_if; - m->m_len = MHLEN; - resid = m->m_pkthdr.len = totlen; - top = 0; - mymp = ⊤ - - /* - * This loop goes through and allocates mbufs for all the data we will - * be copying in. It does not actually do the copying yet. - */ - do { /* while(resid > 0) */ - /* - * Try to allocate an mbuf to hold the data that we have. If we - * already allocated one, just get another one and stick it on the - * end (eventually). If we don't already have one, try to allocate - * an mbuf cluster big enough to hold the whole packet, if we think it's - * reasonable, or a single mbuf which may or may not be big enough. - * Got that? - */ - if(top) { - MGET(m, M_DONTWAIT, MT_DATA); - if(!m) { - m_freem(top); - ie_drop_packet_buffer(unit, ie); - return -1; - } - m->m_len = MLEN; - } - - if(resid >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if(m->m_flags & M_EXT) - m->m_len = min(resid, MCLBYTES); - } else { - if(resid < m->m_len) { - if(!top && resid + max_linkhdr <= m->m_len) - m->m_data += max_linkhdr; - m->m_len = resid; - } - } - resid -= m->m_len; - *mymp = m; - mymp = &m->m_next; - } while(resid > 0); - - resid = totlen; - m = top; - thismboff = 0; - head = ie->rbhead; - - /* - * Now we take the mbuf chain (hopefully only one mbuf most of the - * time) and stuff the data into it. There are no possible failures - * at or after this point. - */ - while(resid > 0) { /* while there's stuff left */ - int thislen = ie_buflen(ie, head) - offset; - - /* - * If too much data for the current mbuf, then fill the current one - * up, go to the next one, and try again. - */ - if(thislen > m->m_len - thismboff) { - int newlen = m->m_len - thismboff; - bcopy((caddr_t)(ie->cbuffs[head] + offset), - mtod(m, caddr_t) + thismboff, (unsigned)newlen); - /* ignore cast-qual warning */ - m = m->m_next; - thismboff = 0; /* new mbuf, so no offset */ - offset += newlen; /* we are now this far into the packet */ - resid -= newlen; /* so there is this much left to get */ - continue; - } - - /* - * If there is more than enough space in the mbuf to hold the - * contents of this buffer, copy everything in, advance pointers, - * and so on. - */ - if(thislen < m->m_len - thismboff) { - bcopy((caddr_t)(ie->cbuffs[head] + offset), /* ignore warning */ - mtod(m, caddr_t) + thismboff, (unsigned)thislen); - thismboff += thislen; /* we are this far into the mbuf */ - resid -= thislen; /* and this much is left */ - goto nextbuf; - } - - /* - * Otherwise, there is exactly enough space to put this buffer's - * contents into the current mbuf. Do the combination of the above - * actions. - */ - bcopy((caddr_t)(ie->cbuffs[head] + offset), /* ignore warning */ - mtod(m, caddr_t) + thismboff, (unsigned)thislen); - m = m->m_next; - thismboff = 0; /* new mbuf, start at the beginning */ - resid -= thislen; /* and we are this far through */ - - /* - * Advance all the pointers. We can get here from either of the - * last two cases, but never the first. - */ -nextbuf: - offset = 0; - ie->rbuffs[head]->ie_rbd_actual = 0; - ie->rbuffs[head]->ie_rbd_length |= IE_RBD_LAST; - ie->rbhead = head = (head + 1) % NBUFFS; - ie->rbuffs[ie->rbtail]->ie_rbd_length &= ~IE_RBD_LAST; - ie->rbtail = (ie->rbtail + 1) % NBUFFS; - } - - /* - * Unless something changed strangely while we were doing the copy, - * we have now copied everything in from the shared memory. - * This means that we are done. - */ - return 0; -} - -/* - * Read frame NUM from unit UNIT (pre-cached as IE). - * - * This routine reads the RFD at NUM, and copies in the buffers from - * the list of RBD, then rotates the RBD and RFD lists so that the receiver - * doesn't start complaining. Trailers are DROPPED---there's no point - * in wasting time on confusing code to deal with them. Hopefully, - * this machine will never ARP for trailers anyway. - */ -static void ie_readframe(unit, ie, num) - int unit; - struct ie_softc *ie; - int num; /* frame number to read */ -{ - struct ie_recv_frame_desc rfd; - struct mbuf *m = 0; - struct ether_header eh; -#if NBPFILTER > 0 - int bpf_gets_it = 0; -#endif - - bcopy((caddr_t)(ie->rframes[num]), &rfd, sizeof(struct ie_recv_frame_desc)); - - /* Immediately advance the RFD list, since we we have copied ours now. */ - ie->rframes[num]->ie_fd_status = 0; - ie->rframes[num]->ie_fd_last |= IE_FD_LAST; - ie->rframes[ie->rftail]->ie_fd_last &= ~IE_FD_LAST; - ie->rftail = (ie->rftail + 1) % NFRAMES; - ie->rfhead = (ie->rfhead + 1) % NFRAMES; - - if(rfd.ie_fd_status & IE_FD_OK) { - if( -#if NBPFILTER > 0 - ieget(unit, ie, &m, &eh, &bpf_gets_it) -#else - ieget(unit, ie, &m, &eh, (int *)0) -#endif - ) { - ie->arpcom.ac_if.if_ierrors++; /* this counts as an error */ - return; - } - } - -#ifdef DEBUG - if(ie_debug & IED_READFRAME) { - printf("ie%d: frame from ether %s type %x\n", unit, - ether_sprintf(eh.ether_shost), (unsigned)eh.ether_type); - } - if(ntohs(eh.ether_type) > ETHERTYPE_TRAIL - && ntohs(eh.ether_type) < (ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER)) - printf("received trailer!\n"); -#endif - - if(!m) return; - -#ifdef FILTER - if(last_not_for_us) { - m_freem(last_not_for_us); - last_not_for_us = 0; - } - -#if NBPFILTER > 0 - /* - * Check for a BPF filter; if so, hand it up. - * Note that we have to stick an extra mbuf up front, because - * bpf_mtap expects to have the ether header at the front. - * It doesn't matter that this results in an ill-formatted mbuf chain, - * since BPF just looks at the data. (It doesn't try to free the mbuf, - * tho' it will make a copy for tcpdump.) - */ - if(bpf_gets_it) { - struct mbuf m0; - m0.m_len = sizeof eh; - m0.m_data = (caddr_t)&eh; - m0.m_next = m; - - /* Pass it up */ - bpf_mtap(ie->ie_bpf, &m0); - } - /* - * A signal passed up from the filtering code indicating that the - * packet is intended for BPF but not for the protocol machinery. - * We can save a few cycles by not handing it off to them. - */ - if(bpf_gets_it == 2) { - last_not_for_us = m; - return; - } -#endif /* NBPFILTER > 0 */ - /* - * In here there used to be code to check destination addresses upon - * receipt of a packet. We have deleted that code, and replaced it - * with code to check the address much earlier in the cycle, before - * copying the data in; this saves us valuable cycles when operating - * as a multicast router or when using BPF. - */ -#endif /* FILTER */ - - eh.ether_type = ntohs(eh.ether_type); - - /* - * Finally pass this packet up to higher layers. - */ - ether_input(&ie->arpcom.ac_if, &eh, m); -} - -static void ie_drop_packet_buffer(int unit, struct ie_softc *ie) { - int i; - - do { - /* - * This means we are somehow out of sync. So, we reset the - * adapter. - */ - if(!(ie->rbuffs[ie->rbhead]->ie_rbd_actual & IE_RBD_USED)) { -#ifdef DEBUG - print_rbd(ie->rbuffs[ie->rbhead]); -#endif - log(LOG_ERR, "ie%d: receive descriptors out of sync at %d\n", - unit, ie->rbhead); - iereset(unit, 0); - return; - } - - i = ie->rbuffs[ie->rbhead]->ie_rbd_actual & IE_RBD_LAST; - - ie->rbuffs[ie->rbhead]->ie_rbd_length |= IE_RBD_LAST; - ie->rbuffs[ie->rbhead]->ie_rbd_actual = 0; - ie->rbhead = (ie->rbhead + 1) % NBUFFS; - ie->rbuffs[ie->rbtail]->ie_rbd_length &= ~IE_RBD_LAST; - ie->rbtail = (ie->rbtail + 1) % NBUFFS; - } while(!i); -} - - -/* - * Start transmission on an interface. - */ -int iestart(ifp) - struct ifnet *ifp; -{ - struct ie_softc *ie = &ie_softc[ifp->if_unit]; - struct mbuf *m0, *m; - unsigned char *buffer; - u_short len; - /* This is not really volatile, in this routine, but it makes gcc happy. */ - volatile u_short *bptr = &ie->scb->ie_command_list; - - if(!(ifp->if_flags & IFF_RUNNING)) - return 0; - if(ifp->if_flags & IFF_OACTIVE) - return 0; - - do { - IF_DEQUEUE(&ie->arpcom.ac_if.if_snd, m); - if(!m) - break; - - buffer = ie->xmit_cbuffs[ie->xmit_count]; - len = 0; - - for(m0 = m; m && len < IE_BUF_LEN; m = m->m_next) { - bcopy(mtod(m, caddr_t), buffer, m->m_len); - buffer += m->m_len; - len += m->m_len; - } - - m_freem(m0); - len = MAX(len, ETHERMINLEN); - -#if NBPFILTER > 0 - /* - * See if bpf is listening on this interface, let it see the packet - * before we commit it to the wire. - */ - if(ie->ie_bpf) - bpf_tap(ie->ie_bpf, ie->xmit_cbuffs[ie->xmit_count], len); -#endif - - ie->xmit_buffs[ie->xmit_count]->ie_xmit_flags = IE_XMIT_LAST | len; - ie->xmit_buffs[ie->xmit_count]->ie_xmit_next = 0xffff; - ie->xmit_buffs[ie->xmit_count]->ie_xmit_buf = - MK_24(ie->iomem, ie->xmit_cbuffs[ie->xmit_count]); - - ie->xmit_cmds[ie->xmit_count]->com.ie_cmd_cmd = IE_CMD_XMIT; - ie->xmit_cmds[ie->xmit_count]->ie_xmit_status = 0; - ie->xmit_cmds[ie->xmit_count]->ie_xmit_desc = - MK_16(ie->iomem, ie->xmit_buffs[ie->xmit_count]); - - *bptr = MK_16(ie->iomem, ie->xmit_cmds[ie->xmit_count]); - bptr = &ie->xmit_cmds[ie->xmit_count]->com.ie_cmd_link; - ie->xmit_count++; - } while(ie->xmit_count < 2); - - /* - * If we queued up anything for transmission, send it. - */ - if(ie->xmit_count) { - ie->xmit_cmds[ie->xmit_count - 1]->com.ie_cmd_cmd |= - IE_CMD_LAST | IE_CMD_INTR; - - /* - * By passing the command pointer as a null, we tell - * command_and_wait() to pretend that this isn't an action - * command. I wish I understood what was happening here. - */ - command_and_wait(ifp->if_unit, IE_CU_START, 0, 0); - ifp->if_flags |= IFF_OACTIVE; - } - - return 0; -} - -/* - * Check to see if there's an 82586 out there. - */ -int check_ie_present(unit, where, size) - int unit; - caddr_t where; - unsigned size; -{ - volatile struct ie_sys_conf_ptr *scp; - volatile struct ie_int_sys_conf_ptr *iscp; - volatile struct ie_sys_ctl_block *scb; - u_long realbase; - int s; - - s = splimp(); - - realbase = (u_long)where + size - (1 << 24); - - scp = (volatile struct ie_sys_conf_ptr *)(realbase + IE_SCP_ADDR); - bzero((char *)scp, sizeof *scp); /* ignore cast-qual */ - - /* - * First we put the ISCP at the bottom of memory; this tests to make - * sure that our idea of the size of memory is the same as the controller's. - * This is NOT where the ISCP will be in normal operation. - */ - iscp = (volatile struct ie_int_sys_conf_ptr *)where; - bzero((char *)iscp, sizeof *iscp); /* ignore cast-qual */ - - scb = (volatile struct ie_sys_ctl_block *)where; - bzero((char *)scb, sizeof *scb); /* ignore cast-qual */ - - scp->ie_bus_use = 0; /* 16-bit */ - scp->ie_iscp_ptr = (caddr_t)((volatile caddr_t)iscp - /* ignore cast-qual */ - (volatile caddr_t)realbase); - - iscp->ie_busy = 1; - iscp->ie_scb_offset = MK_16(realbase, scb) + 256; - - (*ie_softc[unit].ie_reset_586)(unit); - (*ie_softc[unit].ie_chan_attn)(unit); - - DELAY(100); /* wait a while... */ - - if(iscp->ie_busy) { - splx(s); - return 0; - } - - /* - * Now relocate the ISCP to its real home, and reset the controller - * again. - */ - iscp = (void *)Align((caddr_t)(realbase + IE_SCP_ADDR - - sizeof(struct ie_int_sys_conf_ptr))); - bzero((char *)iscp, sizeof *iscp); /* ignore cast-qual */ - - scp->ie_iscp_ptr = (caddr_t)((caddr_t)iscp - (caddr_t)realbase); - /* ignore cast-qual */ - - iscp->ie_busy = 1; - iscp->ie_scb_offset = MK_16(realbase, scb); - - (*ie_softc[unit].ie_reset_586)(unit); - (*ie_softc[unit].ie_chan_attn)(unit); - - DELAY(100); - - if(iscp->ie_busy) { - splx(s); - return 0; - } - - ie_softc[unit].iosize = size; - ie_softc[unit].iomem = (caddr_t)realbase; - - ie_softc[unit].iscp = iscp; - ie_softc[unit].scb = scb; - - /* - * Acknowledge any interrupts we may have caused... - */ - ie_ack(scb, IE_ST_WHENCE, unit, ie_softc[unit].ie_chan_attn); - splx(s); - - return 1; -} - -/* - * Divine the memory size of ie board UNIT. - * Better hope there's nothing important hiding just below the ie card... - */ -static void find_ie_mem_size(unit) - int unit; -{ - unsigned size; - - ie_softc[unit].iosize = 0; - - for(size = 65536; size >= 16384; size -= 16384) { - if(check_ie_present(unit, ie_softc[unit].iomembot, size)) { - return; - } - } - - return; -} - -void sl_reset_586(unit) - int unit; -{ - outb(PORT + IEATT_RESET, 0); -} - -void sl_chan_attn(unit) - int unit; -{ - outb(PORT + IEATT_ATTN, 0); -} - -void sl_read_ether(unit, addr) - int unit; - unsigned char addr[6]; -{ - int i; - - for(i = 0; i < 6; i++) - addr[i] = inb(PORT + i); -} - - -int iereset(unit, dummy) - int unit, dummy; -{ - int s = splimp(); - - if(unit >= NIE) { - splx(s); - return -1; - } - - printf("ie%d: reset\n", unit); - ie_softc[unit].arpcom.ac_if.if_flags &= ~IFF_UP; - ieioctl(&ie_softc[unit].arpcom.ac_if, SIOCSIFFLAGS, 0); - - /* - * Stop i82586 dead in its tracks. - */ - if(command_and_wait(unit, IE_RU_ABORT | IE_CU_ABORT, 0, 0)) - printf("ie%d: abort commands timed out\n", unit); - - if(command_and_wait(unit, IE_RU_DISABLE | IE_CU_STOP, 0, 0)) - printf("ie%d: disable commands timed out\n", unit); - -#ifdef notdef - if(!check_ie_present(unit, ie_softc[unit].iomembot, ie_softc[unit].iosize)) - panic("ie disappeared!\n"); -#endif - - ie_softc[unit].arpcom.ac_if.if_flags |= IFF_UP; - ieioctl(&ie_softc[unit].arpcom.ac_if, SIOCSIFFLAGS, 0); - - splx(s); - return 0; -} - -/* - * This is called if we time out. - */ -static int chan_attn_timeout(rock) - caddr_t rock; -{ - *(int *)rock = 1; - return 0; -} - -/* - * Send a command to the controller and wait for it to either - * complete or be accepted, depending on the command. If the - * command pointer is null, then pretend that the command is - * not an action command. If the command pointer is not null, - * and the command is an action command, wait for - * ((volatile struct ie_cmd_common *)pcmd)->ie_cmd_status & MASK - * to become true. - */ -static int command_and_wait(unit, cmd, pcmd, mask) - int unit; - int cmd; - volatile void *pcmd; - int mask; -{ - volatile struct ie_cmd_common *cc = pcmd; - volatile int timedout = 0; - extern int hz; - - ie_softc[unit].scb->ie_command = (u_short)cmd; - - if(IE_ACTION_COMMAND(cmd) && pcmd) { - (*ie_softc[unit].ie_chan_attn)(unit); - - /* - * According to the packet driver, the minimum timeout should be - * .369 seconds, which we round up to .37. - */ - timeout(chan_attn_timeout, (caddr_t)&timedout, 37 * hz / 100); - /* ignore cast-qual */ - - /* - * Now spin-lock waiting for status. This is not a very nice - * thing to do, but I haven't figured out how, or indeed if, we - * can put the process waiting for action to sleep. (We may - * be getting called through some other timeout running in the - * kernel.) - */ - while(1) { - if((cc->ie_cmd_status & mask) || timedout) - break; - } - - untimeout(chan_attn_timeout, (caddr_t)&timedout); - /* ignore cast-qual */ - - return timedout; - } else { - - /* - * Otherwise, just wait for the command to be accepted. - */ - (*ie_softc[unit].ie_chan_attn)(unit); - - while(ie_softc[unit].scb->ie_command) - ; /* spin lock */ - - return 0; - } -} - -/* - * Run the time-domain reflectometer... - */ -static void run_tdr(unit, cmd) - int unit; - struct ie_tdr_cmd *cmd; -{ - int result; - - cmd->com.ie_cmd_status = 0; - cmd->com.ie_cmd_cmd = IE_CMD_TDR | IE_CMD_LAST; - cmd->com.ie_cmd_link = 0xffff; - cmd->ie_tdr_time = 0; - - ie_softc[unit].scb->ie_command_list = MK_16(MEM, cmd); - cmd->ie_tdr_time = 0; - - if(command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL)) - result = 0x2000; - else - result = cmd->ie_tdr_time; - - ie_ack(ie_softc[unit].scb, IE_ST_WHENCE, unit, - ie_softc[unit].ie_chan_attn); - - if(result & IE_TDR_SUCCESS) - return; - - if(result & IE_TDR_XCVR) { - printf("ie%d: transceiver problem\n", unit); - } else if(result & IE_TDR_OPEN) { - printf("ie%d: TDR detected an open %d clocks away\n", unit, - result & IE_TDR_TIME); - } else if(result & IE_TDR_SHORT) { - printf("ie%d: TDR detected a short %d clocks away\n", unit, - result & IE_TDR_TIME); - } else { - printf("ie%d: TDR returned unknown status %x\n", result); - } -} - -static void start_receiver(unit) - int unit; -{ - int s = splimp(); - - ie_softc[unit].scb->ie_recv_list = MK_16(MEM, ie_softc[unit].rframes[0]); - command_and_wait(unit, IE_RU_START, 0, 0); - - ie_ack(ie_softc[unit].scb, IE_ST_WHENCE, unit, ie_softc[unit].ie_chan_attn); - - splx(s); -} - -/* - * Here is a helper routine for iernr() and ieinit(). This sets up - * the RFA. - */ -static caddr_t setup_rfa(caddr_t ptr, struct ie_softc *ie) { - volatile struct ie_recv_frame_desc *rfd = (void *)ptr; - volatile struct ie_recv_buf_desc *rbd; - int i; - int unit = ie - &ie_softc[0]; - - /* First lay them out */ - for(i = 0; i < NFRAMES; i++) { - ie->rframes[i] = rfd; - bzero((char *)rfd, sizeof *rfd); /* ignore cast-qual */ - rfd++; - } - - ptr = (caddr_t)Align((caddr_t)rfd); /* ignore cast-qual */ - - /* Now link them together */ - for(i = 0; i < NFRAMES; i++) { - ie->rframes[i]->ie_fd_next = - MK_16(MEM, ie->rframes[(i + 1) % NFRAMES]); - } - - /* Finally, set the EOL bit on the last one. */ - ie->rframes[NFRAMES - 1]->ie_fd_last |= IE_FD_LAST; - - /* - * Now lay out some buffers for the incoming frames. Note that - * we set aside a bit of slop in each buffer, to make sure that - * we have enough space to hold a single frame in every buffer. - */ - rbd = (void *)ptr; - - for(i = 0; i < NBUFFS; i++) { - ie->rbuffs[i] = rbd; - bzero((char *)rbd, sizeof *rbd); /* ignore cast-qual */ - ptr = (caddr_t)Align(ptr + sizeof *rbd); - rbd->ie_rbd_length = IE_RBUF_SIZE; - rbd->ie_rbd_buffer = MK_24(MEM, ptr); - ie->cbuffs[i] = (void *)ptr; - ptr += IE_RBUF_SIZE; - rbd = (void *)ptr; - } - - /* Now link them together */ - for(i = 0; i < NBUFFS; i++) { - ie->rbuffs[i]->ie_rbd_next = MK_16(MEM, ie->rbuffs[(i + 1) % NBUFFS]); - } - - /* Tag EOF on the last one */ - ie->rbuffs[NBUFFS - 1]->ie_rbd_length |= IE_RBD_LAST; - - /* We use the head and tail pointers on receive to keep track of - * the order in which RFDs and RBDs are used. */ - ie->rfhead = 0; - ie->rftail = NFRAMES - 1; - ie->rbhead = 0; - ie->rbtail = NBUFFS - 1; - - ie->scb->ie_recv_list = MK_16(MEM, ie->rframes[0]); - ie->rframes[0]->ie_fd_buf_desc = MK_16(MEM, ie->rbuffs[0]); - - ptr = Align(ptr); - return ptr; -} - -/* - * Run the multicast setup command. - * Call at splimp(). - */ -static int mc_setup(int unit, caddr_t ptr, - volatile struct ie_sys_ctl_block *scb) { - struct ie_softc *ie = &ie_softc[unit]; - volatile struct ie_mcast_cmd *cmd = (void *)ptr; - - cmd->com.ie_cmd_status = 0; - cmd->com.ie_cmd_cmd = IE_CMD_MCAST | IE_CMD_LAST; - cmd->com.ie_cmd_link = 0xffff; - - /* ignore cast-qual */ - bcopy((caddr_t)ie->mcast_addrs, (caddr_t)cmd->ie_mcast_addrs, - ie->mcast_count * sizeof *ie->mcast_addrs); - - cmd->ie_mcast_bytes = ie->mcast_count * 6; /* grrr... */ - - scb->ie_command_list = MK_16(MEM, cmd); - if(command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL) - || !(cmd->com.ie_cmd_status & IE_STAT_OK)) { - printf("ie%d: multicast address setup command failed\n", unit); - return 0; - } - return 1; -} - -/* - * This routine takes the environment generated by check_ie_present() - * and adds to it all the other structures we need to operate the adapter. - * This includes executing the CONFIGURE, IA-SETUP, and MC-SETUP commands, - * starting the receiver unit, and clearing interrupts. - * - * THIS ROUTINE MUST BE CALLED AT splimp() OR HIGHER. - */ -int ieinit(unit) - int unit; -{ - struct ie_softc *ie = &ie_softc[unit]; - volatile struct ie_sys_ctl_block *scb = ie->scb; - caddr_t ptr; - - ptr = (caddr_t)Align((caddr_t)scb + sizeof *scb); /* ignore cast-qual */ - - /* - * Send the configure command first. - */ - { - volatile struct ie_config_cmd *cmd = (void *)ptr; - - ie_setup_config(cmd, ie->promisc, ie->hard_type == IE_STARLAN10); - cmd->com.ie_cmd_status = 0; - cmd->com.ie_cmd_cmd = IE_CMD_CONFIG | IE_CMD_LAST; - cmd->com.ie_cmd_link = 0xffff; - - scb->ie_command_list = MK_16(MEM, cmd); - - if(command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL) - || !(cmd->com.ie_cmd_status & IE_STAT_OK)) { - printf("ie%d: configure command failed\n", unit); - return 0; - } - } - /* - * Now send the Individual Address Setup command. - */ - { - volatile struct ie_iasetup_cmd *cmd = (void *)ptr; - - cmd->com.ie_cmd_status = 0; - cmd->com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST; - cmd->com.ie_cmd_link = 0xffff; - - bcopy((char *)ie_softc[unit].arpcom.ac_enaddr, (char *)&cmd->ie_address, - sizeof cmd->ie_address); /* ignore cast-qual */ - - scb->ie_command_list = MK_16(MEM, cmd); - if(command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL) - || !(cmd->com.ie_cmd_status & IE_STAT_OK)) { - printf("ie%d: individual address setup command failed\n", unit); - return 0; - } - } - - /* - * Now run the time-domain reflectometer. - */ - run_tdr(unit, (void *)ptr); - - /* - * Acknowledge any interrupts we have generated thus far. - */ - ie_ack(ie->scb, IE_ST_WHENCE, unit, ie->ie_chan_attn); - - /* - * Set up the RFA. - */ - ptr = setup_rfa(ptr, ie); - - /* - * Finally, the transmit command and buffer are the last little bit of work. - */ - ie->xmit_cmds[0] = (void *)ptr; - ptr += sizeof *ie->xmit_cmds[0]; - ptr = Align(ptr); - ie->xmit_buffs[0] = (void *)ptr; - ptr += sizeof *ie->xmit_buffs[0]; - ptr = Align(ptr); - - /* Second transmit command */ - ie->xmit_cmds[1] = (void *)ptr; - ptr += sizeof *ie->xmit_cmds[1]; - ptr = Align(ptr); - ie->xmit_buffs[1] = (void *)ptr; - ptr += sizeof *ie->xmit_buffs[1]; - ptr = Align(ptr); - - /* Both transmit buffers */ - ie->xmit_cbuffs[0] = (void *)ptr; - ptr += IE_BUF_LEN; - ptr = Align(ptr); - ie->xmit_cbuffs[1] = (void *)ptr; - - bzero((caddr_t)ie->xmit_cmds[0], sizeof *ie->xmit_cmds[0]); /* ignore */ - bzero((caddr_t)ie->xmit_buffs[0], sizeof *ie->xmit_buffs[0]); /* cast-qual */ - bzero((caddr_t)ie->xmit_cmds[1], sizeof *ie->xmit_cmds[0]); /* warnings */ - bzero((caddr_t)ie->xmit_buffs[1], sizeof *ie->xmit_buffs[0]); /* here */ - - /* - * This must be coordinated with iestart() and ietint(). - */ - ie->xmit_cmds[0]->ie_xmit_status = IE_STAT_COMPL; - - ie->arpcom.ac_if.if_flags |= IFF_RUNNING; /* tell higher levels that we are here */ - start_receiver(unit); - return 0; -} - -static void ie_stop(unit) - int unit; -{ - command_and_wait(unit, IE_RU_DISABLE, 0, 0); -} - -int ieioctl(ifp, command, data) - struct ifnet *ifp; - int command; - void *data; -{ - struct ifaddr *ifa = (struct ifaddr *)data; - struct ie_softc *ie = &ie_softc[ifp->if_unit]; - int s, error = 0; - - s = splimp(); - - switch(command) { - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch(ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - ieinit(ifp->if_unit); - ((struct arpcom *)ifp)->ac_ipaddr = - IA_SIN(ifa)->sin_addr; - arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr); - break; -#endif /* INET */ - -#ifdef NS - /* This magic copied from if_is.c; I don't use XNS, so I have no - * way of telling if this actually works or not. - */ - case AF_NS: - { - struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - - if(ns_nullhost(*ina)) { - ina->x_host = *(union ns_host *)(ie->arpcom.ac_enaddr); - } else { - ifp->if_flags &= ~IFF_RUNNING; - bcopy((caddr_t)ina->x_host.c_host, - (caddr_t)ie->arpcom.ac_enaddr, - sizeof ie->arpcom.ac_enaddr); - } - - ieinit(ifp->if_unit); - } - break; -#endif /* NS */ - - default: - ieinit(ifp->if_unit); - break; - } - break; - - case SIOCSIFFLAGS: - /* - * Note that this device doesn't have an "all multicast" mode, so we - * must turn on promiscuous mode and do the filtering manually. - */ - if((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING)) { - ifp->if_flags &= ~IFF_RUNNING; - ie_stop(ifp->if_unit); - } else if((ifp->if_flags & IFF_UP) && - (ifp->if_flags & IFF_RUNNING) == 0) { - ie_softc[ifp->if_unit].promisc = - ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI); - ieinit(ifp->if_unit); - } else if(ie_softc[ifp->if_unit].promisc ^ - (ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI))) { - ie_softc[ifp->if_unit].promisc = - ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI); - ieinit(ifp->if_unit); - } - break; - -#ifdef MULTICAST - case SIOCADDMULTI: - case SIOCDELMULTI: - /* - * Update multicast listeners - */ - error = ((command == SIOCADDMULTI) - ? ether_addmulti((struct ifreq *)data, &ie->arpcom) - : ether_delmulti((struct ifreq *)data, &ie->arpcom)); - - if(error == ENETRESET) { - /* reset multicast filtering */ - ie_mc_reset(ifp->if_unit); - error = 0; - } - break; -#endif /* MULTICAST */ - - default: - error = EINVAL; - } - - splx(s); - return error; -} - -#ifdef MULTICAST -static void ie_mc_reset(int unit) { - struct ie_softc *ie = &ie_softc[unit]; - struct ether_multi *enm; - struct ether_multistep step; - - /* - * Step through the list of addresses. - */ - ie->mcast_count = 0; - ETHER_FIRST_MULTI(step, &ie->arpcom, enm); - while(enm) { - if(ie->mcast_count >= MAXMCAST - || bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) { - ie->arpcom.ac_if.if_flags |= IFF_ALLMULTI; - ieioctl(&ie->arpcom.ac_if, SIOCSIFFLAGS, (void *)0); - goto setflag; - } - - bcopy(enm->enm_addrlo, &(ie->mcast_addrs[ie->mcast_count]), 6); - ie->mcast_count++; - ETHER_NEXT_MULTI(step, enm); - } - -setflag: - ie->want_mcsetup = 1; -} - -#endif - -#ifdef DEBUG -void print_rbd(volatile struct ie_recv_buf_desc *rbd) { - printf("RBD at %08lx:\n" - "actual %04x, next %04x, buffer %08x\n" - "length %04x, mbz %04x\n", - (unsigned long)rbd, - rbd->ie_rbd_actual, rbd->ie_rbd_next, rbd->ie_rbd_buffer, - rbd->ie_rbd_length, rbd->mbz); -} -#endif /* DEBUG */ -#endif /* NIE > 0 */ - diff --git a/sys/i386/isa/if_iereg.h b/sys/i386/isa/if_iereg.h deleted file mode 100644 index 3588b84..0000000 --- a/sys/i386/isa/if_iereg.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * $Id$ - * definitions for AT&T StarLAN 10 etc... - */ - -#define IEATT_RESET 0 /* any write here resets the 586 */ -#define IEATT_ATTN 1 /* any write here sends a Chan attn */ -#define IEATT_REVISION 6 /* read here to figure out this board */ -#define IEATT_ATTRIB 7 /* more information about this board */ - -#define SL_BOARD(x) ((x) & 0x0f) -#define SL_REV(x) ((x) >> 4) - -#define SL1_BOARD 0 -#define SL10_BOARD 1 -#define EN100_BOARD 2 -#define SLFIBER_BOARD 3 - -#define SL_ATTR_WIDTH 0x04 /* bus width: clear -> 8-bit */ -#define SL_ATTR_SPEED 0x08 /* medium speed: clear -> 10 Mbps */ -#define SL_ATTR_CODING 0x10 /* encoding: clear -> Manchester */ -#define SL_ATTR_HBW 0x20 /* host bus width: clear -> 16-bit */ -#define SL_ATTR_TYPE 0x40 /* medium type: clear -> Ethernet */ -#define SL_ATTR_BOOTROM 0x80 /* set -> boot ROM present */ diff --git a/sys/i386/isa/if_is.c b/sys/i386/isa/if_is.c deleted file mode 100644 index ceb8401..0000000 --- a/sys/i386/isa/if_is.c +++ /dev/null @@ -1,1008 +0,0 @@ -/* - * Isolan AT 4141-0 Ethernet driver - * Isolink 4110 - * - * By Paul Richards - * - * Copyright (C) 1993, Paul Richards. 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. - * -*/ - -/* TODO - -1) Add working multicast support -2) Use better allocation of memory to card -3) Advertise for more packets until all transmit buffers are full -4) Add more of the timers/counters e.g. arpcom.opackets etc. -*/ - -#include "is.h" -#if NIS > 0 - -#include "bpfilter.h" - -#include "param.h" -#include "systm.h" -#include "errno.h" -#include "ioctl.h" -#include "mbuf.h" -#include "socket.h" -#include "syslog.h" - -#include "net/if.h" -#include "net/if_dl.h" -#include "net/if_types.h" -#include "net/netisr.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 - -#ifdef NS -#include "netns/ns.h" -#include "netns/ns_if.h" -#endif - -#if NBPFILTER > 0 -#include "net/bpf.h" -#include "net/bpfdesc.h" -#endif - -#include "i386/isa/isa_device.h" -#include "i386/isa/if_isreg.h" -#include "i386/isa/icu.h" - -#include "vm/vm.h" - - - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - - -/* - * Ethernet software status per interface. - * - * Each interface is referenced by a network interface structure, - * arpcom.ac_if, which the routing code uses to locate the interface. - * This structure contains the output queue for the interface, its address, ... - */ -struct is_softc { - struct arpcom arpcom; /* Ethernet common part */ - int iobase; /* IO base address of card */ - void *lance_mem; /* Base of memory allocated to card */ - struct mds *rd; - struct mds *td; - unsigned char *rbuf; - unsigned char *tbuf; - int last_rd; - int last_td; - int no_td; - caddr_t bpf; /* BPF "magic cookie" */ - -} is_softc[NIS] ; - -struct init_block init_block[NIS]; - -/* Function prototypes */ -int is_probe(),is_attach(),is_watchdog(); -int is_ioctl(),is_init(),is_start(); - -static inline void is_rint(int unit); -static inline void isread(struct is_softc*, unsigned char*, int); - -struct mbuf *isget(); - -struct isa_driver isdriver = { - is_probe, - is_attach, - "is" -}; - -iswrcsr(unit,port,val) - int unit; - u_short port; - u_short val; -{ - int iobase; - - iobase = is_softc[unit].iobase; - outw(iobase+RAP,port); - outw(iobase+RDP,val); -} - -u_short isrdcsr(unit,port) - int unit; - u_short port; -{ - int iobase; - - iobase = is_softc[unit].iobase; - outw(iobase+RAP,port); - return(inw(iobase+RDP)); -} - -is_probe(isa_dev) - struct isa_device *isa_dev; -{ - int val,i,s; - int unit = isa_dev->id_unit ; - register struct is_softc *is = &is_softc[unit]; - - is->iobase = isa_dev->id_iobase; - - /* Stop the lance chip, put it known state */ - iswrcsr(unit,0,STOP); - DELAY(100); - - /* is there a lance? */ - iswrcsr(unit,3, 0xffff); - if (isrdcsr(unit,3) != 7) { - is->iobase = 0; - return (0); - } - iswrcsr(unit,3, 0); - - /* Extract board address */ - for(i=0;iarpcom.ac_enaddr[i]=inb(is->iobase+(i*2)); - - return (1); -} - - - -/* - * Reset of interface. - */ -int -is_reset(int unit) -{ - int s; - struct is_softc *is = &is_softc[unit]; - - if (unit >= NIS) - return; - s = splnet(); - printf("is%d: reset\n", unit); - is_init(unit); - (void) splx(s); -} - -/* - * Interface exists: make available by filling in network interface - * record. System will initialize the interface when it is ready - * to accept packets. We get the ethernet address here. - */ -int -is_attach(isa_dev) - struct isa_device *isa_dev; -{ - int unit = isa_dev->id_unit; - struct is_softc *is = &is_softc[unit]; - struct ifnet *ifp = &is->arpcom.ac_if; - struct ifaddr *ifa; - struct sockaddr_dl *sdl; - - ifp->if_unit = unit; - ifp->if_name = isdriver.name ; - ifp->if_mtu = ETHERMTU; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; - ifp->if_init = is_init; - ifp->if_output = ether_output; - ifp->if_start = is_start; - ifp->if_ioctl = is_ioctl; - ifp->if_reset = is_reset; - ifp->if_watchdog = is_watchdog; - - /* - * XXX - Set is->lance_mem to NULL so first pass - * through init_mem it won't try and free memory - * This is getting messy and needs redoing. - * Yes, I know NULL != 0 but it does what I want :-) - */ - - is->lance_mem = NULL; - - /* Set up DMA */ - isa_dmacascade(isa_dev->id_drq); - - if_attach(ifp); - - /* - * Search down the ifa address list looking - * for the AF_LINK type entry - */ - - ifa = ifp->if_addrlist; - while ((ifa != 0) && (ifa->ifa_addr != 0) && - (ifa->ifa_addr->sa_family != AF_LINK)) - ifa = ifa->ifa_next; - - /* - * If we find an AF_LINK type entry, we will fill - * in the hardware address for this interface. - */ - - if ((ifa != 0) && (ifa->ifa_addr != 0)) { - - /* - * Fill in the link level address for this interface - */ - - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDR_LEN; - sdl->sdl_slen = 0; - bcopy(is->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); - } - - printf ("is%d: address %s\n", unit, - ether_sprintf(is->arpcom.ac_enaddr)) ; - -#if NBPFILTER > 0 - bpfattach(&is->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif -} - -int -is_watchdog(unit) - int unit; -{ - log(LOG_ERR, "is%d: device timeout\n", unit); - is_reset(unit); -} - - -/* Lance initialisation block set up */ -init_mem(unit) - int unit; -{ - int i; - u_long temp; - struct is_softc *is = &is_softc[unit]; - - /* Allocate memory */ - - /* - * XXX - hopefully have better way to get dma'able memory later, - * this code assumes that the physical memory address returned - * from malloc will be below 16Mb. The Lance's address registers - * are only 16 bits wide! - */ - -#define MAXMEM ((NRBUF+NTBUF)*(BUFSIZE) + (NRBUF+NTBUF)*sizeof(struct mds) + 8) - - /* - * XXX - If we've been here before then free - * the previously allocated memory - */ - if (is->lance_mem) - free(is->lance_mem,M_TEMP); - - is->lance_mem = malloc(MAXMEM,M_TEMP,M_NOWAIT); - if (!is->lance_mem) { - printf("is%d : Couldn't allocate memory for card\n",unit); - return; - } - temp = (u_long) is->lance_mem; - - /* Align message descriptors on quad word boundary - (this is essential) */ - - temp = (temp+8) - (temp%8); - is->rd = (struct mds *) temp; - is->td = (struct mds *) (temp + (NRBUF*sizeof(struct mds))); - temp += (NRBUF+NTBUF) * sizeof(struct mds); - - init_block[unit].mode = 0; - init_block[unit].rdra = kvtop(is->rd); - init_block[unit].rlen = ((kvtop(is->rd) >> 16) & 0xff) | (RLEN<<13); - init_block[unit].tdra = kvtop(is->td); - init_block[unit].tlen = ((kvtop(is->td) >> 16) & 0xff) | (TLEN<<13); - - /* Set up receive ring descriptors */ - - is->rbuf = (unsigned char *)temp; - for (i=0; ird+i)->addr = kvtop(temp); - (is->rd+i)->flags= ((kvtop(temp) >> 16) & 0xff) | OWN; - (is->rd+i)->bcnt = -BUFSIZE; - (is->rd+i)->mcnt = 0; - temp += BUFSIZE; - } - - /* Set up transmit ring descriptors */ - - is->tbuf = (unsigned char *)temp; - for (i=0; itd+i)->addr = kvtop(temp); - (is->td+i)->flags= ((kvtop(temp) >> 16) & 0xff); - (is->td+i)->bcnt = 0; - (is->td+i)->mcnt = 0; - temp += BUFSIZE; - } - -} - -/* - * Initialization of interface; set up initialization block - * and transmit/receive descriptor rings. - */ -is_init(unit) - int unit; -{ - register struct is_softc *is = &is_softc[unit]; - struct ifnet *ifp = &is->arpcom.ac_if; - int s; - register i; - - /* Address not known */ - if (ifp->if_addrlist == (struct ifaddr *)0) return; - - s = splnet(); - is->last_rd = is->last_td = is->no_td = 0; - - /* Set up lance's memory area */ - init_mem(unit); - - /* Stop Lance to get access to other registers */ - iswrcsr(unit,0,STOP); - - /* Get ethernet address */ - for (i=0; iarpcom.ac_enaddr[i]; - -#if NBPFILTER > 0 - /* - * Initialize multicast address hashing registers to accept - * all multicasts (only used when in promiscuous mode) - */ - for (i = 0; i < 8; ++i) - init_block[unit].ladrf[i] = 0xff; -#endif - - - /* No byte swapping etc */ - iswrcsr(unit,3,0); - - /* Give lance the physical address of its memory area */ - iswrcsr(unit,1,kvtop(&init_block[unit])); - iswrcsr(unit,2,(kvtop(&init_block[unit]) >> 16) & 0xff); - - /* OK, let's try and initialise the Lance */ - iswrcsr(unit,0,INIT); - - /* Wait for initialisation to finish */ - for(i=0; i<1000; i++){ - if (isrdcsr(unit,0)&IDON) - break; - } - if (isrdcsr(unit,0)&IDON) { - /* Start lance */ - iswrcsr(unit,0,STRT|IDON|INEA); - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - - is_start(ifp); - } - else - printf("is%d: card failed to initialise\n", unit); - - (void) splx(s); -} - -/* - * Setup output on interface. - * Get another datagram to send off of the interface queue, - * and map it to the interface before starting the output. - * called only at splimp or interrupt level. - */ -is_start(ifp) - struct ifnet *ifp; -{ - int unit = ifp->if_unit; - register struct is_softc *is = &is_softc[unit]; - struct mbuf *m0, *m; - unsigned char *buffer; - u_short len; - int i; - struct mds *cdm; - - - if ((is->arpcom.ac_if.if_flags & IFF_RUNNING) == 0) - return; - - do { - cdm = (is->td + is->last_td); - if (cdm->flags&OWN) - return; - - IF_DEQUEUE(&is->arpcom.ac_if.if_snd, m); - - if (m == 0) - return; - - /* - * Copy the mbuf chain into the transmit buffer - */ - - buffer = is->tbuf+(BUFSIZE*is->last_td); - len=0; - for (m0=m; m != 0; m=m->m_next) { - bcopy(mtod(m,caddr_t),buffer,m->m_len); - buffer += m->m_len; - len += m->m_len; - } -#if NBPFILTER > 0 - if (is->bpf) { - u_short etype; - int off, datasize, resid; - struct ether_header *eh; - struct trailer_header { - u_short ether_type; - u_short ether_residual; - } trailer_header; - char ether_packet[ETHER_MAX_LEN]; - char *ep; - - ep = ether_packet; - - /* - * We handle trailers below: - * Copy ether header first, then residual data, - * then data. Put all this in a temporary buffer - * 'ether_packet' and send off to bpf. Since the - * system has generated this packet, we assume - * that all of the offsets in the packet are - * correct; if they're not, the system will almost - * certainly crash in m_copydata. - * We make no assumptions about how the data is - * arranged in the mbuf chain (i.e. how much - * data is in each mbuf, if mbuf clusters are - * used, etc.), which is why we use m_copydata - * to get the ether header rather than assume - * that this is located in the first mbuf. - */ - /* copy ether header */ - m_copydata(m0, 0, sizeof(struct ether_header), ep); - eh = (struct ether_header *) ep; - ep += sizeof(struct ether_header); - etype = ntohs(eh->ether_type); - if (etype >= ETHERTYPE_TRAIL && - etype < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) { - datasize = ((etype - ETHERTYPE_TRAIL) << 9); - off = datasize + sizeof(struct ether_header); - - /* copy trailer_header into a data structure */ - m_copydata(m0, off, sizeof(struct trailer_header), - &trailer_header.ether_type); - - /* copy residual data */ - resid = trailer_header.ether_residual - - sizeof(struct trailer_header); - resid = ntohs(resid); - m_copydata(m0, off+sizeof(struct trailer_header), - resid, ep); - ep += resid; - - /* copy data */ - m_copydata(m0, sizeof(struct ether_header), - datasize, ep); - ep += datasize; - - /* restore original ether packet type */ - eh->ether_type = trailer_header.ether_type; - - bpf_tap(is->bpf, ether_packet, ep - ether_packet); - } else - bpf_mtap(is->bpf, m0); - } -#endif - - - m_freem(m0); - len = MAX(len,ETHER_MIN_LEN); - - /* - * Init transmit registers, and set transmit start flag. - */ - - cdm->flags |= (OWN|STP|ENP); - cdm->bcnt = -len; - cdm->mcnt = 0; -#if ISDEBUG > 3 - xmit_print(unit,is->last_td); -#endif - - iswrcsr(unit,0,TDMD|INEA); - if (++is->last_td >= NTBUF) - is->last_td=0; - }while(++is->no_td < NTBUF); - is->no_td = NTBUF; - is->arpcom.ac_if.if_flags |= IFF_OACTIVE; -#if ISDEBUG >4 - printf("no_td = %x, last_td = %x\n",is->no_td, is->last_td); -#endif - return(0); -} - - -/* - * Controller interrupt. - */ -isintr(unit) -{ - register struct is_softc *is = &is_softc[unit]; - u_short isr; - - while((isr=isrdcsr(unit,0))&INTR) { - if (isr&ERR) { - if (isr&BABL){ - printf("is%d: BABL\n",unit); - is->arpcom.ac_if.if_oerrors++; - } - if (isr&CERR) { - printf("is%d: CERR\n",unit); - is->arpcom.ac_if.if_collisions++; - } - if (isr&MISS) { - printf("is%d: MISS\n",unit); - is->arpcom.ac_if.if_ierrors++; - } - if (isr&MERR) - printf("is%d: MERR\n",unit); - iswrcsr(unit,0,BABL|CERR|MISS|MERR|INEA); - } - if (!(isr&RXON)) { - printf("is%d: !(isr&RXON)\n", unit); - is->arpcom.ac_if.if_ierrors++; - is_reset(unit); - return(1); - } - if (!(isr&TXON)) { - printf("is%d: !(isr&TXON)\n", unit); - is->arpcom.ac_if.if_oerrors++; - is_reset(unit); - return(1); - } - - if (isr&RINT) { - /* reset watchdog timer */ - is->arpcom.ac_if.if_timer = 0; - is_rint(unit); - } - if (isr&TINT) { - /* reset watchdog timer */ - is->arpcom.ac_if.if_timer = 0; - iswrcsr(unit,0,TINT|INEA); - istint(unit); - } - } -} - -istint(unit) - int unit; -{ - struct is_softc *is = &is_softc[unit]; - register struct ifnet *ifp = &is->arpcom.ac_if; - int i,loopcount=0; - struct mds *cdm; - - is->arpcom.ac_if.if_opackets++; - do { - if ((i=is->last_td - is->no_td) < 0) - i+=NTBUF; - cdm = (is->td+i); -#if ISDEBUG >4 - printf("Trans cdm = %x\n",cdm); -#endif - if (cdm->flags&OWN) { - if (loopcount) - break; - return; - } - loopcount++; - is->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - }while(--is->no_td > 0); - is_start(ifp); - -} - -#define NEXTRDS \ - if (++rmd == NRBUF) rmd=0, cdm=is->rd; else ++cdm - -/* only called from one place, so may as well integrate */ -static inline void is_rint(int unit) -{ - register struct is_softc *is=&is_softc[unit]; - register int rmd = is->last_rd; - struct mds *cdm = (is->rd + rmd); - - /* Out of sync with hardware, should never happen */ - - if (cdm->flags & OWN) { - printf("is%d: error: out of sync\n",unit); - iswrcsr(unit,0,RINT|INEA); - return; - } - - /* Process all buffers with valid data */ - while (!(cdm->flags&OWN)) { - /* Clear interrupt to avoid race condition */ - iswrcsr(unit,0,RINT|INEA); - if (cdm->flags&ERR) { - if (cdm->flags&FRAM) - printf("is%d: FRAM\n",unit); - if (cdm->flags&OFLO) - printf("is%d: OFLO\n",unit); - if (cdm->flags&CRC) - printf("is%d: CRC\n",unit); - if (cdm->flags&RBUFF) - printf("is%d: RBUFF\n",unit); - }else - if (cdm->flags&(STP|ENP) != (STP|ENP)) { - do { - iswrcsr(unit,0,RINT|INEA); - cdm->mcnt = 0; - cdm->flags |= OWN; - NEXTRDS; - }while (!(cdm->flags&(OWN|ERR|STP|ENP))); - is->last_rd = rmd; - printf("is%d: Chained buffer\n",unit); - if ((cdm->flags & (OWN|ERR|STP|ENP)) != ENP) { - is_reset(unit); - return; - } - }else - { -#if ISDEBUG >2 - recv_print(unit,is->last_rd); -#endif - isread(is,is->rbuf+(BUFSIZE*rmd),(int)cdm->mcnt); - is->arpcom.ac_if.if_ipackets++; - } - - cdm->flags |= OWN; - cdm->mcnt = 0; - NEXTRDS; -#if ISDEBUG >4 - printf("is->last_rd = %x, cdm = %x\n",is->last_rd,cdm); -#endif - } /* while */ - is->last_rd = rmd; -} /* is_rint */ - - -/* - * Pass a packet to the higher levels. - * We deal with the trailer protocol here. - */ -static inline void -isread(struct is_softc *is, unsigned char *buf, int len) -{ - register struct ether_header *eh; - struct mbuf *m; - int off, resid; - register struct ifqueue *inq; - - /* - * Deal with trailer protocol: if type is trailer type - * get true type from first 16-bit word past data. - * Remember that type was trailer by setting off. - */ - eh = (struct ether_header *)buf; - eh->ether_type = ntohs((u_short)eh->ether_type); - len = len - sizeof(struct ether_header) - 4; -#define nedataaddr(eh, off, type) ((type)(((caddr_t)((eh)+1)+(off)))) - if (eh->ether_type >= ETHERTYPE_TRAIL && - eh->ether_type < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) { - off = (eh->ether_type - ETHERTYPE_TRAIL) * 512; - if (off >= ETHERMTU) return; /* sanity */ - eh->ether_type = ntohs(*nedataaddr(eh, off, u_short *)); - resid = ntohs(*(nedataaddr(eh, off+2, u_short *))); - if (off + resid > len) return; /* sanity */ - len = off + resid; - } else off = 0; - - if (len == 0) return; - - /* - * Pull packet off interface. Off is nonzero if packet - * has trailing header; neget will then force this header - * information to be at the front, but we still have to drop - * the type and length which are at the front of any trailer data. - */ - is->arpcom.ac_if.if_ipackets++; - m = isget(buf, len, off, &is->arpcom.ac_if); - if (m == 0) return; -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to bpf. - */ - if (is->bpf) { - bpf_mtap(is->bpf, m); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - * - * XXX This test does not support multicasts. - */ - if ((is->arpcom.ac_if.if_flags & IFF_PROMISC) && - bcmp(eh->ether_dhost, is->arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0 && - bcmp(eh->ether_dhost, etherbroadcastaddr, - sizeof(eh->ether_dhost)) != 0) { - - m_freem(m); - return; - } - } -#endif - - - ether_input(&is->arpcom.ac_if, eh, m); -} - -/* - * Supporting routines - */ - -/* - * Pull read data off a interface. - * Len is length of data, with local net header stripped. - * Off is non-zero if a trailer protocol was used, and - * gives the offset of the trailer information. - * We copy the trailer information and then all the normal - * data into mbufs. When full cluster sized units are present - * we copy into clusters. - */ -struct mbuf * -isget(buf, totlen, off0, ifp) - caddr_t buf; - int totlen, off0; - struct ifnet *ifp; -{ - struct mbuf *top, **mp, *m, *p; - int off = off0, len; - register caddr_t cp = buf; - char *epkt; - - buf += sizeof(struct ether_header); - cp = buf; - epkt = cp + totlen; - - - if (off) { - cp += off + 2 * sizeof(u_short); - totlen -= 2 * sizeof(u_short); - } - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return (0); - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = totlen; - m->m_len = MHLEN; - top = 0; - mp = ⊤ - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - return (0); - } - m->m_len = MLEN; - } - len = min(totlen, epkt - cp); - if (len >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - m->m_len = len = min(len, MCLBYTES); - else - len = m->m_len; - } else { - /* - * Place initial small packet/header at end of mbuf. - */ - if (len < m->m_len) { - if (top == 0 && len + max_linkhdr <= m->m_len) - m->m_data += max_linkhdr; - m->m_len = len; - } else - len = m->m_len; - } - bcopy(cp, mtod(m, caddr_t), (unsigned)len); - cp += len; - *mp = m; - mp = &m->m_next; - totlen -= len; - if (cp == epkt) - cp = buf; - } - return (top); -} - - -/* - * Process an ioctl request. - */ -is_ioctl(ifp, cmd, data) - register struct ifnet *ifp; - int cmd; - caddr_t data; -{ - register struct ifaddr *ifa = (struct ifaddr *)data; - int unit = ifp->if_unit; - struct is_softc *is = &is_softc[unit]; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splnet(); - - switch (cmd) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - is_init(ifp->if_unit); /* before arpwhohas */ - /* - * See if another station has *our* IP address. - * i.e.: There is an address conflict! If a - * conflict exists, a message is sent to the - * console. - */ - ((struct arpcom *)ifp)->ac_ipaddr = - IA_SIN(ifa)->sin_addr; - arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - /* - * XXX - This code is probably wrong - */ - case AF_NS: - { - register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(is->arpcom.ac_enaddr); - else { - /* - * - */ - bcopy((caddr_t)ina->x_host.c_host, - (caddr_t)is->arpcom.ac_enaddr, - sizeof(is->arpcom.ac_enaddr)); - } - /* - * Set new address - */ - is_init(ifp->if_unit); - break; - } -#endif - default: - is_init(ifp->if_unit); - break; - } - break; - - case SIOCSIFFLAGS: - /* - * If interface is marked down and it is running, then stop it - */ - if ((ifp->if_flags & IFF_UP) == 0 && - ifp->if_flags & IFF_RUNNING) { - iswrcsr(unit,0,STOP); - ifp->if_flags &= ~IFF_RUNNING; - } else { - /* - * If interface is marked up and it is stopped, then start it - */ - if ((ifp->if_flags & IFF_UP) && - (ifp->if_flags & IFF_RUNNING) == 0) - is_init(ifp->if_unit); - } -#if NBPFILTER > 0 - if (ifp->if_flags & IFF_PROMISC) { - /* - * Set promiscuous mode on interface. - * XXX - for multicasts to work, we would need to - * write 1's in all bits of multicast - * hashing array. For now we assume that - * this was done in is_init(). - */ - init_block[unit].mode = PROM; - } else - /* - * XXX - for multicasts to work, we would need to - * rewrite the multicast hashing array with the - * proper hash (would have been destroyed above). - */ - { /* Don't know about this */}; -#endif - break; - -#ifdef notdef - case SIOCGHWADDR: - bcopy((caddr_t)is->arpcom.ac_enaddr, (caddr_t) &ifr->ifr_data, - sizeof(is->arpcom.ac_enaddr)); - break; -#endif - - default: - error = EINVAL; - } - (void) splx(s); - return (error); -} - -#ifdef ISDEBUG -recv_print(unit,no) - int unit,no; -{ - register struct is_softc *is=&is_softc[unit]; - struct mds *rmd; - int len,i,printed=0; - - rmd = (is->rd+no); - len = rmd->mcnt; - printf("is%d: Receive buffer %d, len = %d\n",unit,no,len); - printf("is%d: Status %x\n",unit,isrdcsr(unit,0)); - for (i=0; irbuf+(BUFSIZE*no)+i)); - } - if (printed) - printf("\n"); -} - -xmit_print(unit,no) - int unit,no; -{ - register struct is_softc *is=&is_softc[unit]; - struct mds *rmd; - int i, printed=0; - u_short len; - - rmd = (is->td+no); - len = -(rmd->bcnt); - printf("is%d: Transmit buffer %d, len = %d\n",unit,no,len); - printf("is%d: Status %x\n",unit,isrdcsr(unit,0)); - printf("is%d: addr %x, flags %x, bcnt %x, mcnt %x\n", - unit,rmd->addr,rmd->flags,rmd->bcnt,rmd->mcnt); - for (i=0; itbuf+(BUFSIZE*no)+i)); - } - if (printed) - printf("\n"); -} -#endif /* ISDEBUG */ - -#endif /* NIS > 0 */ diff --git a/sys/i386/isa/if_isreg.h b/sys/i386/isa/if_isreg.h deleted file mode 100644 index 5e69064..0000000 --- a/sys/i386/isa/if_isreg.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Isolan AT 4141-0 Ethernet driver header file - * Isolink 4110 - * - * By Paul Richards - * - * Copyright (C) 1993, Paul Richards. 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. - * - * $Id$ - */ - -/* Declarations specific to this driver */ -#define NTBUF 2 -#define TLEN 1 -#define NRBUF 8 -#define RLEN 3 -#define BUFSIZE 1518 -#define RAP 0xe -#define RDP 0xc - -/* Control and status register 0 flags */ - -#define ERR 0x8000 -#define BABL 0x4000 -#define CERR 0x2000 -#define MISS 0x1000 -#define MERR 0x0800 -#define RINT 0x0400 -#define TINT 0x0200 -#define IDON 0x0100 -#define INTR 0x0080 -#define INEA 0x0040 -#define RXON 0x0020 -#define TXON 0x0010 -#define TDMD 0x0008 -#define STOP 0x0004 -#define STRT 0x0002 -#define INIT 0x0001 - -/* Coontrol and status register 3 flags */ - -#define BSWP 0x0004 -#define ACON 0x0002 -#define BCON 0x0001 - -/* Initialisation block (must be on word boundary) */ - -struct init_block { - u_short mode; /* Mode register */ - u_char padr[6]; /* Ethernet address */ - u_char ladrf[8]; /* Logical address filter (multicast) */ - u_short rdra; /* Low order pointer to receive ring */ - u_short rlen; /* High order pointer and no. rings */ - u_short tdra; /* Low order pointer to transmit ring */ - u_short tlen; /* High order pointer and no rings */ - }; - -/* Mode settings */ - -#define PROM 0x8000 /* Promiscuous */ -#define INTL 0x0040 /* Internal loopback */ -#define DRTY 0x0020 /* Disable retry */ -#define COLL 0x0010 /* Force collision */ -#define DTCR 0x0008 /* Disable transmit crc */ -#define LOOP 0x0004 /* Loop back */ -#define DTX 0x0002 /* Disable transmitter */ -#define DRX 0x0001 /* Disable receiver */ - -/* Message descriptor structure */ - -struct mds { - u_short addr; - u_short flags; - u_short bcnt; - u_short mcnt; - }; - -/* Receive ring status flags */ - -#define OWN 0x8000 /* Owner bit, 0=host, 1=Lance */ -#define MDERR 0x4000 /* Error */ -#define FRAM 0x2000 /* Framing error error */ -#define OFLO 0x1000 /* Silo overflow */ -#define CRC 0x0800 /* CRC error */ -#define RBUFF 0x0400 /* Buffer error */ -#define STP 0x0200 /* Start of packet */ -#define ENP 0x0100 /* End of packet */ - -/* Transmit ring flags */ - -#define MORE 0x1000 /* More than 1 retry */ -#define ONE 0x0800 /* One retry */ -#define DEF 0x0400 /* Deferred transmit */ - -/* Transmit errors */ - -#define TBUFF 0x8000 /* Buffer error */ -#define UFLO 0x4000 /* Silo underflow */ -#define LCOL 0x1000 /* Late collision */ -#define LCAR 0x0800 /* Loss of carrier */ -#define RTRY 0x0400 /* Tried 16 times */ diff --git a/sys/i386/isa/isa.c b/sys/i386/isa/isa.c deleted file mode 100644 index ec08312..0000000 --- a/sys/i386/isa/isa.c +++ /dev/null @@ -1,791 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)isa.c 7.2 (Berkeley) 5/13/91 - * $Id: isa.c,v 1.4 1993/10/13 15:59:28 rgrimes Exp $ - */ - -/* - * code to manage AT bus - * - * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com): - * Fixed uninitialized variable problem and added code to deal - * with DMA page boundaries in isa_dmarangecheck(). Fixed word - * mode DMA count compution and reorganized DMA setup code in - * isa_dmastart() - */ - -#include "param.h" -#include "systm.h" -#include "conf.h" -#include "file.h" -#include "buf.h" -#include "uio.h" -#include "syslog.h" -#include "malloc.h" -#include "rlist.h" -#include "machine/segments.h" -#include "vm/vm.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/isa.h" -#include "i386/isa/icu.h" -#include "i386/isa/ic/i8237.h" -#include "i386/isa/ic/i8042.h" - -/* -** Register definitions for DMA controller 1 (channels 0..3): -*/ -#define DMA1_CHN(c) (IO_DMA1 + 1*(2*(c))) /* addr reg for channel c */ -#define DMA1_SMSK (IO_DMA1 + 1*10) /* single mask register */ -#define DMA1_MODE (IO_DMA1 + 1*11) /* mode register */ -#define DMA1_FFC (IO_DMA1 + 1*12) /* clear first/last FF */ - -/* -** Register definitions for DMA controller 2 (channels 4..7): -*/ -#define DMA2_CHN(c) (IO_DMA2 + 2*(2*(c))) /* addr reg for channel c */ -#define DMA2_SMSK (IO_DMA2 + 2*10) /* single mask register */ -#define DMA2_MODE (IO_DMA2 + 2*11) /* mode register */ -#define DMA2_FFC (IO_DMA2 + 2*12) /* clear first/last FF */ - -int config_isadev __P((struct isa_device *, u_int *)); - -/* - * print a conflict message - */ -void -conflict(dvp, tmpdvp, item, reason, format) - struct isa_device *dvp, *tmpdvp; - int item; - char *reason; - char *format; -{ - printf("%s%d not probed due to %s conflict with %s%d at ", - dvp->id_driver->name, dvp->id_unit, reason, - tmpdvp->id_driver->name, tmpdvp->id_unit); - printf(format, item); - printf("\n"); -} - -/* - * Check to see if things are alread in use, like IRQ's, I/O addresses - * and Memory addresses. - */ -int -haveseen(dvp, tmpdvp) - struct isa_device *dvp, *tmpdvp; -{ - int status = 0; - - /* - * Only check against devices that have already been found - */ - if (tmpdvp->id_alive) { - /* - * Check for I/O address conflict. We can only check the - * starting address of the device against the range of the - * device that has already been probed since we do not - * know how many I/O addresses this device uses. - */ - if (tmpdvp->id_alive != -1) { - if ((dvp->id_iobase >= tmpdvp->id_iobase) && - (dvp->id_iobase <= - (tmpdvp->id_iobase + tmpdvp->id_alive - 1))) { - conflict(dvp, tmpdvp, dvp->id_iobase, - "I/O address", "0x%x"); - status = 1; - } - } - /* - * Check for Memory address conflict. We can check for - * range overlap, but it will not catch all cases since the - * driver may adjust the msize paramater during probe, for - * now we just check that the starting address does not - * fall within any allocated region. - * XXX could add a second check after the probe for overlap, - * since at that time we would know the full range. - * XXX KERNBASE is a hack, we should have vaddr in the table! - */ - if(tmpdvp->id_maddr) { - if((KERNBASE + dvp->id_maddr >= tmpdvp->id_maddr) && - (KERNBASE + dvp->id_maddr <= - (tmpdvp->id_maddr + tmpdvp->id_msize - 1))) { - conflict(dvp, tmpdvp, dvp->id_maddr, "maddr", - "0x%x"); - status = 1; - } - } - /* - * Check for IRQ conflicts. - */ - if(tmpdvp->id_irq) { - if (tmpdvp->id_irq == dvp->id_irq) { - conflict(dvp, tmpdvp, ffs(dvp->id_irq) - 1, - "irq", "%d"); - status = 1; - } - } - /* - * Check for DRQ conflicts. - */ - if(tmpdvp->id_drq != -1) { - if (tmpdvp->id_drq == dvp->id_drq) { - conflict(dvp, tmpdvp, dvp->id_drq, - "drq", "%d"); - status = 1; - } - } - } - return (status); -} - -/* - * Search through all the isa_devtab_* tables looking for anything that - * conflicts with the current device. - */ -int -haveseen_isadev(dvp) - struct isa_device *dvp; -{ - struct isa_device *tmpdvp; - int status = 0; - - for (tmpdvp = isa_devtab_tty; tmpdvp->id_driver; tmpdvp++) { - status |= haveseen(dvp, tmpdvp); - } - for (tmpdvp = isa_devtab_bio; tmpdvp->id_driver; tmpdvp++) { - status |= haveseen(dvp, tmpdvp); - } - for (tmpdvp = isa_devtab_net; tmpdvp->id_driver; tmpdvp++) { - status |= haveseen(dvp, tmpdvp); - } - for (tmpdvp = isa_devtab_null; tmpdvp->id_driver; tmpdvp++) { - status |= haveseen(dvp, tmpdvp); - } - return(status); -} - -/* - * Configure all ISA devices - */ -void -isa_configure() { - struct isa_device *dvp; - - enable_intr(); - splhigh(); - INTREN(IRQ_SLAVE); - printf("Probing for devices on the ISA bus:\n"); - for (dvp = isa_devtab_tty; dvp->id_driver; dvp++) { - if (!haveseen_isadev(dvp)) - config_isadev(dvp,&ttymask); - } - for (dvp = isa_devtab_bio; dvp->id_driver; dvp++) { - if (!haveseen_isadev(dvp)) - config_isadev(dvp,&biomask); - } - for (dvp = isa_devtab_net; dvp->id_driver; dvp++) { - if (!haveseen_isadev(dvp)) - config_isadev(dvp,&netmask); - } - for (dvp = isa_devtab_null; dvp->id_driver; dvp++) { - if (!haveseen_isadev(dvp)) - config_isadev(dvp,(u_int *) NULL); - } -/* - * XXX We should really add the tty device to netmask when the line is - * switched to SLIPDISC, and then remove it when it is switched away from - * SLIPDISC. No need to block out ALL ttys during a splnet when only one - * of them is running slip. - */ -#include "sl.h" -#if NSL > 0 - netmask |= ttymask; - ttymask |= netmask; -#endif - /* biomask |= ttymask ; can some tty devices use buffers? */ - printf("biomask %x ttymask %x netmask %x\n", biomask, ttymask, netmask); - splnone(); -} - -/* - * Configure an ISA device. - */ -config_isadev(isdp, mp) - struct isa_device *isdp; - u_int *mp; -{ - struct isa_driver *dp = isdp->id_driver; - - if (isdp->id_maddr) { - extern u_int atdevbase; - - isdp->id_maddr -= 0xa0000; /* XXX should be a define */ - isdp->id_maddr += atdevbase; - } - isdp->id_alive = (*dp->probe)(isdp); - if (isdp->id_alive) { - /* - * Only print the I/O address range if id_alive != -1 - * Right now this is a temporary fix just for the new - * NPX code so that if it finds a 486 that can use trap - * 16 it will not report I/O addresses. - * Rod Grimes 04/26/94 - */ - printf("%s%d", dp->name, isdp->id_unit); - if (isdp->id_alive != -1) { - printf(" at 0x%x", isdp->id_iobase); - if ((isdp->id_iobase + isdp->id_alive - 1) != - isdp->id_iobase) { - printf("-0x%x", - isdp->id_iobase + - isdp->id_alive - 1); - } - } - if(isdp->id_irq) - printf(" irq %d", ffs(isdp->id_irq) - 1); - if (isdp->id_drq != -1) - printf(" drq %d", isdp->id_drq); - if (isdp->id_maddr) - printf(" maddr 0x%x", kvtop(isdp->id_maddr)); - if (isdp->id_msize) - printf(" msize %d", isdp->id_msize); - if (isdp->id_flags) - printf(" flags 0x%x", isdp->id_flags); - if (isdp->id_iobase < 0x100) - printf(" on motherboard\n"); - else - printf(" on isa\n"); - - (*dp->attach)(isdp); - - if(isdp->id_irq) { - int intrno; - - intrno = ffs(isdp->id_irq)-1; - setidt(ICU_OFFSET+intrno, isdp->id_intr, - SDT_SYS386IGT, SEL_KPL); - if(mp) { - INTRMASK(*mp,isdp->id_irq); - } - INTREN(isdp->id_irq); - } - } else { - printf("%s%d not found", dp->name, isdp->id_unit); - if (isdp->id_iobase) { - printf(" at 0x%x", isdp->id_iobase); - } - printf("\n"); - } -} - -#define IDTVEC(name) __CONCAT(X,name) -/* default interrupt vector table entries */ -extern IDTVEC(intr0), IDTVEC(intr1), IDTVEC(intr2), IDTVEC(intr3), - IDTVEC(intr4), IDTVEC(intr5), IDTVEC(intr6), IDTVEC(intr7), - IDTVEC(intr8), IDTVEC(intr9), IDTVEC(intr10), IDTVEC(intr11), - IDTVEC(intr12), IDTVEC(intr13), IDTVEC(intr14), IDTVEC(intr15); - -static *defvec[16] = { - &IDTVEC(intr0), &IDTVEC(intr1), &IDTVEC(intr2), &IDTVEC(intr3), - &IDTVEC(intr4), &IDTVEC(intr5), &IDTVEC(intr6), &IDTVEC(intr7), - &IDTVEC(intr8), &IDTVEC(intr9), &IDTVEC(intr10), &IDTVEC(intr11), - &IDTVEC(intr12), &IDTVEC(intr13), &IDTVEC(intr14), &IDTVEC(intr15) }; - -/* out of range default interrupt vector gate entry */ -extern IDTVEC(intrdefault); - -/* - * Fill in default interrupt table (in case of spuruious interrupt - * during configuration of kernel, setup interrupt control unit - */ -isa_defaultirq() { - int i; - - /* icu vectors */ - for (i = NRSVIDT ; i < NRSVIDT+ICU_LEN ; i++) - setidt(i, defvec[i], SDT_SYS386IGT, SEL_KPL); - - /* out of range vectors */ - for (i = NRSVIDT; i < NIDT; i++) - setidt(i, &IDTVEC(intrdefault), SDT_SYS386IGT, SEL_KPL); - - /* initialize 8259's */ - outb(IO_ICU1, 0x11); /* reset; program device, four bytes */ - outb(IO_ICU1+1, NRSVIDT); /* starting at this vector index */ - outb(IO_ICU1+1, 1<<2); /* slave on line 2 */ -#ifdef AUTO_EOI_1 - outb(IO_ICU1+1, 2 | 1); /* auto EOI, 8086 mode */ -#else - outb(IO_ICU1+1, 1); /* 8086 mode */ -#endif - outb(IO_ICU1+1, 0xff); /* leave interrupts masked */ - outb(IO_ICU1, 0x0a); /* default to IRR on read */ - outb(IO_ICU1, 0xc0 | (3 - 1)); /* pri order 3-7, 0-2 (com2 first) */ - - outb(IO_ICU2, 0x11); /* reset; program device, four bytes */ - outb(IO_ICU2+1, NRSVIDT+8); /* staring at this vector index */ - outb(IO_ICU2+1,2); /* my slave id is 2 */ -#ifdef AUTO_EOI_2 - outb(IO_ICU2+1, 2 | 1); /* auto EOI, 8086 mode */ -#else - outb(IO_ICU2+1,1); /* 8086 mode */ -#endif - outb(IO_ICU2+1, 0xff); /* leave interrupts masked */ - outb(IO_ICU2, 0x0a); /* default to IRR on read */ -} - -/* region of physical memory known to be contiguous */ -vm_offset_t isaphysmem; -static caddr_t dma_bounce[8]; /* XXX */ -static char bounced[8]; /* XXX */ -#define MAXDMASZ 512 /* XXX */ - -/* high byte of address is stored in this port for i-th dma channel */ -static short dmapageport[8] = - { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a }; - -/* - * isa_dmacascade(): program 8237 DMA controller channel to accept - * external dma control by a board. - */ -void isa_dmacascade(unsigned chan) -{ - if (chan > 7) - panic("isa_dmacascade: impossible request"); - - /* set dma channel mode, and set dma channel mode */ - if ((chan & 4) == 0) { - outb(DMA1_MODE, DMA37MD_CASCADE | chan); - outb(DMA1_SMSK, chan); - } else { - outb(DMA2_MODE, DMA37MD_CASCADE | (chan & 3)); - outb(DMA2_SMSK, chan & 3); - } -} - -/* - * isa_dmastart(): program 8237 DMA controller channel, avoid page alignment - * problems by using a bounce buffer. - */ -void isa_dmastart(int flags, caddr_t addr, unsigned nbytes, unsigned chan) -{ vm_offset_t phys; - int waport; - caddr_t newaddr; - - if ( chan > 7 - || (chan < 4 && nbytes > (1<<16)) - || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1))) - panic("isa_dmastart: impossible request"); - - if (isa_dmarangecheck(addr, nbytes, chan)) { - if (dma_bounce[chan] == 0) - dma_bounce[chan] = - /*(caddr_t)malloc(MAXDMASZ, M_TEMP, M_WAITOK);*/ - (caddr_t) isaphysmem + NBPG*chan; - bounced[chan] = 1; - newaddr = dma_bounce[chan]; - *(int *) newaddr = 0; /* XXX */ - - /* copy bounce buffer on write */ - if (!(flags & B_READ)) - bcopy(addr, newaddr, nbytes); - addr = newaddr; - } - - /* translate to physical */ - phys = pmap_extract(pmap_kernel(), (vm_offset_t)addr); - - if ((chan & 4) == 0) { - /* - * Program one of DMA channels 0..3. These are - * byte mode channels. - */ - /* set dma channel mode, and reset address ff */ - if (flags & B_READ) - outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|chan); - else - outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_READ|chan); - outb(DMA1_FFC, 0); - - /* send start address */ - waport = DMA1_CHN(chan); - outb(waport, phys); - outb(waport, phys>>8); - outb(dmapageport[chan], phys>>16); - - /* send count */ - outb(waport + 1, --nbytes); - outb(waport + 1, nbytes>>8); - - /* unmask channel */ - outb(DMA1_SMSK, chan); - } else { - /* - * Program one of DMA channels 4..7. These are - * word mode channels. - */ - /* set dma channel mode, and reset address ff */ - if (flags & B_READ) - outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|(chan&3)); - else - outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_READ|(chan&3)); - outb(DMA2_FFC, 0); - - /* send start address */ - waport = DMA2_CHN(chan - 4); - outb(waport, phys>>1); - outb(waport, phys>>9); - outb(dmapageport[chan], phys>>16); - - /* send count */ - nbytes >>= 1; - outb(waport + 2, --nbytes); - outb(waport + 2, nbytes>>8); - - /* unmask channel */ - outb(DMA2_SMSK, chan & 3); - } -} - -void isa_dmadone(int flags, caddr_t addr, int nbytes, int chan) -{ - - /* copy bounce buffer on read */ - /*if ((flags & (B_PHYS|B_READ)) == (B_PHYS|B_READ))*/ - if (bounced[chan]) { - bcopy(dma_bounce[chan], addr, nbytes); - bounced[chan] = 0; - } -} - -/* - * Check for problems with the address range of a DMA transfer - * (non-contiguous physical pages, outside of bus address space, - * crossing DMA page boundaries). - * Return true if special handling needed. - */ - -isa_dmarangecheck(caddr_t va, unsigned length, unsigned chan) { - vm_offset_t phys, priorpage = 0, endva; - u_int dma_pgmsk = (chan & 4) ? ~(128*1024-1) : ~(64*1024-1); - - endva = (vm_offset_t)round_page(va + length); - for (; va < (caddr_t) endva ; va += NBPG) { - phys = trunc_page(pmap_extract(pmap_kernel(), (vm_offset_t)va)); -#define ISARAM_END RAM_END - if (phys == 0) - panic("isa_dmacheck: no physical page present"); - if (phys > ISARAM_END) - return (1); - if (priorpage) { - if (priorpage + NBPG != phys) - return (1); - /* check if crossing a DMA page boundary */ - if (((u_int)priorpage ^ (u_int)phys) & dma_pgmsk) - return (1); - } - priorpage = phys; - } - return (0); -} - -/* head of queue waiting for physmem to become available */ -struct buf isa_physmemq; - -/* blocked waiting for resource to become free for exclusive use */ -static isaphysmemflag; -/* if waited for and call requested when free (B_CALL) */ -static void (*isaphysmemunblock)(); /* needs to be a list */ - -/* - * Allocate contiguous physical memory for transfer, returning - * a *virtual* address to region. May block waiting for resource. - * (assumed to be called at splbio()) - */ -caddr_t -isa_allocphysmem(caddr_t va, unsigned length, void (*func)()) { - - isaphysmemunblock = func; - while (isaphysmemflag & B_BUSY) { - isaphysmemflag |= B_WANTED; - sleep(&isaphysmemflag, PRIBIO); - } - isaphysmemflag |= B_BUSY; - - return((caddr_t)isaphysmem); -} - -/* - * Free contiguous physical memory used for transfer. - * (assumed to be called at splbio()) - */ -void -isa_freephysmem(caddr_t va, unsigned length) { - - isaphysmemflag &= ~B_BUSY; - if (isaphysmemflag & B_WANTED) { - isaphysmemflag &= B_WANTED; - wakeup(&isaphysmemflag); - if (isaphysmemunblock) - (*isaphysmemunblock)(); - } -} - -/* - * Handle a NMI, possibly a machine check. - * return true to panic system, false to ignore. - */ -isa_nmi(cd) { - - log(LOG_CRIT, "\nNMI port 61 %x, port 70 %x\n", inb(0x61), inb(0x70)); - return(0); -} - -/* - * Caught a stray interrupt, notify - */ -isa_strayintr(d) { - - /* DON'T BOTHER FOR NOW! */ - /* for some reason, we get bursts of intr #7, even if not enabled! */ - /* - * Well the reason you got bursts of intr #7 is because someone - * raised an interrupt line and dropped it before the 8259 could - * prioritize it. This is documented in the intel data book. This - * means you have BAD hardware! I have changed this so that only - * the first 5 get logged, then it quits logging them, and puts - * out a special message. rgrimes 3/25/1993 - */ - extern u_long intrcnt_stray; - - intrcnt_stray++; - if (intrcnt_stray <= 5) - log(LOG_ERR,"ISA strayintr %x\n", d); - if (intrcnt_stray == 5) - log(LOG_CRIT,"Too many ISA strayintr not logging any more\n"); -} - -/* - * Wait "n" microseconds. - * Relies on timer 1 counting down from (TIMER_FREQ / hz) at - * (1 * TIMER_FREQ) Hz. - * Note: timer had better have been programmed before this is first used! - * (The standard programming causes the timer to generate a square wave and - * the counter is decremented twice every cycle.) - */ -#define CF (1 * TIMER_FREQ) -#define TIMER_FREQ 1193182 /* XXX - should be elsewhere */ - -extern int hz; /* XXX - should be elsewhere */ - -int DELAY(n) - int n; -{ - int counter_limit; - int prev_tick; - int tick; - int ticks_left; - int sec; - int usec; - -#ifdef DELAYDEBUG - int getit_calls = 1; - int n1; - static int state = 0; - - if (state == 0) { - state = 1; - for (n1 = 1; n1 <= 10000000; n1 *= 10) - DELAY(n1); - state = 2; - } - if (state == 1) - printf("DELAY(%d)...", n); -#endif - - /* - * Read the counter first, so that the rest of the setup overhead is - * counted. Guess the initial overhead is 20 usec (on most systems it - * takes about 1.5 usec for each of the i/o's in getit(). The loop - * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The - * multiplications and divisions to scale the count take a while). - */ - prev_tick = getit(0, 0); - n -= 20; - - /* - * Calculate (n * (CF / 1e6)) without using floating point and without - * any avoidable overflows. - */ - sec = n / 1000000; - usec = n - sec * 1000000; - ticks_left = sec * CF - + usec * (CF / 1000000) - + usec * ((CF % 1000000) / 1000) / 1000 - + usec * (CF % 1000) / 1000000; - - counter_limit = TIMER_FREQ / hz; - while (ticks_left > 0) { - tick = getit(0, 0); -#ifdef DELAYDEBUG - ++getit_calls; -#endif - if (tick > prev_tick) - ticks_left -= prev_tick - (tick - counter_limit); - else - ticks_left -= prev_tick - tick; - prev_tick = tick; - } -#ifdef DELAYDEBUG - if (state == 1) - printf(" %d calls to getit() at %d usec each\n", - getit_calls, (n + 5) / getit_calls); -#endif -} - -getit(unit, timer) { - int high; - int low; - - /* - * XXX - isa.h defines bogus timers. There's no such timer as - * IO_TIMER_2 = 0x48. There's a timer in the CMOS RAM chip but - * its interface is quite different. Neither timer is an 8252. - * We actually only call this with unit = 0 and timer = 0. It - * could be static... - */ - /* - * Protect ourself against interrupts. - * XXX - sysbeep() and sysbeepstop() need protection. - */ - disable_intr(); - /* - * Latch the count for 'timer' (cc00xxxx, c = counter, x = any). - */ - outb(IO_TIMER1 + 3, timer << 6); - - low = inb(IO_TIMER1 + timer); - high = inb(IO_TIMER1 + timer); - enable_intr(); - return ((high << 8) | low); -} - -static beeping; -static -sysbeepstop(f) -{ - /* disable counter 2 */ - outb(0x61, inb(0x61) & 0xFC); - if (f) - timeout(sysbeepstop, 0, f); - else - beeping = 0; -} - -void sysbeep(int pitch, int period) -{ - - outb(0x61, inb(0x61) | 3); /* enable counter 2 */ - /* - * XXX - move timer stuff to clock.c. - * Program counter 2: - * ccaammmb, c counter, a = access, m = mode, b = BCD - * 1011x110, 11 for aa = LSB then MSB, x11 for mmm = square wave. - */ - outb(0x43, 0xb6); /* set command for counter 2, 2 byte write */ - - outb(0x42, pitch); - outb(0x42, (pitch>>8)); - - if (!beeping) { - beeping = period; - timeout(sysbeepstop, period/2, period); - } -} - -/* - * Pass command to keyboard controller (8042) - */ -unsigned kbc_8042cmd(val) { - - while (inb(KBSTATP)&KBS_IBF); - if (val) outb(KBCMDP, val); - while (inb(KBSTATP)&KBS_IBF); - return (inb(KBDATAP)); -} - -/* - * find an ISA device in a given isa_devtab_* table, given - * the table to search, the expected id_driver entry, and the unit number. - * - * this function is defined in isa_device.h, and this location is debatable; - * i put it there because it's useless w/o, and directly operates on - * the other stuff in that file. - * - */ - -struct isa_device *find_isadev(table, driverp, unit) - struct isa_device *table; - struct isa_driver *driverp; - int unit; -{ - if (driverp == NULL) /* sanity check */ - return NULL; - - while ((table->id_driver != driverp) || (table->id_unit != unit)) { - if (table->id_driver == 0) - return NULL; - - table++; - } - - return table; -} - -/* - * Return nonzero if a (masked) irq is pending for a given device. - */ -int -isa_irq_pending(dvp) - struct isa_device *dvp; -{ - unsigned id_irq; - - id_irq = (unsigned short) dvp->id_irq; /* XXX silly type in struct */ - if (id_irq & 0xff) - return (inb(IO_ICU1) & id_irq); - return (inb(IO_ICU2) & (id_irq >> 8)); -} diff --git a/sys/i386/isa/isa.h b/sys/i386/isa/isa.h deleted file mode 100644 index 24dc5cd..0000000 --- a/sys/i386/isa/isa.h +++ /dev/null @@ -1,180 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)isa.h 5.7 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * ISA Bus conventions - */ - -#ifndef LOCORE -#include - -unsigned char rtcin __P((int)); -extern unsigned int atdevbase; /* offset in virtual memory of ISA io mem */ -void sysbeep __P((int, int)); -unsigned kbd_8042cmd __P((int)); -struct isa_device; -int isa_irq_pending __P((struct isa_device *dvp)); -#endif - - -/* - * Input / Output Port Assignments - */ - -#ifndef IO_BEGIN -#define IO_ISABEGIN 0x000 /* 0x000 - Beginning of I/O Registers */ - - /* CPU Board */ -#define IO_DMA1 0x000 /* 8237A DMA Controller #1 */ -#define IO_ICU1 0x020 /* 8259A Interrupt Controller #1 */ -#define IO_TIMER1 0x040 /* 8252 Timer #1 */ -#define IO_TIMER2 0x048 /* 8252 Timer #2 */ -#define IO_KBD 0x060 /* 8042 Keyboard */ -#define IO_RTC 0x070 /* RTC */ -#define IO_NMI IO_RTC /* NMI Control */ -#define IO_DMAPG 0x080 /* DMA Page Registers */ -#define IO_ICU2 0x0A0 /* 8259A Interrupt Controller #2 */ -#define IO_DMA2 0x0C0 /* 8237A DMA Controller #2 */ -#define IO_NPX 0x0F0 /* Numeric Coprocessor */ - - /* Cards */ - /* 0x100 - 0x16F Open */ - -#define IO_WD2 0x170 /* Secondary Fixed Disk Controller */ - - /* 0x178 - 0x1EF Open */ - -#define IO_WD1 0x1f0 /* Primary Fixed Disk Controller */ -#define IO_GAME 0x200 /* Game Controller */ - - /* 0x208 - 0x277 Open */ - -#define IO_LPT2 0x278 /* Parallel Port #2 */ - - /* 0x280 - 0x2E7 Open */ - -#define IO_COM4 0x2e8 /* COM4 i/o address */ - - /* 0x2F0 - 0x2F7 Open */ - -#define IO_COM2 0x2f8 /* COM2 i/o address */ - /* 0x300 - 0x32F Open */ - -#define IO_BT0 0x330 /* bustek 742a default addr. */ -#define IO_AHA0 0x330 /* adaptec 1542 default addr. */ -#define IO_UHA0 0x330 /* ultrastore 14f default addr. */ -#define IO_BT1 0x334 /* bustek 742a default addr. */ -#define IO_AHA1 0x334 /* adaptec 1542 default addr. */ - /* 0x338 - 0x36F Open */ - -#define IO_FD2 0x370 /* secondary base i/o address */ -#define IO_LPT1 0x378 /* Parallel Port #1 */ - - /* 0x380 - 0x3AF Open */ - -#define IO_MDA 0x3B0 /* Monochome Adapter */ -#define IO_LPT3 0x3BC /* Monochome Adapter Printer Port */ -#define IO_VGA 0x3C0 /* E/VGA Ports */ -#define IO_CGA 0x3D0 /* CGA Ports */ - - /* 0x3E0 - 0x3E7 Open */ - -#define IO_COM3 0x3e8 /* COM3 i/o address */ -#define IO_FD1 0x3f0 /* primary base i/o address */ -#define IO_COM1 0x3f8 /* COM1 i/o address */ - -#define IO_ISAEND 0x3FF /* - 0x3FF End of I/O Registers */ -#endif IO_ISABEGIN - -/* - * Input / Output Port Sizes - these are from several sources, and tend - * to be the larger of what was found, ie COM ports can be 4, but some - * boards do not fully decode the address, thus 8 ports are used. - */ - -#ifndef IO_ISASIZES -#define IO_ISASIZES - -#define IO_COMSIZE 8 /* 8250, 16X50 com controllers (4?) */ -#define IO_CGASIZE 16 /* CGA controllers */ -#define IO_DMASIZE 16 /* 8237 DMA controllers */ -#define IO_DPGSIZE 32 /* 74LS612 DMA page reisters */ -#define IO_FDCSIZE 8 /* Nec765 floppy controllers */ -#define IO_WDCSIZE 8 /* WD compatible disk controllers */ -#define IO_GAMSIZE 16 /* AT compatible game controllers */ -#define IO_ICUSIZE 16 /* 8259A interrupt controllers */ -#define IO_KBDSIZE 16 /* 8042 Keyboard controllers */ -#define IO_LPTSIZE 8 /* LPT controllers, some use only 4 */ -#define IO_MDASIZE 16 /* Monochrome display controllers */ -#define IO_RTCSIZE 16 /* CMOS real time clock, NMI control */ -#define IO_TMRSIZE 16 /* 8253 programmable timers */ -#define IO_NPXSIZE 16 /* 80387/80487 NPX registers */ -#define IO_VGASIZE 16 /* VGA controllers */ - -#endif /* IO_ISASIZES */ - -/* - * Input / Output Memory Physical Addresses - */ - -#ifndef IOM_BEGIN -#define IOM_BEGIN 0x0a0000 /* Start of I/O Memory "hole" */ -#define IOM_END 0x100000 /* End of I/O Memory "hole" */ -#define IOM_SIZE (IOM_END - IOM_BEGIN) -#endif IOM_BEGIN - -/* - * RAM Physical Address Space (ignoring the above mentioned "hole") - */ - -#ifndef RAM_BEGIN -#define RAM_BEGIN 0x0000000 /* Start of RAM Memory */ -#define RAM_END 0x1000000 /* End of RAM Memory */ -#define RAM_SIZE (RAM_END - RAM_BEGIN) -#endif RAM_BEGIN - -/* - * Oddball Physical Memory Addresses - */ -#ifndef COMPAQ_RAMRELOC -#define COMPAQ_RAMRELOC 0x80c00000 /* Compaq RAM relocation/diag */ -#define COMPAQ_RAMSETUP 0x80c00002 /* Compaq RAM setup */ -#define WEITEK_FPU 0xC0000000 /* WTL 2167 */ -#define CYRIX_EMC 0xC0000000 /* Cyrix EMC */ -#endif COMPAQ_RAMRELOC diff --git a/sys/i386/isa/isa_device.h b/sys/i386/isa/isa_device.h deleted file mode 100644 index 4405c70..0000000 --- a/sys/i386/isa/isa_device.h +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)isa_device.h 7.1 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * ISA Bus Autoconfiguration - */ - -/* - * Per device structure. - */ -struct isa_device { - struct isa_driver *id_driver; - short id_iobase; /* base i/o address */ - u_short id_irq; /* interrupt request */ - short id_drq; /* DMA request */ - caddr_t id_maddr; /* physical i/o memory address on bus (if any)*/ - int id_msize; /* size of i/o memory */ - int (*id_intr)(); /* interrupt interface routine */ - int id_unit; /* unit number */ - int id_flags; /* flags */ - int id_scsiid; /* scsi id if needed */ - int id_alive; /* device is present */ -}; - -/* - * Per-driver structure. - * - * Each device driver defines entries for a set of routines - * as well as an array of types which are acceptable to it. - * These are used at boot time by the configuration program. - */ -struct isa_driver { - int (*probe)(); /* test whether device is present */ - int (*attach)(); /* setup driver for a device */ - char *name; /* device name */ -}; - -extern struct isa_device isa_devtab_bio[], isa_devtab_tty[], isa_devtab_net[], - isa_devtab_null[]; - -extern struct isa_device *find_isadev(/* table, driver, unit*/); diff --git a/sys/i386/isa/iso8859.font b/sys/i386/isa/iso8859.font deleted file mode 100644 index 4c5e972..0000000 --- a/sys/i386/isa/iso8859.font +++ /dev/null @@ -1,1230 +0,0 @@ -/* - * ISO 8859-1 font file - * - * $Id$ - */ - -char font_8x8[256*8] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E, -0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, -0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, -0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00, -0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x7C, 0x38, 0x7C, -0x10, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C, -0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, -0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, -0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, -0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, -0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78, -0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, -0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0, -0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, -0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99, -0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00, -0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00, -0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, -0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, -0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, -0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0xCC, 0x78, -0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, -0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF, -0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, -0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, -0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, -0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00, -0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, -0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, -0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, -0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00, -0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, -0x30, 0x7C, 0xC0, 0x78, 0x0C, 0xF8, 0x30, 0x00, -0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00, -0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, -0x60, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, -0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00, -0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, -0x00, 0x30, 0x30, 0xFC, 0x30, 0x30, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60, -0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, -0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, -0x7C, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0x7C, 0x00, -0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00, -0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00, -0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00, -0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00, -0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00, -0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00, -0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00, -0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00, -0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00, -0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, -0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60, -0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00, -0x00, 0x00, 0xFC, 0x00, 0x00, 0xFC, 0x00, 0x00, -0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, -0x78, 0xCC, 0x0C, 0x18, 0x30, 0x00, 0x30, 0x00, -0x7C, 0xC6, 0xDE, 0xDE, 0xDE, 0xC0, 0x78, 0x00, -0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00, -0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, -0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00, -0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, -0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, -0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00, -0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3E, 0x00, -0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00, -0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, -0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, -0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00, -0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00, -0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, -0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00, -0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, -0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, -0x78, 0xCC, 0xCC, 0xCC, 0xDC, 0x78, 0x1C, 0x00, -0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00, -0x78, 0xCC, 0xE0, 0x70, 0x1C, 0xCC, 0x78, 0x00, -0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, -0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, -0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00, -0xC6, 0xC6, 0x6C, 0x38, 0x38, 0x6C, 0xC6, 0x00, -0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00, -0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00, -0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00, -0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, -0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, -0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00, -0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00, -0x1C, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0x76, 0x00, -0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0x38, 0x6C, 0x60, 0xF0, 0x60, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, -0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, -0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, -0x0C, 0x00, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, -0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, -0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xC6, 0x00, -0x00, 0x00, 0xF8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, -0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, -0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0, -0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E, -0x00, 0x00, 0xDC, 0x76, 0x66, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x7C, 0xC0, 0x78, 0x0C, 0xF8, 0x00, -0x10, 0x30, 0x7C, 0x30, 0x30, 0x34, 0x18, 0x00, -0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, -0x00, 0x00, 0xC6, 0xD6, 0xFE, 0xFE, 0x6C, 0x00, -0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, -0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, -0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00, -0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00, -0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, -0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00, -0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x7E, 0xFF, 0x7E, 0x18, 0x00, -0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, -0x44, 0x44, 0x44, 0x44, 0x1F, 0x04, 0x04, 0x04, -0x7C, 0x40, 0x40, 0x40, 0x1F, 0x10, 0x10, 0x10, -0x38, 0x44, 0x44, 0x38, 0x1E, 0x11, 0x14, 0x13, -0x40, 0x40, 0x40, 0x7C, 0x1F, 0x10, 0x10, 0x10, -0x38, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, -0x44, 0x64, 0x4C, 0x44, 0x10, 0x10, 0x10, 0x1F, -0x44, 0x44, 0x28, 0x10, 0x1F, 0x04, 0x04, 0x04, -0x18, 0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, -0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x00, 0x0C, 0x30, 0x60, 0x18, 0x0C, 0x7E, 0x00, -0x00, 0x30, 0x0C, 0x06, 0x18, 0x30, 0x7E, 0x00, -0x00, 0x00, 0x03, 0x3E, 0x36, 0x36, 0x6C, 0x00, -0x00, 0x00, 0x04, 0x7E, 0x10, 0x7E, 0x40, 0x00, -0x00, 0x1C, 0x30, 0x30, 0x30, 0x30, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x30, 0x00, 0x30, 0x30, 0x78, 0x78, 0x30, 0x00, -0x00, 0x00, 0x10, 0x7C, 0xC0, 0xC0, 0x7C, 0x10, -0x00, 0x38, 0x60, 0x60, 0xF0, 0x60, 0xFC, 0x00, -0x00, 0xC3, 0x3C, 0x66, 0x66, 0x3C, 0xC3, 0x00, -0x00, 0xCC, 0xCC, 0x78, 0x30, 0xFC, 0x30, 0x00, -0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, -0x7E, 0xC0, 0x7C, 0xC6, 0x7C, 0x06, 0xFC, 0x00, -0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7C, 0x82, 0xBA, 0xA2, 0xBA, 0x82, 0x7C, 0x00, -0x1C, 0x06, 0x1E, 0x22, 0x1F, 0x3F, 0x00, 0x00, -0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00, -0x00, 0xFE, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7C, 0x82, 0xBA, 0xB2, 0xAA, 0x82, 0x7C, 0x00, -0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x38, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x7C, 0x10, 0x00, 0x7C, 0x00, 0x00, -0x1C, 0x36, 0x06, 0x18, 0x3E, 0x00, 0x00, 0x00, -0x1E, 0x02, 0x0E, 0x02, 0x1E, 0x00, 0x00, 0x00, -0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0xC0, -0x7E, 0xCA, 0xCA, 0x7E, 0x0A, 0x0A, 0x0A, 0x00, -0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, -0x06, 0x0E, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, -0x0E, 0x11, 0x11, 0x11, 0x0E, 0x1F, 0x00, 0x00, -0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00, -0x60, 0xE0, 0x66, 0x6C, 0x33, 0x67, 0x0F, 0x03, -0x60, 0xE0, 0x66, 0x6C, 0x36, 0x6A, 0x04, 0x0E, -0xF0, 0x20, 0x96, 0x6C, 0x33, 0x67, 0x0F, 0x03, -0x30, 0x00, 0x30, 0x60, 0xC0, 0xCC, 0x78, 0x00, -0x18, 0x0C, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x60, 0xC0, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x78, 0x84, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x66, 0x98, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0xCC, 0x00, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x30, 0x48, 0x30, 0x78, 0xCC, 0xFC, 0xCC, 0x00, -0x3E, 0x78, 0x98, 0x9C, 0xF8, 0x98, 0x9E, 0x00, -0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x1C, 0x30, -0x30, 0x18, 0xFE, 0x62, 0x78, 0x62, 0xFE, 0x00, -0x18, 0x30, 0xFE, 0x62, 0x78, 0x62, 0xFE, 0x00, -0x38, 0x44, 0xFE, 0x62, 0x78, 0x62, 0xFE, 0x00, -0x66, 0x00, 0xFE, 0x62, 0x78, 0x62, 0xFE, 0x00, -0x60, 0x30, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00, -0x18, 0x30, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00, -0x78, 0x84, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00, -0xCC, 0x00, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00, -0x78, 0x6C, 0x66, 0xF6, 0x66, 0x6C, 0x78, 0x00, -0x66, 0x98, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0x00, -0x30, 0x18, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0x18, 0x30, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0x38, 0x44, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0x66, 0x98, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0xC6, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, -0x00, 0xC6, 0x6C, 0x38, 0x38, 0x6C, 0xC6, 0x00, -0x06, 0x7C, 0xCE, 0x9A, 0xB2, 0xE6, 0x78, 0xC0, -0x60, 0x30, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0x18, 0x30, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0x78, 0x84, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, -0x18, 0x30, 0xCC, 0xCC, 0x78, 0x30, 0x78, 0x00, -0x60, 0x78, 0x6C, 0x78, 0x60, 0x60, 0x60, 0x00, -0x78, 0xCC, 0xC4, 0xDC, 0xC6, 0xC6, 0xDC, 0xC0, -0x30, 0x18, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x18, 0x30, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x78, 0x84, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x66, 0x98, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0xCC, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x30, 0x48, 0x38, 0x0C, 0x7C, 0xCC, 0x76, 0x00, -0x00, 0x00, 0xEC, 0x32, 0x7E, 0xB0, 0x6E, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC0, 0x66, 0x1C, 0x30, -0x30, 0x18, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0x18, 0x30, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0x78, 0x84, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0xCC, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, -0x60, 0x30, 0x00, 0x70, 0x30, 0x30, 0x78, 0x00, -0x18, 0x30, 0x00, 0x70, 0x30, 0x30, 0x78, 0x00, -0x70, 0x88, 0x00, 0x70, 0x30, 0x30, 0x78, 0x00, -0xCC, 0x00, 0x00, 0x70, 0x30, 0x30, 0x78, 0x00, -0x6C, 0x38, 0x6C, 0x0C, 0x6C, 0xCC, 0x78, 0x00, -0x66, 0x98, 0xF8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, -0x60, 0x30, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0x18, 0x30, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0x38, 0x44, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0x66, 0x98, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0xC6, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, -0x00, 0x00, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x00, -0x00, 0x00, 0x06, 0x7C, 0xDE, 0xF6, 0x7C, 0xC0, -0x60, 0x30, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0x18, 0x30, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0x30, 0x48, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0xCC, 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, -0x18, 0x30, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, -0xE0, 0x78, 0x6C, 0x66, 0x6C, 0x78, 0xE0, 0x00, -0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8 -}; - -char font_8x14[256*14] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7E, 0x81, 0xA5, 0x81, 0x81, 0xBD, 0x99, 0x81, -0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0xFF, -0xDB, 0xFF, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x7F, 0x7F, -0x7F, 0x7F, 0x3E, 0x1C, 0x08, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x1C, 0x3E, 0x7F, 0x3E, -0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x3C, 0x3C, 0xE7, 0xE7, 0xE7, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, -0x7E, 0xFF, 0xFF, 0x7E, 0x18, 0x18, 0x3C, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, -0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x24, 0x42, 0x42, 0x24, 0x3C, -0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, -0xC3, 0xDB, 0xBD, 0xBD, 0xDB, 0xC3, 0xFF, 0xFF, -0xFF, 0xFF, 0x00, 0x00, 0x1F, 0x07, 0x0D, 0x19, -0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, -0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x0A, 0x09, 0x09, 0x09, 0x0A, 0x08, 0x38, -0x78, 0x78, 0x30, 0x00, 0x00, 0x00, 0x1F, 0x11, -0x1F, 0x11, 0x11, 0x11, 0x13, 0x37, 0x77, 0x72, -0x20, 0x00, 0x00, 0x00, 0x18, 0x18, 0xDB, 0x3C, -0xE7, 0x3C, 0xDB, 0x18, 0x18, 0x00, 0x00, 0x00, -0x00, 0x00, 0x40, 0x60, 0x70, 0x7C, 0x7F, 0x7C, -0x70, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x03, 0x07, 0x1F, 0x7F, 0x1F, 0x07, 0x03, -0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, -0x7E, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, -0x00, 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, -0x33, 0x33, 0x00, 0x33, 0x33, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7F, 0xDB, 0xDB, 0xDB, 0x7B, 0x1B, -0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x30, 0x1C, 0x36, 0x63, 0x63, 0x36, 0x1C, -0x06, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, -0x18, 0x18, 0x7E, 0x3C, 0x18, 0x7E, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x06, 0x7F, 0x06, 0x0C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, -0x7F, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, -0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x24, 0x42, 0xFF, 0x42, 0x24, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, -0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x7F, 0x36, -0x36, 0x36, 0x7F, 0x36, 0x36, 0x00, 0x00, 0x00, -0x08, 0x08, 0x3E, 0x63, 0x60, 0x60, 0x3E, 0x03, -0x03, 0x63, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x00, -0x00, 0x61, 0x63, 0x06, 0x0C, 0x18, 0x30, 0x63, -0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x36, -0x36, 0x1C, 0x3B, 0x6E, 0x66, 0x66, 0x3B, 0x00, -0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x60, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, -0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, -0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x66, 0x3C, 0x7E, 0x3C, 0x66, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, -0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, -0x18, 0x30, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3E, 0x63, 0x67, 0x6F, 0x7B, 0x73, -0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x1C, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, -0x03, 0x06, 0x0C, 0x18, 0x30, 0x63, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, 0x03, 0x03, -0x1E, 0x03, 0x03, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x06, 0x0E, 0x1E, 0x36, 0x66, 0x7F, -0x06, 0x06, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7E, 0x60, 0x60, 0x60, 0x7E, 0x03, 0x03, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x30, -0x60, 0x60, 0x7E, 0x63, 0x63, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x7F, 0x63, 0x03, 0x06, -0x0C, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x3E, 0x63, -0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3E, 0x63, 0x63, 0x63, 0x3F, 0x03, 0x03, 0x06, -0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, -0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, -0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x30, -0x18, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, -0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, 0x63, 0x06, -0x0C, 0x0C, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3E, 0x63, 0x63, 0x6F, 0x6F, 0x6F, -0x6E, 0x60, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x08, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, 0x63, -0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x33, -0x33, 0x33, 0x3E, 0x33, 0x33, 0x33, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1E, 0x33, 0x60, 0x60, -0x60, 0x60, 0x60, 0x33, 0x1E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0x36, 0x33, 0x33, 0x33, 0x33, -0x33, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7F, 0x33, 0x30, 0x34, 0x3C, 0x34, 0x30, 0x33, -0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x33, -0x30, 0x34, 0x3C, 0x34, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1E, 0x33, 0x60, 0x60, -0x60, 0x6F, 0x63, 0x33, 0x1D, 0x00, 0x00, 0x00, -0x00, 0x00, 0x63, 0x63, 0x63, 0x63, 0x7F, 0x63, -0x63, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x06, -0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C, 0x00, -0x00, 0x00, 0x00, 0x00, 0x73, 0x33, 0x36, 0x36, -0x3C, 0x36, 0x36, 0x33, 0x73, 0x00, 0x00, 0x00, -0x00, 0x00, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, -0x30, 0x33, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, -0x63, 0x77, 0x7F, 0x6B, 0x63, 0x63, 0x63, 0x63, -0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x73, -0x7B, 0x7F, 0x6F, 0x67, 0x63, 0x63, 0x63, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1C, 0x36, 0x63, 0x63, -0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0x33, 0x33, 0x33, 0x3E, 0x30, -0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, -0x1C, 0x36, 0x63, 0x63, 0x63, 0x63, 0x6B, 0x3E, -0x1C, 0x06, 0x03, 0x00, 0x00, 0x00, 0x7E, 0x33, -0x33, 0x33, 0x3E, 0x36, 0x33, 0x33, 0x73, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3E, 0x63, 0x63, 0x30, -0x1C, 0x06, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x08, 0x00, -0x00, 0x00, 0x00, 0x00, 0x63, 0x63, 0x63, 0x63, -0x63, 0x6B, 0x6B, 0x7F, 0x36, 0x00, 0x00, 0x00, -0x00, 0x00, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x36, -0x63, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, -0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x63, -0x06, 0x0C, 0x18, 0x30, 0x60, 0x63, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3C, 0x30, 0x30, 0x30, -0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x40, 0x60, 0x30, 0x18, 0x0C, 0x06, -0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0x3C, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, 0x63, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x18, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x30, -0x30, 0x3E, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x60, 0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0E, 0x06, 0x06, 0x3E, 0x66, 0x66, -0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x33, -0x30, 0x7C, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, -0x66, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C, 0x00, -0x00, 0x00, 0x70, 0x30, 0x30, 0x36, 0x3B, 0x33, -0x33, 0x33, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, -0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, -0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xCC, -0x78, 0x00, 0x00, 0x00, 0x70, 0x30, 0x30, 0x33, -0x36, 0x3C, 0x36, 0x33, 0x73, 0x00, 0x00, 0x00, -0x00, 0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0x0C, 0x0C, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x66, 0x7F, 0x6B, 0x6B, 0x6B, -0x6B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x6E, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x33, 0x33, -0x33, 0x3E, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3B, 0x66, 0x66, 0x66, 0x3E, -0x06, 0x06, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x6E, 0x33, 0x30, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x38, 0x0E, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x18, 0x7E, 0x18, 0x18, -0x18, 0x1B, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x08, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, -0x63, 0x6B, 0x6B, 0x7F, 0x36, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x36, 0x1C, -0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x63, 0x66, 0x66, 0x66, 0x3E, -0x06, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x7F, 0x66, 0x0C, 0x18, 0x33, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0E, 0x18, 0x18, 0x18, -0x70, 0x18, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x70, 0x18, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x18, -0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0x6E, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, -0x36, 0x63, 0x63, 0x7F, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x7E, 0x3C, -0x18, 0x00, 0x00, 0x00, 0x55, 0xAA, 0x55, 0xAA, -0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, -0x55, 0xAA, 0x00, 0x44, 0x44, 0x7C, 0x44, 0x44, -0x00, 0x1F, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, -0x00, 0x7C, 0x40, 0x78, 0x40, 0x40, 0x00, 0x1F, -0x10, 0x1E, 0x10, 0x10, 0x00, 0x00, 0x00, 0x38, -0x44, 0x40, 0x44, 0x38, 0x00, 0x1E, 0x11, 0x1E, -0x14, 0x13, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, -0x40, 0x7C, 0x00, 0x1F, 0x10, 0x1E, 0x10, 0x10, -0x00, 0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, -0x18, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x44, -0x64, 0x54, 0x4C, 0x44, 0x00, 0x10, 0x10, 0x10, -0x10, 0x1F, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, -0x28, 0x10, 0x00, 0x1F, 0x04, 0x04, 0x04, 0x04, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x0C, 0x18, -0x30, 0x60, 0x30, 0x18, 0x0C, 0x00, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x0C, 0x06, -0x0C, 0x18, 0x30, 0x00, 0x7E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x03, 0x3E, 0x76, 0x36, -0x36, 0x36, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x02, 0x04, 0x7E, 0x08, 0x10, 0x7E, 0x20, -0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x36, -0x30, 0x30, 0x7C, 0x30, 0x30, 0x73, 0x7E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x3C, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x08, 0x3E, 0x63, 0x60, 0x60, 0x63, 0x3E, 0x08, -0x08, 0x00, 0x00, 0x00, 0x1C, 0x36, 0x30, 0x30, -0x7C, 0x30, 0x30, 0x73, 0x7E, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x42, 0x3C, 0x66, 0x66, 0x66, -0x3C, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x7E, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, -0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, -0x00, 0x00, 0x00, 0x3E, 0x63, 0x30, 0x1C, 0x36, -0x63, 0x63, 0x36, 0x1C, 0x06, 0x63, 0x3E, 0x00, -0x00, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x3E, 0x41, 0x5D, 0x51, 0x51, 0x5D, 0x41, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x38, 0x04, 0x3C, -0x44, 0x3C, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x36, -0x6C, 0x36, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x03, -0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x41, 0x5D, 0x55, 0x59, 0x55, 0x41, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, -0x7E, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6C, 0x18, -0x30, 0x64, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x7C, 0x0C, 0x38, 0x0C, 0x6C, -0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x06, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, -0x3B, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x7F, 0xDB, -0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0C, 0x0C, 0x06, 0x1C, 0x00, 0x30, -0x70, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, -0x44, 0x38, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x36, -0x1B, 0x36, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x60, 0xE0, 0x63, 0x66, 0x6C, 0x18, 0x33, -0x67, 0xCF, 0x1F, 0x03, 0x03, 0x00, 0x00, 0x60, -0xE0, 0x63, 0x66, 0x6C, 0x18, 0x30, 0x6E, 0xC3, -0x06, 0x0C, 0x1F, 0x00, 0x00, 0xF0, 0x30, 0x63, -0xF6, 0x6C, 0x18, 0x33, 0x67, 0xCF, 0x1F, 0x03, -0x03, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, -0x18, 0x30, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0x1C, 0x36, 0x63, 0x63, -0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, 0x03, 0x06, -0x0C, 0x00, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, -0x63, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, 0x00, -0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, 0x63, 0x00, -0x00, 0x00, 0x3B, 0x6E, 0x00, 0x08, 0x1C, 0x36, -0x63, 0x63, 0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, -0x00, 0x63, 0x63, 0x08, 0x1C, 0x36, 0x63, 0x63, -0x7F, 0x63, 0x63, 0x00, 0x00, 0x00, 0x1C, 0x36, -0x1C, 0x00, 0x1C, 0x36, 0x63, 0x63, 0x7F, 0x63, -0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x36, -0x66, 0x66, 0x67, 0x7E, 0x66, 0x66, 0x67, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1E, 0x33, 0x60, 0x60, -0x60, 0x60, 0x60, 0x33, 0x1E, 0x0C, 0x06, 0x1C, -0x60, 0x30, 0x18, 0x00, 0x7F, 0x33, 0x30, 0x3E, -0x30, 0x33, 0x7F, 0x00, 0x00, 0x00, 0x06, 0x0C, -0x18, 0x00, 0x7F, 0x33, 0x30, 0x3E, 0x30, 0x33, -0x7F, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, 0x00, -0x7F, 0x33, 0x30, 0x3E, 0x30, 0x33, 0x7F, 0x00, -0x00, 0x00, 0x00, 0x63, 0x63, 0x00, 0x7F, 0x33, -0x30, 0x3E, 0x30, 0x33, 0x7F, 0x00, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0x3C, 0x18, 0x18, 0x18, -0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x06, 0x0C, -0x18, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x66, 0x00, -0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, -0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x3C, 0x18, -0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x36, 0x33, 0x33, 0x7B, 0x33, -0x33, 0x36, 0x3C, 0x00, 0x00, 0x00, 0x3B, 0x6E, -0x00, 0x63, 0x73, 0x7B, 0x7F, 0x6F, 0x67, 0x63, -0x63, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, -0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, -0x00, 0x00, 0x03, 0x06, 0x0C, 0x00, 0x1C, 0x36, -0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, -0x08, 0x1C, 0x36, 0x00, 0x1C, 0x36, 0x63, 0x63, -0x63, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x3B, -0x6E, 0x00, 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, -0x1C, 0x00, 0x00, 0x00, 0x00, 0x63, 0x63, 0x00, -0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x36, 0x1C, -0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, -0x00, 0x03, 0x1E, 0x36, 0x67, 0x6F, 0x6B, 0x7B, -0x73, 0x36, 0x3C, 0x60, 0x00, 0x00, 0x60, 0x30, -0x18, 0x00, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x03, 0x06, 0x0C, 0x00, -0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x08, 0x1C, 0x36, 0x00, 0x63, 0x63, -0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x63, 0x63, 0x00, 0x63, 0x63, 0x63, 0x63, -0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x06, 0x0C, -0x18, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x78, 0x30, 0x3E, -0x33, 0x33, 0x3E, 0x30, 0x30, 0x30, 0x78, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1C, 0x36, 0x63, 0x66, -0x6C, 0x67, 0x63, 0x6B, 0x6E, 0x60, 0x60, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x3C, 0x06, 0x3E, -0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x06, -0x0C, 0x18, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, -0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3B, 0x6E, 0x00, 0x3C, -0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, -0x00, 0x00, 0x66, 0x66, 0x00, 0x3C, 0x06, 0x3E, -0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x1C, -0x36, 0x1C, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x76, 0x0B, 0x3B, 0x6E, 0x68, 0x37, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, -0x63, 0x60, 0x60, 0x63, 0x3E, 0x0C, 0x06, 0x1C, -0x00, 0x30, 0x18, 0x0C, 0x00, 0x3E, 0x63, 0x7F, -0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x03, -0x06, 0x0C, 0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x36, -0x00, 0x3E, 0x63, 0x7F, 0x60, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x63, 0x63, 0x00, 0x3E, -0x63, 0x7F, 0x60, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x06, -0x0C, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, -0x3C, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x66, -0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, -0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x38, -0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x36, 0x1C, 0x36, 0x06, 0x3E, 0x66, -0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3B, 0x6E, 0x00, 0x6E, 0x33, 0x33, 0x33, 0x33, -0x33, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, -0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, 0x00, 0x3E, -0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, -0x00, 0x08, 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x63, -0x63, 0x63, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3B, 0x6E, 0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, -0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x63, -0x00, 0x3E, 0x63, 0x63, 0x63, 0x63, 0x3E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, -0x7E, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x03, 0x3E, 0x67, 0x6F, -0x7B, 0x73, 0x3E, 0x60, 0x00, 0x00, 0x00, 0x60, -0x30, 0x18, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, -0x3B, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, -0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3B, 0x00, -0x00, 0x00, 0x00, 0x18, 0x3C, 0x66, 0x00, 0x66, -0x66, 0x66, 0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, -0x00, 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, -0x66, 0x66, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x06, -0x0C, 0x18, 0x00, 0x63, 0x66, 0x66, 0x66, 0x3E, -0x06, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x78, -0x30, 0x3E, 0x33, 0x33, 0x33, 0x33, 0x3E, 0x30, -0x78, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x66, -0x66, 0x66, 0x66, 0x3E, 0x06, 0x66, 0x3C, 0x00 -}; - -char font_8x16[256*16] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0x81, 0xA5, 0x81, 0x81, 0xBD, -0x99, 0x81, 0x81, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7E, 0xFF, 0xDB, 0xFF, 0xFF, 0xC3, -0xE7, 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x6C, 0xFE, 0xFE, 0xFE, -0xFE, 0x7C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7C, 0xFE, -0x7C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x18, 0x3C, 0x3C, 0xE7, 0xE7, -0xE7, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, -0x7E, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, -0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC3, -0xC3, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, -0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x42, -0x42, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC3, 0x99, 0xBD, -0xBD, 0x99, 0xC3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, -0x00, 0x00, 0x1E, 0x0E, 0x1A, 0x32, 0x78, 0xCC, -0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, -0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3F, 0x33, 0x3F, 0x30, 0x30, 0x30, -0x30, 0x70, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x63, -0x63, 0x67, 0xE7, 0xE6, 0xC0, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x18, 0x18, 0xDB, 0x3C, 0xE7, -0x3C, 0xDB, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFE, 0xF8, -0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, -0x00, 0x02, 0x06, 0x0E, 0x1E, 0x3E, 0xFE, 0x3E, -0x1E, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, -0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, -0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7F, 0xDB, 0xDB, 0xDB, 0x7B, 0x1B, -0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00, -0x00, 0x7C, 0xC6, 0x60, 0x38, 0x6C, 0xC6, 0xC6, -0x6C, 0x38, 0x0C, 0xC6, 0x7C, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xFE, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, -0x7E, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0C, 0xFE, -0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xFE, -0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, -0xC0, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x66, 0xFF, -0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7C, -0x7C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x7C, 0x7C, -0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x18, -0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x6C, 0x6C, 0xFE, 0x6C, 0x6C, -0x6C, 0xFE, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x7C, 0xC6, 0xC2, 0xC0, 0x7C, 0x06, -0x06, 0x86, 0xC6, 0x7C, 0x18, 0x18, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xC2, 0xC6, 0x0C, 0x18, -0x30, 0x60, 0xC6, 0x86, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x76, 0xDC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, -0x30, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, -0x0C, 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3C, 0xFF, -0x3C, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, -0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0C, 0x18, -0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC3, 0xC3, 0xDB, 0xDB, -0xC3, 0xC3, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0x06, 0x0C, 0x18, 0x30, -0x60, 0xC0, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0x06, 0x06, 0x3C, 0x06, -0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0C, 0x1C, 0x3C, 0x6C, 0xCC, 0xFE, -0x0C, 0x0C, 0x0C, 0x1E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFE, 0xC0, 0xC0, 0xC0, 0xFC, 0x06, -0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x60, 0xC0, 0xC0, 0xFC, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFE, 0xC6, 0x06, 0x06, 0x0C, 0x18, -0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, -0x06, 0x06, 0x0C, 0x78, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, -0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, -0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, -0x30, 0x18, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, -0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x06, -0x0C, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0x0C, 0x18, 0x18, -0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xDE, 0xDE, -0xDE, 0xDC, 0xC0, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, -0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x66, -0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xC0, -0xC0, 0xC2, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x66, -0x66, 0x66, 0x6C, 0xF8, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, -0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xDE, -0xC6, 0xC6, 0x66, 0x3A, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, -0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xE6, 0x66, 0x66, 0x6C, 0x78, 0x78, -0x6C, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xF0, 0x60, 0x60, 0x60, 0x60, 0x60, -0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xE7, 0xFF, 0xFF, 0xDB, 0xC3, -0xC3, 0xC3, 0xC3, 0xC3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0xE6, 0xF6, 0xFE, 0xDE, 0xCE, -0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x60, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xD6, 0xDE, 0x7C, 0x0C, 0x0E, 0x00, 0x00, -0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x6C, -0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0xC6, 0x60, 0x38, 0x0C, -0x06, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFF, 0xDB, 0x99, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, -0xC3, 0x66, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xDB, -0xDB, 0xFF, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xC3, 0x66, 0x3C, 0x18, 0x18, -0x3C, 0x66, 0xC3, 0xC3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0xC3, 0xC3, 0x66, 0x3C, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xFF, 0xC3, 0x86, 0x0C, 0x18, 0x30, -0x60, 0xC1, 0xC3, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, -0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0x38, -0x1C, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, -0x0C, 0x0C, 0x0C, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, -0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xE0, 0x60, 0x60, 0x78, 0x6C, 0x66, -0x66, 0x66, 0x66, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x1C, 0x0C, 0x0C, 0x3C, 0x6C, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x6C, 0x64, 0x60, 0xF0, 0x60, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xCC, 0x78, 0x00, -0x00, 0x00, 0xE0, 0x60, 0x60, 0x6C, 0x76, 0x66, -0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06, -0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C, 0x00, -0x00, 0x00, 0xE0, 0x60, 0x60, 0x66, 0x6C, 0x78, -0x78, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0xFF, 0xDB, -0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, -0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, -0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0x0C, 0x1E, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x76, 0x66, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x60, -0x38, 0x0C, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x10, 0x30, 0x30, 0xFC, 0x30, 0x30, -0x30, 0x30, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xC3, 0xC3, -0xC3, 0x66, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0xC3, 0xC3, -0xDB, 0xDB, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x66, 0x3C, -0x18, 0x3C, 0x66, 0xC3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x0C, 0xF8, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xCC, 0x18, -0x30, 0x60, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x0E, 0x18, 0x18, 0x18, 0x70, 0x18, -0x18, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0E, 0x18, -0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6, -0xC6, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, -0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, -0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, -0x00, 0x88, 0x88, 0xF8, 0x88, 0x88, 0x88, 0x00, -0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, -0x00, 0xF8, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00, -0x3E, 0x20, 0x3C, 0x20, 0x20, 0x20, 0x00, 0x00, -0x00, 0x70, 0x88, 0x80, 0x80, 0x88, 0x70, 0x00, -0x3C, 0x22, 0x3C, 0x28, 0x24, 0x22, 0x00, 0x00, -0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0xF8, 0x00, -0x3E, 0x20, 0x3C, 0x20, 0x20, 0x20, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, -0x18, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x88, 0xC8, 0xA8, 0xA8, 0x98, 0x88, 0x00, -0x20, 0x20, 0x20, 0x20, 0x20, 0x3E, 0x00, 0x00, -0x00, 0x88, 0x88, 0x88, 0x88, 0x50, 0x20, 0x00, -0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, -0x00, 0x00, 0x00, 0x0C, 0x18, 0x30, 0x60, 0x30, -0x18, 0x0C, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x30, 0x18, 0x0C, 0x06, 0x0C, -0x18, 0x30, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x02, 0x7E, 0xEC, 0x6C, 0x6C, -0x6C, 0x6C, 0x6C, 0xCC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x06, 0x0C, 0x7E, 0x18, 0x18, -0x7E, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x64, 0x60, 0xF0, 0x60, 0x60, -0x60, 0x60, 0xE6, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, -0x3C, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x18, 0x7E, 0xC3, 0xC0, 0xC0, 0xC0, -0xC3, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x64, 0x60, 0xF0, 0x60, 0x60, -0x60, 0x60, 0xE6, 0xFC, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x82, 0xC6, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0x7C, 0xC6, 0x82, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC3, 0x66, 0x3C, 0x18, 0xFF, 0x18, -0xFF, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, -0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, -0x00, 0x7C, 0xC6, 0x60, 0x38, 0x6C, 0xC6, 0xC6, -0x6C, 0x38, 0x0C, 0xC6, 0x7C, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0x82, 0xBA, 0xA2, 0xA2, -0xBA, 0x82, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x70, 0x18, 0x78, 0xC8, 0x78, 0x00, 0xF8, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6C, 0xD8, -0x6C, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x06, -0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7C, 0xC6, 0x82, 0xBA, 0xAA, 0xB2, -0xAA, 0x82, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, -0x18, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, -0x00, 0x70, 0xD8, 0x30, 0x60, 0xC8, 0xF8, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xF8, 0x18, 0x30, 0x18, 0xD8, 0x70, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, -0x66, 0x7E, 0x63, 0x60, 0xC0, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7F, 0xDB, 0xDB, 0xDB, 0x7B, 0x1B, -0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, -0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x18, 0x0C, 0x06, 0x3C, 0x00, 0x00, -0x00, 0x60, 0xE0, 0x60, 0x60, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x70, 0xD8, 0x88, 0xD8, 0x70, 0x00, 0xF8, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x6C, 0x36, -0x6C, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC0, 0xC0, 0xC2, 0xC6, 0xCC, 0x18, 0x30, -0x66, 0xCE, 0x96, 0x3E, 0x06, 0x06, 0x00, 0x00, -0x00, 0xC0, 0xC0, 0xC2, 0xC6, 0xCC, 0x18, 0x30, -0x60, 0xCE, 0x9B, 0x06, 0x0C, 0x1F, 0x00, 0x00, -0x00, 0xF0, 0x30, 0x72, 0x36, 0xEC, 0x18, 0x30, -0x66, 0xCE, 0x96, 0x3E, 0x06, 0x06, 0x00, 0x00, -0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, -0xC0, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x76, 0xDC, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x38, 0x6C, 0x38, 0x00, 0x38, 0x6C, 0xC6, 0xC6, -0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3E, 0x6C, 0xCC, 0xCC, 0xFE, 0xCC, -0xCC, 0xCC, 0xCC, 0xCE, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xC0, -0xC2, 0x66, 0x3C, 0x0C, 0x06, 0x7C, 0x00, 0x00, -0x30, 0x18, 0x0C, 0x00, 0xFE, 0x66, 0x60, 0x7C, -0x60, 0x60, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x18, 0x30, 0x60, 0x00, 0xFE, 0x66, 0x60, 0x7C, -0x60, 0x60, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0x00, 0xFE, 0x66, 0x60, 0x7C, -0x60, 0x60, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0xFE, 0x66, 0x60, 0x60, 0x7C, -0x60, 0x60, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, -0x30, 0x18, 0x0C, 0x00, 0x3C, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0x3C, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x18, 0x3C, 0x66, 0x00, 0x3C, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x66, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x78, 0x6C, 0x66, 0x66, 0x66, 0xF6, -0x66, 0x66, 0x6C, 0x78, 0x00, 0x00, 0x00, 0x00, -0x76, 0xDC, 0x00, 0xC6, 0xE6, 0xF6, 0xFE, 0xDE, -0xCE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x76, 0xDC, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x10, -0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, -0x02, 0x06, 0x7C, 0xCE, 0xCE, 0xDE, 0xD6, 0xD6, -0xF6, 0xE6, 0xE6, 0x7C, 0xC0, 0x80, 0x00, 0x00, -0x60, 0x30, 0x18, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x10, 0x38, 0x6C, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0xC6, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x0C, 0x18, 0x30, 0x00, 0xC3, 0xC3, 0x66, 0x3C, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0xF0, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, -0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x38, 0x6C, 0xC6, 0xCE, 0xDC, 0xD8, -0xCC, 0xC6, 0xD6, 0xDC, 0xC0, 0x80, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x38, 0x6C, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x76, 0xDC, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xCC, 0x00, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x38, 0x6C, 0x38, 0x00, 0x78, 0x0C, 0x7C, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x3B, 0x1B, -0x7E, 0xD8, 0xDC, 0x77, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x60, -0x66, 0x3C, 0x0C, 0x06, 0x3C, 0x00, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x0C, 0x18, 0x30, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x38, 0x6C, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0x00, 0x00, 0x7C, 0xC6, 0xFE, -0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x06, 0x0C, 0x18, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x3C, 0x66, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, -0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x6C, 0x38, 0x38, 0x6C, 0x0C, 0x3C, 0x6C, -0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x76, 0xDC, 0x00, 0xDC, 0x66, 0x66, -0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x30, 0x60, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x10, 0x38, 0x6C, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x76, 0xDC, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xC6, 0x00, 0x00, 0x7C, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7E, -0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x02, 0x06, 0x7C, 0xCE, 0xDE, -0xD6, 0xF6, 0xE6, 0x7C, 0xC0, 0x80, 0x00, 0x00, -0x00, 0x60, 0x30, 0x18, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x30, 0x60, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x30, 0x78, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xCC, 0x00, 0x00, 0xCC, 0xCC, 0xCC, -0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, -0x00, 0x18, 0x30, 0x60, 0x00, 0xC6, 0xC6, 0xC6, -0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x0C, 0xF8, 0x00, -0x00, 0x00, 0x00, 0xF0, 0x60, 0x7C, 0x66, 0x66, -0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, -0x00, 0x00, 0x66, 0x66, 0x00, 0xEE, 0x66, 0x66, -0x66, 0x66, 0x66, 0x3E, 0x06, 0x0C, 0x38, 0x00 -}; diff --git a/sys/i386/isa/kbd.h b/sys/i386/isa/kbd.h deleted file mode 100644 index 66e5224..0000000 --- a/sys/i386/isa/kbd.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Keyboard definitions - * from: unknown origin, 386BSD 0.1 - * $Id$ - */ - -/* Reference: IBM AT Technical Reference Manual, - * pp. 1-38 to 1-43, 4-3 to 4-22 - */ - -/* commands sent to KBCMDP */ - -#define KBC_CMDREAD 0x20 /* read kbd cntrl command byte */ -#define KBC_CMDWRITE 0x60 /* == LD_CMDBYTE in kd.h, write command */ -#define KBC_SELFTEST 0xAA /* perform self test, returns 55 when ok */ -#define KBC_IFTEST 0xAB /* perform interface test */ -#define KBC_DIAGDUMP 0xAC /* send 19 status bytes to system */ -#define KBC_DISKBD 0xAD /* disable keyboard */ -#define KBC_ENAKBD 0xAE /* enable keyboard */ -#define KBC_RDINP 0xC0 /* read input port */ -#define KBC_RDID 0xC4 /* read keyboard ID */ -#define KBC_RDOUTP 0xD0 /* read output port */ -#define KBC_WROUTP 0xD1 /* write output port */ -#define KBC_RDTINP 0xE0 /* read test inputs */ - -/* commands sent to KBDATAP */ -#define KBC_STSIND 0xED /* set keyboard status indicators */ -#define KBC_ECHO 0xEE /* reply with 0xEE */ -#define KBC_SETTPM 0xF3 /* Set typematic rate/delay */ -#define KBC_ENABLE 0xF4 /* Start scanning */ -#define KBC_SETDEFD 0xF5 /* =KBC_SETDEF, but disable scanning */ -#define KBC_SETDEF 0xF6 /* Set power on defaults */ -#define KBC_RESEND 0xFE /* system wants keyboard to resend last code */ -#define KBC_RESET 0xFF /* Reset the keyboard */ - -/* responses */ -#define KBR_OVERRUN 0x00 /* Keyboard flooded */ -#define KBR_STOK 0x55 /* Selftest ok response */ -#define KBR_IFOK 0x00 /* Interface test ok */ -#define KBR_IFCL_SA0 0x01 /* Clock Stuck-at-0 fault */ -#define KBR_IFCL_SA1 0x02 /* Clock Stuck-at-1 fault */ -#define KBR_IFDA_SA0 0x03 /* Data Stuck-at-0 fault */ -#define KBR_IFDA_SA1 0x04 /* Data Stuck-at-1 fault */ -#define KBR_RSTDONE 0xAA /* Keyboard reset (BAT) complete */ -#define KBR_E0 0xE0 /* Extended prefix */ -#define KBR_E1 0xE1 /* BREAK'S HIT :-( */ -#define KBR_ECHO 0xEE /* Echo response */ -#define KBR_F0 0xF0 /* Break code prefix */ -#define KBR_ACK 0xFA /* Keyboard did receive command */ -#define KBR_BATFAIL 0xFC /* BAT failed */ -#define KBR_DIAGFAIL 0xFD /* Diagnostic failed response */ -#define KBR_RESEND 0xFE /* Keyboard needs resend of command */ diff --git a/sys/i386/isa/kbdtables.h b/sys/i386/isa/kbdtables.h deleted file mode 100644 index 5acb9af..0000000 --- a/sys/i386/isa/kbdtables.h +++ /dev/null @@ -1,858 +0,0 @@ -/* - * Copyright (C) 1992, 1993 Søren Schmidt - * - * This program is free software; you may redistribute it and/or - * modify it, provided that it retain the above copyright notice - * and the following disclaimer. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Søren Schmidt Email: sos@kmd-ac.dk - * Tritonvej 36 UUCP: ...uunet!dkuug!kmd-ac!sos - * DK9210 Aalborg SO Phone: +45 9814 8076 - * - * $Id$ - */ - -#define META 0x80 /* eight bit for emacs META-key */ - -#ifdef DKKEYMAP -keymap_t key_map = { 0x69, /* DK iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, NOP, NOP, 0x33, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '"', 0x00, 0x00, '@', '"', 0x00, 0x00, 0x00, 0x00, -/* sc=04 */ '3', '#', NOP, NOP, 0x9E, '#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', 0xA4, NOP, NOP, '$', 0xA4, NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '&', NOP, NOP, '6', '&', NOP, NOP, 0x33, 0x00, -/* sc=08 */ '7', '/', NOP, NOP, '{', '/', NOP, NOP, 0x33, 0x00, -/* sc=09 */ '8', '(', 0x1B, 0x1B, '[', '(', 0x1B, 0x1B, 0x00, 0x00, -/* sc=0a */ '9', ')', 0x1D, 0x1D, ']', ')', 0x1D, 0x1D, 0x00, 0x00, -/* sc=0b */ '0', '=', NOP, NOP, '}', '=', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '+', '?', NOP, NOP, '+', '?', NOP, NOP, 0x33, 0x00, -/* sc=0d */ '\'', '`', NOP, NOP, '|', '`', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x33, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ 0xE5, 0xC5, NOP, NOP, 0x86, 0x8F, NOP, NOP, 0x33, 0x01, -/* sc=1b */ '"', '^', 0x1E, 0x1E, '~', '^', 0x1E, 0x1E, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ 0xE6, 0xC6, NOP, NOP, 0x91, 0x92, NOP, NOP, 0x33, 0x01, -/* sc=28 */ 0xF8, 0xD8, NOP, NOP, 0x9B, 0x9D, NOP, NOP, 0x33, 0x01, -/* sc=29 */ 0xBD, 0xA7, NOP, NOP, 0xBD, 0xA7, NOP, NOP, 0x33, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\'', '*', NOP, NOP, '\'', '*', NOP, NOP, 0x33, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', ';', NOP, NOP, ',', ';', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', ':', NOP, NOP, '.', ':', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', '*', '*', '*', '*', '*', '*', 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00, -/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', '-', '-', '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ NOP, '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', '6', '6', '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', '.', '.', '.', '.', '.', '.', 0x00, 0x02, -/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ '<', '>', 0x1C, 0x1C, '\\', '>', 0x1C, 0x1C, 0x00, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x02, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x00, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x00, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; -#endif - -#ifdef UKKEYMAP -keymap_t key_map = { 0x69, /* uk iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00, -/* sc=04 */ '3', 0xA3, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, '4', '$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '^', 0x1E, 0x1E, '^', '^', 0x1E, 0x1E, 0x00, 0x00, -/* sc=08 */ '7', '&', NOP, NOP, '[', '[', 0x1B, 0x1B, 0x30, 0x00, -/* sc=09 */ '8', '*', NOP, NOP, '8', '*', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '9', '(', NOP, NOP, ']', ']', 0x1D, 0x1D, 0x30, 0x00, -/* sc=0b */ '0', ')', NOP, NOP, '{', '{', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '-', '_', 0x1F, 0x1F, '|', '|', 0x1F, 0x1F, 0x00, 0x00, -/* sc=0d */ '=', '+', NOP, NOP, '}', '}', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x77, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ '[', '{', 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x00, -/* sc=1b */ ']', '}', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ ';', ':', NOP, NOP, ';', ':', NOP, NOP, 0x33, 0x00, -/* sc=28 */ '\'', '@', 0x00, 0x00, '\'', '@', 0x00, 0x00, 0x00, 0x00, -/* sc=29 */ '\\', '|', 0x1C, 0x1C, '\\', '\\', 0x1C, 0x1C, 0x00, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '#', '~', NOP, NOP, '~', '~', NOP, NOP, 0x33, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', '<', NOP, NOP, ',', '<', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', '>', NOP, NOP, '.', '>', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '/', '?', NOP, NOP, '/', '?', NOP, NOP, 0x33, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00, -/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02, -/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x02, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; -#endif - -#ifdef GRKEYMAP -keymap_t key_map = { 0x69, /* german iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, '`', '`', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '"', 0x00, 0x00, '@', '@', 0x00, 0x00, 0x00, 0x00, -/* sc=04 */ '3', 0xA7, NOP, NOP, '#', '#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, '4', '$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '&', 0x1E, 0x1E, '^', '^', 0x1E, 0x1E, 0x00, 0x00, -/* sc=08 */ '7', '/', 0x1B, 0x1B, '[', '[', 0x1B, 0x1B, 0x00, 0x00, -/* sc=09 */ '8', '(', NOP, NOP, '8', '(', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '9', ')', 0x1D, 0x1D, ']', ']', 0x1D, 0x1D, 0x00, 0x00, -/* sc=0b */ '0', '=', NOP, NOP, '{', '{', NOP, NOP, 0x33, 0x00, -/* sc=0c */ 0xDF, '?', NOP, NOP, '|', '|', NOP, NOP, 0x33, 0x00, -/* sc=0d */ 0x92, 0x93, NOP, NOP, '\'', '`', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x77, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ 0xFC, 0xDC, 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x01, -/* sc=1b */ '+', '*', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ 0xF6, 0xD6, NOP, NOP, 0xF6, 0xD6, NOP, NOP, 0x33, 0x01, -/* sc=28 */ 0xE4, 0xC4, NOP, NOP, 0xE4, 0xC4, NOP, NOP, 0x33, 0x01, -/* sc=29 */ '<', '>', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '#', '^', 0x1E, 0x1E, '`', '~', 0x1E, 0x1E, 0x00, 0x00, -/* sc=2c */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', ';', NOP, NOP, ',', ';', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', ':', NOP, NOP, '.', ':', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00, -/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02, -/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x02, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; -#endif - -#ifdef SWKEYMAP -keymap_t key_map = { 0x69, /* swedish iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00, -/* sc=03 */ '2', '"', NOP, NOP, NOP, '@', NOP, NOP, 0x3B, 0x00, -/* sc=04 */ '3', 0xA3, NOP, NOP, NOP, '#', NOP, NOP, 0x3B, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, NOP, NOP, NOP, NOP, 0x3F, 0x00, -/* sc=07 */ '6', '&', 0x1E, NOP, NOP, '^', 0x1E, NOP, 0x19, 0x00, -/* sc=08 */ '7', '/', NOP, NOP, NOP, '&', NOP, NOP, 0x3B, 0x00, -/* sc=09 */ '8', '(', NOP, NOP, NOP, '*', NOP, NOP, 0x3B, 0x00, -/* sc=0a */ '9', ')', NOP, NOP, NOP, '(', NOP, NOP, 0x3B, 0x00, -/* sc=0b */ '0', '=', NOP, NOP, NOP, ')', NOP, NOP, 0x3B, 0x00, -/* sc=0c */ '+', '?', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00, -/* sc=0d */ 0xB4, '`', NOP, NOP, '=', '+', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x77, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ 0xE5, 0xC5, NOP, NOP, '[', '{', 0x1B, NOP, 0x31, 0x01, -/* sc=1b */ 0xA8, '^', NOP, NOP, ']', '}', 0x1D, NOP, 0x31, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ 0xF8, 0xD8, NOP, NOP, ';', ':', NOP, NOP, 0x33, 0x01, -/* sc=28 */ 0xE6, 0xC6, NOP, NOP, '\'', '"', NOP, NOP, 0x33, 0x01, -/* sc=29 */ '<', '>', NOP, NOP, '\\', '|', 0x1C, NOP, 0x31, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\'', '*', NOP, NOP, '`', '~', NOP, NOP, 0x33, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', ';', NOP, NOP, NOP, '<', NOP, NOP, 0x3B, 0x00, -/* sc=34 */ '.', ':', NOP, NOP, NOP, '>', NOP, NOP, 0x3B, 0x00, -/* sc=35 */ '-', '_', 0x1F, NOP, '/', '?', NOP, NOP, 0x13, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, 0x13, 0x13, NLK, NLK, 0x13, 0x13, 0xCC, 0x00, -/* sc=46 */ SLK, SLK, 0x7F, 0x7F, SLK, SLK, 0x7F, 0x7F, 0xCC, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', 0x1F, 0x1F, '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ F(54), '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', 0x1E, 0x1E, '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02, -/* sc=54 */ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0xFF, 0x02, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x02, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x02, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; -#endif - -#ifdef RUKEYMAP -keymap_t key_map = { 0xe9, /* keys number */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * ------------------------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, NOP, NOP, META|0x1B, META|0x1B, NOP, NOP, 0x33, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, META|'1', META|'!', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '@', 0x00, 0x00, META|'2', META|'@', META|0x00, META|0x00, 0x00, 0x00, -/* sc=04 */ '3', '#', NOP, NOP, META|'3', META|'#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, META|'4', META|'$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, META|'5', META|'%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '^', 0x1E, 0x1E, META|'6', META|'^', META|0x1E, META|0x1E, 0x00, 0x00, -/* sc=08 */ '7', '&', NOP, NOP, META|'7', META|'&', NOP, NOP, 0x33, 0x00, -/* sc=09 */ '8', '*', NOP, NOP, META|'8', META|'*', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '9', '(', NOP, NOP, META|'9', META|'(', NOP, NOP, 0x33, 0x00, -/* sc=0b */ '0', ')', NOP, NOP, META|'0', META|')', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '-', '_', 0x1F, 0x1F, META|'-', META|'_', META|0x1F, META|0x1F, 0x00, 0x00, -/* sc=0d */ '=', '+', NOP, NOP, META|'=', META|'+', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, META|0x08, META|0x08, META|0x7F, META|0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, F(16), NOP, NOP, META|0x09, F(16), NOP, NOP, 0x77, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, META|'q', META|'Q', META|0x11, META|0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, META|'w', META|'W', META|0x17, META|0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, META|'e', META|'E', META|0x05, META|0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, META|'r', META|'R', META|0x12, META|0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, META|'t', META|'T', META|0x14, META|0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, META|'y', META|'Y', META|0x19, META|0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, META|'u', META|'U', META|0x15, META|0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, META|'i', META|'I', META|0x09, META|0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, META|'o', META|'O', META|0x0F, META|0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, META|'p', META|'P', META|0x10, META|0x10, 0x00, 0x01, -/* sc=1a */ '[', '{', 0x1B, 0x1B, META|'[', META|'{', META|0x1B, META|0x1B, 0x00, 0x00, -/* sc=1b */ ']', '}', 0x1D, 0x1D, META|']', META|'}', META|0x1D, META|0x1D, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, META|0x0D, META|0x0D, META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, META|'a', META|'A', META|0x01, META|0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, META|'s', META|'S', META|0x13, META|0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, META|'d', META|'D', META|0x04, META|0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, META|'f', META|'F', META|0x06, META|0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, META|'g', META|'G', META|0x07, META|0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, META|'h', META|'H', META|0x08, META|0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, META|'j', META|'J', META|0x0A, META|0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, META|'k', META|'K', META|0x0B, META|0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, META|'l', META|'L', META|0x0C, META|0x0C, 0x00, 0x01, -/* sc=27 */ ';', ':', NOP, NOP, META|';', META|':', NOP, NOP, 0x33, 0x00, -/* sc=28 */ '\'', '"', NOP, NOP, META|'\'', META|'"', NOP, NOP, 0x33, 0x00, -/* sc=29 */ '`', '~', NOP, NOP, META|'`', META|'~', NOP, NOP, 0x33, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\\', '|', 0x1C, 0x1C, META|'\\', META|'|', META|0x1C, META|0x1C, 0x00, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, META|'z', META|'Z', META|0x1A, META|0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, META|'x', META|'X', META|0x18, META|0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, META|'c', META|'C', META|0x03, META|0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, META|'v', META|'V', META|0x16, META|0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, META|'b', META|'B', META|0x02, META|0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, META|'n', META|'N', META|0x0E, META|0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, META|'m', META|'M', META|0x0D, META|0x0D, 0x00, 0x01, -/* sc=33 */ ',', '<', NOP, NOP, META|',', META|'<', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', '>', NOP, NOP, META|'.', META|'>', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '/', '?', NOP, NOP, META|'/', META|'?', NOP, NOP, 0x33, 0x00, -/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, META|'*', META|'*', META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', META|' ', META|' ', META|' ', META|' ', 0x00, 0x00, -/* sc=3a */ ALK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00, -/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=47 */ F(49), '7', '7', '7', META|'7', META|'7', META|'7', META|'7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', META|'8', META|'8', META|'8', META|'8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', META|'9', META|'9', META|'9', META|'9', 0x80, 0x02, -/* sc=4a */ F(52), '-', '-', '-', META|'-', META|'-', META|'-', META|'-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', META|'4', META|'4', META|'4', META|'4', 0x80, 0x02, -/* sc=4c */ F(48), '5', '5', '5', META|'5', META|'5', META|'5', META|'5', 0x80, 0x02, -/* sc=4d */ F(55), '6', '6', '6', META|'6', META|'6', META|'6', META|'6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', META|'+', META|'+', META|'+', META|'+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', META|'1', META|'1', META|'1', META|'1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', META|'2', META|'2', META|'2', META|'2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', META|'3', META|'3', META|'3', META|'3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', META|'0', META|'0', META|'0', META|'0', 0x80, 0x02, -/* sc=53 */ F(54), '.', 0x7F, 0x7F, META|0x7F, META|0x7F, META|0x7F, META|0x7F, 0x80, 0x02, -/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, META|0x0D, META|0x0D, META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', NOP, NOP, META|'/', META|'/', NOP, NOP, 0x33, 0x00, -/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), 0x7F, 0x7F, META|0x7F, META|0x7F, META|0x7F, META|0x7F, 0xC0, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=69 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6b */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6c */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6d */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6e */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=6f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=70 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=71 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=72 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=73 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=74 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=75 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=76 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=77 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=78 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=79 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7a */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7b */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7c */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7d */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7e */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=7f */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* extended (ALTGR LOCK keys) */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, NOP, NOP, META|0x1B, META|0x1B, NOP, NOP, 0x33, 0x00, -/* sc=02 */ '!', '1', NOP, NOP, META|'1', META|'!', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '"', '2', 0x00, 0x00, META|'2', META|'@', META|0x00, META|0x00, 0x00, 0x00, -/* sc=04 */ '\'', '3', NOP, NOP, META|'3', META|'#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ ';', '4', NOP, NOP, META|'4', META|'$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ ':', '5', NOP, NOP, META|'5', META|'%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ ',', '6', 0x1E, 0x1E, META|'6', META|'^', META|0x1E, META|0x1E, 0x00, 0x00, -/* sc=08 */ '.', '7', NOP, NOP, META|'7', META|'&', NOP, NOP, 0x33, 0x00, -/* sc=09 */ '*', '8', NOP, NOP, META|'8', META|'*', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '(', '9', NOP, NOP, META|'9', META|'(', NOP, NOP, 0x33, 0x00, -/* sc=0b */ ')', '0', NOP, NOP, META|'0', META|')', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '_', '-', 0x1F, 0x1F, META|'-', META|'_', META|0x1F, META|0x1F, 0x00, 0x00, -/* sc=0d */ '+', '=', NOP, NOP, META|'=', META|'+', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, META|0x08, META|0x08, META|0x7F, META|0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, F(16), NOP, NOP, META|0x09, F(16), NOP, NOP, 0x77, 0x00, -/* sc=10 */ 0xca, 0xea, 0x11, 0x11, META|'q', META|'Q', META|0x11, META|0x11, 0x00, 0x01, -/* sc=11 */ 0xc3, 0xe3, 0x17, 0x17, META|'w', META|'W', META|0x17, META|0x17, 0x00, 0x01, -/* sc=12 */ 0xd5, 0xf5, 0x05, 0x05, META|'e', META|'E', META|0x05, META|0x05, 0x00, 0x01, -/* sc=13 */ 0xcb, 0xeb, 0x12, 0x12, META|'r', META|'R', META|0x12, META|0x12, 0x00, 0x01, -/* sc=14 */ 0xc5, 0xe5, 0x14, 0x14, META|'t', META|'T', META|0x14, META|0x14, 0x00, 0x01, -/* sc=15 */ 0xce, 0xee, 0x19, 0x19, META|'y', META|'Y', META|0x19, META|0x19, 0x00, 0x01, -/* sc=16 */ 0xc7, 0xe7, 0x15, 0x15, META|'u', META|'U', META|0x15, META|0x15, 0x00, 0x01, -/* sc=17 */ 0xdb, 0xfb, 0x09, 0x09, META|'i', META|'I', META|0x09, META|0x09, 0x00, 0x01, -/* sc=18 */ 0xdd, 0xfd, 0x0F, 0x0F, META|'o', META|'O', META|0x0F, META|0x0F, 0x00, 0x01, -/* sc=19 */ 0xda, 0xfa, 0x10, 0x10, META|'p', META|'P', META|0x10, META|0x10, 0x00, 0x01, -/* sc=1a */ 0xc8, 0xe8, 0x1B, 0x1B, META|'[', META|'{', META|0x1B, META|0x1B, 0x00, 0x01, -/* sc=1b */ 0xdf, 0xff, 0x1D, 0x1D, META|']', META|'}', META|0x1D, META|0x1D, 0x00, 0x01, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, META|0x0D, META|0x0D, META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 0xc6, 0xe6, 0x01, 0x01, META|'a', META|'A', META|0x01, META|0x01, 0x00, 0x01, -/* sc=1f */ 0xd9, 0xf9, 0x13, 0x13, META|'s', META|'S', META|0x13, META|0x13, 0x00, 0x01, -/* sc=20 */ 0xd7, 0xf7, 0x04, 0x04, META|'d', META|'D', META|0x04, META|0x04, 0x00, 0x01, -/* sc=21 */ 0xc1, 0xe1, 0x06, 0x06, META|'f', META|'F', META|0x06, META|0x06, 0x00, 0x01, -/* sc=22 */ 0xd0, 0xf0, 0x07, 0x07, META|'g', META|'G', META|0x07, META|0x07, 0x00, 0x01, -/* sc=23 */ 0xd2, 0xf2, 0x08, 0x08, META|'h', META|'H', META|0x08, META|0x08, 0x00, 0x01, -/* sc=24 */ 0xcf, 0xef, 0x0A, 0x0A, META|'j', META|'J', META|0x0A, META|0x0A, 0x00, 0x01, -/* sc=25 */ 0xcc, 0xec, 0x0B, 0x0B, META|'k', META|'K', META|0x0B, META|0x0B, 0x00, 0x01, -/* sc=26 */ 0xc4, 0xe4, 0x0C, 0x0C, META|'l', META|'L', META|0x0C, META|0x0C, 0x00, 0x01, -/* sc=27 */ 0xd6, 0xf6, NOP, NOP, META|';', META|':', NOP, NOP, 0x33, 0x01, -/* sc=28 */ 0xdc, 0xfc, NOP, NOP, META|'\'', META|'"', NOP, NOP, 0x33, 0x01, -/* sc=29 */ 0xa3, 0xb3, NOP, NOP, META|'`', META|'~', NOP, NOP, 0x33, 0x01, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\\', '|', 0x1C, 0x1C, META|'\\', META|'|', META|0x1C, META|0x1C, 0x00, 0x00, -/* sc=2c */ 0xd1, 0xf1, 0x1A, 0x1A, META|'z', META|'Z', META|0x1A, META|0x1A, 0x00, 0x01, -/* sc=2d */ 0xde, 0xfe, 0x18, 0x18, META|'x', META|'X', META|0x18, META|0x18, 0x00, 0x01, -/* sc=2e */ 0xd3, 0xf3, 0x03, 0x03, META|'c', META|'C', META|0x03, META|0x03, 0x00, 0x01, -/* sc=2f */ 0xcd, 0xed, 0x16, 0x16, META|'v', META|'V', META|0x16, META|0x16, 0x00, 0x01, -/* sc=30 */ 0xc9, 0xe9, 0x02, 0x02, META|'b', META|'B', META|0x02, META|0x02, 0x00, 0x01, -/* sc=31 */ 0xd4, 0xf4, 0x0E, 0x0E, META|'n', META|'N', META|0x0E, META|0x0E, 0x00, 0x01, -/* sc=32 */ 0xd8, 0xf8, 0x0D, 0x0D, META|'m', META|'M', META|0x0D, META|0x0D, 0x00, 0x01, -/* sc=33 */ 0xc2, 0xe2, NOP, NOP, META|',', META|'<', NOP, NOP, 0x33, 0x01, -/* sc=34 */ 0xc0, 0xe0, NOP, NOP, META|'.', META|'>', NOP, NOP, 0x33, 0x01, -/* sc=35 */ '/', '?', NOP, NOP, META|'/', META|'?', NOP, NOP, 0x33, 0x00, -/* sc=36 */ ASH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, META|'*', META|'*', META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', META|' ', META|' ', META|' ', META|' ', 0x00, 0x00, -/* sc=3a */ ALK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00, -/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=47 */ F(49), '7', '7', '7', META|'7', META|'7', META|'7', META|'7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', META|'8', META|'8', META|'8', META|'8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', META|'9', META|'9', META|'9', META|'9', 0x80, 0x02, -/* sc=4a */ F(52), '-', '-', '-', META|'-', META|'-', META|'-', META|'-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', META|'4', META|'4', META|'4', META|'4', 0x80, 0x02, -/* sc=4c */ F(48), '5', '5', '5', META|'5', META|'5', META|'5', META|'5', 0x80, 0x02, -/* sc=4d */ F(55), '6', '6', '6', META|'6', META|'6', META|'6', META|'6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', META|'+', META|'+', META|'+', META|'+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', META|'1', META|'1', META|'1', META|'1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', META|'2', META|'2', META|'2', META|'2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', META|'3', META|'3', META|'3', META|'3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', META|'0', META|'0', META|'0', META|'0', 0x80, 0x02, -/* sc=53 */ F(54), '.', 0x7F, 0x7F, META|0x7F, META|0x7F, META|0x7F, META|0x7F, 0x80, 0x02, -/* sc=54 */ ALK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0A, 0x0A, META|0x0D, META|0x0D, META|0x0A, META|0x0A, 0x00, 0x00, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', NOP, NOP, META|'/', META|'/', NOP, NOP, 0x33, 0x00, -/* sc=5c */ CLK, ALK, ALK, ALK, ALK, ALK, ALK, ALK, 0xFF, 0x00, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), 0x7F, 0x7F, META|0x7F, META|0x7F, META|0x7F, META|0x7F, 0xC0, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; - -#endif - -#if !defined(DKKEYMAP) && !defined(UKKEYMAP) && !defined(GRKEYMAP) && !defined(SWKEYMAP) && !defined(RUKEYMAP) -keymap_t key_map = { 0x69, /* US iso8859 keymap */ -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/* sc=00 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=01 */ 0x1B, 0x1B, NOP, NOP, 0x1B, 0x1B, NOP, NOP, 0x33, 0x00, -/* sc=02 */ '1', '!', NOP, NOP, '1', '!', NOP, NOP, 0x33, 0x00, -/* sc=03 */ '2', '@', 0x00, 0x00, '2', '@', 0x00, 0x00, 0x00, 0x00, -/* sc=04 */ '3', '#', NOP, NOP, '3', '#', NOP, NOP, 0x33, 0x00, -/* sc=05 */ '4', '$', NOP, NOP, '4', '$', NOP, NOP, 0x33, 0x00, -/* sc=06 */ '5', '%', NOP, NOP, '5', '%', NOP, NOP, 0x33, 0x00, -/* sc=07 */ '6', '^', 0x1E, 0x1E, '6', '^', 0x1E, 0x1E, 0x00, 0x00, -/* sc=08 */ '7', '&', NOP, NOP, '7', '&', NOP, NOP, 0x33, 0x00, -/* sc=09 */ '8', '*', NOP, NOP, '8', '*', NOP, NOP, 0x33, 0x00, -/* sc=0a */ '9', '(', NOP, NOP, '9', '(', NOP, NOP, 0x33, 0x00, -/* sc=0b */ '0', ')', NOP, NOP, '0', ')', NOP, NOP, 0x33, 0x00, -/* sc=0c */ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, 0x00, 0x00, -/* sc=0d */ '=', '+', NOP, NOP, '=', '+', NOP, NOP, 0x33, 0x00, -/* sc=0e */ 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x00, 0x00, -/* sc=0f */ 0x09, 0x08, NOP, NOP, 0x09, 0x08, NOP, NOP, 0x33, 0x00, -/* sc=10 */ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, 0x00, 0x01, -/* sc=11 */ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, 0x00, 0x01, -/* sc=12 */ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, 0x00, 0x01, -/* sc=13 */ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, 0x00, 0x01, -/* sc=14 */ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, 0x00, 0x01, -/* sc=15 */ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, 0x00, 0x01, -/* sc=16 */ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, 0x00, 0x01, -/* sc=17 */ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, 0x00, 0x01, -/* sc=18 */ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, 0x00, 0x01, -/* sc=19 */ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, 0x00, 0x01, -/* sc=1a */ '[', '{', 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, 0x00, 0x00, -/* sc=1b */ ']', '}', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, 0x00, 0x00, -/* sc=1c */ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, 0x00, 0x00, -/* sc=1d */ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, 0xFF, 0x00, -/* sc=1e */ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, 0x00, 0x01, -/* sc=1f */ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, 0x00, 0x01, -/* sc=20 */ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, 0x00, 0x01, -/* sc=21 */ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, 0x00, 0x01, -/* sc=22 */ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, 0x00, 0x01, -/* sc=23 */ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, 0x00, 0x01, -/* sc=24 */ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, 0x00, 0x01, -/* sc=25 */ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, 0x00, 0x01, -/* sc=26 */ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, 0x00, 0x01, -/* sc=27 */ ';', ':', NOP, NOP, ';', ':', NOP, NOP, 0x33, 0x00, -/* sc=28 */ '\'', '"', NOP, NOP, '\'', '"', NOP, NOP, 0x33, 0x00, -/* sc=29 */ '`', '~', NOP, NOP, '`', '~', NOP, NOP, 0x33, 0x00, -/* sc=2a */ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, 0xFF, 0x00, -/* sc=2b */ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, 0x00, 0x00, -/* sc=2c */ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, 0x00, 0x01, -/* sc=2d */ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, 0x00, 0x01, -/* sc=2e */ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, 0x00, 0x01, -/* sc=2f */ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, 0x00, 0x01, -/* sc=30 */ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, 0x00, 0x01, -/* sc=31 */ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, 0x00, 0x01, -/* sc=32 */ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, 0x00, 0x01, -/* sc=33 */ ',', '<', NOP, NOP, ',', '<', NOP, NOP, 0x33, 0x00, -/* sc=34 */ '.', '>', NOP, NOP, '.', '>', NOP, NOP, 0x33, 0x00, -/* sc=35 */ '/', '?', NOP, NOP, '/', '?', NOP, NOP, 0x33, 0x00, -/* sc=36 */ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, 0xFF, 0x00, -/* sc=37 */ '*', '*', 0x0A, 0x0A, '*', '*', 0x0A, 0x0A, 0x33, 0x00, -/* sc=38 */ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, 0xFF, 0x00, -/* sc=39 */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x00, 0x00, -/* sc=3a */ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, 0xFF, 0x00, -/* sc=3b */ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11), 0xFF, 0x00, -/* sc=3c */ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12), 0xFF, 0x00, -/* sc=3d */ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13), 0xFF, 0x00, -/* sc=3e */ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14), 0xFF, 0x00, -/* sc=3f */ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15), 0xFF, 0x00, -/* sc=40 */ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16), 0xFF, 0x00, -/* sc=41 */ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7), 0xFF, 0x00, -/* sc=42 */ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8), 0xFF, 0x00, -/* sc=43 */ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9), 0xFF, 0x00, -/* sc=44 */ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10), 0xFF, 0x00, -/* sc=45 */ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, 0xFF, 0x00, -/* sc=46 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -/* sc=47 */ F(49), '7', '7', '7', '7', '7', '7', '7', 0x80, 0x02, -/* sc=48 */ F(50), '8', '8', '8', '8', '8', '8', '8', 0x80, 0x02, -/* sc=49 */ F(51), '9', '9', '9', '9', '9', '9', '9', 0x80, 0x02, -/* sc=4a */ F(52), '-', '-', '-', '-', '-', '-', '-', 0x80, 0x02, -/* sc=4b */ F(53), '4', '4', '4', '4', '4', '4', '4', 0x80, 0x02, -/* sc=4c */ NOP, '5', '5', '5', '5', '5', '5', '5', 0x80, 0x02, -/* sc=4d */ F(55), '6', '6', '6', '6', '6', '6', '6', 0x80, 0x02, -/* sc=4e */ F(56), '+', '+', '+', '+', '+', '+', '+', 0x80, 0x02, -/* sc=4f */ F(57), '1', '1', '1', '1', '1', '1', '1', 0x80, 0x02, -/* sc=50 */ F(58), '2', '2', '2', '2', '2', '2', '2', 0x80, 0x02, -/* sc=51 */ F(59), '3', '3', '3', '3', '3', '3', '3', 0x80, 0x02, -/* sc=52 */ F(60), '0', '0', '0', '0', '0', '0', '0', 0x80, 0x02, -/* sc=53 */ 0x7F, '.', 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x02, -/* sc=54 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=55 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=56 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, 0xFF, 0x00, -/* sc=57 */ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11), 0xFF, 0x00, -/* sc=58 */ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12), 0xFF, 0x00, -/* sc=59 */ 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x00, 0x00, -/* sc=5a */ RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, RCTR, 0xFF, 0x00, -/* sc=5b */ '/', '/', '/', '/', '/', '/', '/', '/', 0x00, 0x00, -/* sc=5c */ '*', '*', '*', '*', '*', '*', '*', '*', 0x00, 0x00, -/* sc=5d */ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, 0xFF, 0x00, -/* sc=5e */ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49), 0xFF, 0x00, -/* sc=5f */ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50), 0xFF, 0x00, -/* sc=60 */ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51), 0xFF, 0x00, -/* sc=61 */ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53), 0xFF, 0x00, -/* sc=62 */ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55), 0xFF, 0x00, -/* sc=63 */ F(57), F(57), F(57), F(57), F(57), F(57), F(57), F(57), 0xFF, 0x00, -/* sc=64 */ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58), 0xFF, 0x00, -/* sc=65 */ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59), 0xFF, 0x00, -/* sc=66 */ F(60), F(60), F(60), F(60), F(60), F(60), F(60), F(60), 0xFF, 0x00, -/* sc=67 */ F(54), F(54), F(54), F(54), F(54), F(54), F(54), F(54), 0xFF, 0x00, -/* sc=68 */ SLK, SLK, SLK, SLK, SLK, SLK, SLK, SLK, 0xFF, 0x00, -}; - -#endif - -fkeytab_t fkey_tab[60] = { -/* 00-03 */ {"\033[M", 3}, {"\033[N", 3}, {"\033[O", 3}, {"\033[P", 3}, -/* 04-07 */ {"\033[Q", 3}, {"\033[R", 3}, {"\033[S", 3}, {"\033[T", 3}, -/* 08-0B */ {"\033[U", 3}, {"\033[V", 3}, {"\033[W", 3}, {"\033[X", 3}, -/* 0C-0F */ {"\033[W", 3}, {"\033[X", 3}, {"\033[Y", 3}, {"\033[Z", 3}, -/* 10-13 */ {"\033[a", 3}, {"\033[b", 3}, {"\033[c", 3}, {"\033[d", 3}, -/* 14-17 */ {"\033[e", 3}, {"\033[f", 3}, {"\033[g", 3}, {"\033[h", 3}, -/* 18-1B */ {"\033[g", 3}, {"\033[h", 3}, {"\033[i", 3}, {"\033[j", 3}, -/* 1C-1F */ {"\033[k", 3}, {"\033[l", 3}, {"\033[m", 3}, {"\033[n", 3}, -/* 20-23 */ {"\033[o", 3}, {"\033[p", 3}, {"\033[q", 3}, {"\033[r", 3}, -/* 24-27 */ {"\033[g", 3}, {"\033[h", 3}, {"\033[i", 3}, {"\033[j", 3}, -/* 28-2B */ {"\033[k", 3}, {"\033[l", 3}, {"\033[m", 3}, {"\033[n", 3}, -/* 2C-2F */ {"\033[o", 3}, {"\033[p", 3}, {"\033[q", 3}, {"\033[r", 3}, -/* 30-33 */ {"\033[H", 3}, {"\033[A", 3}, {"\033[I", 3}, {"-" , 1}, -/* 34-37 */ {"\033[D", 3}, {"\177" , 1}, {"\033[C", 3}, {"+" , 1}, -/* 38-3B */ {"\033[F", 3}, {"\033[B", 3}, {"\033[G", 3}, {"\033[L", 3} -}; diff --git a/sys/i386/isa/lpt.c b/sys/i386/isa/lpt.c deleted file mode 100644 index 6d65d8a..0000000 --- a/sys/i386/isa/lpt.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright (c) 1990 William F. Jolitz, TeleMuse - * 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 software is a component of "386BSD" developed by - * William F. Jolitz, TeleMuse. - * 4. Neither the name of the developer nor the name "386BSD" - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS A COMPONENT OF 386BSD DEVELOPED BY WILLIAM F. JOLITZ - * AND IS INTENDED FOR RESEARCH AND EDUCATIONAL PURPOSES ONLY. THIS - * SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT. - * THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT - * NOT MAKE USE OF THIS WORK. - * - * FOR USERS WHO WISH TO UNDERSTAND THE 386BSD SYSTEM DEVELOPED - * BY WILLIAM F. JOLITZ, WE RECOMMEND THE USER STUDY WRITTEN - * REFERENCES SUCH AS THE "PORTING UNIX TO THE 386" SERIES - * (BEGINNING JANUARY 1991 "DR. DOBBS JOURNAL", USA AND BEGINNING - * JUNE 1991 "UNIX MAGAZIN", GERMANY) BY WILLIAM F. JOLITZ AND - * LYNNE GREER JOLITZ, AS WELL AS OTHER BOOKS ON UNIX AND THE - * ON-LINE 386BSD USER MANUAL BEFORE USE. A BOOK DISCUSSING THE INTERNALS - * OF 386BSD ENTITLED "386BSD FROM THE INSIDE OUT" WILL BE AVAILABLE LATE 1992. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``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 DEVELOPER 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: unknown origin, 386BSD 0.1 - * $Id$ - */ - -/* - * Device Driver for AT parallel printer port - * Written by William Jolitz 12/18/90 - */ - -#include "lpt.h" -#if NLPT > 0 - -#include "param.h" -#include "systm.h" -#include "proc.h" -#include "user.h" -#include "buf.h" -#include "kernel.h" -#include "ioctl.h" -#include "tty.h" -#include "uio.h" - -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/lptreg.h" - -#define LPINITRDY 4 /* wait up to 4 seconds for a ready */ -#define LPTOUTTIME 4 /* wait up to 4 seconds for a ready */ -#define LPPRI (PZERO+8) -#define BUFSIZE 1024 - -#ifndef DEBUG -#define lprintf -#else -#define lprintf if (lptflag) printf -int lptflag = 1; -#endif - -void lptout(); -#ifdef DEBUG -int lptflag = 1; -#endif - -int lptprobe(), lptattach(); -void lptintr(); - -struct isa_driver lptdriver = { - lptprobe, lptattach, "lpt" -}; - -#define LPTUNIT(s) (((s)>>6)&0x3) -#define LPTFLAGS(s) ((s)&0x3f) - -struct lpt_softc { - short sc_port; - short sc_state; - /* default case: negative prime, negative ack, handshake strobe, - prime once */ - u_char sc_control; - char sc_flags; -#define LP_POS_INIT 0x01 /* if we are a postive init signal */ -#define LP_POS_ACK 0x02 /* if we are a positive going ack */ -#define LP_NO_PRIME 0x04 /* don't prime the printer at all */ -#define LP_PRIMEOPEN 0x08 /* prime on every open */ -#define LP_AUTOLF 0x10 /* tell printer to do an automatic lf */ -#define LP_BYPASS 0x20 /* bypass printer ready checks */ - struct buf *sc_inbuf; - short sc_xfercnt ; - char sc_primed; - char *sc_cp ; -} lpt_sc[NLPT] ; - -/* bits for state */ -#define OPEN (1<<0) /* device is open */ -#define ASLP (1<<1) /* awaiting draining of printer */ -#define ERROR (1<<2) /* error was received from printer */ -#define OBUSY (1<<3) /* printer is busy doing output */ -#define LPTOUT (1<<4) /* timeout while not selected */ -#define TOUT (1<<5) /* timeout while not selected */ -#define INIT (1<<6) /* waiting to initialize for open */ - -/* - * Internal routine to lptprobe to do port tests of one byte value - */ -int -lpt_port_test(port, data, mask) - short port; - u_char data; - u_char mask; - { - int temp, timeout; - - data = data & mask; - outb(port, data); - timeout = 100; - do - temp = inb(port) & mask; - while (temp != data && --timeout); - lprintf("Port 0x%x\tout=%x\tin=%x\n", port, data, temp); - return (temp == data); - } - -/* - * New lptprobe routine written by Rodney W. Grimes, 3/25/1993 - * - * Logic: - * 1) You should be able to write to and read back the same value - * to the data port. Do an alternating zeros, alternating ones, - * walking zero, and walking one test to check for stuck bits. - * - * 2) You should be able to write to and read back the same value - * to the control port lower 5 bits, the upper 3 bits are reserved - * per the IBM PC technical reference manauls and different boards - * do different things with them. Do an alternating zeros, alternating - * ones, walking zero, and walking one test to check for stuck bits. - * - * Some printers drag the strobe line down when the are powered off - * so this bit has been masked out of the control port test. - * - * XXX Some printers may not like a fast pulse on init or strobe, I - * don't know at this point, if that becomes a problem these bits - * should be turned off in the mask byte for the control port test. - * - * 3) Set the data and control ports to a value of 0 - */ - -int -lptprobe(dvp) - struct isa_device *dvp; -{ - int status; - short port; - u_char data; - u_char mask; - int i; - - status = IO_LPTSIZE; - - port = dvp->id_iobase + lpt_data; - mask = 0xff; - while (mask != 0) - { - data = 0x55; /* Alternating zeros */ - if (!lpt_port_test(port, data, mask)) status = 0; - - data = 0xaa; /* Alternating ones */ - if (!lpt_port_test(port, data, mask)) status = 0; - - for (i = 0; i < 8; i++) /* Walking zero */ - { - data = ~(1 << i); - if (!lpt_port_test(port, data, mask)) status = 0; - } - - for (i = 0; i < 8; i++) /* Walking one */ - { - data = (1 << i); - if (!lpt_port_test(port, data, mask)) status = 0; - } - - if (port == dvp->id_iobase + lpt_data) - { - port = dvp->id_iobase + lpt_control; - mask = 0x1e; - } - else - mask = 0; - } - outb(dvp->id_iobase+lpt_data, 0); - outb(dvp->id_iobase+lpt_control, 0); - return (status); - } - -int -lptattach(isdp) - struct isa_device *isdp; -{ - struct lpt_softc *sc; - - sc = lpt_sc + isdp->id_unit; - sc->sc_port = isdp->id_iobase; - outb(sc->sc_port+lpt_control, LPC_NINIT); - return (1); -} - -/* - * lptopen -- reset the printer, then wait until it's selected and not busy. - */ - -int -lptopen(dev, flag) - dev_t dev; - int flag; -{ - struct lpt_softc *sc; - int s; - int trys, port; - u_int unit = LPTUNIT(minor(dev)); - - if (unit >= NLPT) - return (ENXIO); - sc = lpt_sc + unit; - - if (sc->sc_state) { -lprintf("lp: still open\n") ; -lprintf("still open %x\n", sc->sc_state); - return(EBUSY); - } else sc->sc_state |= INIT; - - s = spltty(); - sc->sc_flags = LPTFLAGS(minor(dev)); -lprintf("lp flags 0x%x\n", sc->sc_flags); - port = sc->sc_port; - - /* init printer */ - if((sc->sc_flags & LP_NO_PRIME) == 0) { - if((sc->sc_flags & LP_PRIMEOPEN) || sc->sc_primed == 0) { - outb(port+lpt_control, 0); - sc->sc_primed++; - DELAY(500); - } - } - outb(port+lpt_control, LPC_SEL|LPC_NINIT); - - /* wait till ready (printer running diagnostics) */ - trys = 0; - do { - /* ran out of waiting for the printer */ - if (trys++ >= LPINITRDY*4) { - splx(s); - sc->sc_state = 0; -lprintf ("status %x\n", inb(port+lpt_status) ); - return (EBUSY); - } - - /* wait 1/4 second, give up if we get a signal */ - if (tsleep (sc, LPPRI|PCATCH, "lptinit", hz/4) != EWOULDBLOCK) { - sc->sc_state = 0; - splx(s); - return (EBUSY); - } - - /* is printer online and ready for output */ - } while ((inb(port+lpt_status) & (LPS_SEL|LPS_OUT|LPS_NBSY|LPS_NERR)) != - (LPS_SEL|LPS_NBSY|LPS_NERR)); - - if(sc->sc_flags&LP_AUTOLF) { - outb(port+lpt_control, LPC_SEL|LPC_NINIT|LPC_ENA|LPC_AUTOL); - sc->sc_control = LPC_SEL|LPC_NINIT|LPC_ENA|LPC_AUTOL; - } else { - outb(port+lpt_control, LPC_SEL|LPC_NINIT|LPC_ENA); - sc->sc_control = LPC_SEL|LPC_NINIT|LPC_ENA; - } - - sc->sc_state = OPEN | TOUT; - sc->sc_inbuf = geteblk(BUFSIZE); - sc->sc_xfercnt = 0; - splx(s); - timeout (lptout, sc, hz/2); -lprintf("opened.\n"); - return(0); -} - -void -lptout (sc) - struct lpt_softc *sc; -{ int pl; - -lprintf ("T %x ", inb(sc->sc_port+lpt_status)); - if (sc->sc_state&OPEN) - timeout (lptout, sc, hz/2); - else sc->sc_state &= ~TOUT; - - if (sc->sc_state & ERROR) - sc->sc_state &= ~ERROR; - - /* - * Avoid possible hangs do to missed interrupts - */ - if (sc->sc_xfercnt) { - pl = spltty(); - lptintr(sc - lpt_sc); - splx(pl); - } else { - sc->sc_state &= ~OBUSY; - wakeup((caddr_t)sc); - } -} - -/* - * lptclose -- close the device, free the local line buffer. - */ - -int -lptclose(dev, flag) - dev_t dev; - int flag; -{ - struct lpt_softc *sc = lpt_sc + LPTUNIT(minor(dev)); - int port = sc->sc_port; - - sc->sc_state &= ~OPEN; - while ((inb(port+lpt_status) & (LPS_SEL|LPS_OUT|LPS_NBSY|LPS_NERR)) != - (LPS_SEL|LPS_NBSY|LPS_NERR) || sc->sc_xfercnt) - /* wait 1/4 second, give up if we get a signal */ - if (tsleep (sc, LPPRI|PCATCH, "lpclose", hz) != EWOULDBLOCK) - break; - - sc->sc_state = 0; - sc->sc_xfercnt = 0; - outb(sc->sc_port+lpt_control, LPC_NINIT); - brelse(sc->sc_inbuf); -lprintf("closed.\n"); - return(0); -} - -/* - * lptwrite --copy a line from user space to a local buffer, then call - * putc to get the chars moved to the output queue. - */ - -int -lptwrite(dev, uio) - dev_t dev; - struct uio *uio; -{ - register unsigned n; - int pl, err; - struct lpt_softc *sc = lpt_sc + LPTUNIT(minor(dev)); - - while (n = MIN(BUFSIZE, uio->uio_resid)) { - sc->sc_cp = sc->sc_inbuf->b_un.b_addr ; - uiomove(sc->sc_cp, n, uio); - sc->sc_xfercnt = n ; - while (sc->sc_xfercnt > 0) { - /* if the printer is ready for a char, give it one */ - if ((sc->sc_state & OBUSY) == 0){ -lprintf("\nC %d. ", sc->sc_xfercnt); - pl = spltty(); - lptintr(sc - lpt_sc); - (void) splx(pl); - } -lprintf("W "); - if (err = tsleep (sc, LPPRI|PCATCH, "lpwrite", 0)) - return(err); - } - } - return(0); -} - -/* - * lptintr -- handle printer interrupts which occur when the printer is - * ready to accept another char. - */ - -void -lptintr(unit) - int unit; -{ - struct lpt_softc *sc = lpt_sc + unit; - int port = sc->sc_port,sts; - - /* is printer online and ready for output */ - if (((sts=inb(port+lpt_status)) & (LPS_SEL|LPS_OUT|LPS_NBSY|LPS_NERR/*|LPS_NACK*/)) == - (LPS_SEL|LPS_NBSY|LPS_NERR)) { - /* is this a false interrupt ? */ - if ((sc->sc_state & OBUSY) - && (sts & LPS_NACK) == 0) return; - sc->sc_state |= OBUSY; sc->sc_state &= ~ERROR; - - if (sc->sc_xfercnt) { - /* send char */ -/*lprintf("%x ", *sc->sc_cp); */ - outb(port+lpt_data, *sc->sc_cp++) ; sc->sc_xfercnt-- ; - outb(port+lpt_control, sc->sc_control|LPC_STB); - /* DELAY(X) */ - outb(port+lpt_control, sc->sc_control); - } - - /* any more bytes for the printer? */ - if (sc->sc_xfercnt > 0) return; - - /* none, wake up the top half to get more */ - sc->sc_state &= ~OBUSY; - wakeup((caddr_t)sc); -lprintf("w "); -return; - } else sc->sc_state |= ERROR; -lprintf("sts %x ", sts); -} - -int -lptioctl(dev, cmd, data, flag) - dev_t dev; - int cmd; - caddr_t data; - int flag; -{ - int error; - - error = 0; - switch (cmd) { -#ifdef THISISASAMPLE - case XXX: - dothis; andthis; andthat; - error=x; - break; -#endif /* THISISASAMPLE */ - default: - error = ENODEV; - } - - return(error); -} - -#endif /* NLPT */ diff --git a/sys/i386/isa/lptreg.h b/sys/i386/isa/lptreg.h deleted file mode 100644 index 9e10ba9..0000000 --- a/sys/i386/isa/lptreg.h +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * form: @(#)lptreg.h 1.1 (Berkeley) 12/19/90 - * $Id$ - */ - -/* - * AT Parallel Port (for lineprinter) - * Interface port and bit definitions - * Written by William Jolitz 12/18/90 - * Copyright (C) William Jolitz 1990 - */ - -#define lpt_data 0 /* Data to/from printer (R/W) */ - -#define lpt_status 1 /* Status of printer (R) */ -#define LPS_NERR 0x08 /* printer no error */ -#define LPS_SEL 0x10 /* printer selected */ -#define LPS_OUT 0x20 /* printer out of paper */ -#define LPS_NACK 0x40 /* printer no ack of data */ -#define LPS_NBSY 0x80 /* printer no ack of data */ - -#define lpt_control 2 /* Control printer (R/W) */ -#define LPC_STB 0x01 /* strobe data to printer */ -#define LPC_AUTOL 0x02 /* automatic linefeed */ -#define LPC_NINIT 0x04 /* initialize printer */ -#define LPC_SEL 0x08 /* printer selected */ -#define LPC_ENA 0x10 /* printer out of paper */ diff --git a/sys/i386/isa/mcd.c b/sys/i386/isa/mcd.c deleted file mode 100644 index 3064d08..0000000 --- a/sys/i386/isa/mcd.c +++ /dev/null @@ -1,1260 +0,0 @@ -/* - * Copyright 1993 by Holger Veit (data part) - * Copyright 1993 by Brian Moore (audio part) - * 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 software was developed by Holger Veit and Brian Moore - * for use with "386BSD" and similar operating systems. - * "Similar operating systems" includes mainly non-profit oriented - * systems for research and education, including but not restricted to - * "NetBSD", "FreeBSD", "Mach" (by CMU). - * 4. Neither the name of the developer(s) nor the name "386BSD" - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``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 DEVELOPER(S) 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. - * - * $Id: mcd.c,v 1.1 1993/10/12 06:08:29 rgrimes Exp $ - */ -static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; - -#include "mcd.h" -#if NMCD > 0 -#include "types.h" -#include "param.h" -#include "systm.h" -#include "conf.h" -#include "file.h" -#include "buf.h" -#include "stat.h" -#include "uio.h" -#include "ioctl.h" -#include "cdio.h" -#include "errno.h" -#include "dkbad.h" -#include "disklabel.h" -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "mcdreg.h" - -/* user definable options */ -/*#define MCD_TO_WARNING_ON*/ /* define to get timeout messages */ -/*#define MCDMINI*/ /* define for a mini configuration for boot kernel */ - - -#ifdef MCDMINI -#define MCD_TRACE(fmt,a,b,c,d) -#ifdef MCD_TO_WARNING_ON -#undef MCD_TO_WARNING_ON -#endif -#else -#define MCD_TRACE(fmt,a,b,c,d) {if (mcd_data[unit].debug) {printf("mcd%d st=%02x: ",unit,mcd_data[unit].status); printf(fmt,a,b,c,d);}} -#endif - -#define mcd_part(dev) ((minor(dev)) & 7) -#define mcd_unit(dev) (((minor(dev)) & 0x38) >> 3) -#define mcd_phys(dev) (((minor(dev)) & 0x40) >> 6) -#define RAW_PART 3 - -/* flags */ -#define MCDOPEN 0x0001 /* device opened */ -#define MCDVALID 0x0002 /* parameters loaded */ -#define MCDINIT 0x0004 /* device is init'd */ -#define MCDWAIT 0x0008 /* waiting for something */ -#define MCDLABEL 0x0010 /* label is read */ -#define MCDPROBING 0x0020 /* probing */ -#define MCDREADRAW 0x0040 /* read raw mode (2352 bytes) */ -#define MCDVOLINFO 0x0080 /* already read volinfo */ -#define MCDTOC 0x0100 /* already read toc */ -#define MCDMBXBSY 0x0200 /* local mbx is busy */ - -/* status */ -#define MCDAUDIOBSY MCD_ST_AUDIOBSY /* playing audio */ -#define MCDDSKCHNG MCD_ST_DSKCHNG /* sensed change of disk */ -#define MCDDSKIN MCD_ST_DSKIN /* sensed disk in drive */ -#define MCDDOOROPEN MCD_ST_DOOROPEN /* sensed door open */ - -/* toc */ -#define MCD_MAXTOCS 104 /* from the Linux driver */ -#define MCD_LASTPLUS1 170 /* special toc entry */ - -struct mcd_mbx { - short unit; - short port; - short retry; - short nblk; - int sz; - u_long skip; - struct buf *bp; - int p_offset; - short count; -}; - -struct mcd_data { - short config; - short flags; - short status; - int blksize; - u_long disksize; - int iobase; - struct disklabel dlabel; - int partflags[MAXPARTITIONS]; - int openflags; - struct mcd_volinfo volinfo; -#ifndef MCDMINI - struct mcd_qchninfo toc[MCD_MAXTOCS]; - short audio_status; - struct mcd_read2 lastpb; -#endif - short debug; - struct buf head; /* head of buf queue */ - struct mcd_mbx mbx; -} mcd_data[NMCD]; - -/* reader state machine */ -#define MCD_S_BEGIN 0 -#define MCD_S_BEGIN1 1 -#define MCD_S_WAITSTAT 2 -#define MCD_S_WAITMODE 3 -#define MCD_S_WAITREAD 4 - -/* prototypes */ -int mcdopen(dev_t dev); -int mcdclose(dev_t dev); -int mcdstrategy(struct buf *bp); -int mcdioctl(dev_t dev, int cmd, caddr_t addr, int flags); -int mcdsize(dev_t dev); -static void mcd_done(struct mcd_mbx *mbx); -static void mcd_start(int unit); -static int mcd_getdisklabel(int unit); -static void mcd_configure(struct mcd_data *cd); -static int mcd_get(int unit, char *buf, int nmax); -static void mcd_setflags(int unit,struct mcd_data *cd); -static int mcd_getstat(int unit,int sflg); -static int mcd_send(int unit, int cmd,int nretrys); -static int bcd2bin(bcd_t b); -static bcd_t bin2bcd(int b); -static void hsg2msf(int hsg, bcd_t *msf); -static int msf2hsg(bcd_t *msf); -static int mcd_volinfo(int unit); -static int mcd_waitrdy(int port,int dly); -static void mcd_doread(int state, struct mcd_mbx *mbxin); -#ifndef MCDMINI -static int mcd_setmode(int unit, int mode); -static int mcd_getqchan(int unit, struct mcd_qchninfo *q); -static int mcd_subchan(int unit, struct ioc_read_subchannel *sc); -static int mcd_toc_header(int unit, struct ioc_toc_header *th); -static int mcd_read_toc(int unit); -static int mcd_toc_entry(int unit, struct ioc_read_toc_entry *te); -static int mcd_stop(int unit); -static int mcd_playtracks(int unit, struct ioc_play_track *pt); -static int mcd_play(int unit, struct mcd_read2 *pb); -static int mcd_pause(int unit); -static int mcd_resume(int unit); -#endif - -extern int hz; -extern int mcd_probe(struct isa_device *dev); -extern int mcd_attach(struct isa_device *dev); -struct isa_driver mcddriver = { mcd_probe, mcd_attach, "mcd" }; - -#define mcd_put(port,byte) outb(port,byte) - -#define MCD_RETRYS 5 -#define MCD_RDRETRYS 8 - -#define MCDBLK 2048 /* for cooked mode */ -#define MCDRBLK 2352 /* for raw mode */ - -/* several delays */ -#define RDELAY_WAITSTAT 300 -#define RDELAY_WAITMODE 300 -#define RDELAY_WAITREAD 800 - -#define DELAY_STATUS 10000l /* 10000 * 1us */ -#define DELAY_GETREPLY 200000l /* 200000 * 2us */ -#define DELAY_SEEKREAD 20000l /* 20000 * 1us */ -#define mcd_delay DELAY - -int mcd_attach(struct isa_device *dev) -{ - struct mcd_data *cd = mcd_data + dev->id_unit; - int i; - - cd->iobase = dev->id_iobase; - cd->flags |= MCDINIT; - cd->openflags = 0; - for (i=0; ipartflags[i] = 0; - -#ifdef NOTYET - /* wire controller for interrupts and dma */ - mcd_configure(cd); -#endif - - return 1; -} - -int mcdopen(dev_t dev) -{ - int unit,part,phys; - struct mcd_data *cd; - - unit = mcd_unit(dev); - if (unit >= NMCD) - return ENXIO; - - cd = mcd_data + unit; - part = mcd_part(dev); - phys = mcd_phys(dev); - - /* not initialized*/ - if (!(cd->flags & MCDINIT)) - return ENXIO; - - /* invalidated in the meantime? mark all open part's invalid */ - if (!(cd->flags & MCDVALID) && cd->openflags) - return ENXIO; - - if (mcd_getstat(unit,1) < 0) - return ENXIO; - - /* XXX get a default disklabel */ - mcd_getdisklabel(unit); - - if (mcdsize(dev) < 0) { - printf("mcd%d: failed to get disk size\n",unit); - return ENXIO; - } else - cd->flags |= MCDVALID; - -MCD_TRACE("open: partition=%d, disksize = %d, blksize=%d\n", - part,cd->disksize,cd->blksize,0); - - if (part == RAW_PART || - (part < cd->dlabel.d_npartitions && - cd->dlabel.d_partitions[part].p_fstype != FS_UNUSED)) { - cd->partflags[part] |= MCDOPEN; - cd->openflags |= (1<partflags[part] |= MCDREADRAW; - return 0; - } - - return ENXIO; -} - -int mcdclose(dev_t dev) -{ - int unit,part,phys; - struct mcd_data *cd; - - unit = mcd_unit(dev); - if (unit >= NMCD) - return ENXIO; - - cd = mcd_data + unit; - part = mcd_part(dev); - phys = mcd_phys(dev); - - if (!(cd->flags & MCDINIT)) - return ENXIO; - - mcd_getstat(unit,1); /* get status */ - - /* close channel */ - cd->partflags[part] &= ~(MCDOPEN|MCDREADRAW); - cd->openflags &= ~(1<b_dev); - - cd = mcd_data + unit; - - /* test validity */ -/*MCD_TRACE("strategy: buf=0x%lx, unit=%ld, block#=%ld bcount=%ld\n", - bp,unit,bp->b_blkno,bp->b_bcount);*/ - if (unit >= NMCD || bp->b_blkno < 0) { - printf("mcdstrategy: unit = %d, blkno = %d, bcount = %d\n", - unit, bp->b_blkno, bp->b_bcount); - pg("mcd: mcdstratregy failure"); - bp->b_error = EINVAL; - bp->b_flags |= B_ERROR; - goto bad; - } - - /* if device invalidated (e.g. media change, door open), error */ - if (!(cd->flags & MCDVALID)) { -MCD_TRACE("strategy: drive not valid\n",0,0,0,0); - bp->b_error = EIO; - goto bad; - } - - /* read only */ - if (!(bp->b_flags & B_READ)) { - bp->b_error = EROFS; - goto bad; - } - - /* no data to read */ - if (bp->b_bcount == 0) - goto done; - - /* for non raw access, check partition limits */ - if (mcd_part(bp->b_dev) != RAW_PART) { - if (!(cd->flags & MCDLABEL)) { - bp->b_error = EIO; - goto bad; - } - /* adjust transfer if necessary */ - if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0) { - goto done; - } - } - - /* queue it */ - qp = &cd->head; - s = splbio(); - disksort(qp,bp); - splx(s); - - /* now check whether we can perform processing */ - mcd_start(unit); - return; - -bad: - bp->b_flags |= B_ERROR; -done: - bp->b_resid = bp->b_bcount; - biodone(bp); - return; -} - -static void mcd_start(int unit) -{ - struct mcd_data *cd = mcd_data + unit; - struct buf *bp, *qp = &cd->head; - struct partition *p; - int part; - register s = splbio(); - - if (cd->flags & MCDMBXBSY) - return; - - if ((bp = qp->b_actf) != 0) { - /* block found to process, dequeue */ - /*MCD_TRACE("mcd_start: found block bp=0x%x\n",bp,0,0,0);*/ - qp->b_actf = bp->av_forw; - splx(s); - } else { - /* nothing to do */ - splx(s); - return; - } - - /* changed media? */ - if (!(cd->flags & MCDVALID)) { - MCD_TRACE("mcd_start: drive not valid\n",0,0,0,0); - return; - } - - p = cd->dlabel.d_partitions + mcd_part(bp->b_dev); - - cd->flags |= MCDMBXBSY; - cd->mbx.unit = unit; - cd->mbx.port = cd->iobase; - cd->mbx.retry = MCD_RETRYS; - cd->mbx.bp = bp; - cd->mbx.p_offset = p->p_offset; - - /* calling the read routine */ - mcd_doread(MCD_S_BEGIN,&(cd->mbx)); - /* triggers mcd_start, when successful finished */ - return; -} - -int mcdioctl(dev_t dev, int cmd, caddr_t addr, int flags) -{ - struct mcd_data *cd; - int unit,part; - - unit = mcd_unit(dev); - part = mcd_part(dev); - cd = mcd_data + unit; - -#ifdef MCDMINI - return ENOTTY; -#else - if (!(cd->flags & MCDVALID)) - return EIO; -MCD_TRACE("ioctl called 0x%x\n",cmd,0,0,0); - - switch (cmd) { - case DIOCSBAD: - return EINVAL; - case DIOCGDINFO: - case DIOCGPART: - case DIOCWDINFO: - case DIOCSDINFO: - case DIOCWLABEL: - return ENOTTY; - case CDIOCPLAYTRACKS: - return mcd_playtracks(unit, (struct ioc_play_track *) addr); - case CDIOCPLAYBLOCKS: - return mcd_play(unit, (struct mcd_read2 *) addr); - case CDIOCREADSUBCHANNEL: - return mcd_subchan(unit, (struct ioc_read_subchannel *) addr); - case CDIOREADTOCHEADER: - return mcd_toc_header(unit, (struct ioc_toc_header *) addr); - case CDIOREADTOCENTRYS: - return mcd_toc_entry(unit, (struct ioc_read_toc_entry *) addr); - case CDIOCSETPATCH: - case CDIOCGETVOL: - case CDIOCSETVOL: - case CDIOCSETMONO: - case CDIOCSETSTERIO: - case CDIOCSETMUTE: - case CDIOCSETLEFT: - case CDIOCSETRIGHT: - return EINVAL; - case CDIOCRESUME: - return mcd_resume(unit); - case CDIOCPAUSE: - return mcd_pause(unit); - case CDIOCSTART: - return EINVAL; - case CDIOCSTOP: - return mcd_stop(unit); - case CDIOCEJECT: - return EINVAL; - case CDIOCSETDEBUG: - cd->debug = 1; - return 0; - case CDIOCCLRDEBUG: - cd->debug = 0; - return 0; - case CDIOCRESET: - return EINVAL; - default: - return ENOTTY; - } - /*NOTREACHED*/ -#endif /*!MCDMINI*/ -} - -/* this could have been taken from scsi/cd.c, but it is not clear - * whether the scsi cd driver is linked in - */ -static int mcd_getdisklabel(int unit) -{ - struct mcd_data *cd = mcd_data + unit; - - if (cd->flags & MCDLABEL) - return -1; - - bzero(&cd->dlabel,sizeof(struct disklabel)); - strncpy(cd->dlabel.d_typename,"Mitsumi CD ROM ",16); - strncpy(cd->dlabel.d_packname,"unknown ",16); - cd->dlabel.d_secsize = cd->blksize; - cd->dlabel.d_nsectors = 100; - cd->dlabel.d_ntracks = 1; - cd->dlabel.d_ncylinders = (cd->disksize/100)+1; - cd->dlabel.d_secpercyl = 100; - cd->dlabel.d_secperunit = cd->disksize; - cd->dlabel.d_rpm = 300; - cd->dlabel.d_interleave = 1; - cd->dlabel.d_flags = D_REMOVABLE; - cd->dlabel.d_npartitions= 1; - cd->dlabel.d_partitions[0].p_offset = 0; - cd->dlabel.d_partitions[0].p_size = cd->disksize; - cd->dlabel.d_partitions[0].p_fstype = 9; - cd->dlabel.d_magic = DISKMAGIC; - cd->dlabel.d_magic2 = DISKMAGIC; - cd->dlabel.d_checksum = dkcksum(&cd->dlabel); - - cd->flags |= MCDLABEL; - return 0; -} - -int mcdsize(dev_t dev) -{ - int size; - int unit = mcd_unit(dev); - struct mcd_data *cd = mcd_data + unit; - - if (mcd_volinfo(unit) >= 0) { - cd->blksize = MCDBLK; - size = msf2hsg(cd->volinfo.vol_msf); - cd->disksize = size * (MCDBLK/DEV_BSIZE); - return 0; - } - return -1; -} - -/*************************************************************** - * lower level of driver starts here - **************************************************************/ - -#ifdef NOTDEF -static char irqs[] = { - 0x00,0x00,0x10,0x20,0x00,0x30,0x00,0x00, - 0x00,0x10,0x40,0x50,0x00,0x00,0x00,0x00 -}; - -static char drqs[] = { - 0x00,0x01,0x00,0x03,0x00,0x05,0x06,0x07, -}; -#endif - -static void mcd_configure(struct mcd_data *cd) -{ - outb(cd->iobase+mcd_config,cd->config); -} - -/* check if there is a cdrom */ -/* Heavly hacked by gclarkii@sugar.neosoft.com */ - -int mcd_probe(struct isa_device *dev) -{ - int port = dev->id_iobase; - int unit = dev->id_unit; - int i; - int st; - int check; - int junk; - - mcd_data[unit].flags = MCDPROBING; - -#ifdef NOTDEF - /* get irq/drq configuration word */ - mcd_data[unit].config = irqs[dev->id_irq]; /* | drqs[dev->id_drq];*/ -#else - mcd_data[unit].config = 0; -#endif - - /* send a reset */ - outb(port+MCD_FLAGS,0); - DELAY(100000); - /* get any pending status and throw away...*/ - for (i=10; i != 0; i--) { - inb(port+MCD_DATA); - } - DELAY(1000); - - outb(port+MCD_DATA,MCD_CMDGETSTAT); /* Send get status command */ - - /* Loop looking for avail of status */ - /* XXX May have to increase for fast machinces */ - for (i = 1000; i != 0; i--) { - if ((inb(port+MCD_FLAGS) & 0xF ) == STATUS_AVAIL) { - break; - } - DELAY(10); - } - /* get status */ - - if (i == 0) { -#ifdef DEBUG - printf ("Mitsumi drive NOT detected\n"); -#endif - return 0; - } - -/* - * The following code uses the 0xDC command, it returns a M from the - * second byte and a number in the third. Does anyone know what the - * number is for? Better yet, how about someone thats REAL good in - * i80x86 asm looking at the Dos driver... Most of this info came - * from a friend of mine spending a whole weekend..... - */ - - DELAY (2000); - outb(port+MCD_DATA,MCD_CMDCONTINFO); - for (i = 0; i < 100000; i++) { - if ((inb(port+MCD_FLAGS) & 0xF) == STATUS_AVAIL) - break; - } - if (i > 100000) { -#ifdef DEBUG - printf ("Mitsumi drive error\n"); -#endif - return 0; - } - DELAY (40000); - st = inb(port+MCD_DATA); - DELAY (500); - check = inb(port+MCD_DATA); - DELAY (500); - junk = inb(port+MCD_DATA); /* What is byte used for?!?!? */ - - if (check = 'M') { -#ifdef DEBUG - printf("Mitsumi drive detected\n"); -#endif - return 4; - } else { - printf("Mitsumi drive NOT detected\n"); - printf("Mitsumi drive error\n"); - return 0; - } -} - -static int mcd_waitrdy(int port,int dly) -{ - int i; - - /* wait until xfer port senses data ready */ - for (i=0; iiobase; - - /* wait data to become ready */ - if (mcd_waitrdy(port,dly)<0) { -#ifdef MCD_TO_WARNING_ON - printf("mcd%d: timeout getreply\n",unit); -#endif - return -1; - } - - /* get the data */ - return inb(port+mcd_status) & 0xFF; -} - -static int mcd_getstat(int unit,int sflg) -{ - int i; - struct mcd_data *cd = mcd_data + unit; - int port = cd->iobase; - - /* get the status */ - if (sflg) - outb(port+mcd_command, MCD_CMDGETSTAT); - i = mcd_getreply(unit,DELAY_GETREPLY); - if (i<0) return -1; - - cd->status = i; - - mcd_setflags(unit,cd); - return cd->status; -} - -static void mcd_setflags(int unit, struct mcd_data *cd) -{ - /* check flags */ - if (cd->status & (MCDDSKCHNG|MCDDOOROPEN)) { - MCD_TRACE("getstat: sensed DSKCHNG or DOOROPEN\n",0,0,0,0); - cd->flags &= ~MCDVALID; - } - -#ifndef MCDMINI - if (cd->status & MCDAUDIOBSY) - cd->audio_status = CD_AS_PLAY_IN_PROGRESS; - else if (cd->audio_status == CD_AS_PLAY_IN_PROGRESS) - cd->audio_status = CD_AS_PLAY_COMPLETED; -#endif -} - -static int mcd_get(int unit, char *buf, int nmax) -{ - int port = mcd_data[unit].iobase; - int i,k; - - for (i=0; i> 4) * 10 + (b & 15); -} - -static bcd_t bin2bcd(int b) -{ - return ((b / 10) << 4) | (b % 10); -} - -static void hsg2msf(int hsg, bcd_t *msf) -{ - hsg += 150; - M_msf(msf) = bin2bcd(hsg / 4500); - hsg %= 4500; - S_msf(msf) = bin2bcd(hsg / 75); - F_msf(msf) = bin2bcd(hsg % 75); -} - -static int msf2hsg(bcd_t *msf) -{ - return (bcd2bin(M_msf(msf)) * 60 + - bcd2bin(S_msf(msf))) * 75 + - bcd2bin(F_msf(msf)) - 150; -} - -static int mcd_volinfo(int unit) -{ - struct mcd_data *cd = mcd_data + unit; - int i; - -/*MCD_TRACE("mcd_volinfo: enter\n",0,0,0,0);*/ - - /* Get the status, in case the disc has been changed */ - if (mcd_getstat(unit, 1) < 0) return EIO; - - /* Just return if we already have it */ - if (cd->flags & MCDVOLINFO) return 0; - - /* send volume info command */ - if (mcd_send(unit,MCD_CMDGETVOLINFO,MCD_RETRYS) < 0) - return -1; - - /* get data */ - if (mcd_get(unit,(char*) &cd->volinfo,sizeof(struct mcd_volinfo)) < 0) { - printf("mcd%d: mcd_volinfo: error read data\n",unit); - return -1; - } - - if (cd->volinfo.trk_low != 0 || cd->volinfo.trk_high != 0) { - cd->flags |= MCDVOLINFO; /* volinfo is OK */ - return 0; - } - - return -1; -} - -int mcdintr(unit) -{ - int port = mcd_data[unit].iobase; - u_int i; - - MCD_TRACE("stray interrupt xfer=0x%x\n",inb(port+mcd_xfer),0,0,0); - - /* just read out status and ignore the rest */ - if ((inb(port+mcd_xfer)&0xFF) != 0xFF) { - i = inb(port+mcd_status); - } -} - -/* state machine to process read requests - * initialize with MCD_S_BEGIN: calculate sizes, and read status - * MCD_S_WAITSTAT: wait for status reply, set mode - * MCD_S_WAITMODE: waits for status reply from set mode, set read command - * MCD_S_WAITREAD: wait for read ready, read data - */ -static struct mcd_mbx *mbxsave; - -static void mcd_doread(int state, struct mcd_mbx *mbxin) -{ - struct mcd_mbx *mbx = (state!=MCD_S_BEGIN) ? mbxsave : mbxin; - int unit = mbx->unit; - int port = mbx->port; - struct buf *bp = mbx->bp; - struct mcd_data *cd = mcd_data + unit; - - int rm,i,k; - struct mcd_read2 rbuf; - int blknum; - caddr_t addr; - -loop: - switch (state) { - case MCD_S_BEGIN: - mbx = mbxsave = mbxin; - - case MCD_S_BEGIN1: - /* get status */ - outb(port+mcd_command, MCD_CMDGETSTAT); - mbx->count = RDELAY_WAITSTAT; - timeout(mcd_doread,MCD_S_WAITSTAT,hz/100); - return; - case MCD_S_WAITSTAT: - untimeout(mcd_doread,MCD_S_WAITSTAT); - if (mbx->count-- >= 0) { - if (inb(port+mcd_xfer) & MCD_ST_BUSY) { - timeout(mcd_doread,MCD_S_WAITSTAT,hz/100); - return; - } - mcd_setflags(unit,cd); - MCD_TRACE("got WAITSTAT delay=%d\n",RDELAY_WAITSTAT-mbx->count,0,0,0); - /* reject, if audio active */ - if (cd->status & MCDAUDIOBSY) { - printf("mcd%d: audio is active\n",unit); - goto readerr; - } - - /* to check for raw/cooked mode */ - if (cd->flags & MCDREADRAW) { - rm = MCD_MD_RAW; - mbx->sz = MCDRBLK; - } else { - rm = MCD_MD_COOKED; - mbx->sz = cd->blksize; - } - - mbx->count = RDELAY_WAITMODE; - - mcd_put(port+mcd_command, MCD_CMDSETMODE); - mcd_put(port+mcd_command, rm); - timeout(mcd_doread,MCD_S_WAITMODE,hz/100); - return; - } else { -#ifdef MCD_TO_WARNING_ON - printf("mcd%d: timeout getstatus\n",unit); -#endif - goto readerr; - } - - case MCD_S_WAITMODE: - untimeout(mcd_doread,MCD_S_WAITMODE); - if (mbx->count-- < 0) { -#ifdef MCD_TO_WARNING_ON - printf("mcd%d: timeout set mode\n",unit); -#endif - goto readerr; - } - if (inb(port+mcd_xfer) & MCD_ST_BUSY) { - timeout(mcd_doread,MCD_S_WAITMODE,hz/100); - return; - } - mcd_setflags(unit,cd); - MCD_TRACE("got WAITMODE delay=%d\n",RDELAY_WAITMODE-mbx->count,0,0,0); - /* for first block */ - mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz; - mbx->skip = 0; - -nextblock: - blknum = (bp->b_blkno / (mbx->sz/DEV_BSIZE)) - + mbx->p_offset + mbx->skip/mbx->sz; - - MCD_TRACE("mcd_doread: read blknum=%d for bp=0x%x\n",blknum,bp,0,0); - - /* build parameter block */ - hsg2msf(blknum,rbuf.start_msf); - - /* send the read command */ - mcd_put(port+mcd_command,MCD_CMDREAD2); - mcd_put(port+mcd_command,rbuf.start_msf[0]); - mcd_put(port+mcd_command,rbuf.start_msf[1]); - mcd_put(port+mcd_command,rbuf.start_msf[2]); - mcd_put(port+mcd_command,0); - mcd_put(port+mcd_command,0); - mcd_put(port+mcd_command,1); - mbx->count = RDELAY_WAITREAD; - timeout(mcd_doread,MCD_S_WAITREAD,hz/100); - return; - case MCD_S_WAITREAD: - untimeout(mcd_doread,MCD_S_WAITREAD); - if (mbx->count-- > 0) { - k = inb(port+mcd_xfer); - if ((k & 2)==0) { - MCD_TRACE("got data delay=%d\n",RDELAY_WAITREAD-mbx->count,0,0,0); - /* data is ready */ - addr = bp->b_un.b_addr + mbx->skip; - outb(port+mcd_ctl2,0x04); /* XXX */ - for (i=0; isz; i++) - *addr++ = inb(port+mcd_rdata); - outb(port+mcd_ctl2,0x0c); /* XXX */ - - if (--mbx->nblk > 0) { - mbx->skip += mbx->sz; - goto nextblock; - } - - /* return buffer */ - bp->b_resid = 0; - biodone(bp); - - cd->flags &= ~MCDMBXBSY; - mcd_start(mbx->unit); - return; - } - if ((k & 4)==0) - mcd_getstat(unit,0); - timeout(mcd_doread,MCD_S_WAITREAD,hz/100); - return; - } else { -#ifdef MCD_TO_WARNING_ON - printf("mcd%d: timeout read data\n",unit); -#endif - goto readerr; - } - } - -readerr: - if (mbx->retry-- > 0) { -#ifdef MCD_TO_WARNING_ON - printf("mcd%d: retrying\n",unit); -#endif - state = MCD_S_BEGIN1; - goto loop; - } - - /* invalidate the buffer */ - bp->b_flags |= B_ERROR; - bp->b_resid = bp->b_bcount; - biodone(bp); - mcd_start(mbx->unit); - return; - -#ifdef NOTDEF - printf("mcd%d: unit timeout, resetting\n",mbx->unit); - outb(mbx->port+mcd_reset,MCD_CMDRESET); - DELAY(300000); - (void)mcd_getstat(mbx->unit,1); - (void)mcd_getstat(mbx->unit,1); - /*cd->status &= ~MCDDSKCHNG; */ - cd->debug = 1; /* preventive set debug mode */ - -#endif - -} - -#ifndef MCDMINI -static int mcd_setmode(int unit, int mode) -{ - struct mcd_data *cd = mcd_data + unit; - int port = cd->iobase; - int retry; - - printf("mcd%d: setting mode to %d\n", unit, mode); - for(retry=0; retrylen = msf2hsg(cd->volinfo.vol_msf); - th->starting_track = bcd2bin(cd->volinfo.trk_low); - th->ending_track = bcd2bin(cd->volinfo.trk_high); - - return 0; -} - -static int mcd_read_toc(int unit) -{ - struct mcd_data *cd = mcd_data + unit; - struct ioc_toc_header th; - struct mcd_qchninfo q; - int rc, trk, idx, retry; - - /* Only read TOC if needed */ - if (cd->flags & MCDTOC) return 0; - - printf("mcd%d: reading toc header\n", unit); - if (mcd_toc_header(unit, &th) != 0) - return ENXIO; - - printf("mcd%d: stopping play\n", unit); - if ((rc=mcd_stop(unit)) != 0) - return rc; - - /* try setting the mode twice */ - if (mcd_setmode(unit, MCD_MD_TOC) != 0) - return EIO; - if (mcd_setmode(unit, MCD_MD_TOC) != 0) - return EIO; - - printf("mcd%d: get_toc reading qchannel info\n",unit); - for(trk=th.starting_track; trk<=th.ending_track; trk++) - cd->toc[trk].idx_no = 0; - trk = th.ending_track - th.starting_track + 1; - for(retry=0; retry<300 && trk>0; retry++) - { - if (mcd_getqchan(unit, &q) < 0) break; - idx = bcd2bin(q.idx_no); - if (idx>0 && idx < MCD_MAXTOCS && q.trk_no==0) - if (cd->toc[idx].idx_no == 0) - { - cd->toc[idx] = q; - trk--; - } - } - - if (mcd_setmode(unit, MCD_MD_COOKED) != 0) - return EIO; - - if (trk != 0) return ENXIO; - - /* add a fake last+1 */ - idx = th.ending_track + 1; - cd->toc[idx].ctrl_adr = cd->toc[idx-1].ctrl_adr; - cd->toc[idx].trk_no = 0; - cd->toc[idx].idx_no = 0xAA; - cd->toc[idx].hd_pos_msf[0] = cd->volinfo.vol_msf[0]; - cd->toc[idx].hd_pos_msf[1] = cd->volinfo.vol_msf[1]; - cd->toc[idx].hd_pos_msf[2] = cd->volinfo.vol_msf[2]; - - cd->flags |= MCDTOC; - - return 0; -} - -static int mcd_toc_entry(int unit, struct ioc_read_toc_entry *te) -{ - struct mcd_data *cd = mcd_data + unit; - struct ret_toc - { - struct ioc_toc_header th; - struct cd_toc_entry rt; - } ret_toc; - struct ioc_toc_header th; - int rc, i; - - /* Make sure we have a valid toc */ - if ((rc=mcd_read_toc(unit)) != 0) - return rc; - - /* find the toc to copy*/ - i = te->starting_track; - if (i == MCD_LASTPLUS1) - i = bcd2bin(cd->volinfo.trk_high) + 1; - - /* verify starting track */ - if (i < bcd2bin(cd->volinfo.trk_low) || - i > bcd2bin(cd->volinfo.trk_high)+1) - return EINVAL; - - /* do we have room */ - if (te->data_len < sizeof(struct ioc_toc_header) + - sizeof(struct cd_toc_entry)) return EINVAL; - - /* Copy the toc header */ - if (mcd_toc_header(unit, &th) < 0) return EIO; - ret_toc.th = th; - - /* copy the toc data */ - ret_toc.rt.control = cd->toc[i].ctrl_adr; - ret_toc.rt.addr_type = te->address_format; - ret_toc.rt.track = i; - if (te->address_format == CD_MSF_FORMAT) - { - ret_toc.rt.addr[1] = cd->toc[i].hd_pos_msf[0]; - ret_toc.rt.addr[2] = cd->toc[i].hd_pos_msf[1]; - ret_toc.rt.addr[3] = cd->toc[i].hd_pos_msf[2]; - } - - /* copy the data back */ - copyout(&ret_toc, te->data, sizeof(struct cd_toc_entry) - + sizeof(struct ioc_toc_header)); - - return 0; -} - -static int mcd_stop(int unit) -{ - struct mcd_data *cd = mcd_data + unit; - - if (mcd_send(unit, MCD_CMDSTOPAUDIO, MCD_RETRYS) < 0) - return ENXIO; - cd->audio_status = CD_AS_PLAY_COMPLETED; - return 0; -} - -static int mcd_getqchan(int unit, struct mcd_qchninfo *q) -{ - struct mcd_data *cd = mcd_data + unit; - - if (mcd_send(unit, MCD_CMDGETQCHN, MCD_RETRYS) < 0) - return -1; - if (mcd_get(unit, (char *) q, sizeof(struct mcd_qchninfo)) < 0) - return -1; - if (cd->debug) - printf("mcd%d: qchannel ctl=%d, t=%d, i=%d, ttm=%d:%d.%d dtm=%d:%d.%d\n", - unit, - q->ctrl_adr, q->trk_no, q->idx_no, - q->trk_size_msf[0], q->trk_size_msf[1], q->trk_size_msf[2], - q->trk_size_msf[0], q->trk_size_msf[1], q->trk_size_msf[2]); - return 0; -} - -static int mcd_subchan(int unit, struct ioc_read_subchannel *sc) -{ - struct mcd_data *cd = mcd_data + unit; - struct mcd_qchninfo q; - struct cd_sub_channel_info data; - - printf("mcd%d: subchan af=%d, df=%d\n", unit, - sc->address_format, - sc->data_format); - if (sc->address_format != CD_MSF_FORMAT) return EIO; - if (sc->data_format != CD_CURRENT_POSITION) return EIO; - - if (mcd_getqchan(unit, &q) < 0) return EIO; - - data.header.audio_status = cd->audio_status; - data.what.position.data_format = CD_MSF_FORMAT; - data.what.position.track_number = bcd2bin(q.trk_no); - - if (copyout(&data, sc->data, sizeof(struct cd_sub_channel_info))!=0) - return EFAULT; - return 0; -} - -static int mcd_playtracks(int unit, struct ioc_play_track *pt) -{ - struct mcd_data *cd = mcd_data + unit; - struct mcd_read2 pb; - int a = pt->start_track; - int z = pt->end_track; - int rc; - - if ((rc = mcd_read_toc(unit)) != 0) return rc; - - printf("mcd%d: playtracks from %d:%d to %d:%d\n", unit, - a, pt->start_index, z, pt->end_index); - - if (a < cd->volinfo.trk_low || a > cd->volinfo.trk_high || a > z || - z < cd->volinfo.trk_low || z > cd->volinfo.trk_high) - return EINVAL; - - pb.start_msf[0] = cd->toc[a].hd_pos_msf[0]; - pb.start_msf[1] = cd->toc[a].hd_pos_msf[1]; - pb.start_msf[2] = cd->toc[a].hd_pos_msf[2]; - pb.end_msf[0] = cd->toc[z+1].hd_pos_msf[0]; - pb.end_msf[1] = cd->toc[z+1].hd_pos_msf[1]; - pb.end_msf[2] = cd->toc[z+1].hd_pos_msf[2]; - - return mcd_play(unit, &pb); -} - -static int mcd_play(int unit, struct mcd_read2 *pb) -{ - struct mcd_data *cd = mcd_data + unit; - int port = cd->iobase; - int retry, st; - - cd->lastpb = *pb; - for(retry=0; retrystart_msf[0]); - outb(port+mcd_command, pb->start_msf[1]); - outb(port+mcd_command, pb->start_msf[2]); - outb(port+mcd_command, pb->end_msf[0]); - outb(port+mcd_command, pb->end_msf[1]); - outb(port+mcd_command, pb->end_msf[2]); - if ((st=mcd_getstat(unit, 0)) != -1) break; - } - - if (cd->debug) - printf("mcd%d: mcd_play retry=%d, status=%d\n", unit, retry, st); - if (st == -1) return ENXIO; - cd->audio_status = CD_AS_PLAY_IN_PROGRESS; - return 0; -} - -static int mcd_pause(int unit) -{ - struct mcd_data *cd = mcd_data + unit; - struct mcd_qchninfo q; - int rc; - - /* Verify current status */ - if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS) - { - printf("mcd%d: pause attempted when not playing\n", unit); - return EINVAL; - } - - /* Get the current position */ - if (mcd_getqchan(unit, &q) < 0) return EIO; - - /* Copy it into lastpb */ - cd->lastpb.start_msf[0] = q.hd_pos_msf[0]; - cd->lastpb.start_msf[1] = q.hd_pos_msf[1]; - cd->lastpb.start_msf[2] = q.hd_pos_msf[2]; - - /* Stop playing */ - if ((rc=mcd_stop(unit)) != 0) return rc; - - /* Set the proper status and exit */ - cd->audio_status = CD_AS_PLAY_PAUSED; - return 0; -} - -static int mcd_resume(int unit) -{ - struct mcd_data *cd = mcd_data + unit; - - if (cd->audio_status != CD_AS_PLAY_PAUSED) return EINVAL; - return mcd_play(unit, &cd->lastpb); -} -#endif /*!MCDMINI*/ - -#endif /* NMCD > 0 */ diff --git a/sys/i386/isa/mcdreg.h b/sys/i386/isa/mcdreg.h deleted file mode 100644 index 83664a7..0000000 --- a/sys/i386/isa/mcdreg.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 1993 by Holger Veit (data part) - * Copyright 1993 by Brian Moore (audio part) - * 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 software was developed by Holger Veit and Brian Moore - * for use with "386BSD" and similar operating systems. - * "Similar operating systems" includes mainly non-profit oriented - * systems for research and education, including but not restricted to - * "NetBSD", "FreeBSD", "Mach" (by CMU). - * 4. Neither the name of the developer(s) nor the name "386BSD" - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``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 DEVELOPER(S) 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 definitions for some cdrom control commands - * and status codes. This info was "inherited" from the DOS MTMCDE.SYS - * driver, and is thus not complete (and may even be wrong). Some day - * the manufacturer or anyone else might provide better documentation, - * so this file (and the driver) will then have a better quality. - * - * $Id$ - */ - -#ifndef MCD_H -#define MCD_H - -#ifdef __GNUC__ -#if __GNUC__ >= 2 -#pragma pack(1) -#endif -#endif - -typedef unsigned char bcd_t; -#define M_msf(msf) msf[0] -#define S_msf(msf) msf[1] -#define F_msf(msf) msf[2] - -/* io lines used */ -#define MCD_IO_BASE 0x300 - -#define mcd_command 0 -#define mcd_status 0 -#define mcd_rdata 0 - -#define mcd_reset 1 -#define mcd_xfer 1 -#define mcd_ctl2 2 /* XXX Is this right? */ - -#define mcd_config 3 -#define MCD_MASK_DMA 0x07 /* bits 2-0 = DMA channel */ -#define MCD_MASK_IRQ 0x70 /* bits 6-4 = INT number */ - /* 001 = int 2,9 */ - /* 010 = int 3 */ - /* 011 = int 5 */ - /* 100 = int 10 */ - /* 101 = int 11 */ -/* flags */ -#define STATUS_AVAIL 0xb -#define DATA_AVAIL 0xf - -/* ports */ -#define MCD_DATA 0 -#define MCD_FLAGS 1 -#define MCD_DONT_KNOW 2 /* What are these two ports for??? */ -#define CHANNEL 3 - -/* Status bits */ -#define MCD_ST_DOOROPEN 0x80 -#define MCD_ST_DSKIN 0x40 -#define MCD_ST_DSKCHNG 0x20 -#define MCD_ST_BUSY 0x04 -#define MCD_ST_AUDIOBSY 0x02 - -/* commands known by the controller */ -#define MCD_CMDRESET 0x00 -#define MCD_CMDGETVOLINFO 0x10 /* gets mcd_volinfo */ -#define MCD_CMDGETQCHN 0x20 /* gets mcd_qchninfo */ -#define MCD_CMDGETSTAT 0x40 /* gets a byte of status */ -#define MCD_CMDSETMODE 0x50 /* set transmission mode, needs byte */ -#define MCD_MD_RAW 0x60 -#define MCD_MD_COOKED 0x01 -#define MCD_MD_TOC 0x05 -#define MCD_CMDSTOPAUDIO 0x70 -#define MCD_CMDGETVOLUME 0x8E /* gets mcd_volume */ -#define MCD_CMDSETVOLUME 0xAE /* sets mcd_volume */ -#define MCD_CMDREAD1 0xB0 /* read n sectors */ -#define MCD_CMDREAD2 0xC0 /* read from-to */ -#define MCD_CMDCONTINFO 0xDC /* Get controller info */ -#define MCD_CMDEJECTDISK 0xF6 -#define MCD_CMDCLOSETRAY 0xF8 -#define MCD_CMDLOCKDRV 0xFE /* needs byte */ -#define MCD_LK_UNLOCK 0x00 -#define MCD_LK_LOCK 0x01 -#define MCD_LK_TEST 0x02 - -struct mcd_volinfo { - bcd_t trk_low; - bcd_t trk_high; - bcd_t vol_msf[3]; - bcd_t trk1_msf[3]; -}; - -struct mcd_qchninfo { - u_char ctrl_adr; - u_char trk_no; - u_char idx_no; - bcd_t trk_size_msf[3]; - u_char :8; - bcd_t hd_pos_msf[3]; -}; - -struct mcd_volume { - u_char v0l; - u_char v0rs; - u_char v0r; - u_char v0ls; -}; - -struct mcd_read1 { - bcd_t start_msf[3]; - u_char nsec[3]; -}; - -struct mcd_read2 { - bcd_t start_msf[3]; - bcd_t end_msf[3]; -}; -#endif /* MCD_H */ diff --git a/sys/i386/isa/mse.c b/sys/i386/isa/mse.c deleted file mode 100644 index 60621cc..0000000 --- a/sys/i386/isa/mse.c +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Copyright 1992 by the University of Guelph - * - * Permission to use, copy and modify this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting - * documentation. - * University of Guelph makes no representations about the suitability of - * this software for any purpose. It is provided "as is" - * without express or implied warranty. - */ -/* - * Driver for the Logitech and ATI Inport Bus mice for use with 386bsd and - * the X386 port, courtesy of - * Rick Macklem, rick@snowhite.cis.uoguelph.ca - * Caveats: The driver currently uses spltty(), but doesn't use any - * generic tty code. It could use splmse() (that only masks off the - * bus mouse interrupt, but that would require hacking in i386/isa/icu.s. - * (This may be worth the effort, since the Logitech generates 30/60 - * interrupts/sec continuously while it is open.) - * NB: The ATI has NOT been tested yet! - */ - -/* - * Modification history: - * - * Oct 19, 1992 -- E. Stark (stark@cs.sunysb.edu) - * fixes to make it work with Microsoft InPort busmouse - * - * Jan, 1993 -- E. Stark (stark@cs.sunysb.edu) - * added patches for new "select" interface - * - * May 4, 1993 -- E. Stark (stark@cs.sunysb.edu) - * changed position of some spl()'s in mseread - * - * October 8, 1993 -- E. Stark (stark@cs.sunysb.edu) - * limit maximum negative x/y value to -127 to work around XFree problem - * that causes spurious button pushes. - */ - -#include "mse.h" -#if NMSE > 0 -#include "param.h" -#include "proc.h" -#include "user.h" -#include "buf.h" -#include "systm.h" -#include "kernel.h" -#include "ioctl.h" -#include "tty.h" -#include "uio.h" - -#include "i386/isa/isa_device.h" -#include "i386/isa/icu.h" - -int mseprobe(), mseattach(), mseintr(); - -struct isa_driver msedriver = { - mseprobe, mseattach, "mse" -}; - -/* - * Software control structure for mouse. The sc_enablemouse(), - * sc_disablemouse() and sc_getmouse() routines must be called spl'd(). - */ -#define PROTOBYTES 5 -struct mse_softc { - int sc_flags; - int sc_mousetype; - pid_t sc_selp; - u_int sc_port; - void (*sc_enablemouse)(); - void (*sc_disablemouse)(); - void (*sc_getmouse)(); - int sc_deltax; - int sc_deltay; - int sc_obuttons; - int sc_buttons; - int sc_bytesread; - u_char sc_bytes[PROTOBYTES]; -} mse_sc[NMSE]; - -/* Flags */ -#define MSESC_OPEN 0x1 -#define MSESC_WANT 0x2 - -/* and Mouse Types */ -#define MSE_LOGITECH 0x1 -#define MSE_ATIINPORT 0x2 - -#define MSE_PORTA 0 -#define MSE_PORTB 1 -#define MSE_PORTC 2 -#define MSE_PORTD 3 - -#define MSE_UNIT(dev) (minor(dev) >> 1) -#define MSE_NBLOCKIO(dev) (minor(dev) & 0x1) - -/* - * Logitech bus mouse definitions - */ -#define MSE_SETUP 0x91 /* What does this mean? */ -#define MSE_HOLD 0x80 -#define MSE_RXLOW 0x00 -#define MSE_RXHIGH 0x20 -#define MSE_RYLOW 0x40 -#define MSE_RYHIGH 0x60 -#define MSE_DISINTR 0x10 -#define MSE_INTREN 0x00 - -static int mse_probelogi(); -static void mse_enablelogi(), mse_disablelogi(), mse_getlogi(); - -/* - * ATI Inport mouse definitions - */ -#define MSE_INPORT_RESET 0x80 -#define MSE_INPORT_STATUS 0x00 -#define MSE_INPORT_DX 0x01 -#define MSE_INPORT_DY 0x02 -#define MSE_INPORT_MODE 0x07 -#define MSE_INPORT_HOLD 0x20 -#define MSE_INPORT_INTREN 0x09 - -static int mse_probeati(); -static void mse_enableati(), mse_disableati(), mse_getati(); - -#define MSEPRI (PZERO + 3) - -/* - * Table of mouse types. - * Keep the Logitech last, since I haven't figured out how to probe it - * properly yet. (Someday I'll have the documentation.) - */ -struct mse_types { - int m_type; /* Type of bus mouse */ - int (*m_probe)(); /* Probe routine to test for it */ - void (*m_enable)(); /* Start routine */ - void (*m_disable)(); /* Disable interrupts routine */ - void (*m_get)(); /* and get mouse status */ -} mse_types[] = { - { MSE_ATIINPORT, mse_probeati, mse_enableati, mse_disableati, mse_getati }, - { MSE_LOGITECH, mse_probelogi, mse_enablelogi, mse_disablelogi, mse_getlogi }, - { 0, }, -}; - -mseprobe(idp) - register struct isa_device *idp; -{ - register struct mse_softc *sc = &mse_sc[idp->id_unit]; - register int i; - - /* - * Check for each mouse type in the table. - */ - i = 0; - while (mse_types[i].m_type) { - if ((*mse_types[i].m_probe)(idp)) { - sc->sc_mousetype = mse_types[i].m_type; - sc->sc_enablemouse = mse_types[i].m_enable; - sc->sc_disablemouse = mse_types[i].m_disable; - sc->sc_getmouse = mse_types[i].m_get; - return (1); - } - i++; - } - return (0); -} - -mseattach(idp) - struct isa_device *idp; -{ - struct mse_softc *sc = &mse_sc[idp->id_unit]; - - sc->sc_port = idp->id_iobase; - return (1); -} - -/* - * Exclusive open the mouse, initialize it and enable interrupts. - */ -mseopen(dev, flag) - dev_t dev; - int flag; -{ - register struct mse_softc *sc; - int s; - - if (MSE_UNIT(dev) >= NMSE) - return (ENXIO); - sc = &mse_sc[MSE_UNIT(dev)]; - if (sc->sc_flags & MSESC_OPEN) - return (EBUSY); - sc->sc_flags |= MSESC_OPEN; - sc->sc_obuttons = sc->sc_buttons = 0x7; - sc->sc_deltax = sc->sc_deltay = 0; - sc->sc_bytesread = PROTOBYTES; - - /* - * Initialize mouse interface and enable interrupts. - */ - s = spltty(); - (*sc->sc_enablemouse)(sc->sc_port); - splx(s); - return (0); -} - -/* - * mseclose: just turn off mouse innterrupts. - */ -mseclose(dev, flag) - int flag; -{ - struct mse_softc *sc = &mse_sc[MSE_UNIT(dev)]; - int s; - - s = spltty(); - (*sc->sc_disablemouse)(sc->sc_port); - sc->sc_flags &= ~MSESC_OPEN; - splx(s); - return(0); -} - -/* - * mseread: return mouse info using the MSC serial protocol, but without - * using bytes 4 and 5. - * (Yes this is cheesy, but it makes the X386 server happy, so...) - */ -mseread(dev, uio) - dev_t dev; - struct uio *uio; -{ - register struct mse_softc *sc = &mse_sc[MSE_UNIT(dev)]; - int xfer, s, error; - - /* - * If there are no protocol bytes to be read, set up a new protocol - * packet. - */ - s = spltty(); /* XXX Should be its own spl, but where is imlXX() */ - if (sc->sc_bytesread >= PROTOBYTES) { - while (sc->sc_deltax == 0 && sc->sc_deltay == 0 && - (sc->sc_obuttons ^ sc->sc_buttons) == 0) { - if (MSE_NBLOCKIO(dev)) { - splx(s); - return (0); - } - sc->sc_flags |= MSESC_WANT; - if (error = tsleep((caddr_t)sc, MSEPRI | PCATCH, - "mseread", 0)) { - splx(s); - return (error); - } - } - - /* - * Generate protocol bytes. - * For some reason X386 expects 5 bytes but never uses - * the fourth or fifth? - */ - sc->sc_bytes[0] = 0x80 | (sc->sc_buttons & ~0xf8); - if (sc->sc_deltax > 127) - sc->sc_deltax = 127; - if (sc->sc_deltax < -127) - sc->sc_deltax = -127; - sc->sc_deltay = -sc->sc_deltay; /* Otherwise mousey goes wrong way */ - if (sc->sc_deltay > 127) - sc->sc_deltay = 127; - if (sc->sc_deltay < -127) - sc->sc_deltay = -127; - sc->sc_bytes[1] = sc->sc_deltax; - sc->sc_bytes[2] = sc->sc_deltay; - sc->sc_bytes[3] = sc->sc_bytes[4] = 0; - sc->sc_obuttons = sc->sc_buttons; - sc->sc_deltax = sc->sc_deltay = 0; - sc->sc_bytesread = 0; - } - splx(s); - xfer = MIN(uio->uio_resid, PROTOBYTES - sc->sc_bytesread); - if (error = uiomove(&sc->sc_bytes[sc->sc_bytesread], xfer, uio)) - return (error); - sc->sc_bytesread += xfer; - return(0); -} - -/* - * mseselect: check for mouse input to be processed. - */ -mseselect(dev, rw, p) - dev_t dev; - int rw; - struct proc *p; -{ - register struct mse_softc *sc = &mse_sc[MSE_UNIT(dev)]; - int s; - - s = spltty(); - if (sc->sc_bytesread != PROTOBYTES || sc->sc_deltax != 0 || - sc->sc_deltay != 0 || (sc->sc_obuttons ^ sc->sc_buttons) != 0) { - splx(s); - return (1); - } - - /* - * Since this is an exclusive open device, any previous proc. - * pointer is trash now, so we can just assign it. - */ - sc->sc_selp = p->p_pid; - splx(s); - return (0); -} - -/* - * mseintr: update mouse status. sc_deltax and sc_deltay are accumulative. - */ -mseintr(unit) - int unit; -{ - register struct mse_softc *sc = &mse_sc[unit]; - pid_t p; - -#ifdef DEBUG - static int mse_intrcnt = 0; - if((mse_intrcnt++ % 10000) == 0) - printf("mseintr\n"); -#endif /* DEBUG */ - if ((sc->sc_flags & MSESC_OPEN) == 0) - return; - - (*sc->sc_getmouse)(sc->sc_port, &sc->sc_deltax, &sc->sc_deltay, &sc->sc_buttons); - - /* - * If mouse state has changed, wake up anyone wanting to know. - */ - if (sc->sc_deltax != 0 || sc->sc_deltay != 0 || - (sc->sc_obuttons ^ sc->sc_buttons) != 0) { - if (sc->sc_flags & MSESC_WANT) { - sc->sc_flags &= ~MSESC_WANT; - wakeup((caddr_t)sc); - } - if (sc->sc_selp) { - p = sc->sc_selp; - sc->sc_selp = (pid_t)0; - selwakeup(p, 0); - } - } -} - -/* - * Routines for the Logitech mouse. - */ -/* - * Test for a Logitech bus mouse and return 1 if it is. - * (until I know how to use the signature port properly, just disable - * interrupts and return 1) - */ -static int -mse_probelogi(idp) - register struct isa_device *idp; -{ - - outb(idp->id_iobase + MSE_PORTB, 0x55); - if (inb(idp->id_iobase + MSE_PORTB) == 0x55) { - outb(idp->id_iobase + MSE_PORTB, 0xaa); - if (inb(idp->id_iobase + MSE_PORTB) == 0xaa) - return (1); - } - return (0); -} - -/* - * Initialize Logitech mouse and enable interrupts. - */ -static void -mse_enablelogi(port) - register u_int port; -{ - int dx, dy, but; - - outb(port + MSE_PORTD, MSE_SETUP); - mse_getlogi(port, &dx, &dy, &but); -} - -/* - * Disable interrupts for Logitech mouse. - */ -static void -mse_disablelogi(port) - register u_int port; -{ - - outb(port + MSE_PORTC, MSE_DISINTR); -} - -/* - * Get the current dx, dy and button up/down state. - */ -static void -mse_getlogi(port, dx, dy, but) - register u_int port; - int *dx; - int *dy; - int *but; -{ - register char x, y; - - outb(port + MSE_PORTC, MSE_HOLD | MSE_RXLOW); - x = inb(port + MSE_PORTA); - *but = (x >> 5) & 0x7; - x &= 0xf; - outb(port + MSE_PORTC, MSE_HOLD | MSE_RXHIGH); - x |= (inb(port + MSE_PORTA) << 4); - outb(port + MSE_PORTC, MSE_HOLD | MSE_RYLOW); - y = (inb(port + MSE_PORTA) & 0xf); - outb(port + MSE_PORTC, MSE_HOLD | MSE_RYHIGH); - y |= (inb(port + MSE_PORTA) << 4); - *dx += x; - *dy += y; - outb(port + MSE_PORTC, MSE_INTREN); -} - -/* - * Routines for the ATI Inport bus mouse. - */ -/* - * Test for a ATI Inport bus mouse and return 1 if it is. - * (do not enable interrupts) - */ -static int -mse_probeati(idp) - register struct isa_device *idp; -{ - int i; - - for (i = 0; i < 2; i++) - if (inb(idp->id_iobase + MSE_PORTC) == 0xde) - return (1); - return (0); -} - -/* - * Initialize ATI Inport mouse and enable interrupts. - */ -static void -mse_enableati(port) - register u_int port; -{ - - outb(port + MSE_PORTA, MSE_INPORT_RESET); - outb(port + MSE_PORTA, MSE_INPORT_MODE); - outb(port + MSE_PORTB, MSE_INPORT_INTREN); -} - -/* - * Disable interrupts for ATI Inport mouse. - */ -static void -mse_disableati(port) - register u_int port; -{ - - outb(port + MSE_PORTA, MSE_INPORT_MODE); - outb(port + MSE_PORTB, 0); -} - -/* - * Get current dx, dy and up/down button state. - */ -static void -mse_getati(port, dx, dy, but) - register u_int port; - int *dx; - int *dy; - int *but; -{ - register char byte; - - outb(port + MSE_PORTA, MSE_INPORT_MODE); - outb(port + MSE_PORTB, MSE_INPORT_HOLD); - outb(port + MSE_PORTA, MSE_INPORT_STATUS); - *but = ~(inb(port + MSE_PORTB) & 0x7); - outb(port + MSE_PORTA, MSE_INPORT_DX); - byte = inb(port + MSE_PORTB); - *dx += byte; - outb(port + MSE_PORTA, MSE_INPORT_DY); - byte = inb(port + MSE_PORTB); - *dy += byte; - outb(port + MSE_PORTA, MSE_INPORT_MODE); - outb(port + MSE_PORTB, MSE_INPORT_INTREN); -} -#endif /* NMSE */ diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c deleted file mode 100644 index 08256a6..0000000 --- a/sys/i386/isa/npx.c +++ /dev/null @@ -1,554 +0,0 @@ -/*- - * Copyright (c) 1990 William Jolitz. - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 - * $Id$ - */ - -#include "npx.h" -#if NNPX > 0 - -#include "param.h" -#include "systm.h" -#include "conf.h" -#include "file.h" -#include "proc.h" -#include "machine/cpu.h" -#include "machine/pcb.h" -#include "machine/trap.h" -#include "ioctl.h" -#include "machine/specialreg.h" -#include "i386/isa/icu.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/isa.h" - -/* - * 387 and 287 Numeric Coprocessor Extension (NPX) Driver. - */ - -#ifdef __GNUC__ - -#define disable_intr() __asm("cli") -#define enable_intr() __asm("sti") -#define fldcw(addr) __asm("fldcw %0" : : "m" (*addr)) -#define fnclex() __asm("fnclex") -#define fninit() __asm("fninit") -#define fnsave(addr) __asm("fnsave %0" : "=m" (*addr) : "0" (*addr)) -#define fnstcw(addr) __asm("fnstcw %0" : "=m" (*addr) : "0" (*addr)) -#define fnstsw(addr) __asm("fnstsw %0" : "=m" (*addr) : "0" (*addr)) -#define fp_divide_by_0() __asm("fldz; fld1; fdiv %st,%st(1); fwait") -#define frstor(addr) __asm("frstor %0" : : "m" (*addr)) -#define fwait() __asm("fwait") -#define read_eflags() ({u_long ef; \ - __asm("pushf; popl %0" : "=a" (ef)); \ - ef; }) -#define start_emulating() __asm("smsw %%ax; orb %0,%%al; lmsw %%ax" \ - : : "n" (CR0_TS) : "ax") -#define stop_emulating() __asm("clts") -#define write_eflags(ef) __asm("pushl %0; popf" : : "a" ((u_long) ef)) - -#else /* not __GNUC__ */ - -void disable_intr __P((void)); -void enable_intr __P((void)); -void fldcw __P((caddr_t addr)); -void fnclex __P((void)); -void fninit __P((void)); -void fnsave __P((caddr_t addr)); -void fnstcw __P((caddr_t addr)); -void fnstsw __P((caddr_t addr)); -void fp_divide_by_0 __P((void)); -void frstor __P((caddr_t addr)); -void fwait __P((void)); -u_long read_eflags __P((void)); -void start_emulating __P((void)); -void stop_emulating __P((void)); -void write_eflags __P((u_long ef)); - -#endif /* __GNUC__ */ - -typedef u_char bool_t; - -extern struct gate_descriptor idt[]; - -int npxdna __P((void)); -void npxexit __P((struct proc *p)); -void npxinit __P((u_int control)); -void npxintr __P((struct intrframe frame)); -void npxsave __P((struct save87 *addr)); -static int npxattach __P((struct isa_device *dvp)); -static int npxprobe __P((struct isa_device *dvp)); -static int npxprobe1 __P((struct isa_device *dvp)); - -struct isa_driver npxdriver = { - npxprobe, npxattach, "npx", -}; - -u_int npx0mask; -struct proc *npxproc; - -static bool_t npx_ex16; -static bool_t npx_exists; -static struct gate_descriptor npx_idt_probeintr; -static int npx_intrno; -static volatile u_int npx_intrs_while_probing; -static bool_t npx_irq13; -static volatile u_int npx_traps_while_probing; - -/* - * Special interrupt handlers. Someday intr0-intr15 will be used to count - * interrupts. We'll still need a special exception 16 handler. The busy - * latch stuff in probintr() can be moved to npxprobe(). - */ -void probeintr(void); -asm -(" - .text -_probeintr: - ss - incl _npx_intrs_while_probing - pushl %eax - movb $0x20,%al /* EOI (asm in strings loses cpp features) */ - outb %al,$0xa0 /* IO_ICU2 */ - outb %al,$0x20 /* IO_ICU1 */ - movb $0,%al - outb %al,$0xf0 /* clear BUSY# latch */ - popl %eax - iret -"); - -void probetrap(void); -asm -(" - .text -_probetrap: - ss - incl _npx_traps_while_probing - fnclex - iret -"); - -/* - * Probe routine. Initialize cr0 to give correct behaviour for [f]wait - * whether the device exists or not (XXX should be elsewhere). Set flags - * to tell npxattach() what to do. Modify device struct if npx doesn't - * need to use interrupts. Return 1 if device exists. - */ -static int -npxprobe(dvp) - struct isa_device *dvp; -{ - int result; - u_long save_eflags; - u_char save_icu1_mask; - u_char save_icu2_mask; - struct gate_descriptor save_idt_npxintr; - struct gate_descriptor save_idt_npxtrap; - /* - * This routine is now just a wrapper for npxprobe1(), to install - * special npx interrupt and trap handlers, to enable npx interrupts - * and to disable other interrupts. Someday isa_configure() will - * install suitable handlers and run with interrupts enabled so we - * won't need to do so much here. - */ - npx_intrno = NRSVIDT + ffs(dvp->id_irq) - 1; - save_eflags = read_eflags(); - disable_intr(); - save_icu1_mask = inb(IO_ICU1 + 1); - save_icu2_mask = inb(IO_ICU2 + 1); - save_idt_npxintr = idt[npx_intrno]; - save_idt_npxtrap = idt[16]; - outb(IO_ICU1 + 1, ~(IRQ_SLAVE | dvp->id_irq)); - outb(IO_ICU2 + 1, ~(dvp->id_irq >> 8)); - setidt(16, probetrap, SDT_SYS386TGT, SEL_KPL); - setidt(npx_intrno, probeintr, SDT_SYS386IGT, SEL_KPL); - npx_idt_probeintr = idt[npx_intrno]; - enable_intr(); - result = npxprobe1(dvp); - disable_intr(); - outb(IO_ICU1 + 1, save_icu1_mask); - outb(IO_ICU2 + 1, save_icu2_mask); - idt[npx_intrno] = save_idt_npxintr; - idt[16] = save_idt_npxtrap; - write_eflags(save_eflags); - return (result); -} - -static int -npxprobe1(dvp) - struct isa_device *dvp; -{ - int control; - int status; -#ifdef lint - npxintr(); -#endif - /* - * Partially reset the coprocessor, if any. Some BIOS's don't reset - * it after a warm boot. - */ - outb(0xf1, 0); /* full reset on some systems, NOP on others */ - outb(0xf0, 0); /* clear BUSY# latch */ - /* - * Prepare to trap all ESC (i.e., NPX) instructions and all WAIT - * instructions. We must set the CR0_MP bit and use the CR0_TS - * bit to control the trap, because setting the CR0_EM bit does - * not cause WAIT instructions to trap. It's important to trap - * WAIT instructions - otherwise the "wait" variants of no-wait - * control instructions would degenerate to the "no-wait" variants - * after FP context switches but work correctly otherwise. It's - * particularly important to trap WAITs when there is no NPX - - * otherwise the "wait" variants would always degenerate. - * - * Try setting CR0_NE to get correct error reporting on 486DX's. - * Setting it should fail or do nothing on lesser processors. - */ - load_cr0(rcr0() | CR0_MP | CR0_NE); - /* - * But don't trap while we're probing. - */ - stop_emulating(); - /* - * Finish resetting the coprocessor, if any. If there is an error - * pending, then we may get a bogus IRQ13, but probeintr() will handle - * it OK. Bogus halts have never been observed, but we enabled - * IRQ13 and cleared the BUSY# latch early to handle them anyway. - */ - fninit(); - DELAY(1000); /* wait for any IRQ13 (fwait might hang) */ -#ifdef DIAGNOSTIC - if (npx_intrs_while_probing != 0) - printf("fninit caused %u bogus npx interrupt(s)\n", - npx_intrs_while_probing); - if (npx_traps_while_probing != 0) - printf("fninit caused %u bogus npx trap(s)\n", - npx_traps_while_probing); -#endif - /* - * Check for a status of mostly zero. - */ - status = 0x5a5a; - fnstsw(&status); - if ((status & 0xb8ff) == 0) { - /* - * Good, now check for a proper control word. - */ - control = 0x5a5a; - fnstcw(&control); - if ((control & 0x1f3f) == 0x033f) { - npx_exists = 1; - /* - * We have an npx, now divide by 0 to see if exception - * 16 works. - */ - control &= ~(1 << 2); /* enable divide by 0 trap */ - fldcw(&control); - npx_traps_while_probing = npx_intrs_while_probing = 0; - fp_divide_by_0(); - if (npx_traps_while_probing != 0) { - /* - * Good, exception 16 works. - */ - npx_ex16 = 1; - dvp->id_irq = 0; /* zap the interrupt */ - /* - * special return value to flag that we do not - * actually use any I/O registers - */ - return (-1); - } - if (npx_intrs_while_probing != 0) { - /* - * Bad, we are stuck with IRQ13. - */ - npx_irq13 = 1; - npx0mask = dvp->id_irq; /* npxattach too late */ - return (IO_NPXSIZE); - } - /* - * Worse, even IRQ13 is broken. Use emulator. - */ - } - } - /* - * Probe failed, but we want to get to npxattach to initialize the - * emulator and say that it has been installed. XXX handle devices - * that aren't really devices better. - */ - dvp->id_irq = 0; - /* - * special return value to flag that we do not - * actually use any I/O registers - */ - return (-1); -} - -/* - * Attach routine - announce which it is, and wire into system - */ -int -npxattach(dvp) - struct isa_device *dvp; -{ - if (!npx_ex16 && !npx_irq13) { - if (npx_exists) - printf("npx%d: Error reporting broken, using 387 emulator\n",dvp->id_unit); - else - printf("npx%d: 387 Emulator\n",dvp->id_unit); - } - npxinit(__INITIAL_NPXCW__); - return (1); /* XXX unused */ -} - -/* - * Initialize floating point unit. - */ -void -npxinit(control) - u_int control; -{ - struct save87 dummy; - - if (!npx_exists) - return; - /* - * fninit has the same h/w bugs as fnsave. Use the detoxified - * fnsave to throw away any junk in the fpu. fnsave initializes - * the fpu and sets npxproc = NULL as important side effects. - */ - npxsave(&dummy); - stop_emulating(); - fldcw(&control); - if (curpcb != NULL) - fnsave(&curpcb->pcb_savefpu); - start_emulating(); -} - -/* - * Free coprocessor (if we have it). - */ -void -npxexit(p) - struct proc *p; -{ - - if (p == npxproc) { - start_emulating(); - npxproc = NULL; - } -} - -/* - * Record the FPU state and reinitialize it all except for the control word. - * Then generate a SIGFPE. - * - * Reinitializing the state allows naive SIGFPE handlers to longjmp without - * doing any fixups. - * - * XXX there is currently no way to pass the full error state to signal - * handlers, and if this is a nested interrupt there is no way to pass even - * a status code! So there is no way to have a non-naive SIGFPE handler. At - * best a handler could do an fninit followed by an fldcw of a static value. - * fnclex would be of little use because it would leave junk on the FPU stack. - * Returning from the handler would be even less safe than usual because - * IRQ13 exception handling makes exceptions even less precise than usual. - */ -void -npxintr(frame) - struct intrframe frame; -{ - int code; - - if (npxproc == NULL || !npx_exists) { - /* XXX no %p in stand/printf.c. Cast to quiet gcc -Wall. */ - printf("npxintr: npxproc = %lx, curproc = %lx, npx_exists = %d\n", - (u_long) npxproc, (u_long) curproc, npx_exists); - panic("npxintr from nowhere"); - } - if (npxproc != curproc) { - printf("npxintr: npxproc = %lx, curproc = %lx, npx_exists = %d\n", - (u_long) npxproc, (u_long) curproc, npx_exists); - panic("npxintr from non-current process"); - } - /* - * Save state. This does an implied fninit. It had better not halt - * the cpu or we'll hang. - */ - outb(0xf0, 0); - fnsave(&curpcb->pcb_savefpu); - fwait(); - /* - * Restore control word (was clobbered by fnsave). - */ - fldcw(&curpcb->pcb_savefpu.sv_env.en_cw); - fwait(); - /* - * Remember the exception status word and tag word. The current - * (almost fninit'ed) fpu state is in the fpu and the exception - * state just saved will soon be junk. However, the implied fninit - * doesn't change the error pointers or register contents, and we - * preserved the control word and will copy the status and tag - * words, so the complete exception state can be recovered. - */ - curpcb->pcb_savefpu.sv_ex_sw = curpcb->pcb_savefpu.sv_env.en_sw; - curpcb->pcb_savefpu.sv_ex_tw = curpcb->pcb_savefpu.sv_env.en_tw; - - /* - * Pass exception to process. - */ - if (ISPL(frame.if_cs) == SEL_UPL) { - /* - * Interrupt is essentially a trap, so we can afford to call - * the SIGFPE handler (if any) as soon as the interrupt - * returns. - * - * XXX little or nothing is gained from this, and plenty is - * lost - the interrupt frame has to contain the trap frame - * (this is otherwise only necessary for the rescheduling trap - * in doreti, and the frame for that could easily be set up - * just before it is used). - */ - curproc->p_regs = (int *)&frame.if_es; - curpcb->pcb_flags |= FM_TRAP; /* used by sendsig */ -#ifdef notyet - /* - * Encode the appropriate code for detailed information on - * this exception. - */ - code = XXX_ENCODE(curpcb->pcb_savefpu.sv_ex_sw); -#else - code = 0; /* XXX */ -#endif - trapsignal(curproc, SIGFPE, code); - curpcb->pcb_flags &= ~FM_TRAP; - } else { - /* - * Nested interrupt. These losers occur when: - * o an IRQ13 is bogusly generated at a bogus time, e.g.: - * o immediately after an fnsave or frstor of an - * error state. - * o a couple of 386 instructions after - * "fstpl _memvar" causes a stack overflow. - * These are especially nasty when combined with a - * trace trap. - * o an IRQ13 occurs at the same time as another higher- - * priority interrupt. - * - * Treat them like a true async interrupt. - */ - psignal(npxproc, SIGFPE); - } -} - -/* - * Implement device not available (DNA) exception - * - * It would be better to switch FP context here (only). This would require - * saving the state in the proc table instead of in the pcb. - */ -int -npxdna() -{ - if (!npx_exists) - return (0); - if (npxproc != NULL) { - printf("npxdna: npxproc = %lx, curproc = %lx\n", - (u_long) npxproc, (u_long) curproc); - panic("npxdna"); - } - stop_emulating(); - /* - * Record new context early in case frstor causes an IRQ13. - */ - npxproc = curproc; - /* - * The following frstor may cause an IRQ13 when the state being - * restored has a pending error. The error will appear to have been - * triggered by the current (npx) user instruction even when that - * instruction is a no-wait instruction that should not trigger an - * error (e.g., fnclex). On at least one 486 system all of the - * no-wait instructions are broken the same as frstor, so our - * treatment does not amplify the breakage. On at least one - * 386/Cyrix 387 system, fnclex works correctly while frstor and - * fnsave are broken, so our treatment breaks fnclex if it is the - * first FPU instruction after a context switch. - */ - frstor(&curpcb->pcb_savefpu); - - return (1); -} - -/* - * Wrapper for fnsave instruction to handle h/w bugs. If there is an error - * pending, then fnsave generates a bogus IRQ13 on some systems. Force - * any IRQ13 to be handled immediately, and then ignore it. This routine is - * often called at splhigh so it must not use many system services. In - * particular, it's much easier to install a special handler than to - * guarantee that it's safe to use npxintr() and its supporting code. - */ -void -npxsave(addr) - struct save87 *addr; -{ - u_char icu1_mask; - u_char icu2_mask; - u_char old_icu1_mask; - u_char old_icu2_mask; - struct gate_descriptor save_idt_npxintr; - - disable_intr(); - old_icu1_mask = inb(IO_ICU1 + 1); - old_icu2_mask = inb(IO_ICU2 + 1); - save_idt_npxintr = idt[npx_intrno]; - outb(IO_ICU1 + 1, old_icu1_mask & ~(IRQ_SLAVE | npx0mask)); - outb(IO_ICU2 + 1, old_icu2_mask & ~(npx0mask >> 8)); - idt[npx_intrno] = npx_idt_probeintr; - enable_intr(); - stop_emulating(); - fnsave(addr); - fwait(); - start_emulating(); - npxproc = NULL; - disable_intr(); - icu1_mask = inb(IO_ICU1 + 1); /* masks may have changed */ - icu2_mask = inb(IO_ICU2 + 1); - outb(IO_ICU1 + 1, - (icu1_mask & ~npx0mask) | (old_icu1_mask & npx0mask)); - outb(IO_ICU2 + 1, - (icu2_mask & ~(npx0mask >> 8)) - | (old_icu2_mask & (npx0mask >> 8))); - idt[npx_intrno] = save_idt_npxintr; - enable_intr(); /* back to usual state */ -} - -#endif /* NNPX > 0 */ diff --git a/sys/i386/isa/rtc.h b/sys/i386/isa/rtc.h deleted file mode 100644 index 3f7b4c2..0000000 --- a/sys/i386/isa/rtc.h +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)rtc.h 7.1 (Berkeley) 5/12/91 - * $Id$ - */ - -/* - * RTC Register locations - */ - -#define RTC_SEC 0x00 /* seconds */ -#define RTC_SECALRM 0x01 /* seconds alarm */ -#define RTC_MIN 0x02 /* minutes */ -#define RTC_MINALRM 0x03 /* minutes alarm */ -#define RTC_HRS 0x04 /* hours */ -#define RTC_HRSALRM 0x05 /* hours alarm */ -#define RTC_WDAY 0x06 /* week day */ -#define RTC_DAY 0x07 /* day of month */ -#define RTC_MONTH 0x08 /* month of year */ -#define RTC_YEAR 0x09 /* month of year */ -#define RTC_STATUSA 0x0a /* status register A */ -#define RTCSA_TUP 0x80 /* time update, don't look now */ - -#define RTC_STATUSB 0x0b /* status register B */ - -#define RTC_INTR 0x0c /* status register C (R) interrupt source */ -#define RTCIR_UPDATE 0x10 /* update intr */ -#define RTCIR_ALARM 0x20 /* alarm intr */ -#define RTCIR_PERIOD 0x40 /* periodic intr */ -#define RTCIR_INT 0x80 /* interrupt output signal */ - -#define RTC_STATUSD 0x0d /* status register D (R) Lost Power */ -#define RTCSD_PWR 0x80 /* clock lost power */ - -#define RTC_DIAG 0x0e /* status register E - bios diagnostic */ -#define RTCDG_BITS "\020\010clock_battery\007ROM_cksum\006config_unit\005memory_size\004fixed_disk\003invalid_time" - -#define RTC_RESET 0x0f /* status register F - reset code byte */ -#define RTCRS_RST 0x00 /* normal reset */ -#define RTCRS_LOAD 0x04 /* load system */ - -#define RTC_FDISKETTE 0x10 /* diskette drive type in upper/lower nibble */ -#define RTCFDT_NONE 0 /* none present */ -#define RTCFDT_360K 0x10 /* 360K */ -#define RTCFDT_12M 0x20 /* 1.2M */ -#define RTCFDT_144M 0x40 /* 1.44M */ - -#define RTC_BASELO 0x15 /* low byte of basemem size */ -#define RTC_BASEHI 0x16 /* high byte of basemem size */ -#define RTC_EXTLO 0x17 /* low byte of extended mem size */ -#define RTC_EXTHI 0x18 /* low byte of extended mem size */ - -#define RTC_CENTURY 0x32 /* current century - please increment in Dec99*/ diff --git a/sys/i386/isa/sio.c b/sys/i386/isa/sio.c deleted file mode 100644 index 055a5e8..0000000 --- a/sys/i386/isa/sio.c +++ /dev/null @@ -1,1740 +0,0 @@ -/*- - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id$ - */ - -#include "sio.h" -#if NSIO > 0 -/* - * COM driver, based on HP dca driver. - * Mostly rewritten to use pseudo-DMA. - * Works for National Semiconductor NS8250-NS16550AF UARTs. - */ -#include "param.h" -#include "systm.h" -#include "ioctl.h" -#include "tty.h" -#include "proc.h" -#include "user.h" -#include "conf.h" -#include "file.h" -#include "uio.h" -#include "kernel.h" -#include "syslog.h" - -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/comreg.h" -#include "i386/isa/ic/ns16550.h" - -#undef CRTS_IFLOW -#define CRTS_IFLOW CRTSCTS /* XXX, CCTS_OFLOW = CRTSCTS already */ -#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ -#define RB_I_HIGH_WATER (RBSZ - 2 * RS_IBUFSIZE) -#define RB_I_LOW_WATER ((RBSZ - 2 * RS_IBUFSIZE) * 7 / 8) -#define RS_IBUFSIZE 256 -#define TS_RTSBLOCK TS_TBLOCK /* XXX */ -#define TTY_BI TTY_FE /* XXX */ -#define TTY_OE TTY_PE /* XXX */ -#ifndef COM_BIDIR -#define UNIT(x) (minor(x)) /* XXX */ -#else /* COM_BIDIR */ -#define COM_UNITMASK 0x7f -#define COM_CALLOUTMASK 0x80 - -#define UNIT(x) (minor(x) & COM_UNITMASK) -#define CALLOUT(x) (minor(x) & COM_CALLOUTMASK) -#endif /* COM_BIDIR */ - -#ifdef COM_MULTIPORT -/* checks in flags for multiport and which is multiport "master chip" - * for a given card - */ -#define COM_ISMULTIPORT(dev) ((dev)->id_flags & 0x01) -#define COM_MPMASTER(dev) (((dev)->id_flags >> 8) & 0x0ff) -#endif /* COM_MULTIPORT */ - -#define com_scr 7 /* scratch register for 16450-16550 (R/W) */ -#define schedsoftcom() (ipending |= 1 << 4) /* XXX */ - -/* - * Input buffer watermarks. - * The external device is asked to stop sending when the buffer exactly reaches - * high water, or when the high level requests it. - * The high level is notified immediately (rather than at a later clock tick) - * when this watermark is reached. - * The buffer size is chosen so the watermark should almost never be reached. - * The low watermark is invisibly 0 since the buffer is always emptied all at - * once. - */ -#define RS_IHIGHWATER (3 * RS_IBUFSIZE / 4) - -/* - * com state bits. - * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher - * than the other bits so that they can be tested as a group without masking - * off the low bits. - * - * The following com and tty flags correspond closely: - * TS_BUSY = CS_BUSY (maintained by comstart() and comflush()) - * CS_TTGO = ~TS_TTSTOP (maintained by comstart() and siostop()) - * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) - * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) - * TS_FLUSH is not used. - * Bug: I think TIOCSETA doesn't clear TS_TTSTOP when it clears IXON. - */ -#define CS_BUSY 0x80 /* output in progress */ -#define CS_TTGO 0x40 /* output not stopped by XOFF */ -#define CS_ODEVREADY 0x20 /* external device h/w ready (CTS) */ -#define CS_CHECKMSR 1 /* check of MSR scheduled */ -#define CS_CTS_OFLOW 2 /* use CTS output flow control */ -#define CS_ODONE 4 /* output completed */ -#define CS_RTS_IFLOW 8 /* use RTS input flow control */ - -static char *error_desc[] = { -#define CE_OVERRUN 0 - "silo overflow", -#define CE_INTERRUPT_BUF_OVERFLOW 1 - "interrupt-level buffer overflow", -#define CE_TTY_BUF_OVERFLOW 2 - "tty-level buffer overflow", -}; - -#define CE_NTYPES 3 -#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum]) - -/* types. XXX - should be elsewhere */ -typedef u_int Port_t; /* hardware port */ -typedef int Bool_t; /* promoted boolean */ -typedef u_char bool_t; /* boolean */ - -/* com device structure */ -struct com_s { - u_char state; /* miscellaneous flag bits */ - u_char cfcr_image; /* copy of value written to CFCR */ - bool_t hasfifo; /* nonzero for 16550 UARTs */ - u_char mcr_image; /* copy of value written to MCR */ - bool_t softDCD; /* nonzero for faked carrier detect */ -#ifdef COM_BIDIR - bool_t bidir; /* is this unit bidirectional? */ - bool_t active; /* is the port active _at all_? */ - bool_t active_in; /* is the incoming port in use? */ - bool_t active_out; /* is the outgoing port in use? */ -#endif /* COM_BIDIR */ -#ifdef COM_MULTIPORT - bool_t multiport; /* is this unit part of a multiport device? */ -#endif /* COM_MULTIPORT */ - - /* - * The high level of the driver never reads status registers directly - * because there would be too many side effects to handle conveniently. - * Instead, it reads copies of the registers stored here by the - * interrupt handler. - */ - u_char last_modem_status; /* last MSR read by intr handler */ - u_char prev_modem_status; /* last MSR handled by high level */ - - u_char *ibuf; /* start of input buffer */ - u_char *ibufend; /* end of input buffer */ - u_char *ihighwater; /* threshold in input buffer */ - u_char *iptr; /* next free spot in input buffer */ - - u_char *obufend; /* end of output buffer */ - int ocount; /* original count for current output */ - u_char *optr; /* next char to output */ - - Port_t data_port; /* i/o ports */ - Port_t int_id_port; - Port_t iobase; - Port_t modem_ctl_port; - Port_t line_status_port; - Port_t modem_status_port; - - struct tty *tp; /* cross reference */ - - u_long bytes_in; /* statistics */ - u_long bytes_out; - u_int delta_error_counts[CE_NTYPES]; - u_int error_counts[CE_NTYPES]; - - /* - * Ping-pong input buffers. The extra factor of 2 in the sizes is - * to allow for an error byte for each input byte. - */ -#define CE_INPUT_OFFSET RS_IBUFSIZE - u_char ibuf1[2 * RS_IBUFSIZE]; - u_char ibuf2[2 * RS_IBUFSIZE]; -}; - - -/* - * These functions in the com module ought to be declared (with a prototype) - * in a com-driver system header. The void ones may need to be int to match - * ancient devswitch declarations, but they don't actually return anything. - */ -#define Dev_t int /* promoted dev_t */ -struct consdev; - -int sioclose __P((Dev_t dev, int fflag, int devtype, - struct proc *p)); -void siointr __P((int unit)); -#ifdef COM_MULTIPORT -bool_t comintr1 __P((struct com_s *com)); -#endif /* COM_MULTIPORT */ -int sioioctl __P((Dev_t dev, int cmd, caddr_t data, - int fflag, struct proc *p)); -int siocngetc __P((Dev_t dev)); -void siocninit __P((struct consdev *cp)); -void siocnprobe __P((struct consdev *cp)); -void siocnputc __P((Dev_t dev, int c)); -int sioopen __P((Dev_t dev, int oflags, int devtype, - struct proc *p)); -/* - * sioopen gets compared to the d_open entry in struct cdevsw. d_open and - * other functions are declared in with short types like dev_t - * in the prototype. Such declarations are broken because they vary with - * __P (significantly in theory - the compiler is allowed to push a short - * arg if it has seen the prototype; insignificantly in practice - gcc - * doesn't push short args and it would be slower on 386's to do so). - * - * Also, most of the device switch functions are still declared old-style - * so they take a Dev_t arg and shorten it to a dev_t. It would be simpler - * and faster if dev_t's were always promoted (to ints or whatever) as - * early as possible. - * - * Until is fixed, we cast sioopen to the following `wrong' type - * when comparing it to the d_open entry just to avoid compiler warnings. - */ -typedef int (*bogus_open_t) __P((dev_t dev, int oflags, int devtype, - struct proc *p)); -int sioread __P((Dev_t dev, struct uio *uio, int ioflag)); -void siostop __P((struct tty *tp, int rw)); -int siowrite __P((Dev_t dev, struct uio *uio, int ioflag)); -void softsio0 __P((void)); -void softsio1 __P((void)); -void softsio2 __P((void)); -void softsio3 __P((void)); -void softsio4 __P((void)); -void softsio5 __P((void)); -void softsio6 __P((void)); -void softsio7 __P((void)); -void softsio8 __P((void)); - -static int sioattach __P((struct isa_device *dev)); -static void comflush __P((struct com_s *com)); -static void comhardclose __P((struct com_s *com)); -static void cominit __P((int unit, int rate)); -static int commctl __P((struct com_s *com, int bits, int how)); -static int comparam __P((struct tty *tp, struct termios *t)); -static int sioprobe __P((struct isa_device *dev)); -static void compoll __P((void)); -static int comstart __P((struct tty *tp)); -static void comwakeup __P((void)); -static int tiocm2mcr __P((int)); - -/* table and macro for fast conversion from a unit number to its com struct */ -static struct com_s *p_com_addr[NSIO]; -#define com_addr(unit) (p_com_addr[unit]) - -static struct com_s com_structs[NSIO]; - -struct isa_driver siodriver = { - sioprobe, sioattach, "sio" -}; - -#ifdef COMCONSOLE -static int comconsole = COMCONSOLE; -#else -static int comconsole = -1; -#endif -static bool_t comconsinit; -static speed_t comdefaultrate = TTYDEF_SPEED; -static u_int com_events; /* input chars + weighted output completions */ -static int commajor; -struct tty sio_tty[NSIO]; -extern struct tty *constty; -extern u_int ipending; /* XXX */ -extern int tk_nin; /* XXX */ -extern int tk_rawcc; /* XXX */ - -#ifdef KGDB -#include "machine/remote-sl.h" - -extern int kgdb_dev; -extern int kgdb_rate; -extern int kgdb_debug_init; -#endif - -static struct speedtab comspeedtab[] = { - 0, 0, - 50, COMBRD(50), - 75, COMBRD(75), - 110, COMBRD(110), - 134, COMBRD(134), - 150, COMBRD(150), - 200, COMBRD(200), - 300, COMBRD(300), - 600, COMBRD(600), - 1200, COMBRD(1200), - 1800, COMBRD(1800), - 2400, COMBRD(2400), - 4800, COMBRD(4800), - 9600, COMBRD(9600), - 19200, COMBRD(19200), - 38400, COMBRD(38400), - 57600, COMBRD(57600), - 115200, COMBRD(115200), - -1, -1 -}; - -/* XXX - configure this list */ -static Port_t likely_com_ports[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, }; - -static int -sioprobe(dev) - struct isa_device *dev; -{ - static bool_t already_init; - Port_t *com_ptr; - Port_t iobase; - int result; - - if (!already_init) { - /* - * Turn off MCR_IENABLE for all likely serial ports. An unused - * port with its MCR_IENABLE gate open will inhibit interrupts - * from any used port that shares the interrupt vector. - */ - for (com_ptr = likely_com_ports; - com_ptr < &likely_com_ports[sizeof likely_com_ports - / sizeof likely_com_ports[0]]; - ++com_ptr) - outb(*com_ptr + com_mcr, 0); - already_init = TRUE; - } - iobase = dev->id_iobase; - result = IO_COMSIZE; - - /* - * We don't want to get actual interrupts, just masked ones. - * Interrupts from this line should already be masked in the ICU, - * but mask them in the processor as well in case there are some - * (misconfigured) shared interrupts. - */ - disable_intr(); - - /* - * Enable output interrupts (only) and check the following: - * o the CFCR, IER and MCR in UART hold the values written to them - * (the values happen to be all distinct - this is good for - * avoiding false positive tests from bus echoes). - * o an output interrupt is generated and its vector is correct. - * o the interrupt goes away when the IIR in the UART is read. - */ - outb(iobase + com_cfcr, CFCR_8BITS); /* ensure IER is addressed */ - outb(iobase + com_mcr, MCR_IENABLE); /* open gate early */ - outb(iobase + com_ier, 0); /* ensure edge on next intr */ - outb(iobase + com_ier, IER_ETXRDY); /* generate interrupt */ - if ( inb(iobase + com_cfcr) != CFCR_8BITS - || inb(iobase + com_ier) != IER_ETXRDY - || inb(iobase + com_mcr) != MCR_IENABLE - || (inb(iobase + com_iir) & IIR_IMASK) != IIR_TXRDY - || isa_irq_pending(dev) - || (inb(iobase + com_iir) & IIR_IMASK) != IIR_NOPEND) - result = 0; - - /* - * Turn off all device interrupts and check that they go off properly. - * Leave MCR_IENABLE set. It gates the OUT2 output of the UART to - * the ICU input. Closing the gate would give a floating ICU input - * (unless there is another device driving at) and spurious interrupts. - * (On the system that this was first tested on, the input floats high - * and gives a (masked) interrupt as soon as the gate is closed.) - */ - outb(iobase + com_ier, 0); - outb(iobase + com_mcr, MCR_IENABLE); /* dummy to avoid bus echo */ - if ( inb(iobase + com_ier) != 0 - || isa_irq_pending(dev) - || (inb(iobase + com_iir) & IIR_IMASK) != IIR_NOPEND) - result = 0; - - enable_intr(); - - return (result); -} - -static int /* XXX - should be void */ -sioattach(isdp) - struct isa_device *isdp; -{ - struct com_s *com; - static bool_t comwakeup_started = FALSE; - Port_t iobase; - int s; - u_char scr; - u_char scr1; - u_char scr2; - int unit; - - iobase = isdp->id_iobase; - unit = isdp->id_unit; - if (unit == comconsole) - DELAY(1000); /* XXX */ - s = spltty(); - - /* - * sioprobe() has initialized the device registers as follows: - * o cfcr = CFCR_8BITS. - * It is most important that CFCR_DLAB is off, so that the - * data port is not hidden when we enable interrupts. - * o ier = 0. - * Interrupts are only enabled when the line is open. - * o mcr = MCR_IENABLE. - * Keeping MCR_DTR and MCR_RTS off might stop the external - * device from sending before we are ready. - */ - - com = &com_structs[unit]; - com->cfcr_image = CFCR_8BITS; - com->mcr_image = MCR_IENABLE; -#if 0 - com->softDCD = TRUE; -#endif - com->iptr = com->ibuf = com->ibuf1; - com->ibufend = com->ibuf1 + RS_IBUFSIZE; - com->ihighwater = com->ibuf1 + RS_IHIGHWATER; - com->iobase = iobase; - com->data_port = iobase + com_data; - com->int_id_port = iobase + com_iir; - com->modem_ctl_port = iobase + com_mcr; - com->line_status_port = iobase + com_lsr; - com->modem_status_port = iobase + com_msr; - com->tp = &sio_tty[unit]; -#ifdef COM_BIDIR - /* - * if bidirectional ports possible, clear the bidir port info; - */ - com->bidir = FALSE; - com->active = FALSE; - com->active_in = com->active_out = FALSE; -#endif /* COM_BIDIR */ - - /* attempt to determine UART type */ - scr = inb(iobase + com_scr); - outb(iobase + com_scr, 0xa5); - scr1 = inb(iobase + com_scr); - outb(iobase + com_scr, 0x5a); - scr2 = inb(iobase + com_scr); - outb(iobase + com_scr, scr); - printf("sio%d: type", unit); -#ifdef COM_MULTIPORT - if (0); -#else - if (scr1 != 0xa5 || scr2 != 0x5a) - printf(" <8250>"); -#endif - else { - outb(iobase + com_fifo, FIFO_ENABLE | FIFO_TRIGGER_14); - DELAY(100); - switch (inb(iobase + com_iir) & IIR_FIFO_MASK) { - case FIFO_TRIGGER_1: - printf(" <16450>"); - break; - case FIFO_TRIGGER_4: - printf(" <16450?>"); - break; - case FIFO_TRIGGER_8: - printf(" <16550?>"); - break; - case FIFO_TRIGGER_14: - com->hasfifo = TRUE; - printf(" <16550A>"); - break; - } - outb(iobase + com_fifo, 0); - } -#ifdef COM_MULTIPORT - if (COM_ISMULTIPORT(isdp)) { - struct isa_device *masterdev; - - com->multiport = TRUE; - printf(" (multiport)"); - - /* set the master's common-interrupt-enable reg., - * as appropriate. YYY See your manual - */ - /* enable only common interrupt for port */ - outb(iobase + com_mcr, 0); - - masterdev = find_isadev(isa_devtab_tty, &siodriver, - COM_MPMASTER(isdp)); - outb(masterdev->id_iobase+com_scr, 0x80); - } - else - com->multiport = FALSE; -#endif /* COM_MULTIPORT */ - printf("\n"); - -#ifdef KGDB - if (kgdb_dev == makedev(commajor, unit)) { - if (comconsole == unit) - kgdb_dev = -1; /* can't debug over console port */ - else { - cominit(unit, kgdb_rate); - if (kgdb_debug_init) { - /* - * Print prefix of device name, - * let kgdb_connect print the rest. - */ - printf("com%d: ", unit); - kgdb_connect(1); - } - else - printf("com%d: kgdb enabled\n", unit); - } - } -#endif - - /* - * Need to reset baud rate, etc. of next print so reset comconsinit. - * Also make sure console is always "hardwired" - */ - if (unit == comconsole) { - comconsinit = FALSE; - com->softDCD = TRUE; - } - - com_addr(unit) = com; - - splx(s); - - if (!comwakeup_started) { - comwakeup(); - comwakeup_started = TRUE; - } - - return (1); -} - -/* ARGSUSED */ -int -sioopen(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; -{ - struct com_s *com; - int error = 0; - Port_t iobase; - int s; - struct tty *tp; - int unit = UNIT(dev); -#ifdef COM_BIDIR - bool_t callout = CALLOUT(dev); -#endif /* COM_BIDIR */ - if ((u_int) unit >= NSIO || (com = com_addr(unit)) == NULL) - return (ENXIO); -#ifdef COM_BIDIR - /* if it's a callout device, and bidir not possible on that dev, die */ - if (callout && !(com->bidir)) - return (ENXIO); -#endif /* COM_BIDIR */ - - tp = com->tp; - s = spltty(); - -#ifdef COM_BIDIR - -bidir_open_top: - /* if it's bidirectional, we've gotta deal with it... */ - if (com->bidir) { - if (callout) { - if (com->active_in) { - /* it's busy. die */ - splx(s); - return (EBUSY); - } else { - /* it's ours. lock it down, and set it up */ - com->active_out = TRUE; - com->softDCD = TRUE; - } - } else { - if (com->active_out) { - /* it's busy, outgoing. wait, if possible */ - if (flag & O_NONBLOCK) { - /* can't wait; bail */ - splx(s); - return (EBUSY); - } else { - /* wait for it... */ - error = tsleep(&com->active_out, - TTIPRI|PCATCH, - "comoth", - 0); - /* if there was an error, take off. */ - if (error != 0) { - splx(s); - return (error); - } - /* else take it from the top */ - goto bidir_open_top; - } - } else if (com->last_modem_status & MSR_DCD) { - /* there's a carrier on the line; we win */ - com->active_in = TRUE; - com->softDCD = FALSE; - } else { - /* there is no carrier on the line */ - if (flag & O_NONBLOCK) { - /* can't wait; let it open */ - com->active_in = TRUE; - com->softDCD = FALSE; - } else { - /* put DTR & RTS up */ - /* NOTE: cgd'sdriver used the ier register - * to enable/disable interrupts. This one - * uses both ier and IENABLE in the mcr. - */ - (void) commctl(com, MCR_DTR | MCR_RTS, DMSET); - outb(com->iobase + com_ier, IER_EMSC); - /* wait for it... */ - error = tsleep(&com->active_in, - TTIPRI|PCATCH, - "comdcd", - 0); - - /* if not active, turn DTR & RTS off */ - if (!com->active) - (void) commctl(com, MCR_DTR, DMBIC); - - /* if there was an error, take off. */ - if (error != 0) { - splx(s); - return (error); - } - /* else take it from the top */ - goto bidir_open_top; - } - } - } - } - - com->active = TRUE; -#endif /* COM_BIDIR */ - - tp->t_oproc = comstart; - tp->t_param = comparam; - tp->t_dev = dev; - if (!(tp->t_state & TS_ISOPEN)) { - tp->t_state |= TS_WOPEN; - ttychars(tp); - if (tp->t_ispeed == 0) { - /* - * We no longer use the flags from - * since those are only relevant for logins. It's - * important to have echo off initially so that the - * line doesn't start blathering before the echo flag - * can be turned off. - */ - tp->t_iflag = 0; - tp->t_oflag = 0; - tp->t_cflag = CREAD | CS8 | HUPCL; - tp->t_lflag = 0; - tp->t_ispeed = tp->t_ospeed = comdefaultrate; - } - (void) commctl(com, MCR_DTR | MCR_RTS, DMSET); - error = comparam(tp, &tp->t_termios); - if (error != 0) - goto out; - ttsetwater(tp); - iobase = com->iobase; - disable_intr(); - if (com->hasfifo) - /* (re)enable and drain FIFO */ - outb(iobase + com_fifo, FIFO_ENABLE | FIFO_TRIGGER_14 - | FIFO_RCV_RST | FIFO_XMT_RST); - (void) inb(com->line_status_port); - (void) inb(com->data_port); - com->last_modem_status = - com->prev_modem_status = inb(com->modem_status_port); - outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY | IER_ERLS - | IER_EMSC); - enable_intr(); - if (com->softDCD || com->prev_modem_status & MSR_DCD) - tp->t_state |= TS_CARR_ON; - } - else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) { - splx(s); - return (EBUSY); - } - while (!(flag & O_NONBLOCK) && !(tp->t_cflag & CLOCAL) -#ifdef COM_BIDIR - /* We went through a lot of trouble to open it, - * but it's certain we have a carrier now, so - * don't spend any time on it now. - */ - && !(com->bidir) -#endif /* COM_BIDIR */ - && !(tp->t_state & TS_CARR_ON)) { - tp->t_state |= TS_WOPEN; - error = ttysleep(tp, (caddr_t)&tp->t_raw, TTIPRI | PCATCH, - ttopen, 0); - if (error != 0) - break; - } -out: - splx(s); - if (error == 0) - error = (*linesw[tp->t_line].l_open)(dev, tp); - -#ifdef COM_BIDIR - /* wakeup sleepers */ - wakeup((caddr_t) &com->active_in); -#endif /* COM_BIDIR */ - - /* - * XXX - the next step was once not done, so interrupts, DTR and RTS - * remainded hot if the process was killed while it was sleeping - * waiting for carrier. Now there is the opposite problem. If several - * processes are sleeping waiting for carrier on the same line and one - * is killed, interrupts are turned off so the other processes will - * never see the carrier rise. - */ - if (error != 0 && !(tp->t_state & TS_ISOPEN)) -{ - comhardclose(com); -} - tp->t_state &= ~TS_WOPEN; - - return (error); -} - -/*ARGSUSED*/ -int -sioclose(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; -{ - struct com_s *com; - struct tty *tp; - - com = com_addr(UNIT(dev)); - tp = com->tp; - (*linesw[tp->t_line].l_close)(tp, flag); - comhardclose(com); - ttyclose(tp); - return (0); -} - -void -comhardclose(com) - struct com_s *com; -{ - Port_t iobase; - int s; - struct tty *tp; - - s = spltty(); - iobase = com->iobase; - outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK); -#ifdef KGDB - /* do not disable interrupts if debugging */ - if (kgdb_dev != makedev(commajor, com - &com_structs[0])) -#endif - outb(iobase + com_ier, 0); - tp = com->tp; - if (tp->t_cflag & HUPCL || tp->t_state & TS_WOPEN - || !(tp->t_state & TS_ISOPEN)) - (void) commctl(com, MCR_RTS, DMSET); -#ifdef COM_BIDIR - com->active = com->active_in = com->active_out = FALSE; - com->softDCD = FALSE; - - /* wakeup sleepers who are waiting for out to finish */ - wakeup((caddr_t) &com->active_out); -#endif /* COM_BIDIR */ - - splx(s); -} - -int -sioread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct tty *tp = com_addr(UNIT(dev))->tp; - - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -int -siowrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int unit = UNIT(dev); - struct tty *tp = com_addr(unit)->tp; - - /* - * (XXX) We disallow virtual consoles if the physical console is - * a serial port. This is in case there is a display attached that - * is not the console. In that situation we don't need/want the X - * server taking over the console. - */ - if (constty && unit == comconsole) - constty = NULL; - return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - -void -siointr(unit) - int unit; -{ - struct com_s *com; -#ifndef COM_MULTIPORT - u_char line_status; - u_char modem_status; - u_char *ioptr; - u_char recv_data; - - com = com_addr(unit); -#else /* COM_MULTIPORT */ - int i; - bool_t donesomething; - - do { - donesomething = FALSE; - for(i=0;iline_status_port); - - /* input event? (check first to help avoid overruns) */ - while (line_status & LSR_RCV_MASK) { - /* break/unnattached error bits or real input? */ -#ifdef COM_MULTIPORT - donesomething = TRUE; -#endif /* COM_MULTIPORT */ - if (!(line_status & LSR_RXRDY)) - recv_data = 0; - else - recv_data = inb(com->data_port); - ++com->bytes_in; -#ifdef KGDB - /* trap into kgdb? (XXX - needs testing and optim) */ - if (recv_data == FRAME_END - && !(com->tp->t_state & TS_ISOPEN) - && kgdb_dev == makedev(commajor, unit)) { - kgdb_connect(0); - continue; - } -#endif /* KGDB */ - ioptr = com->iptr; - if (ioptr >= com->ibufend) - CE_RECORD(com, CE_INTERRUPT_BUF_OVERFLOW); - else { - ++com_events; - ioptr[0] = recv_data; - ioptr[CE_INPUT_OFFSET] = line_status; - com->iptr = ++ioptr; - if (ioptr == com->ihighwater - && com->state & CS_RTS_IFLOW) - outb(com->modem_ctl_port, - com->mcr_image &= ~MCR_RTS); - } - - /* - * "& 0x7F" is to avoid the gcc-1.40 generating a slow - * jump from the top of the loop to here - */ - line_status = inb(com->line_status_port) & 0x7F; - } - - /* modem status change? (always check before doing output) */ - modem_status = inb(com->modem_status_port); - if (modem_status != com->last_modem_status) { - /* - * Schedule high level to handle DCD changes. Note - * that we don't use the delta bits anywhere. Some - * UARTs mess them up, and it's easy to remember the - * previous bits and calculate the delta. - */ -#ifdef COM_MULTIPORT - donesomething = TRUE; -#endif /* COM_MULTIPORT */ - com->last_modem_status = modem_status; - if (!(com->state & CS_CHECKMSR)) { - com_events += LOTS_OF_EVENTS; - com->state |= CS_CHECKMSR; - schedsoftcom(); - } - - /* handle CTS change immediately for crisp flow ctl */ - if (com->state & CS_CTS_OFLOW) { - if (modem_status & MSR_CTS) - com->state |= CS_ODEVREADY; - else - com->state &= ~CS_ODEVREADY; - } - } - - /* output queued and everything ready? */ - if (line_status & LSR_TXRDY - && com->state >= (CS_ODEVREADY | CS_BUSY | CS_TTGO)) { -#ifdef COM_MULTIPORT - donesomething = TRUE; -#endif /* COM_MULTIPORT */ - ioptr = com->optr; - outb(com->data_port, *ioptr); - ++com->bytes_out; - com->optr = ++ioptr; - if (ioptr >= com->obufend) { - /* output just completed */ - com_events += LOTS_OF_EVENTS; - com->state ^= (CS_ODONE | CS_BUSY); - schedsoftcom(); /* handle at high level ASAP */ - } - } - - /* finished? */ - if ((inb(com->int_id_port) & IIR_IMASK) == IIR_NOPEND) -#ifdef COM_MULTIPORT - return (donesomething); -#else - return; -#endif /* COM_MULTIPORT */ - } -} - -static int -tiocm2mcr(data) - int data; -{ - register m = 0; - if (data & TIOCM_DTR) m |= MCR_DTR; - if (data & TIOCM_RTS) m |= MCR_RTS; - return m; -} -int -sioioctl(dev, cmd, data, flag, p) - dev_t dev; - int cmd; - caddr_t data; - int flag; - struct proc *p; -{ - struct com_s *com; - int error; - Port_t iobase; - int s; - struct tty *tp; - - com = com_addr(UNIT(dev)); - tp = com->tp; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag); - if (error >= 0) - return (error); - error = ttioctl(tp, cmd, data, flag); - if (error >= 0) - return (error); - - iobase = com->iobase; - s = spltty(); - switch (cmd) { - case TIOCSBRK: - outb(iobase + com_cfcr, com->cfcr_image |= CFCR_SBREAK); - break; - case TIOCCBRK: - outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK); - break; - case TIOCSDTR: - (void) commctl(com, MCR_DTR, DMBIS); - break; - case TIOCCDTR: - (void) commctl(com, MCR_DTR, DMBIC); - break; - case TIOCMSET: - (void) commctl(com, tiocm2mcr(*(int *)data), DMSET); - break; - case TIOCMBIS: - (void) commctl(com, tiocm2mcr(*(int *)data), DMBIS); - break; - case TIOCMBIC: - (void) commctl(com, tiocm2mcr(*(int *)data), DMBIC); - break; - case TIOCMGET: - { - register int bits = 0, mode; - - mode = commctl(com, 0, DMGET); - if (inb(com->iobase+com_ier)) bits |= TIOCM_LE; /* XXX */ - if (mode & MSR_DCD) bits |= TIOCM_CD; - if (mode & MSR_CTS) bits |= TIOCM_CTS; - if (mode & MSR_DSR) bits |= TIOCM_DSR; - if (mode & (MCR_DTR<<8)) bits |= TIOCM_DTR; - if (mode & (MCR_RTS<<8)) bits |= TIOCM_RTS; - if (mode & (MSR_RI|MSR_TERI)) bits |= TIOCM_RI; - *(int *)data = bits; - } - break; -#ifdef COM_BIDIR - case TIOCMSBIDIR: - /* must be root to set bidir. capability */ - if (p->p_ucred->cr_uid != 0) - return(EPERM); - - /* if it's the console, can't do it */ - if (UNIT(dev) == comconsole) - return(ENOTTY); - - /* can't do the next, for obvious reasons... - * but there are problems to be looked at... - */ - - /* if the port is active, don't do it */ - /* if (com->active) - return(EBUSY); */ - - com->bidir = *(int *)data; - break; - case TIOCMGBIDIR: - *(int *)data = com->bidir; - break; -#endif /* COM_BIDIR */ - default: - splx(s); - return (ENOTTY); - } - splx(s); - return (0); -} - -/* cancel pending output */ -static void -comflush(com) - struct com_s *com; -{ - struct ringb *rbp; - - disable_intr(); - if (com->state & CS_ODONE) - com_events -= LOTS_OF_EVENTS; - com->state &= ~(CS_ODONE | CS_BUSY); - enable_intr(); - rbp = &com->tp->t_out; - rbp->rb_hd += com->ocount; - rbp->rb_hd = RB_ROLLOVER(rbp, rbp->rb_hd); - com->ocount = 0; - com->tp->t_state &= ~TS_BUSY; -} - -static void -compoll() -{ - static bool_t awake = FALSE; - struct com_s *com; - int s; - int unit; - - if (com_events == 0) - return; - disable_intr(); - if (awake) { - enable_intr(); - return; - } - awake = TRUE; - enable_intr(); - s = spltty(); -repeat: - for (unit = 0; unit < NSIO; ++unit) { - u_char *buf; - u_char *ibuf; - int incc; - struct tty *tp; - - com = com_addr(unit); - if (com == NULL) - continue; - tp = com->tp; - - /* switch the role of the low-level input buffers */ - if (com->iptr == (ibuf = com->ibuf)) - incc = 0; - else { - buf = ibuf; - disable_intr(); - incc = com->iptr - buf; - com_events -= incc; - if (ibuf == com->ibuf1) - ibuf = com->ibuf2; - else - ibuf = com->ibuf1; - com->ibufend = ibuf + RS_IBUFSIZE; - com->ihighwater = ibuf + RS_IHIGHWATER; - com->iptr = ibuf; - - /* - * There is now room for another low-level buffer full - * of input, so enable RTS if it is now disabled and - * there is room in the high-level buffer. - */ - if (!(com->mcr_image & MCR_RTS) - && !(tp->t_state & TS_RTSBLOCK)) - outb(com->modem_ctl_port, - com->mcr_image |= MCR_RTS); - enable_intr(); - com->ibuf = ibuf; - } - - if (com->state & CS_CHECKMSR) { - u_char delta_modem_status; - - disable_intr(); - delta_modem_status = com->last_modem_status - ^ com->prev_modem_status; - com->prev_modem_status = com->last_modem_status; - com_events -= LOTS_OF_EVENTS; - com->state &= ~CS_CHECKMSR; - enable_intr(); - if (delta_modem_status & MSR_DCD && - unit != comconsole) { -#ifdef COM_BIDIR - if (com->prev_modem_status & MSR_DCD) { - (*linesw[tp->t_line].l_modem)(tp, 1); - com->softDCD = FALSE; - wakeup((caddr_t) &com->active_in); - } -#else - if (com->prev_modem_status & MSR_DCD) - (*linesw[tp->t_line].l_modem)(tp, 1); -#endif /* COM_BIDIR */ - else if ((*linesw[tp->t_line].l_modem)(tp, 0) - == 0) { - disable_intr(); - outb(com->modem_ctl_port, - com->mcr_image - &= ~MCR_DTR); - enable_intr(); - } - } - } - - /* XXX */ - if (TRUE) { - u_int delta; - u_int delta_error_counts[CE_NTYPES]; - int errnum; - u_long total; - - disable_intr(); - bcopy(com->delta_error_counts, delta_error_counts, - sizeof delta_error_counts); - bzero(com->delta_error_counts, - sizeof delta_error_counts); - enable_intr(); - for (errnum = 0; errnum < CE_NTYPES; ++errnum) { - delta = delta_error_counts[errnum]; - if (delta != 0) { - total = - com->error_counts[errnum] += delta; - log(LOG_WARNING, - "com%d: %u more %s%s (total %lu)\n", - unit, delta, error_desc[errnum], - delta == 1 ? "" : "s", total); - } - } - } - if (com->state & CS_ODONE) { - comflush(com); - /* XXX - why isn't the table used for t_line == 0? */ - if (tp->t_line != 0) - (*linesw[tp->t_line].l_start)(tp); - else - comstart(tp); - } - if (incc <= 0 || !(tp->t_state & TS_ISOPEN)) - continue; - if (com->state & CS_RTS_IFLOW - && RB_LEN(&tp->t_raw) + incc >= RB_I_HIGH_WATER - && !(tp->t_state & TS_RTSBLOCK) - /* - * XXX - need RTS flow control for all line disciplines. - * Only have it in standard one now. - */ - && linesw[tp->t_line].l_rint == ttyinput) { - tp->t_state |= TS_RTSBLOCK; - ttstart(tp); - } - /* - * Avoid the grotesquely inefficient lineswitch routine - * (ttyinput) in "raw" mode. It usually takes about 450 - * instructions (that's without canonical processing or echo!). - * slinput is reasonably fast (usually 40 instructions plus - * call overhead). - */ - if (!(tp->t_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP - | IXOFF | IXON)) - && !(tp->t_lflag & (ECHO | ECHONL | ICANON | IEXTEN | ISIG - | PENDIN)) - && !(tp->t_state & (TS_CNTTB | TS_LNCH)) - && linesw[tp->t_line].l_rint == ttyinput) { - tk_nin += incc; - tk_rawcc += incc; - tp->t_rawcc += incc; - com->delta_error_counts[CE_TTY_BUF_OVERFLOW] - += incc - rb_write(&tp->t_raw, (char *) buf, - incc); - ttwakeup(tp); - if (tp->t_state & TS_TTSTOP - && (tp->t_iflag & IXANY - || tp->t_cc[VSTART] == tp->t_cc[VSTOP])) { - tp->t_state &= ~TS_TTSTOP; - tp->t_lflag &= ~FLUSHO; - ttstart(tp); - } - } - else { - do { - u_char line_status; - int recv_data; - - line_status = (u_char) buf[CE_INPUT_OFFSET]; - recv_data = (u_char) *buf++; - if (line_status - & (LSR_BI | LSR_FE | LSR_OE | LSR_PE)) { - if (line_status & LSR_BI) - recv_data |= TTY_BI; - if (line_status & LSR_FE) - recv_data |= TTY_FE; - if (line_status & LSR_OE) - recv_data |= TTY_OE; - if (line_status & LSR_PE) - recv_data |= TTY_PE; - } - (*linesw[tp->t_line].l_rint)(recv_data, tp); - } while (--incc > 0); - } - if (com_events == 0) - break; - } - if (com_events >= LOTS_OF_EVENTS) - goto repeat; - splx(s); - awake = FALSE; -} - -static int -comparam(tp, t) - struct tty *tp; - struct termios *t; -{ - u_int cfcr; - int cflag; - struct com_s *com; - int divisor; - int error; - Port_t iobase; - int s; - int unit; - - /* check requested parameters */ - divisor = ttspeedtab(t->c_ospeed, comspeedtab); - if (divisor < 0 || t->c_ispeed != 0 && t->c_ispeed != t->c_ospeed) - return (EINVAL); - - /* parameters are OK, convert them to the com struct and the device */ - unit = UNIT(tp->t_dev); - com = com_addr(unit); - iobase = com->iobase; - s = spltty(); - if (divisor == 0) { - (void) commctl(com, MCR_RTS, DMSET); /* hang up line */ - splx(s); - return (0); - } - cflag = t->c_cflag; - switch (cflag & CSIZE) { - case CS5: - cfcr = CFCR_5BITS; - break; - case CS6: - cfcr = CFCR_6BITS; - break; - case CS7: - cfcr = CFCR_7BITS; - break; - default: - cfcr = CFCR_8BITS; - break; - } - if (cflag & PARENB) { - cfcr |= CFCR_PENAB; - if (!(cflag & PARODD)) - cfcr |= CFCR_PEVEN; - } - if (cflag & CSTOPB) - cfcr |= CFCR_STOPB; - - /* - * Some UARTs lock up if the divisor latch registers are selected - * while the UART is doing output (they refuse to transmit anything - * more until given a hard reset). Fix this by stopping filling - * the device buffers and waiting for them to drain. Reading the - * line status port outside of siointr() might lose some receiver - * error bits, but that is acceptable here. - */ - disable_intr(); - com->state &= ~CS_TTGO; - enable_intr(); - while ((inb(com->line_status_port) & (LSR_TSRE | LSR_TXRDY)) - != (LSR_TSRE | LSR_TXRDY)) { - error = ttysleep(tp, (caddr_t)&tp->t_raw, TTIPRI | PCATCH, - "comparam", 1); - if (error != 0 && error != EAGAIN) { - if (!(tp->t_state & TS_TTSTOP)) { - disable_intr(); - com->state |= CS_TTGO; - enable_intr(); - } - splx(s); - return (error); - } - } - - disable_intr(); /* very important while com_data is hidden */ - outb(iobase + com_cfcr, cfcr | CFCR_DLAB); - outb(iobase + com_dlbl, divisor & 0xFF); - outb(iobase + com_dlbh, (u_int) divisor >> 8); - outb(iobase + com_cfcr, com->cfcr_image = cfcr); - if (!(tp->t_state & TS_TTSTOP)) - com->state |= CS_TTGO; - if (cflag & CRTS_IFLOW) - com->state |= CS_RTS_IFLOW; /* XXX - secondary changes? */ - else - com->state &= ~CS_RTS_IFLOW; - - /* - * Set up state to handle output flow control. - * XXX - worth handling MDMBUF (DCD) flow control at the lowest level? - * Now has 16+ msec latency, while CTS flow has 50- usec latency. - * Note that DCD flow control stupidly uses the same state flag - * (TS_TTSTOP) as XON/XOFF flow control. - */ - com->state &= ~CS_CTS_OFLOW; - com->state |= CS_ODEVREADY; - if (cflag & CCTS_OFLOW) { - com->state |= CS_CTS_OFLOW; - if (!(com->prev_modem_status & MSR_CTS)) - com->state &= ~CS_ODEVREADY; - } - - enable_intr(); - siointr(unit); /* recover from fiddling with CS_TTGO */ - splx(s); - return (0); -} - -static int /* XXX - should be void */ -comstart(tp) - struct tty *tp; -{ - struct com_s *com; - int s; - int unit; - - unit = UNIT(tp->t_dev); - com = com_addr(unit); - s = spltty(); - disable_intr(); - if (tp->t_state & TS_TTSTOP) - com->state &= ~CS_TTGO; - else - com->state |= CS_TTGO; - if (tp->t_state & TS_RTSBLOCK) { - if (com->mcr_image & MCR_RTS && com->state & CS_RTS_IFLOW) - outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS); - } - else { - if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater) { - tp->t_state &= ~TS_RTSBLOCK; - outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS); - } - } - enable_intr(); - if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) - goto out; - if (RB_LEN(&tp->t_out) <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_out); - } - if (tp->t_wsel) { - selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL); - tp->t_wsel = 0; - tp->t_state &= ~TS_WCOLL; - } - } - if (com->ocount != 0) { - disable_intr(); - siointr(unit); - enable_intr(); - } - else if (RB_LEN(&tp->t_out) != 0) { - tp->t_state |= TS_BUSY; - com->ocount = RB_CONTIGGET(&tp->t_out); - disable_intr(); - com->obufend = (com->optr = (u_char *) tp->t_out.rb_hd) - + com->ocount; - com->state |= CS_BUSY; - siointr(unit); /* fake interrupt to start output */ - enable_intr(); - } -out: - splx(s); - return (1); -} - -void -siostop(tp, rw) - struct tty *tp; - int rw; -{ - struct com_s *com; - - com = com_addr(UNIT(tp->t_dev)); - if (rw & FWRITE) - comflush(com); - disable_intr(); - if (tp->t_state & TS_TTSTOP) - com->state &= ~CS_TTGO; - else - com->state |= CS_TTGO; - enable_intr(); -} - -static int -commctl(com, bits, how) - struct com_s *com; - int bits; - int how; -{ - disable_intr(); - switch (how) { - case DMSET: -#ifdef COM_MULTIPORT - /* YYY maybe your card doesn't want IENABLE to be reset? */ - if(com->multiport) - outb(com->modem_ctl_port, - com->mcr_image = bits); - else -#endif /* COM_MULTIPORT */ - outb(com->modem_ctl_port, - com->mcr_image = bits | MCR_IENABLE); - break; - case DMBIS: - outb(com->modem_ctl_port, com->mcr_image |= bits); - break; - case DMBIC: -#ifdef COM_MULTIPORT - /* YYY maybe your card doesn't want IENABLE to be reset? */ - if(com->multiport) - outb(com->modem_ctl_port, - com->mcr_image &= ~(bits)); - else -#endif /* COM_MULTIPORT */ - outb(com->modem_ctl_port, - com->mcr_image &= ~(bits & ~MCR_IENABLE)); - break; - case DMGET: - bits = com->prev_modem_status | (com->mcr_image << 8); - break; - } - enable_intr(); - return (bits); -} - -static void -comwakeup() -{ - struct com_s *com; - int unit; - - timeout((timeout_func_t) comwakeup, (caddr_t) NULL, 1); - if (com_events != 0) - /* schedule compoll() to run when the cpl allows */ - schedsoftcom(); - - /* recover from lost output interrupts */ - for (unit = 0; unit < NSIO; ++unit) { - com = com_addr(unit); - if (com != NULL && com->state >= (CS_BUSY | CS_TTGO)) { - disable_intr(); - siointr(unit); - enable_intr(); - } - } -} - -void -softsio0() { compoll(); } - -void -softsio1() { compoll(); } - -void -softsio2() { compoll(); } - -void -softsio3() { compoll(); } - -void -softsio4() { compoll(); } - -void -softsio5() { compoll(); } - -void -softsio6() { compoll(); } - -void -softsio7() { compoll(); } - -void -softsio8() { compoll(); } - -/* - * Following are all routines needed for COM to act as console - * XXX - not tested in this version - * XXX - check that the corresponding serial interrupts are never enabled - */ -#include "i386/i386/cons.h" - -void -siocnprobe(cp) - struct consdev *cp; -{ - int unit; - - /* locate the major number */ - for (commajor = 0; commajor < nchrdev; commajor++) - if (cdevsw[commajor].d_open == (bogus_open_t) sioopen) - break; - - /* XXX: ick */ - unit = CONUNIT; - com_addr(unit) = &com_structs[unit]; - com_addr(unit)->iobase = CONADDR; - - /* make sure hardware exists? XXX */ - - /* initialize required fields */ - cp->cn_dev = makedev(commajor, unit); - cp->cn_tp = &sio_tty[unit]; -#ifdef COMCONSOLE - cp->cn_pri = CN_REMOTE; /* Force a serial port console */ -#else - cp->cn_pri = CN_NORMAL; -#endif -} - -void -siocninit(cp) - struct consdev *cp; -{ - int unit; - - unit = UNIT(cp->cn_dev); - cominit(unit, comdefaultrate); - comconsole = unit; - comconsinit = TRUE; -} - -static void -cominit(unit, rate) - int unit; - int rate; -{ - Port_t iobase; - int s; - - iobase = com_addr(unit)->iobase; - s = splhigh(); - outb(iobase + com_cfcr, CFCR_DLAB); - rate = ttspeedtab(comdefaultrate, comspeedtab); - outb(iobase + com_data, rate & 0xFF); - outb(iobase + com_ier, rate >> 8); - outb(iobase + com_cfcr, CFCR_8BITS); - - /* - * XXX - fishy to enable interrupts and then poll. - * It shouldn't be necessary to ready the iir. - */ - outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC); - outb(iobase + com_fifo, - FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14); - (void) inb(iobase + com_iir); - splx(s); -} - -int -siocngetc(dev) - dev_t dev; -{ - int c; - Port_t iobase; - int s; - - iobase = com_addr(UNIT(dev))->iobase; - s = splhigh(); - while (!(inb(iobase + com_lsr) & LSR_RXRDY)) - ; - c = inb(iobase + com_data); - (void) inb(iobase + com_iir); - splx(s); - return (c); -} - -void -siocnputc(dev, c) - dev_t dev; - int c; -{ - Port_t iobase; - int s; - int timo; - - iobase = com_addr(UNIT(dev))->iobase; - s = splhigh(); -#ifdef KGDB - if (dev != kgdb_dev) -#endif - if (!comconsinit) { - (void) cominit(UNIT(dev), comdefaultrate); - comconsinit = TRUE; - } - /* wait for any pending transmission to finish */ - timo = 50000; - while (!(inb(iobase + com_lsr) & LSR_TXRDY) && --timo) - ; - outb(iobase + com_data, c); - /* wait for this transmission to complete */ - timo = 1500000; - while (!(inb(iobase + com_lsr) & LSR_TXRDY) && --timo) - ; - /* clear any interrupts generated by this transmission */ - (void) inb(iobase + com_iir); - splx(s); -} - -/* - * 10 Feb 93 Jordan K. Hubbard Added select code - * 27 May 93 Rodney W. Grimes Stole the select code from com.c.pl5 - */ - -int -sioselect(dev, rw, p) - dev_t dev; - int rw; - struct proc *p; -{ - register struct tty *tp = &sio_tty[UNIT(dev)]; - int nread; - int s = spltty(); - struct proc *selp; - - switch (rw) { - - case FREAD: - nread = ttnread(tp); - if (nread > 0 || - ((tp->t_cflag&CLOCAL) == 0 && (tp->t_state&TS_CARR_ON) == 0)) - goto win; - if (tp->t_rsel && (selp = pfind(tp->t_rsel)) && selp->p_wchan == (caddr_t)&selwait) - tp->t_state |= TS_RCOLL; - else - tp->t_rsel = p->p_pid; - break; - - case FWRITE: - if (RB_LEN(&tp->t_out) <= tp->t_lowat) - goto win; - if (tp->t_wsel && (selp = pfind(tp->t_wsel)) && selp->p_wchan == (caddr_t)&selwait) - tp->t_state |= TS_WCOLL; - else - tp->t_wsel = p->p_pid; - break; - } - splx(s); - return (0); - win: - splx(s); - return (1); -} - -#endif /* NSIO > 0 */ diff --git a/sys/i386/isa/sioreg.h b/sys/i386/isa/sioreg.h deleted file mode 100644 index 4b0f1b6..0000000 --- a/sys/i386/isa/sioreg.h +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * Copyright (c) 1991 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)comreg.h 7.2 (Berkeley) 5/9/91 - * $Id$ - */ - - -/* 16 bit baud rate divisor (lower byte in dca_data, upper in dca_ier) */ -#define COMBRD(x) (1843200 / (16*(x))) - -/* interrupt enable register */ -#define IER_ERXRDY 0x1 -#define IER_ETXRDY 0x2 -#define IER_ERLS 0x4 -#define IER_EMSC 0x8 - -/* interrupt identification register */ -#define IIR_IMASK 0xf -#define IIR_RXTOUT 0xc -#define IIR_RLS 0x6 -#define IIR_RXRDY 0x4 -#define IIR_TXRDY 0x2 -#define IIR_NOPEND 0x1 -#define IIR_MLSC 0x0 -#define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */ - -/* fifo control register */ -#define FIFO_ENABLE 0x01 -#define FIFO_RCV_RST 0x02 -#define FIFO_XMT_RST 0x04 -#define FIFO_DMA_MODE 0x08 -#define FIFO_TRIGGER_1 0x00 -#define FIFO_TRIGGER_4 0x40 -#define FIFO_TRIGGER_8 0x80 -#define FIFO_TRIGGER_14 0xc0 - -/* character format control register */ -#define CFCR_DLAB 0x80 -#define CFCR_SBREAK 0x40 -#define CFCR_PZERO 0x30 -#define CFCR_PONE 0x20 -#define CFCR_PEVEN 0x10 -#define CFCR_PODD 0x00 -#define CFCR_PENAB 0x08 -#define CFCR_STOPB 0x04 -#define CFCR_8BITS 0x03 -#define CFCR_7BITS 0x02 -#define CFCR_6BITS 0x01 -#define CFCR_5BITS 0x00 - -/* modem control register */ -#define MCR_LOOPBACK 0x10 -#define MCR_IENABLE 0x08 -#define MCR_DRS 0x04 -#define MCR_RTS 0x02 -#define MCR_DTR 0x01 - -/* line status register */ -#define LSR_RCV_FIFO 0x80 -#define LSR_TSRE 0x40 -#define LSR_TXRDY 0x20 -#define LSR_BI 0x10 -#define LSR_FE 0x08 -#define LSR_PE 0x04 -#define LSR_OE 0x02 -#define LSR_RXRDY 0x01 -#define LSR_RCV_MASK 0x1f - -/* modem status register */ -#define MSR_DCD 0x80 -#define MSR_RI 0x40 -#define MSR_DSR 0x20 -#define MSR_CTS 0x10 -#define MSR_DDCD 0x08 -#define MSR_TERI 0x04 -#define MSR_DDSR 0x02 -#define MSR_DCTS 0x01 - -/* - * WARNING: Serial console is assumed to be at COM1 address - * and CONUNIT must be 0. - */ -#define CONADDR (0x3f8) -#define CONUNIT (0) diff --git a/sys/i386/isa/sound/CHANGELOG b/sys/i386/isa/sound/CHANGELOG new file mode 100644 index 0000000..78168dd --- /dev/null +++ b/sys/i386/isa/sound/CHANGELOG @@ -0,0 +1,55 @@ +Changelog for version 2.4 +------------------------- + +Since 2.3b +- Fixed bug which made it impossible to make long recordings to disk. + Recording was not restarted after a buffer overflow situation. +- Limited mixer support for GUS. +- Numerous improvements to the GUS driver by Andrew Robinson. Including + some click removal etc. + +Since 2.3 +- Fixed some minor bugs in the SB16 driver. + +Since 2.2b +- Full SB16 DSP support. 8/16 bit, mono/stereo +- The SCO and FreeBSD versions should be in sync now. There are some + problems with SB16 and GUS in the freebsd versions. + The DMA buffer allocation of the SCO version has been polished but + there could still be some problems. At least it hogs memory. + The DMA channel + configuration method used in the sco/System is a hack. +- Support for the MPU emulation of the SB16. +- Some big arrays are now allocated boot time. This makes the bss segment + smaller which makes it possible to use the full driver with + NetBSD. These arrays are not allocated if no suitable soundcard is available. +- Fixed a bug in the compute_and_set_volume in gus_wave.c +- Fixed the too fast mono playback problem of SB Pro and PAS16. + +Since 2.2 +- Stereo recording for SB Pro. Somehow it was missing and nobody + had noticed it earlier. +- Minor polishing. +- Interpreting of boot time arguments (sound=) for Linux. +- Breakup of sb_dsp.c. Parts of the code has been moved to + sb_mixer.c and sb_midi.c + +Since 2.1 +- Preliminary support for SB16. + - The SB16 mixer is supported in it's native mode. + - Digitized voice capability up to 44.1 kHz/8 bit/mono + (16 bit and stereo support coming in the next release). +- Fixed some bugs in the digitized voice driver for PAS16. +- Proper initialization of the SB emulation of latest PAS16 models. + +- Significantly improved /dev/dsp and /dev/audio support. + - Now supports half duplex mode. It's now possible to record and + playback without closing and reopening the device. + - It's possible to use smaller buffers than earlier. There is a new + ioctl(fd, SNDCTL_DSP_SUBDIVIDE, &n) where n should be 1, 2 or 4. + This call instructs the driver to use smaller buffers. The default + buffer size (0.5 to 1.0 seconds) is divided by n. Should be called + immediately after opening the device. + +Since 2.0 +Just cosmetic changes. diff --git a/sys/i386/isa/sound/HOWTO_MIDI b/sys/i386/isa/sound/HOWTO_MIDI deleted file mode 100644 index f0601e5..0000000 --- a/sys/i386/isa/sound/HOWTO_MIDI +++ /dev/null @@ -1,51 +0,0 @@ -The following file describes the procedure for adding modules to MIDI -Please READ the main documentation files for the driver first!!! - - - Example: We have a sound card with a MIDI chip & port on it - and, we call it the 'MYBLASTER' card: - - ************************************************************************** - - 0: Run 'configure'. Select the MIDI on CHIP support option. - - 1: Write a midi driver module; 'blast_midi.c' - (with functions for open,close,read,write,attach.) - - 1a: Write all functions except the 'attach' the way you want. - - For the 'attach' function, look at a model in the 'pro_midi.c' - file. Just dup it in the same fashion. For the 'generic_midi_operations' - structure which is required, see file 'dev_table.h'. - - 2: We called the 'attach' function: 'blast_attach'. - - Go to the file 'dev_table.h' and add your driver name and the function - pointer ( which is 'blast_attach' ) to the 'midi_supported' table. - - 3: You are almost set. Go and make a reference - to an 'exclude constant'; say EXLCUDE_BLAST_MIDI in your module - (refer to the 'pro_midi.c' file for model). Also make sure to - add the constant to the file 'sound_config.h' (for example, look - where the constant EXCLUDE_PRO_MIDI is in the file.) - - 4: Add the line - - #define ALL_EXTERNAL_TO_ME - - as the 1st line of your 'blast_midi.c' file. This happily, makes - you ignorant of everything else specific to the driver! :). - - 4a: And of course, don't forget to make a device :). Note that your - minor number should be = ( 15 + position of your driver in the - 'midi_supported' table in the 'dev_table.h' file ). - - Eg: Your driver is the second one in the table. viz midi_supported[1]. - Your device minor number should be ( 15 + 1 = 16 ). Then, make the - reference to your device as, say CMIDI_DEV_BLAST in the file - 'sound_config.h'. Also add this in 'soundcard.c' for the open, read, - write and close routines. See files for example using CMIDI_DEV_PRO - (which is the ProAudioSpectrum on chip MIDI). - - 5: You are all set. If ever you have problems, follow the same model - as the file 'pro_midi.c', except for substituting your own functions! diff --git a/sys/i386/isa/sound/RELNOTES b/sys/i386/isa/sound/RELNOTES deleted file mode 100644 index 03d492d..0000000 --- a/sys/i386/isa/sound/RELNOTES +++ /dev/null @@ -1,38 +0,0 @@ -Welcome to use the Linux sound driver for FreeBSD. This -driver supports the SoundBlaster, SB Pro, Pro Audio Spectrum 16, -AdLib and Gravis UltraSound sound cards. - -In addition there is rather limited support for MPU-401 -(and compatible) midi cards. Also, the OPL-3 synthesizer -of the SB Pro and PAS16 cards is now supported in the 4 OP -modes. - -Most of the features of the /dev/sequencer device file are -available just for GUS owners. - -The SoundBlaster 16 and SB 16 ASP cards are not supported, -though they may work in mono mode with speeds < 22 kHz. -The OPL-3 chicp of the SB 16 should work (without problems?). -Is there anybody willing to implement the SB 16 support -(have the SB 16 and the SDK for it)? - -Since this driver is a sound driver, it does not contain support -for SCSI/CD-ROM/Joystick -devices. - -Known bugs ----------- - -- It's not possible to open /dev/dsp (or /dev/audio) while the - /dev/sequencer is open for output and GUS is the only soundcard - installed. It's possible if /dev/dsp is opened before /dev/sequencer - but at this time the GUS is not available for access via /dev/sequencer. - This is a limitation of the driver. -- MPU-401 driver hangs the computer on boot if there is no MPU-401 installed. - It uses by default the I/O port 0x330, which is also used by the - Adaptec 1542 SCSI adapter. -- The /dev/sequencer playback to GUS sounds sometimes rather weird. Hitting - ^C and playing again should solve this problem. This is probably caused by - incompatibilities between the GUS and certain VLB motherboards. Try to avoid - switching between VTs while patches are being loaded to the GUS. -- There is a skeleton of the patch manager support. It doesn't work in - this version. diff --git a/sys/i386/isa/sound/RELNOTES.Linux b/sys/i386/isa/sound/RELNOTES.Linux deleted file mode 100644 index 4082f4e..0000000 --- a/sys/i386/isa/sound/RELNOTES.Linux +++ /dev/null @@ -1,191 +0,0 @@ -Release notes for the Linux Sound Driver 1.99.9 ------------------------------------------------ - -******** THIS IS A BETA TEST RELEASE ******** -which means that there can be some untested things. In theory -there is a risk that this driver causes some trouble to your system. -You should not use this driver before backing up your disks. - - - - -Welcome to use the Gravis UltraSound driver for Linux. This -driver still supports the same cards than version 1.0c -(SoundBlaster, SB Pro, Pro Audio Spectrum 16 and AdLib). -In addition there is rather limited support for MPU-401 -(and compatible) midi cards. Also the OPL-3 synthesizer -of the SB Pro and PAS16 cards is now supported in the 4 OP -modes. -Most of the features of the /dev/sequencer device file are -available just for GUS owners. - -The SoundBlaster 16 and SB 16 ASP cards are not supported. -They could work in mono mode with speeds < 22 kHz. -The OPL-3 chicp of the SB 16 should work (without problems?). -Is there anybody willing to implement the SB 16 support -(have the SB 16 and the SDK for it)? - - -This is the first version of the driver which has almost -all of the features which I have planned to include into -version 2.0. Some features are still missing and some ones -doesn't work. - -NOTE! There are separate driver for CD-ROMS supported by - some soundcards. The driver for CDU31A (Fusion 16) is - called cdu31a-0.6.diff.z. It will be contained in the - Linux version 0.99.12. The driver for the CD-ROM of SB Pro - is sbpcd0.4.tar.gz (these were the latest versions when I wrote - this). These files should be at least at sunsite.unc.edu. - As far as I know, there is no driver for the SCSI interface of PAS16 - (yet). - - There is also a driver for joystick. Look for file joystick-0.5.tar.gz - (sunsite). - - Since this driver is a sound driver, it will not contain support - for SCSI/CD-ROM/Joystick -devices. - -Compatibility with the earlier versions ---------------------------------------- - -This is just like the version 1.99.7/1.99.8. There is just some minor -enhancements. Most of them are portability fixes. If you are porting -this driver to any OS, please look at the 386bsd/os.h. There is some -new macros and some macros have more parameters. In addition this file -contains some usefull comments. - -**** There is some ISC and 386bsd stuff in this driver. Please stay away **** -This stuff is here just because I want to be in sync with the porters. These -ports don't work yet. - -The ioctl() interface has changed completely since version 1.0c. All -programs using this driver must be at least recompiled. -The snd-util-1.99.6 package contains some utilities for this version. - -The version 1.0c and earlier used a 'nonportable' ioctl calling scheme -where the input argument was passed by value and the output value was -returned as the functional return. For example setting the speed of -/dev/dsp were done as the following: - - int actual_speed; - actual_speed = ioctl(fd, SOUND_PCM_WRITE_RATE, 44100); - -After version 1.99.0 this must be done as the following: - - int actual_speed = 44100; - ioctl(fd, SOUND_PCM_WRITE_RATE, &actual_speed); - -If you have an application written for the version 1.0, you should search -for the strings SNDCTL_ and SOUND_ and to check the parameters. - -Since the this version will support more than one synthesizer devices -at the same time, the ioctl(SNDCTL_FM_LOAD_INSTR) is obsolete. In addition -there is some new fields which must be initialized. Look at the sbiset.c in -the snd-util-1.99.6 package for further info. - -The GUS patch format has changed since the version 1.99.3. You have to -use latest versions of the programs in the sound/gustest directory. In -addition the version 0.4g of the Adagio package supports this format. - -New features ------------- - -There is also some changes which make this version more usable than -the version 1.0c. - -- /dev/dsp and /dev/audio - -The DMA buffering is now little bit more intelligent than earlier. The -buffer size is selected run-time so that a buffer holds data for 0.5 to -1.0 seconds of recording or playback. This makes recording more comfortable -than with version 1.0. With the previous version there was sometimes more -than 10 seconds of delay before the driver returned the first input byte. - -There is also support for more than one digitized voice devices. The device -files /dev/dsp1 and /dev/audio1 (minor 19 and 20) are available with PAS16. -The /dev/dsp (/dev/audio) is connected to the PCM circuit of the PAS16 itself -and the /dev/dsp1 (/dev/audio1) to the SB emulation of PAS16 card. Two -dsp/audio devices are available also if you have combination of SB and GUS. -With GUS and PAS16 you will have even three dsp/audio devices. These devices -can be used independently and can be active at the same time (3 channels -at the same time propably don't work). - -The dsp/audio support of PAS16 should be much cleaner now since the -constant clicking sound between the DMA blocks (about once per second) has -been eliminated. - -The stereo playback of GUS doesn't work perfectly. There is lot of -clicking in the output. - -- /dev/mixer - -No changes. - -There is no mixer for the GUS yet. - -- /dev/sequencer - -This part has the most changes. Mostly to support the rich -features of the Gravis UltraSound. There is also the support -for the OPL-3 synthesizer chip. - -- /dev/sndstat - -This is a new devicefile for debugging purposes. A better place for -it is in the /proc -directory but I was just too lazy to implement it -properly. The /dev/sndstat (major 14, minor 6) is a file which returns -info about the current configuration (see the example below). If you -send me a error/problem report, please include a printout from this -device to your message (cat /dev/sndstat). - ------- cut here --- cat /dev/sndstat example -------- -Sound Driver:1.99.7 (Fri Jul 9 17:01:47 GMT 1993 root@lucifer.savolai.fi) -Config options: 0x00000d4b - -Major number: 14 -HW config: -Type 4: Gravis Ultrasound at 0x210 irq 15 drq 6 -Type 3: ProAudioSpectrum at 0x388 irq 10 drq 3 -Type 2: SoundBlaster at 0x220 irq 7 drq 1 -Type 1: AdLib at 0x388 irq 0 drq 0 - -PCM devices: -00: Gravis UltraSound -01: Pro Audio Spectrum -02: SoundBlaster 2.0 - -Synth devices: -00: Gravis UltraSound -01: Yamaha OPL-3 - -Midi devices: -00: Gravis UltraSound -01: Pro Audio Spectrum - -Mixer(s) installed ------- cut here ---- End of Example ----------- - - -Known bugs ----------- - -- There was clicking during stereo playback to /dev/dsp with GUS. - * Fixed in 1.99.9 * -- It's not possible to open /dev/dsp (or /dev/audio) while the - /dev/sequencer is open for output and GUS is the only soundcard - installed. It's possible if /dev/dsp is opened before /dev/sequencer - but at this time the GUS is not available for access via /dev/sequencer. - This is a limitation of the driver. -- MPU-401 driver hangs the computer on boot if there is no MPU-401 installed. - It uses by default the I/O port 0x330 whic is used by Adaptec 1542 SCSI - adapter. -- The /dev/sequencer playback to GUS sounds sometimes rather weird. Hitting - ^C and playing again should solve this problem. This is propably caused by - incompatibilities between GUS and certain VLB motherboards. Try to avoid - switching between VTs while patches are being loaded to the GUS. -- There was some problems with GUS and Mitsumi CD in version 1.99.8. Fixed - in 1.99.9. -- /dev/audio sounded like stereo with GUS. Fixed in 1.99.9. -- There is a skeleton of the patch manager support. It don't work in - this version. diff --git a/sys/i386/isa/sound/gus_linearvol.h b/sys/i386/isa/sound/gus_linearvol.h new file mode 100644 index 0000000..7ad0c30 --- /dev/null +++ b/sys/i386/isa/sound/gus_linearvol.h @@ -0,0 +1,18 @@ +static unsigned short gus_linearvol[128] = { + 0x0000, 0x08ff, 0x09ff, 0x0a80, 0x0aff, 0x0b40, 0x0b80, 0x0bc0, + 0x0bff, 0x0c20, 0x0c40, 0x0c60, 0x0c80, 0x0ca0, 0x0cc0, 0x0ce0, + 0x0cff, 0x0d10, 0x0d20, 0x0d30, 0x0d40, 0x0d50, 0x0d60, 0x0d70, + 0x0d80, 0x0d90, 0x0da0, 0x0db0, 0x0dc0, 0x0dd0, 0x0de0, 0x0df0, + 0x0dff, 0x0e08, 0x0e10, 0x0e18, 0x0e20, 0x0e28, 0x0e30, 0x0e38, + 0x0e40, 0x0e48, 0x0e50, 0x0e58, 0x0e60, 0x0e68, 0x0e70, 0x0e78, + 0x0e80, 0x0e88, 0x0e90, 0x0e98, 0x0ea0, 0x0ea8, 0x0eb0, 0x0eb8, + 0x0ec0, 0x0ec8, 0x0ed0, 0x0ed8, 0x0ee0, 0x0ee8, 0x0ef0, 0x0ef8, + 0x0eff, 0x0f04, 0x0f08, 0x0f0c, 0x0f10, 0x0f14, 0x0f18, 0x0f1c, + 0x0f20, 0x0f24, 0x0f28, 0x0f2c, 0x0f30, 0x0f34, 0x0f38, 0x0f3c, + 0x0f40, 0x0f44, 0x0f48, 0x0f4c, 0x0f50, 0x0f54, 0x0f58, 0x0f5c, + 0x0f60, 0x0f64, 0x0f68, 0x0f6c, 0x0f70, 0x0f74, 0x0f78, 0x0f7c, + 0x0f80, 0x0f84, 0x0f88, 0x0f8c, 0x0f90, 0x0f94, 0x0f98, 0x0f9c, + 0x0fa0, 0x0fa4, 0x0fa8, 0x0fac, 0x0fb0, 0x0fb4, 0x0fb8, 0x0fbc, + 0x0fc0, 0x0fc4, 0x0fc8, 0x0fcc, 0x0fd0, 0x0fd4, 0x0fd8, 0x0fdc, + 0x0fe0, 0x0fe4, 0x0fe8, 0x0fec, 0x0ff0, 0x0ff4, 0x0ff8, 0x0ffc +}; diff --git a/sys/i386/isa/sound/gustest/Makefile b/sys/i386/isa/sound/gustest/Makefile deleted file mode 100644 index d161e5b..0000000 --- a/sys/i386/isa/sound/gustest/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -all: gustest gusload gmod midithru - -gustest: gustest.c - $(CC) -o gustest gustest.c -lm - -gusload: gusload.c - $(CC) -o gusload gusload.c - -gmod: gmod.c - $(CC) -o gmod gmod.c - -midithru: midithru.c - $(CC) -o midithru midithru.c - -clean: - rm -f gusload gustest gmod midithru *.o diff --git a/sys/i386/isa/sound/gustest/Readme b/sys/i386/isa/sound/gustest/Readme deleted file mode 100644 index 7640bf8..0000000 --- a/sys/i386/isa/sound/gustest/Readme +++ /dev/null @@ -1,67 +0,0 @@ -The programs in this directory are more or less incompletely implemented. -I have used them for debugging purposes while developing the driver. - -Files in this directory: - - -../ultrasound.h (sys/ultrasound.h) - This file contains some macros which are similar than - the procedures provided by GUSUNIT.PAS. See gustest.c - for more information. - INSTALL THIS FILE TO YOUR /usr/include/sys !!!!!!!!!!!! - -gusload.c This program can be used to load patches (samples) to - the DRAM of GUS. It understands the format used in the - .pat files shipped with GUS. - - Usage: gusload pgm# patchfile. - or gusload reset #Removes all patches from memory. - - You should load just the patches you will need to play - a Midi file, since the memory capacity of GUS is rather - limited (256k-1M). - - Example: - - gusload 0 acpiano.pat - gusload 1 britepno.pat - gusload 19 church.pat - - This program is not required if the adagio package is - used. It can do the patch uploading itself. - -gmod.c This is a simple module player which demonstrates - programming with GUS. It doesn't try to interpret - most of the effect commands. In fact this program - may interpret the modules incorrectly since I am - not a module player expert. - This version plays .MOD, .STM and .669 modules. - -midithru.c This program reads messages from the Midi interface - and plays the notes with an internal synthesizer - (FM or GUS). The program accepts one argument, the - synthesizer device number. In addition to the note on - and note off messages it interprets also program changes - and channel pressure messages. - If you need an example on programming the /dev/sequencer, - this is a good one. The voice allocation algorithm is - not good so don't look at it. - - NOTE! This program is useful with gmod. Jus load - a module with gmod. Wait until the module has - finished or hit ^C. Now you can play the samples - with the midithru program. - - NOTE2! You need a Midi keyboard to use this program. In - addition the Midi interface of GUS is not supported - yet which means you need also PAS16 or MPU-401. - -pmtest.c -gpatinfo.c ******* For information only ******* - These programs demonstrate the patch manager interface - which will be included to some later driver version. - This interface is not complete in version 1.99.9. - Using pmtest will hang your system sooner or later. - -Hannu Savolainen -hsavolai@cs.helsinki.fi diff --git a/sys/i386/isa/sound/gustest/gmidi.h b/sys/i386/isa/sound/gustest/gmidi.h deleted file mode 100644 index ab951e7..0000000 --- a/sys/i386/isa/sound/gustest/gmidi.h +++ /dev/null @@ -1,131 +0,0 @@ - char patch_names[][9] = - { - /* 0 */ "acpiano", - /* 1 */ "britepno", - /* 2 */ "synpiano", - /* 3 */ "honktonk", - /* 4 */ "epiano1", - /* 5 */ "epiano2", - /* 6 */ "hrpschrd", - /* 7 */ "clavinet", - /* 8 */ "celeste", - /* 9 */ "glocken", - /* 10 */ "musicbox", - /* 11 */ "vibes", - /* 12 */ "marimba", - /* 13 */ "xylophon", - /* 14 */ "tubebell", - /* 15 */ "santur", - /* 16 */ "homeorg", - /* 17 */ "percorg", - /* 18 */ "rockorg", - /* 19 */ "church", - /* 20 */ "reedorg", - /* 21 */ "accordn", - /* 22 */ "harmonca", - /* 23 */ "concrtna", - /* 24 */ "nyguitar", - /* 25 */ "acguitar", - /* 26 */ "jazzgtr", - /* 27 */ "cleangtr", - /* 28 */ "mutegtr", - /* 29 */ "odguitar", - /* 30 */ "distgtr", - /* 31 */ "gtrharm", - /* 32 */ "acbass", - /* 33 */ "fngrbass", - /* 34 */ "pickbass", - /* 35 */ "fretless", - /* 36 */ "slapbas1", - /* 37 */ "slapbas2", - /* 38 */ "synbass1", - /* 39 */ "synbass2", - /* 40 */ "violin", - /* 41 */ "viola", - /* 42 */ "cello", - /* 43 */ "contraba", - /* 44 */ "marcato", - /* 45 */ "pizzcato", - /* 46 */ "harp", - /* 47 */ "timpani", - /* 48 */ "marcato", - /* 49 */ "slowstr", - /* 50 */ "synstr1", - /* 51 */ "synstr2", - /* 52 */ "choir", - /* 53 */ "doo", - /* 54 */ "voices", - /* 55 */ "orchhit", - /* 56 */ "trumpet", - /* 57 */ "trombone", - /* 58 */ "tuba", - /* 59 */ "mutetrum", - /* 60 */ "frenchrn", - /* 61 */ "hitbrass", - /* 62 */ "synbras1", - /* 63 */ "synbras2", - /* 64 */ "sprnosax", - /* 65 */ "altosax", - /* 66 */ "tenorsax", - /* 67 */ "barisax", - /* 68 */ "oboe", - /* 69 */ "englhorn", - /* 70 */ "bassoon", - /* 71 */ "clarinet", - /* 72 */ "piccolo", - /* 73 */ "flute", - /* 74 */ "recorder", - /* 75 */ "woodflut", - /* 76 */ "bottle", - /* 77 */ "shakazul", - /* 78 */ "whistle", - /* 79 */ "ocarina", - /* 80 */ "sqrwave", - /* 81 */ "sawwave", - /* 82 */ "calliope", - /* 83 */ "chiflead", - /* 84 */ "voxlead", - /* 85 */ "voxlead", - /* 86 */ "lead5th", - /* 87 */ "basslead", - /* 88 */ "fantasia", - /* 89 */ "warmpad", - /* 90 */ "polysyn", - /* 91 */ "ghostie", - /* 92 */ "bowglass", - /* 93 */ "metalpad", - /* 94 */ "halopad", - /* 95 */ "sweeper", - /* 96 */ "aurora", - /* 97 */ "soundtrk", - /* 98 */ "crystal", - /* 99 */ "atmosphr", - /* 100 */ "freshair", - /* 101 */ "unicorn", - /* 102 */ "sweeper", - /* 103 */ "startrak", - /* 104 */ "sitar", - /* 105 */ "banjo", - /* 106 */ "shamisen", - /* 107 */ "koto", - /* 108 */ "kalimba", - /* 109 */ "bagpipes", - /* 110 */ "fiddle", - /* 111 */ "Shannai", - /* 112 */ "carillon", - /* 113 */ "agogo", - /* 114 */ "steeldrm", - /* 115 */ "woodblk", - /* 116 */ "taiko", - /* 117 */ "toms", - /* 118 */ "syntom", - /* 119 */ "revcym", - /* 120 */ "fx-fret", - /* 121 */ "fx-blow", - /* 122 */ "seashore", - /* 123 */ "jungle", - /* 124 */ "telephon", - /* 125 */ "helicptr", - /* 126 */ "applause", - /* 127 */ "ringwhsl" - }; diff --git a/sys/i386/isa/sound/gustest/gmod.c b/sys/i386/isa/sound/gustest/gmod.c deleted file mode 100644 index d730e26..0000000 --- a/sys/i386/isa/sound/gustest/gmod.c +++ /dev/null @@ -1,1589 +0,0 @@ -/* - * gmod.c - Module player for GUS and Linux. - * (C) Hannu Savolainen, 1993 - * - * NOTE! This program doesn't try to be a complete module player. - * It's just a too I used while developing the driver. In - * addition it can be used as an example on programming - * the LInux Sound Driver with GUS. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define CMD_ARPEG 0x00 -#define CMD_SLIDEUP 0x01 -#define CMD_SLIDEDOWN 0x02 -#define CMD_SLIDETO 0x03 -#define SLIDE_SIZE 8 -#define CMD_VOLSLIDE 0x0a -#define CMD_JUMP 0x0b -#define CMD_VOLUME 0x0c -#define CMD_BREAK 0x0d -#define CMD_SPEED 0x0f -#define CMD_NOP 0xfe -#define CMD_NONOTE 0xff - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -#define MAX_TRACK 8 -#define MAX_PATTERN 128 -#define MAX_POSITION 128 - -struct note_info - { - unsigned char note; - unsigned char vol; - unsigned char sample; - unsigned char command; - short parm1, parm2; - }; - -struct voice_info - { - int sample; - int note; - int volume; - int pitchbender; - - /* Pitch sliding */ - - int slide_pitch; - int slide_goal; - int slide_rate; - - int volslide; - }; - -typedef struct note_info pattern[MAX_TRACK][64]; -int pattern_len[MAX_POSITION]; -int pattern_tempo[MAX_POSITION]; -pattern *pattern_table[MAX_PATTERN]; - -struct voice_info voices[MAX_TRACK]; - -int nr_channels, nr_patterns, songlength; -int tune[MAX_POSITION]; -double tick_duration; - -int period_table[] = -{ - 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453, - 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226, - 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113 -}; - -SEQ_DEFINEBUF (2048); - -int seqfd; -int sample_ok[128], sample_vol[128]; -int tmp, gus_dev; -double this_time, next_time; -int ticks_per_division; -double clock_rate; /* HZ */ - -/* - * The function seqbuf_dump() must always be provided - */ - -void play_module (char *name); -int load_module (char *name); -int play_note (int channel, struct note_info *pat); -void lets_play_voice (int channel, struct voice_info *v); - -void -seqbuf_dump () -{ - if (_seqbufptr) - if (write (seqfd, _seqbuf, _seqbufptr) == -1) - { - perror ("write /dev/sequencer"); - exit (-1); - } - _seqbufptr = 0; -} - -void -init_voices () -{ - int i; - - for (i = 0; i < MAX_TRACK; i++) - { - voices[i].sample = 0; - voices[i].note = 0; - voices[i].volume = 64; - - voices[i].slide_pitch = 0; - voices[i].slide_goal = 0; - voices[i].slide_rate = 0; - voices[i].pitchbender = 0; - - voices[i].volslide = 0; - } -} - -int -main (int argc, char *argv[]) -{ - int i, n, j; - struct synth_info info; - - if ((seqfd = open ("/dev/sequencer", O_WRONLY, 0)) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_NRSYNTHS, &n) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - for (i = 0; i < n; i++) - { - info.device = i; - - if (ioctl (seqfd, SNDCTL_SYNTH_INFO, &info) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (info.synth_type == SYNTH_TYPE_SAMPLE - && info.synth_subtype == SAMPLE_TYPE_GUS) - gus_dev = i; - } - - if (gus_dev == -1) - { - fprintf (stderr, "Gravis Ultrasound not detected\n"); - exit (-1); - } - - GUS_NUMVOICES (gus_dev, 14); - - for (i = 1; i < argc; i++) - { - for (j = 0; j < MAX_PATTERN; j++) - pattern_table[j] = NULL; - - if (load_module (argv[i])) - { - tick_duration = 100.0 / clock_rate; - play_module (argv[i]); - } - - } - - SEQ_DUMPBUF (); - close (seqfd); - - exit (0); -} - -unsigned short -intelize (unsigned short v) -{ - return ((v & 0xff) << 8) | ((v >> 8) & 0xff); -} - -unsigned long -intelize4 (unsigned long v) -{ - return - (((v >> 16) & 0xff) << 8) | (((v >> 16) >> 8) & 0xff) | - (((v & 0xff) << 8) | ((v >> 8) & 0xff) << 16); -} - -int -load_stm_module (int mod_fd, char *name) -{ - - struct sample_header - { - char name[12]; - unsigned char instr_disk; - unsigned short reserved1; - unsigned short length; /* In bytes */ - unsigned short loop_start; - unsigned short loop_end; - unsigned char volume; - unsigned char reserved2; - unsigned short C2_speed; - unsigned short reserved3; - - }; - - int i, total_mem; - int sample_ptr; - - int position; - - unsigned char *tune_ptr; /* array 0-127 */ - - char header[1105], sname[21]; - - int nr_samples; /* 16 or 32 samples (or 64 or ???) */ - int slen, npat; - - fprintf (stderr, "Loading .STM module: %s\n", name); - - if (read (mod_fd, header, sizeof (header)) != sizeof (header)) - { - fprintf (stderr, "%s: Short file (header)\n", name); - close (mod_fd); - return 0; - } - - strncpy (sname, header, 20); - - fprintf (stderr, "\nModule: %s - ", sname); - - if (header[28] != 0x1a) - { - fprintf (stderr, "Not a STM module\n"); - close (mod_fd); - return 0; - } - - npat = header[33]; - slen = 0; - tune_ptr = &header[48 + (31 * 32)]; - - for (i = 0; i < 64; i++) - { - tune[i] = tune_ptr[i]; - if (tune[i] < npat) - slen = i; - } - - fprintf (stderr, "Song lenght %d, %d patterns.\n", slen, npat); - - nr_samples = 31; - - sample_ptr = 48 + (31 * 32) + 64 + (npat * 1024); /* Location where the - * first sample is - * stored */ - total_mem = 0; - - for (i = 0; i < 32; i++) - sample_ok[i] = 0; - - for (i = 0; i < nr_samples; i++) - { - int len, loop_start, loop_end, base_freq; - unsigned short loop_flags = 0; - - struct sample_header *sample; - - struct patch_info *patch; - - sample = (struct sample_header *) &header[48 + (i * 32)]; - - len = sample->length; - loop_start = sample->loop_start; - loop_end = sample->loop_end; - base_freq = sample->C2_speed; - - if (strlen (sample->name) > 21) - { - fprintf (stderr, "\nInvalid name for sample #%d\n", i); - close (mod_fd); - return 0; - } - - if (len > 0) - { - int x; - - if (loop_end > len) - loop_end = 1; - else if (loop_end < loop_start) - { - loop_start = 0; - loop_end = 0; - } - else - loop_flags = WAVE_LOOPING; - - total_mem += len; - patch = (struct patch_info *) malloc (sizeof (*patch) + len); - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = i; - patch->mode = loop_flags; - patch->len = len; - patch->loop_start = loop_start; - patch->loop_end = loop_end; - patch->base_freq = base_freq; - patch->base_note = 261630; /* Mid C */ - patch->low_note = 0; - patch->high_note = 0x7fffffff; - patch->volume = 120; - - if (lseek (mod_fd, sample_ptr, 0) == -1) - { - perror (name); - close (mod_fd); - free (patch); - return 0; - } - - sample_ptr += len; - - if ((x = read (mod_fd, patch->data, len)) != len) - { - fprintf (stderr, "Short file (sample at %d (%d!=%d)\n", sample_ptr, x, len); - close (mod_fd); - free (patch); - return 0; - } - - fprintf (stderr, "Sample %02d: %05d, %05d, %05d, %07d %s\n", - i, - len, - loop_start, - loop_end, - base_freq, - sample->name); - - if (write (seqfd, patch, sizeof (*patch) + len) == -1) - { - perror ("ioctl /dev/sequencer"); - exit (-1); - } - else - sample_ok[i] = 1; - - free (patch); - } - } - - nr_patterns = slen; - songlength = slen; - nr_channels = 4; - - for (position = 0; position < npat; position++) - { - unsigned char patterns[64][4][4]; - int pat, channel, x; - - int pp = 1104 + (position * 1024); - - if ((pattern_table[position] = (pattern *) malloc (sizeof (struct note_info) * 64 * nr_channels)) == NULL) - { - fprintf (stderr, "Can't allocate memory for a pattern\n"); - return 0; - } - - if (lseek (mod_fd, pp, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if ((x = read (mod_fd, patterns, 1024)) != 1024) - { - fprintf (stderr, "Short file (pattern at %d), %d!=%d\n", pp, x, 1024); - close (mod_fd); - return 0; - } - - for (pat = 0; pat < 64; pat++) - { - - for (channel = 0; channel < 4; channel++) - { - unsigned char *p; - - unsigned vol, note, octave, sample, effect, params; - - p = &patterns[pat][channel][0]; - - if (p[0] < 251) - { - note = p[0] & 15; - octave = p[0] / 16; - - note = 48 + octave * 12 + note; - - sample = p[1] / 8; - vol = (p[1] & 7) + (p[2] / 2); - effect = p[2] & 0xF; - params = p[3]; - } - else - { - note = 0; - octave = 0; - - sample = 0; - vol = 0; - effect = CMD_NONOTE; - params = 0; - } - - (*pattern_table[position])[channel][pat].note = note; - (*pattern_table[position])[channel][pat].sample = sample; - (*pattern_table[position])[channel][pat].command = effect; - (*pattern_table[position])[channel][pat].parm1 = params; - (*pattern_table[position])[channel][pat].parm2 = 0; - (*pattern_table[position])[channel][pat].vol = vol; - } - - } - - } - - close (mod_fd); - return 1; -} - -int -load_669_module (int mod_fd, char *name) -{ - struct sample_header - { - char name[13]; - unsigned long length; /* In bytes */ - unsigned long loop_start; - unsigned long loop_end; - }; - - int i, total_mem; - int sample_ptr; - - int position; - - unsigned char *tune_ptr, *len_ptr, *tempo_ptr; /* array 0-127 */ - - char header[1084]; - char msg[110]; - - int nr_samples; /* 16 or 32 samples */ - int slen, npat; - - clock_rate = 25.0; - - fprintf (stderr, "Loading .669 module: %s\n", name); - - if (read (mod_fd, header, sizeof (header)) != sizeof (header)) - { - fprintf (stderr, "%s: Short file (header)\n", name); - close (mod_fd); - return 0; - } - - if (*(unsigned short *) &header[0] != 0x6669) - { - fprintf (stderr, "Not a 669 file\n"); - close (mod_fd); - return 0; - } - - strncpy (msg, &header[2], 108); - - for (i = 0; i < strlen (msg); i++) - if ((msg[i] >= ' ' && msg[i] <= 'z') || msg[i] == '\n') - printf ("%c", msg[i]); - printf ("\n"); - - npat = header[0x6f]; - - tune_ptr = &header[0x71]; - - for (slen = 0; slen < 128 && tune_ptr[slen] != 0xff; slen++); - slen--; - - for (i = 0; i < slen; i++) - tune[i] = tune_ptr[i]; - - len_ptr = &header[0x171]; - for (i = 0; i < slen; i++) - pattern_len[i] = len_ptr[i] - 1; - - tempo_ptr = &header[0xf1]; - for (i = 0; i < slen; i++) - pattern_tempo[i] = tempo_ptr[i]; - - nr_samples = header[0x6e]; - - fprintf (stderr, "Song lenght %d, %d patterns, %d samples.\n", slen, npat, nr_samples); - - sample_ptr = 0x1f1 + (nr_samples * 0x19) + (npat * 0x600); /* Location where the - * first sample is - * stored */ - total_mem = 0; - - for (i = 0; i < 64; i++) - sample_ok[i] = 0; - - for (i = 0; i < nr_samples; i++) - { - int len, loop_start, loop_end; - unsigned short loop_flags = 0; - - struct sample_header *sample; - char sname[14]; - - struct patch_info *patch; - - sample = (struct sample_header *) &header[0x1f1 + (i * 0x19)]; - - len = *(unsigned long *) &sample->name[13]; - loop_start = *(unsigned long *) &sample->name[17]; - loop_end = *(unsigned long *) &sample->name[21]; - if (loop_end > len) - loop_end = 1; - else if (loop_end == len) - loop_end--; - - if (loop_end < loop_start) - { - loop_start = 0; - loop_end = 0; - } - - strncpy (sname, sample->name, 13); - - if (len > 0 && len < 200000) - { - total_mem += len; - - fprintf (stderr, "Sample %02d: %05d, %05d, %05d %s\n", - i, - len, - loop_start, - loop_end, - sname); - - patch = (struct patch_info *) malloc (sizeof (*patch) + len); - - if (loop_end == 0) - loop_end = 1; - if (loop_end >= len) - loop_end = 1; - - if (loop_end > 1) loop_flags = WAVE_LOOPING; - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = i; - patch->mode = WAVE_UNSIGNED | loop_flags; - patch->len = len; - patch->loop_start = loop_start; - patch->loop_end = loop_end; - patch->base_freq = 8448; - patch->base_note = 261630; - patch->low_note = 1000; - patch->high_note = 0x7fffffff; - patch->volume = 120; - - if (lseek (mod_fd, sample_ptr, 0) == -1) - { - fprintf (stderr, "Seek failed\n"); - perror (name); - close (mod_fd); - free (patch); - return 0; - } - - sample_ptr += len; - - if (read (mod_fd, patch->data, len) != len) - { - fprintf (stderr, "Short file (sample at %d)\n", sample_ptr); - close (mod_fd); - free (patch); - return 0; - } - - if (write (seqfd, patch, sizeof (*patch) + len) == -1) - { - perror ("ioctl /dev/sequencer"); - /* exit (-1); */ - } - else - sample_ok[i] = 1; - - free (patch); - } - } - - nr_patterns = slen; - songlength = slen; - nr_channels = 8; - - for (position = 0; position < npat; position++) - { - unsigned char patterns[0x600]; - int pat, channel, x; - - int pp = 0x1f1 + (nr_samples * 0x19) + (position * 0x600); - - if ((pattern_table[position] = (pattern *) malloc (sizeof (struct note_info) * 64 * nr_channels)) == NULL) - { - fprintf (stderr, "Can't allocate memory for a pattern\n"); - return 0; - } - - - if (lseek (mod_fd, pp, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if ((x = read (mod_fd, patterns, 1024)) != 1024) - { - fprintf (stderr, "Short file (pattern at %d) %d!=1024\n", pp, x); - close (mod_fd); - return 0; - } - - for (pat = 0; pat < 64; pat++) - { - - for (channel = 0; channel < 8; channel++) - { - unsigned char *p; - - unsigned vol, period, sample, effect, params; - - p = &patterns[pat * 24 + channel * 3]; - - if (p[0] >= 0xfe || - (p[0] == 0xff && p[1] == 0xff && p[2] == 0xff) || - (p[0] == 0 && p[1] == 0 && p[2] == 0) || - *(int *) p == -1) - { - period = 0; - effect = CMD_NONOTE; - sample = 0; - vol = 0; - params = 0; - - if (p[0] == 0) - { - effect = CMD_BREAK; - params = -2; - } - } - else - { - period = (p[0] >> 2) + 48; - effect = (p[2] >> 4); - params = p[2] & 0x0f; - vol = p[1] & 0x0f; - - if (p[2] == 0xfe) - { - effect = CMD_VOLUME; - params = vol; - } - else if (p[2] == 0xff) - { - effect = CMD_NOP; - } - else - switch (effect) - { - case 0: /* a - Portamento up */ - effect = CMD_SLIDEUP; - break; - - case 1: /* b - Portamento down */ - effect = CMD_SLIDEDOWN; - break; - - case 2: /* c - Port to note */ - effect = CMD_SLIDETO; - break; - - case 3: /* d - Frequency adjust */ - effect = CMD_NOP; /* To be implemented */ - break; - - case 4: /* e - Frequency vibrato */ - effect = CMD_NOP; /* To be implemented */ - break; - - case 5: /* f - Set tempo */ - effect = CMD_SPEED; - break; - - default: - effect = CMD_NOP; - } - - sample = (((p[0] << 4) & 0x30) | ((p[1] >> 4) & 0x0f)) + 1; - } - - (*pattern_table[position])[channel][pat].note = period; - (*pattern_table[position])[channel][pat].sample = sample; - (*pattern_table[position])[channel][pat].command = effect; - (*pattern_table[position])[channel][pat].parm1 = params; - (*pattern_table[position])[channel][pat].parm2 = 0; - (*pattern_table[position])[channel][pat].vol = vol; - } - - } - - } - - close (mod_fd); - return 1; -} - -int -load_mmd0_module (int mod_fd, char *name) -{ - - struct sample_header - { - unsigned short loop_start; - unsigned short loop_end; - unsigned char midich; - unsigned char midipreset; - unsigned char volume; - unsigned char strans; - }; - - int i, total_mem; - int sample_ptr; - - int position; - - unsigned char *tune_ptr; /* array 0-127 */ - - char header[1105]; - - int nr_samples; /* 16 or 32 samples (or 64 or ???) */ - int slen, npat; - - fprintf (stderr, "Loading .MED module: %s\n", name); - - if (read (mod_fd, header, sizeof (header)) != sizeof (header)) - { - fprintf (stderr, "%s: Short file (header)\n", name); - close (mod_fd); - return 0; - } - - if (strncmp (header, "MMD0", 4)) - { - fprintf (stderr, "Not a MED module\n"); - close (mod_fd); - return 0; - } - - printf ("Module len %d\n", intelize4 (*(long *) &header[4])); - printf ("Song info %d\n", intelize4 (*(long *) &header[8])); - printf ("Song len %d\n", intelize4 (*(long *) &header[12])); - printf ("Blockarr %x\n", intelize4 (*(long *) &header[16])); - printf ("Blockarr len %d\n", intelize4 (*(long *) &header[20])); - printf ("Sample array %x\n", intelize4 (*(long *) &header[24])); - printf ("Sample array len %d\n", intelize4 (*(long *) &header[28])); - printf ("Exp data %x\n", intelize4 (*(long *) &header[32])); - printf ("Exp size %d\n", intelize4 (*(long *) &header[36])); - printf ("Pstate %d\n", intelize (*(long *) &header[40])); - printf ("Pblock %d\n", intelize (*(long *) &header[42])); - - return 0; - - npat = header[33]; - slen = 0; - tune_ptr = &header[48 + (31 * 32)]; - - for (i = 0; i < 64; i++) - { - tune[i] = tune_ptr[i]; - if (tune[i] < npat) - slen = i; - } - - fprintf (stderr, "Song lenght %d, %d patterns.\n", slen, npat); - - nr_samples = 31; - - sample_ptr = 48 + (31 * 32) + 64 + (npat * 1024); /* Location where the - * first sample is - * stored */ - total_mem = 0; - - for (i = 0; i < 32; i++) - sample_ok[i] = 0; - - for (i = 0; i < nr_samples; i++) - { - int len, loop_start, loop_end, base_freq; - unsigned short loop_flags = 0; - - struct sample_header *sample; - - struct patch_info *patch; - - sample = (struct sample_header *) &header[48 + (i * 32)]; - - /* - * len = sample->length; loop_start = sample->loop_start; loop_end = - * sample->loop_end; base_freq = sample->C2_speed; - * - * if (strlen (sample->name) > 21) { fprintf (stderr, "\nInvalid name for - * sample #%d\n", i); close (mod_fd); return 0; } - */ - if (len > 0) - { - int x; - - if (loop_end > len) - loop_end = 1; - - if (loop_end < loop_start) - { - loop_start = 0; - loop_end = 0; - } - - if (loop_end > 2) loop_flags = WAVE_LOOPING; - - total_mem += len; - patch = (struct patch_info *) malloc (sizeof (*patch) + len); - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = i; - patch->mode = loop_flags; - patch->len = len; - patch->loop_start = loop_start; - patch->loop_end = loop_end; - patch->base_freq = base_freq; - patch->base_note = 261630; /* Mid C */ - patch->low_note = 0; - patch->high_note = 0x7fffffff; - patch->volume = 120; - - if (lseek (mod_fd, sample_ptr, 0) == -1) - { - perror (name); - close (mod_fd); - free (patch); - return 0; - } - - sample_ptr += len; - - if ((x = read (mod_fd, patch->data, len)) != len) - { - fprintf (stderr, "Short file (sample at %d (%d!=%d)\n", sample_ptr, x, len); - close (mod_fd); - free (patch); - return 0; - } - /* - * fprintf (stderr, "Sample %02d: %05d, %05d, %05d, %07d %s\n", i, - * len, loop_start, loop_end, base_freq, sample->name); - */ - if (write (seqfd, patch, sizeof (*patch) + len) == -1) - { - perror ("ioctl /dev/sequencer"); - exit (-1); - } - else - sample_ok[i] = 1; - - free (patch); - } - } - - nr_patterns = slen; - songlength = slen; - nr_channels = 4; - - for (position = 0; position < npat; position++) - { - unsigned char patterns[64][4][4]; - int pat, channel, x; - - int pp = 1104 + (position * 1024); - - if ((pattern_table[position] = (pattern *) malloc (sizeof (struct note_info) * 64 * nr_channels)) == NULL) - { - fprintf (stderr, "Can't allocate memory for a pattern\n"); - return 0; - } - - if (lseek (mod_fd, pp, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if ((x = read (mod_fd, patterns, 1024)) != 1024) - { - fprintf (stderr, "Short file (pattern at %d), %d!=%d\n", pp, x, 1024); - close (mod_fd); - return 0; - } - - for (pat = 0; pat < 64; pat++) - { - - for (channel = 0; channel < 4; channel++) - { - unsigned char *p; - - unsigned vol, note, octave, sample, effect, params; - - p = &patterns[pat][channel][0]; - - if (p[0] < 251) - { - note = p[0] & 15; - octave = p[0] / 16; - - note = 48 + octave * 12 + note; - - sample = p[1] / 8; - vol = (p[1] & 7) + (p[2] / 2); - effect = p[2] & 0xF; - params = p[3]; - } - else - { - note = 0; - octave = 0; - - sample = 0; - vol = 0; - effect = CMD_NONOTE; - params = 0; - } - - (*pattern_table[position])[channel][pat].note = note; - (*pattern_table[position])[channel][pat].sample = sample; - (*pattern_table[position])[channel][pat].command = effect; - (*pattern_table[position])[channel][pat].parm1 = params; - (*pattern_table[position])[channel][pat].parm2 = 0; - (*pattern_table[position])[channel][pat].vol = vol; - } - - } - - } - - close (mod_fd); - return 1; -} - -int -load_module (char *name) -{ - - struct sample_header - { - char name[22]; - unsigned short length; /* In words */ - - unsigned char finetune; - unsigned char volume; - - unsigned short repeat_point; /* In words */ - unsigned short repeat_length; /* In words */ - }; - - int i, mod_fd, total_mem; - int sample_ptr, pattern_loc; - - int position; - - unsigned char *tune_ptr; /* array 0-127 */ - - char header[1084]; - - int nr_samples; /* 16 or 32 samples */ - int slen, npat; - char mname[23]; - - ioctl (seqfd, SNDCTL_SEQ_SYNC, 0); - ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev); - - clock_rate = 50.0; - - for (i = 0; i < MAX_POSITION; i++) - pattern_len[i] = 64; - - for (i = 0; i < MAX_POSITION; i++) - pattern_tempo[i] = 0; - - if ((mod_fd = open (name, O_RDONLY, 0)) == -1) - { - perror (name); - return 0; - } - - if (read (mod_fd, header, sizeof (header)) != sizeof (header)) - { - fprintf (stderr, "%s: Short file (header)\n", name); - close (mod_fd); - return 0; - } - - if (lseek (mod_fd, 0, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if (header[28] == 0x1a) - return load_stm_module (mod_fd, name); - - if (*(unsigned short *) &header[0] == 0x6669) - return load_669_module (mod_fd, name); - - if (!strncmp (header, "MMD0", 4)) - return load_mmd0_module (mod_fd, name); - - fprintf (stderr, "Loading .MOD module: %s\n", name); - - strncpy (mname, header, 22); - fprintf (stderr, "\nModule: %s - ", mname); - - if (!strncmp (&header[1080], "M.K.", 4) || !strncmp (&header[1080], "FLT8", 4)) - { - fprintf (stderr, "31 samples\n"); - nr_samples = 31; - } - else - { - fprintf (stderr, "15 samples\n"); - nr_samples = 15; - } - - if (nr_samples == 31) - { - sample_ptr = pattern_loc = 1084; - slen = header[950]; - tune_ptr = (unsigned char *) &header[952]; - } - else - { - sample_ptr = pattern_loc = 600; - slen = header[470]; - tune_ptr = (unsigned char *) &header[472]; - } - - npat = 0; - for (i = 0; i < 128; i++) - { - tune[i] = tune_ptr[i]; - - if (tune_ptr[i] > npat) - npat = tune_ptr[i]; - } - npat++; - - fprintf (stderr, "Song lenght %d, %d patterns.\n", slen, npat); - - sample_ptr += (npat * 1024); /* Location where the first sample is stored */ - total_mem = 0; - - for (i = 0; i < 32; i++) - sample_ok[i] = 0; - - for (i = 0; i < nr_samples; i++) - { - int len, loop_start, loop_end; - unsigned short loop_flags = 0; - char pname[22]; - - struct sample_header *sample; - - struct patch_info *patch; - - sample = (struct sample_header *) &header[20 + (i * 30)]; - - len = intelize (sample->length) * 2; - loop_start = intelize (sample->repeat_point) * 2; - loop_end = loop_start + (intelize (sample->repeat_length) * 2); - - if (loop_start > len) - loop_start = 0; - if (loop_end > len) - loop_end = len; - - if (loop_end <= loop_start) - loop_end = loop_start + 1; - - if (loop_end > 2 && loop_end > loop_start) - loop_flags = WAVE_LOOPING; - - strncpy (pname, sample->name, 20); - - if (len > 0) - { - fprintf (stderr, "Sample %02d: L%05d, S%05d, E%05d V%02d %s\n", - i, - len, - loop_start, - loop_end, - sample->volume, - pname); - - total_mem += len; - - patch = (struct patch_info *) malloc (sizeof (*patch) + len); - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = i; - patch->mode = loop_flags; - patch->len = len; - patch->loop_start = loop_start; - patch->loop_end = loop_end; - patch->base_note = 261630; /* Middle C */ - patch->base_freq = 8448; - patch->low_note = 0; - patch->high_note = 20000000; - patch->volume = 120; - patch->panning = 0; - - if (lseek (mod_fd, sample_ptr, 0) == -1) - { - perror (name); - close (mod_fd); - free (patch); - return 0; - } - - sample_ptr += len; - - if (read (mod_fd, patch->data, len) != len) - { - fprintf (stderr, "Short file (sample) %d\n", sample_ptr); - close (mod_fd); - free (patch); - return 0; - } - - SEQ_WRPATCH (patch, sizeof (*patch) + len); - - sample_ok[i] = 1; - if (sample->volume == 0) sample->volume = 64; - sample_vol[i] = sample->volume; - - free (patch); - } - } - - nr_patterns = npat; - songlength = slen; - nr_channels = 4; - - for (position = 0; position < npat; position++) - { - unsigned char patterns[64][4][4]; - int pat, channel; - - int pp = pattern_loc + (position * 1024); - - if (lseek (mod_fd, pp, 0) == -1) - { - perror (name); - close (mod_fd); - return 0; - } - - if (read (mod_fd, patterns, 1024) != 1024) - { - fprintf (stderr, "Short file (pattern %d) %d\n", tune[position], pp); - close (mod_fd); - return 0; - } - - if ((pattern_table[position] = (pattern *) malloc (sizeof (struct note_info) * 64 * nr_channels)) == NULL) - { - fprintf (stderr, "Can't allocate memory for a pattern\n"); - return 0; - } - - for (pat = 0; pat < 64; pat++) - { - for (channel = 0; channel < 4; channel++) - { - unsigned short tmp; - unsigned char *p; - - unsigned period, sample, effect, params, note, vol; - - p = &patterns[pat][channel][0]; - - tmp = (p[0] << 8) | p[1]; - sample = (tmp >> 8) & 0x10; - period = - MIN (tmp & 0xFFF, 1023); - tmp = (p[2] << 8) | p[3]; - sample |= tmp >> 12; - effect = (tmp >> 8) & 0xF; - params = tmp & 0xFF; - - note = 0; - - if (period) - { - /* - * Convert period to a Midi note number - */ - - for (note = 0; note < 37 && period != period_table[note]; note++); - if (note >= 37) - note = 0; - - note += 48; - } - - vol = 64; - - if (sample) - if (effect == 0xc) - { - vol = params; - } - else - vol = sample_vol[sample - 1]; - - vol *= 2; - if (vol>64)vol--; - - (*pattern_table[position])[channel][pat].note = note; - (*pattern_table[position])[channel][pat].sample = sample; - (*pattern_table[position])[channel][pat].command = effect; - (*pattern_table[position])[channel][pat].parm1 = params; - (*pattern_table[position])[channel][pat].parm2 = 0; - (*pattern_table[position])[channel][pat].vol = vol; - } - } - } - - close (mod_fd); - return 1; -} - -int -panning (int ch) -{ - static int panning_tab[] = - {-110, 110, 110, -110}; - - return panning_tab[ch % 4]; -} - -void -set_speed (int parm) -{ - if (!parm) - parm = 1; - - if (parm < 32) - { - ticks_per_division = parm; - } - else - { - tick_duration = (60.0 / parm) * 10.0; - } - -} - -void -play_module (char *name) -{ - int i, position, jump_to_pos; - - init_voices (); - - SEQ_START_TIMER (); -#if 1 - for (i=0;i<32;i++) - { - SEQ_EXPRESSION(gus_dev, i, 127); - SEQ_MAIN_VOLUME(gus_dev, i, 100); - } -#endif - next_time = 0.0; - - set_speed (6); - - for (position = 0; position < songlength; position++) - { - int tick, pattern, channel, pos, go_to; - - pos = tune[position]; - if (pattern_tempo[position]) - set_speed (pattern_tempo[position]); - - jump_to_pos = -1; - for (pattern = 0; pattern < pattern_len[position] && jump_to_pos == -1; pattern++) - { - this_time = 0.0; - - for (channel = 0; channel < nr_channels; channel++) - { - if ((go_to = play_note (channel, &(*pattern_table[pos])[channel][pattern])) != -1) - jump_to_pos = go_to; - - } - - next_time += tick_duration; - - for (tick = 1; tick < ticks_per_division; tick++) - { - for (channel = 0; channel < nr_channels; channel++) - lets_play_voice (channel, &voices[channel]); - next_time += tick_duration; - } - - } - - if (jump_to_pos >= 0) - position = jump_to_pos; - } - - SEQ_WAIT_TIME ((int) next_time + 200); /* Wait extra 2 secs */ - - for (i = 0; i < nr_channels; i++) - SEQ_STOP_NOTE (gus_dev, i, 0, 127); - SEQ_DUMPBUF (); - - for (i = 0; i < nr_patterns; i++) - free (pattern_table[i]); -} - -void -sync_time () -{ - if (next_time > this_time) - { - SEQ_WAIT_TIME ((long) next_time); - this_time = next_time; - } -} - -void -set_volslide (int channel, struct note_info *pat) -{ - int n; - - voices[channel].volslide = 0; - - if ((n = (pat->parm1 & 0xf0) >> 4)) - voices[channel].volslide = n; - else - voices[channel].volslide = pat->parm1 & 0xf; -} - -void -set_slideto (int channel, struct note_info *pat) -{ - int size, rate, dir, range = 200; - - rate = pat->parm1; - size = voices[channel].note - pat->note; - if (!size) - return; - - if (size < 0) - { - size *= -1; - dir = -1; - } - else - dir = 1; - - if (size > 2) - { - range = size * 100; - rate = rate * size / 200; - } - - rate = pat->parm1 * dir / 30; - if (!rate) - rate = 1; - - voices[channel].slide_pitch = 1; - voices[channel].slide_goal = (dir * 8192 * 200 * 2 / size) / range; - voices[channel].pitchbender = 0; - voices[channel].slide_rate = rate; - SEQ_BENDER_RANGE (gus_dev, channel, range); -} - -int -play_note (int channel, struct note_info *pat) -{ - int jump = -1; - int sample; - - if (pat->sample == 0x3f) - pat->sample = 0; - - if (pat->command == CMD_NONOTE) - return -1; /* Undefined */ - - sample = pat->sample; - - if (sample && !pat->note) - { - pat->note = voices[channel].note; - } - - if (sample) - voices[channel].sample = sample; - else - sample = voices[channel].sample; - - sample--; - - if (pat->note && pat->command != 3) /* Have a note -> play */ - { - if (sample < 0) - sample = voices[channel].sample - 1; - - if (!sample_ok[sample]) - sample = voices[channel].sample - 1; - - if (sample < 0) - sample = 0; - - if (sample_ok[sample]) - { - sync_time (); - - if (pat->vol > 127) pat->vol=127; - SEQ_SET_PATCH (gus_dev, channel, sample); - SEQ_PANNING (gus_dev, channel, panning (channel)); - SEQ_PITCHBEND (gus_dev, channel, 0); - SEQ_START_NOTE (gus_dev, channel, pat->note, pat->vol); - - voices[channel].volume = pat->vol; - voices[channel].note = pat->note; - voices[channel].slide_pitch = 0; - } - else - SEQ_STOP_NOTE (gus_dev, channel, pat->note, pat->vol); - } - - switch (pat->command) - { - - case CMD_NOP:; - break; - - case CMD_JUMP: - jump = pat->parm1; - break; - - case CMD_BREAK: - jump = -2; - break; - - case CMD_SPEED: - set_speed (pat->parm1); - break; - - case CMD_SLIDEUP: - voices[channel].slide_pitch = 1; - voices[channel].slide_goal = 8191; - voices[channel].pitchbender = 0; - voices[channel].slide_rate = pat->parm1 * SLIDE_SIZE; - SEQ_BENDER_RANGE (gus_dev, channel, 200); - break; - - case CMD_SLIDEDOWN: - voices[channel].slide_pitch = 1; - voices[channel].slide_goal = -8192; - voices[channel].pitchbender = 0; - voices[channel].slide_rate = -pat->parm1 * SLIDE_SIZE; - SEQ_BENDER_RANGE (gus_dev, channel, 200); - break; - - case CMD_SLIDETO: - set_slideto (channel, pat); - break; - - case CMD_VOLUME: - { - int vol = pat->parm1*2; - if (vol>127) vol=127; - if (pat->note && pat->command != 3) - break; - SEQ_START_NOTE (gus_dev, channel, 255, vol); - } - break; - - case CMD_ARPEG: - break; - - case 0x0e: - /* printf ("Cmd 0xE%02x\n", pat->parm1); */ - break; - - case CMD_VOLSLIDE: - set_slideto (channel, pat); - break; - - default: - /* printf ("Command %x %02x\n", pat->command, pat->parm1); */ - } - - return jump; -} - -void -lets_play_voice (int channel, struct voice_info *v) -{ - if (v->slide_pitch) - { - v->pitchbender += v->slide_rate; - if (v->slide_goal < 0) - { - if (v->pitchbender <= v->slide_goal) - { - v->pitchbender = v->slide_goal; - v->slide_pitch = 0; /* Stop */ - } - } - else - { - if (v->pitchbender >= v->slide_goal) - { - v->pitchbender = v->slide_goal; - v->slide_pitch = 0; /* Stop */ - } - } - - sync_time (); - SEQ_PITCHBEND (gus_dev, channel, v->pitchbender); - } - - if (v->volslide) - { - v->volume += v->volslide; - sync_time (); - - if (v->volume > 127) v->volume = 127; - SEQ_START_NOTE (gus_dev, channel, 255, v->volume); - } -} diff --git a/sys/i386/isa/sound/gustest/gpatinfo.c b/sys/i386/isa/sound/gustest/gpatinfo.c deleted file mode 100644 index 3e21fc5..0000000 --- a/sys/i386/isa/sound/gustest/gpatinfo.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * gpatinfo.c: This program demonstrates the patch management - * interface of the GUS driver. - * - * NOTE! The patch manager interface is highly device dependent, - * currently incompletely implemented prototype and - * will change before final implementation. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include "gmidi.h" - -#define GUS_DEV gus_dev - -#define patch_access(cmd, rec) \ - rec.command = cmd;\ - rec.device = gus_dev;\ - if (ioctl(seqfd, SNDCTL_PMGR_IFACE, &rec)==-1)\ - {\ - perror("/dev/sequencer(SNDCTL_PMGR_IFACE/" #cmd ")");\ - exit(-1);\ - } - -SEQ_DEFINEBUF (2048); - -int seqfd; - -int gus_dev = -1; - -/* - * The function seqbuf_dump() must always be provided - */ - -void -seqbuf_dump () -{ - if (_seqbufptr) - if (write (seqfd, _seqbuf, _seqbufptr) == -1) - { - perror ("write /dev/sequencer"); - exit (-1); - } - _seqbufptr = 0; -} - -int -main (int argc, char *argv[]) -{ - int i, j, n; - struct synth_info info; - struct patch_info *patch; - struct patmgr_info mgr, mgr2, mgr3; - - if ((seqfd = open ("/dev/sequencer", O_WRONLY, 0)) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_NRSYNTHS, &n) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - -/* - * First locate the GUS device - */ - - for (i = 0; i < n; i++) - { - info.device = i; - - if (ioctl (seqfd, SNDCTL_SYNTH_INFO, &info) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (info.synth_type == SYNTH_TYPE_SAMPLE - && info.synth_subtype == SAMPLE_TYPE_GUS) - gus_dev = i; - } - - if (gus_dev == -1) - { - fprintf (stderr, "Error: Gravis Ultrasound not detected\n"); - exit (-1); - } - - printf("Gravis UltraSound device = %d\n", gus_dev); - - /* - * Get type of the Patch Manager interface of the GUS device - */ - - patch_access(PM_GET_DEVTYPE, mgr); - printf("Patch manager type: %d\n", mgr.parm1); - - if (mgr.parm1 != PMTYPE_WAVE) - { - fprintf(stderr, "Hups, this program seems to be obsolete\n"); - exit(-1); - } - - /* - * The GUS driver supports up to 256 different midi program numbers but - * this limit can be changed before compiling the driver. The following - * call returns the value compiled to the driver. - */ - - patch_access(PM_GET_PGMMAP, mgr); - printf("Device supports %d midi programs.\n", mgr.parm1); - - /* - * Each program can be undefined or it may have one or more patches. - * A patch consists of header and the waveform data. If there is more - * than one patch in a program, the right one is selected by checking the - * note number when the program is played. - * - * The following call reads an array indexed by program number. Each - * element defines the number of patches defined for the corresponding - * program. - */ - printf("Loaded programs:\n"); - - for (i=0;ilen); - - } - } - - i = gus_dev; - - if (ioctl(seqfd, SNDCTL_SYNTH_MEMAVL, &i)==-1) exit(-1); - printf("%d bytes of DRAM available for wave data\n", i); - - - exit(0); -} diff --git a/sys/i386/isa/sound/gustest/gusload.c b/sys/i386/isa/sound/gustest/gusload.c deleted file mode 100644 index 216150a..0000000 --- a/sys/i386/isa/sound/gustest/gusload.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * patutil.c - A sample program which loads patches to the Gravis - * Ultrasound - * - */ - -#ifndef PATCH_PATH -#define PATCH_PATH "/D/ultrasnd/midi" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include "gmidi.h" - -struct pat_header - { - char magic[12]; - char version[10]; - char description[60]; - unsigned char instruments; - char voices; - char channels; - unsigned short nr_waveforms; - unsigned short master_volume; - unsigned long data_size; - }; - -struct sample_header - { - char name[7]; - unsigned char fractions; - long len; - long loop_start; - long loop_end; - unsigned short base_freq; - long low_note; - long high_note; - long base_note; - short detune; - unsigned char panning; - - unsigned char envelope_rate[6]; - unsigned char envelope_offset[6]; - - unsigned char tremolo_sweep; - unsigned char tremolo_rate; - unsigned char tremolo_depth; - - unsigned char vibrato_sweep; - unsigned char vibrato_rate; - unsigned char vibrato_depth; - - char modes; - - short scale_frequency; - unsigned short scale_factor; - }; - -#define GUS_DEV gus_dev - -SEQ_DEFINEBUF (2048); - -int seqfd; - -int gus_dev = -1; - -struct patch_info *patch; - -/* - * The function seqbuf_dump() must always be provided - */ - -void -seqbuf_dump () -{ - if (_seqbufptr) - if (write (seqfd, _seqbuf, _seqbufptr) == -1) - { - perror ("write /dev/sequencer"); - exit (-1); - } - _seqbufptr = 0; -} - -int -main (int argc, char *argv[]) -{ - int i, n, patfd, pgm, print_only = 0; - struct synth_info info; - struct pat_header header; - struct sample_header sample; - char buf[256]; - char name[256]; - long offset; - - if ((seqfd = open ("/dev/sequencer", O_WRONLY, 0)) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_NRSYNTHS, &n) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - - for (i = 0; i < n; i++) - { - info.device = i; - - if (ioctl (seqfd, SNDCTL_SYNTH_INFO, &info) == -1) - { - perror ("/dev/sequencer"); - exit (-1); - } - - if (info.synth_type == SYNTH_TYPE_SAMPLE - && info.synth_subtype == SAMPLE_TYPE_GUS) - gus_dev = i; - } - - if (gus_dev == -1) - { - fprintf (stderr, "Error: Gravis Ultrasound not detected\n"); - exit (-1); - } - - if (argc == 2) - { - if (!strcmp (argv[1], "reset")) - if (ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev) == -1) - perror ("Sample reset"); - exit (0); - } - - if (argc != 3) - { - fprintf (stderr, "Usage: %s pgm# patchfile\n", argv[0]); - fprintf (stderr, " or : %s pgm# GM\n", argv[0]); - fprintf (stderr, " or : %s pgm# -l\n", argv[0]); - fprintf (stderr, " or : %s reset\n", argv[0]); - fprintf (stderr, " or : %s -l patchfile\n", argv[0]); - exit (-1); - } - - pgm = atoi (argv[1]); - strcpy (name, argv[2]); - - if (strcmp (name, "GM") == 0 || strcmp(name, "-l")==0) - { - if (strcmp (name, "-l") == 0) print_only = 1; - if (pgm < 0 || pgm > 127) - { - fprintf (stderr, "pgm# must be between 0 and 127\n"); - exit (-1); - } - - sprintf (name, PATCH_PATH "/%s.pat", patch_names[pgm]); - - if (!print_only) - fprintf (stderr, "Loading program %d from %s\n", pgm, name); - } - else if (strcmp (argv[1], "-l") == 0) - print_only = 1; - - if ((patfd = open (name, O_RDONLY, 0)) == -1) - { - perror (name); - exit (-1); - } - - if (read (patfd, buf, 0xef) != 0xef) - { - fprintf (stderr, "%s: Short file\n", name); - exit (-1); - } - - memcpy ((char *) &header, buf, sizeof (header)); - - if (strncmp (header.magic, "GF1PATCH110", 12)) - { - fprintf (stderr, "%s: Not a patch file\n", name); - exit (-1); - } - - if (strncmp (header.version, "ID#000002", 10)) - { - fprintf (stderr, "%s: Incompatible patch file version\n", name); - exit (-1); - } - - header.nr_waveforms = *(unsigned short *) &buf[85]; - header.master_volume = *(unsigned short *) &buf[87]; - - if (print_only) - { - printf ("Patch file: %s contains %d samples\n\n", name, header.nr_waveforms); - printf ("Master volume: %d\n", header.master_volume); - } - - offset = 0xef; - - for (i = 0; i < header.nr_waveforms; i++) - { - if (lseek (patfd, offset, 0) == -1) - { - perror (name); - exit (-1); - } - - if (read (patfd, &buf, sizeof (sample)) != sizeof (sample)) - { - fprintf (stderr, "%s: Short file\n", name); - exit (-1); - } - - memcpy ((char *) &sample, buf, sizeof (sample)); - - /* - * Since some fields of the patch record are not 32bit aligned, we must - * handle them specially. - */ - sample.low_note = *(long *) &buf[22]; - sample.high_note = *(long *) &buf[26]; - sample.base_note = *(long *) &buf[30]; - sample.detune = *(short *) &buf[34]; - sample.panning = (unsigned char) buf[36]; - - memcpy (sample.envelope_rate, &buf[37], 6); - memcpy (sample.envelope_offset, &buf[43], 6); - - sample.tremolo_sweep = (unsigned char) buf[49]; - sample.tremolo_rate = (unsigned char) buf[50]; - sample.tremolo_depth = (unsigned char) buf[51]; - - sample.vibrato_sweep = (unsigned char) buf[52]; - sample.vibrato_rate = (unsigned char) buf[53]; - sample.vibrato_depth = (unsigned char) buf[54]; - sample.modes = (unsigned char) buf[55]; - sample.scale_frequency = *(short *) &buf[56]; - sample.scale_factor = *(unsigned short *) &buf[58]; - - if (print_only) - { - printf("\nSample: %03d / %s\n", i, sample.name); - printf ("Len: %d, Loop start: %d, Loop end: %d\n", sample.len, sample.loop_start, sample.loop_end); - printf ("Flags: "); - if (sample.modes & WAVE_16_BITS) - printf ("16 bit "); - if (sample.modes & WAVE_UNSIGNED) - printf ("unsigned "); - if (sample.modes & WAVE_LOOP_BACK) - printf("reverse "); - if (sample.modes & WAVE_BIDIR_LOOP) - printf("bidir "); - if (sample.modes & WAVE_LOOPING) - printf ("looping "); else printf("one_shot" ); - if (sample.modes & WAVE_SUSTAIN_ON) - printf ("sustain "); - if (sample.modes & WAVE_ENVELOPES) - printf ("enveloped "); - printf ("\n"); - - if (sample.modes & WAVE_ENVELOPES) - { - int i; - - printf ("Envelope info: "); - for (i = 0; i < 6; i++) - { - printf ("%d/%d ", sample.envelope_rate[i], - sample.envelope_offset[i]); - } - printf ("\n"); - } - - printf("Tremolo: sweep=%d, rate=%d, depth=%d\n", - sample.tremolo_sweep, - sample.tremolo_rate, - sample.tremolo_depth); - - printf("Vibrato: sweep=%d, rate=%d, depth=%d\n", - sample.vibrato_sweep, - sample.vibrato_rate, - sample.vibrato_depth); - } - - offset = offset + 96; - patch = (struct patch_info *) malloc (sizeof (*patch) + sample.len); - - patch->key = GUS_PATCH; - patch->device_no = GUS_DEV; - patch->instr_no = pgm; - patch->mode = sample.modes | WAVE_TREMOLO | - WAVE_VIBRATO | WAVE_SCALE; - patch->len = sample.len; - patch->loop_start = sample.loop_start; - patch->loop_end = sample.loop_end; - patch->base_note = sample.base_note; - patch->high_note = sample.high_note; - patch->low_note = sample.low_note; - patch->base_freq = sample.base_freq; - patch->detuning = sample.detune; - patch->panning = (sample.panning - 7) * 16; - - memcpy (patch->env_rate, sample.envelope_rate, 6); - memcpy (patch->env_offset, sample.envelope_offset, 6); - - patch->tremolo_sweep = sample.tremolo_sweep; - patch->tremolo_rate = sample.tremolo_rate; - patch->tremolo_depth = sample.tremolo_depth; - - patch->vibrato_sweep = sample.vibrato_sweep; - patch->vibrato_rate = sample.vibrato_rate; - patch->vibrato_depth = sample.vibrato_depth; - - patch->scale_frequency = sample.scale_frequency; - patch->scale_factor = sample.scale_factor; - - patch->volume = header.master_volume; - - if (lseek (patfd, offset, 0) == -1) - { - perror (name); - exit (-1); - } - - if (!print_only) - { - if (read (patfd, patch->data, sample.len) != sample.len) - { - fprintf (stderr, "%s: Short file\n", name); - exit (-1); - } - - SEQ_WRPATCH (patch, sizeof (*patch) + sample.len); - } - - offset = offset + sample.len; - } - - exit (0); -} diff --git a/sys/i386/isa/sound/gustest/midithru.c b/sys/i386/isa/sound/gustest/midithru.c deleted file mode 100644 index 36e1e07..0000000 --- a/sys/i386/isa/sound/gustest/midithru.c +++ /dev/null @@ -1,325 +0,0 @@ -#include -#include -#include -#include -#include -#include - -SEQ_DEFINEBUF (2048); -SEQ_PM_DEFINES; - -int seqfd, dev = 0; -unsigned char buf[100]; -int bufp; - -/* LRU list for free operators */ - -unsigned char free_list[256]; -int fhead=0, ftail=0, flen=0; - -/* LRU list for still playing notes */ - -unsigned char note_list[256]; -int nhead=0, ntail=0, nlen=0; -unsigned char oper_note[32]; - -int pgm = 0; -int num_voices; -int bender = 0; /* Initially off */ - -void -seqbuf_dump () -{ - if (_seqbufptr) - if (write (seqfd, _seqbuf, _seqbufptr) == -1) - { - perror ("write /dev/sequencer"); - exit (-1); - } - _seqbufptr = 0; -} - -void -stop_note(int note, int velocity) -{ - int i, op; - - op=255; - - for (i=0;i255) - { -#if 0 - fprintf(stderr, "Note list overflow %d, %d, %d\n", - nlen, nhead, ntail); -#endif - nlen=0; /* Overflow -> hard reset */ - } - nlen++; - ntail = (ntail+1) % 256; - - oper_note[free] = note; - - SEQ_SET_PATCH(dev, free, pgm); - SEQ_PITCHBEND(dev, free, bender); - SEQ_START_NOTE(dev, free, note, velocity); - SEQ_DUMPBUF(); -} - -void -channel_pressure(int ch, int pressure) -{ - int i; - - for (i=0;i> 7); */ - pitch_bender(ch, value); - bufp=1; - break; - - case 0xc0: /* Pgm change */ - if (bufp < 2) break; - /* printf("Pgm change %d %d\n", ch, buf[1]); */ - pgm = buf[1]; - if (PM_LOAD_PATCH(dev, 0, pgm) < 0) - if (errno != ESRCH) /* No such process */ - perror("PM_LOAD_PATCH"); - bufp=0; - break; - - case 0xd0: /* Channel pressure */ - if (bufp < 2) break; - /* printf("Channel pressure %d %d\n", ch, buf[1]); */ - channel_pressure(ch, buf[1]); - bufp=1; - break; - - default: - bufp=0; - } -} - -int -main (int argc, char *argv[]) -{ - int i, n, max_voice = 999; - - struct synth_info info; - - unsigned char ev[4], *p; - - if (argc >= 2) dev = atoi(argv[1]); - - for (i=0;i<16;i++) oper_note[i] = 255; - - if ((seqfd = open ("/dev/sequencer", O_RDWR, 0)) == -1) - { - perror ("open /dev/sequencer"); - exit (-1); - } - - if (argc >= 3) - { - int d = dev; - ioctl(seqfd, SNDCTL_FM_4OP_ENABLE, &d); - } - - info.device = dev; - - if (ioctl(seqfd, SNDCTL_SYNTH_INFO, &info)==-1) - { - perror ("info /dev/sequencer"); - exit (-1); - } - - num_voices = info.nr_voices; - if (num_voices>max_voice)num_voices = max_voice; - fprintf(stderr, "Output to synth device %d (%s)\n", dev, info.name); - fprintf(stderr, "%d voices available\n", num_voices); - - for (i=0;i -#include -#include -#include -#include -#include -#include -#include -#include -#include "gmidi.h" - -#ifndef PATCH_PATH -#define PATCH_PATH "/D/ultrasnd/midi" -#endif - -char loadmap[256] = -{0}; /* 1 if the patch is already loaded */ - -struct pat_header - { - char magic[12]; - char version[10]; - char description[60]; - unsigned char instruments; - char voices; - char channels; - unsigned short nr_waveforms; - unsigned short master_volume; - unsigned long data_size; - }; - -struct sample_header - { - char name[7]; - unsigned char fractions; - long len; - long loop_start; - long loop_end; - unsigned short base_freq; - long low_note; - long high_note; - long base_note; - short detune; - unsigned char panning; - - unsigned char envelope_rate[6]; - unsigned char envelope_offset[6]; - - unsigned char tremolo_sweep; - unsigned char tremolo_rate; - unsigned char tremolo_depth; - - unsigned char vibrato_sweep; - unsigned char vibrato_rate; - unsigned char vibrato_depth; - - char modes; - - short scale_frequency; - unsigned short scale_factor; - }; -int seqfd = 0, gus_dev = -1; - -struct patch_info *patch; - -int -do_load_patch (struct patmgr_info *rec) -{ - int i, patfd, pgm, print_only = 0; - struct pat_header header; - struct sample_header sample; - char buf[256]; - char name[256]; - long offset; - - pgm = rec->data.data8[0]; - - if (loadmap[pgm]) - return 0; /* Already loaded */ - - sprintf (name, PATCH_PATH "/%s.pat", patch_names[pgm]); - - if ((patfd = open (name, O_RDONLY, 0)) == -1) - { - perror (name); - return errno; - } - - if (read (patfd, buf, 0xef) != 0xef) - { - fprintf (stderr, "%s: Short file\n", name); - return EIO; - } - - memcpy ((char *) &header, buf, sizeof (header)); - - if (strncmp (header.magic, "GF1PATCH110", 12)) - { - fprintf (stderr, "%s: Not a patch file\n", name); - return EINVAL; - } - - if (strncmp (header.version, "ID#000002", 10)) - { - fprintf (stderr, "%s: Incompatible patch file version\n", name); - return EINVAL; - } - - header.nr_waveforms = *(unsigned short *) &buf[85]; - header.master_volume = *(unsigned short *) &buf[87]; - - printf ("GUS: Loading: %s\n", name); - - offset = 0xef; - - for (i = 0; i < header.nr_waveforms; i++) - { - if (lseek (patfd, offset, 0) == -1) - { - perror (name); - return errno; - } - - if (read (patfd, &buf, sizeof (sample)) != sizeof (sample)) - { - fprintf (stderr, "%s: Short file\n", name); - return EIO; - } - - memcpy ((char *) &sample, buf, sizeof (sample)); - - /* - * Since some fields of the patch record are not 32bit aligned, we must - * handle them specially. - */ - sample.low_note = *(long *) &buf[22]; - sample.high_note = *(long *) &buf[26]; - sample.base_note = *(long *) &buf[30]; - sample.detune = *(short *) &buf[34]; - sample.panning = (unsigned char) buf[36]; - - memcpy (sample.envelope_rate, &buf[37], 6); - memcpy (sample.envelope_offset, &buf[43], 6); - - sample.tremolo_sweep = (unsigned char) buf[49]; - sample.tremolo_rate = (unsigned char) buf[50]; - sample.tremolo_depth = (unsigned char) buf[51]; - - sample.vibrato_sweep = (unsigned char) buf[52]; - sample.vibrato_rate = (unsigned char) buf[53]; - sample.vibrato_depth = (unsigned char) buf[54]; - sample.modes = (unsigned char) buf[55]; - sample.scale_frequency = *(short *) &buf[56]; - sample.scale_factor = *(unsigned short *) &buf[58]; - - if (print_only) - { - printf ("\nSample: %03d / %s\n", i, sample.name); - printf ("Len: %d, Loop start: %d, Loop end: %d\n", sample.len, sample.loop_start, sample.loop_end); - printf ("Flags: "); - if (sample.modes & WAVE_16_BITS) - printf ("16 bit "); - if (sample.modes & WAVE_UNSIGNED) - printf ("unsigned "); - if (sample.modes & WAVE_LOOP_BACK) - printf ("reverse "); - if (sample.modes & WAVE_BIDIR_LOOP) - printf ("bidir "); - if (sample.modes & WAVE_LOOPING) - printf ("looping "); - else - printf ("one_shot"); - if (sample.modes & WAVE_SUSTAIN_ON) - printf ("sustain "); - if (sample.modes & WAVE_ENVELOPES) - printf ("enveloped "); - printf ("\n"); - - if (sample.modes & WAVE_ENVELOPES) - { - int i; - - printf ("Envelope info: "); - for (i = 0; i < 6; i++) - { - printf ("%d/%d ", sample.envelope_rate[i], - sample.envelope_offset[i]); - } - printf ("\n"); - } - - printf ("Tremolo: sweep=%d, rate=%d, depth=%d\n", - sample.tremolo_sweep, - sample.tremolo_rate, - sample.tremolo_depth); - - printf ("Vibrato: sweep=%d, rate=%d, depth=%d\n", - sample.vibrato_sweep, - sample.vibrato_rate, - sample.vibrato_depth); - } - - offset = offset + 96; - patch = (struct patch_info *) malloc (sizeof (*patch) + sample.len); - - patch->key = GUS_PATCH; - patch->device_no = gus_dev; - patch->instr_no = pgm; - patch->mode = sample.modes | WAVE_TREMOLO | - WAVE_VIBRATO | WAVE_SCALE; - patch->len = sample.len; - patch->loop_start = sample.loop_start; - patch->loop_end = sample.loop_end; - patch->base_note = sample.base_note; - patch->high_note = sample.high_note; - patch->low_note = sample.low_note; - patch->base_freq = sample.base_freq; - patch->detuning = sample.detune; - patch->panning = (sample.panning - 7) * 16; - - memcpy (patch->env_rate, sample.envelope_rate, 6); - memcpy (patch->env_offset, sample.envelope_offset, 6); - - patch->tremolo_sweep = sample.tremolo_sweep; - patch->tremolo_rate = sample.tremolo_rate; - patch->tremolo_depth = sample.tremolo_depth; - - patch->vibrato_sweep = sample.vibrato_sweep; - patch->vibrato_rate = sample.vibrato_rate; - patch->vibrato_depth = sample.vibrato_depth; - - patch->scale_frequency = sample.scale_frequency; - patch->scale_factor = sample.scale_factor; - - patch->volume = header.master_volume; - - if (lseek (patfd, offset, 0) == -1) - { - perror (name); - return errno; - } - - if (!print_only) - { - if (read (patfd, patch->data, sample.len) != sample.len) - { - fprintf (stderr, "%s: Short file\n", name); - return EIO; - } - - if (write (seqfd, patch, sizeof (*patch) + sample.len) == -1) - { - perror ("/dev/pmgr0"); - return errno; - } - } - - offset = offset + sample.len; - } - - loadmap[pgm] = 1; - return 0; -} - -int -main (int argc, char *argv[]) -{ - struct patmgr_info inf; - int err, i, n; - struct synth_info info; - - if ((seqfd = open ("/dev/patmgr0", O_RDWR, 0)) == -1) - { - fprintf (stderr, "Cannot open\n"); - perror ("/dev/patmgr0"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_NRSYNTHS, &n) == -1) - { - perror ("NRSYNTH: /dev/patmgr0"); - exit (-1); - } - - for (i = 0; i < n; i++) - { - info.device = i; - - if (ioctl (seqfd, SNDCTL_SYNTH_INFO, &info) == -1) - { - perror ("SYNTH_INFO: /dev/patmgr0"); - exit (-1); - } - - if (info.synth_type == SYNTH_TYPE_SAMPLE - && info.synth_subtype == SAMPLE_TYPE_GUS) - gus_dev = i; - } - - if (gus_dev == -1) - { - fprintf (stderr, "Error: Gravis Ultrasound not detected\n"); - exit (-1); - } - - if (ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev) == -1) - perror ("Sample reset"); - - for (i = 0; i < 256; i++) - loadmap[i] = 0; - - while (1) - { - if (read (seqfd, (char *) &inf, sizeof (inf)) != sizeof (inf)) - { - perror ("Read"); - exit (-1); - } - - if (inf.key == PM_K_EVENT) - switch (inf.command) - { - case PM_E_OPENED: - printf ("Opened\n"); - break; - - case PM_E_CLOSED: - printf ("Closed\n"); - if (ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev) == -1) - perror ("Sample reset"); - for (i = 0; i < 256; i++) - loadmap[i] = 0; - break; - - case PM_E_PATCH_RESET: - printf ("Patch reset called\n"); - for (i = 0; i < 256; i++) - loadmap[i] = 0; - break; - - case PM_E_PATCH_LOADED: - printf ("Patch loaded by client\n"); - break; - - default: - printf ("Unknown event %d\n", inf.command); - inf.key = PM_ERROR; - inf.parm1 = EINVAL; - } - else if (inf.key == PM_K_COMMAND) - switch (inf.command) - { - case _PM_LOAD_PATCH: - if ((err = do_load_patch (&inf))) - if (err == ENOSPC) - { - if (ioctl (seqfd, SNDCTL_SEQ_RESETSAMPLES, &gus_dev) == -1) - { - perror ("Sample reset"); - return errno; - } - - for (i = 0; i < 256; i++) - loadmap[i] = 0; - err = do_load_patch (&inf); - } - - if (err) - { - inf.key = PM_ERROR; - inf.parm1 = err; - printf("Error = %d\n", err); - } - else - { - inf.key = PM_K_COMMAND; - inf.parm1 = 0; - } - break; - - default: - printf ("Unknown command %d\n", inf.command); - inf.key = PM_ERROR; - inf.parm1 = EINVAL; - } - else - { - printf ("Unknown event %d/%d\n", inf.key, inf.command); - inf.key = PM_ERROR; - inf.parm1 = EINVAL; - } - - if (write (seqfd, (char *) &inf, sizeof (inf)) != sizeof (inf)) - { - perror ("write"); - exit (-1); - } - } - - exit (0); -} diff --git a/sys/i386/isa/sound/ics2101.c b/sys/i386/isa/sound/ics2101.c new file mode 100644 index 0000000..619b635 --- /dev/null +++ b/sys/i386/isa/sound/ics2101.c @@ -0,0 +1,261 @@ +/* + * sound/ics2101.c + * + * Driver for the ICS2101 mixer of GUS v3.7. + * + * Copyright by Hannu Savolainen 1994 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sound_config.h" +#if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_GUS) + +#include "ultrasound.h" +#include "gus_hw.h" + +#define MIX_DEVS (SOUND_MASK_MIC|SOUND_MASK_LINE| \ + SOUND_MASK_SYNTH| \ + SOUND_MASK_CD | SOUND_MASK_VOLUME) + +extern int gus_base; +static int volumes[ICS_MIXDEVS]; +static int left_fix[ICS_MIXDEVS] = +{1, 1, 1, 2, 1, 2}; +static int right_fix[ICS_MIXDEVS] = +{2, 2, 2, 1, 2, 1}; + +static int +scale_vol(int vol) +{ +#if 1 +/* + * Experimental volume scaling by Risto Kankkunen. + * This should give smoother volume response than just + * a plain multiplication. + */ + int e; + + if (vol < 0) + vol = 0; + if (vol > 100) + vol = 100; + vol = (31 * vol + 50) / 100; + e = 0; + if (vol) { + while (vol < 16) { + vol <<= 1; + e--; + } + vol -= 16; + e += 7; + } + return ((e << 4) + vol); +#else + return ((vol*127)+50)/100; +#endif +} + +static void +write_mix (int dev, int chn, int vol) +{ + int *selector; + unsigned long flags; + int ctrl_addr = dev << 3; + int attn_addr = dev << 3; + + vol=scale_vol(vol); + + if (chn == CHN_LEFT) + { + selector = left_fix; + ctrl_addr |= 0x00; + attn_addr |= 0x02; + } + else + { + selector = right_fix; + ctrl_addr |= 0x01; + attn_addr |= 0x03; + } + + DISABLE_INTR (flags); + OUTB (ctrl_addr, u_MixSelect); + OUTB (selector[dev], u_MixData); + OUTB (attn_addr, u_MixSelect); + OUTB ((unsigned char) vol, u_MixData); + RESTORE_INTR (flags); +} + +static int +set_volumes (int dev, int vol) +{ + int left = vol & 0x00ff; + int right = (vol >> 8) & 0x00ff; + + if (left < 0) + left = 0; + if (left > 100) + left = 100; + if (right < 0) + right = 0; + if (right > 100) + right = 100; + + write_mix (dev, CHN_LEFT, left); + write_mix (dev, CHN_RIGHT, right); + + vol = left + (right << 8); + volumes[dev] = vol; + return vol; +} + +static int +ics2101_mixer_ioctl (int dev, unsigned int cmd, unsigned int arg) +{ + if (((cmd >> 8) & 0xff) == 'M') + { + if (cmd & IOC_IN) + switch (cmd & 0xff) + { + case SOUND_MIXER_RECSRC: + return gus_default_mixer_ioctl (dev, cmd, arg); + break; + + case SOUND_MIXER_MIC: + return IOCTL_OUT (arg, set_volumes (DEV_MIC, IOCTL_IN (arg))); + break; + + case SOUND_MIXER_CD: + return IOCTL_OUT (arg, set_volumes (DEV_CD, IOCTL_IN (arg))); + break; + + case SOUND_MIXER_LINE: + return IOCTL_OUT (arg, set_volumes (DEV_LINE, IOCTL_IN (arg))); + break; + + case SOUND_MIXER_SYNTH: + return IOCTL_OUT (arg, set_volumes (DEV_GF1, IOCTL_IN (arg))); + break; + + case SOUND_MIXER_VOLUME: + return IOCTL_OUT (arg, set_volumes (DEV_VOL, IOCTL_IN (arg))); + break; + + default: + return RET_ERROR (EINVAL); + } + else + switch (cmd & 0xff) /* + * Return parameters + */ + { + + case SOUND_MIXER_RECSRC: + return gus_default_mixer_ioctl (dev, cmd, arg); + break; + + case SOUND_MIXER_DEVMASK: + return IOCTL_OUT (arg, MIX_DEVS); + break; + + case SOUND_MIXER_STEREODEVS: + return IOCTL_OUT (arg, SOUND_MASK_LINE | SOUND_MASK_CD | + SOUND_MASK_SYNTH | SOUND_MASK_VOLUME| + SOUND_MASK_MIC); + break; + + case SOUND_MIXER_RECMASK: + return IOCTL_OUT (arg, SOUND_MASK_MIC | SOUND_MASK_LINE); + break; + + case SOUND_MIXER_CAPS: + return IOCTL_OUT (arg, 0); + break; + + case SOUND_MIXER_MIC: + return IOCTL_OUT (arg, volumes[DEV_MIC]); + break; + + case SOUND_MIXER_LINE: + return IOCTL_OUT (arg, volumes[DEV_LINE]); + break; + + case SOUND_MIXER_CD: + return IOCTL_OUT (arg, volumes[DEV_CD]); + break; + + case SOUND_MIXER_VOLUME: + return IOCTL_OUT (arg, volumes[DEV_VOL]); + break; + + case SOUND_MIXER_SYNTH: + return IOCTL_OUT (arg, volumes[DEV_GF1]); + break; + + default: + return RET_ERROR (EINVAL); + } + } + + return RET_ERROR (EINVAL); +} + +static struct mixer_operations ics2101_mixer_operations = +{ + ics2101_mixer_ioctl +}; + +long +ics2101_mixer_init (long mem_start) +{ + int i; + + if (num_mixers < MAX_MIXER_DEV) + { + mixer_devs[num_mixers++] = &ics2101_mixer_operations; + + /* + * Some GUS v3.7 cards had some channels flipped. Disable + * the flipping feature if the model id is other than 5. + */ + + if (INB (u_MixSelect) != 5) + { + for (i = 0; i < ICS_MIXDEVS; i++) + left_fix[i] = 1; + for (i = 0; i < ICS_MIXDEVS; i++) + right_fix[i] = 2; + } + + set_volumes (DEV_GF1, 0x5a5a); + set_volumes (DEV_CD, 0x5a5a); + set_volumes (DEV_MIC, 0x0000); + set_volumes (DEV_LINE, 0x5a5a); + set_volumes (DEV_VOL, 0x5a5a); + set_volumes (DEV_UNUSED, 0x0000); + } + + return mem_start; +} + +#endif diff --git a/sys/i386/isa/sound/midi.c b/sys/i386/isa/sound/midi.c deleted file mode 100644 index 83088d2..0000000 --- a/sys/i386/isa/sound/midi.c +++ /dev/null @@ -1,176 +0,0 @@ -/* UWM - comments to soft-eng@cs.uwm.edu */ -#define _MIDI_TABLE_C_ -#include "sound_config.h" - -#ifdef CONFIGURE_SOUNDCARD - -#ifndef EXCLUDE_CHIP_MIDI - - -static int generic_midi_busy[MAX_MIDI_DEV]; - -long CMIDI_init (long mem_start) -{ - - int i; - int n = num_midi_drivers; - /* int n = sizeof (midi_supported) / sizeof( struct generic_midi_info ); - */ - for (i = 0; i < n; i++) - { - if ( midi_supported[i].attach (mem_start) ) - { - printk("MIDI: Successfully attached %s\n",midi_supported[i].name); - } - - } - return (mem_start); -} - - -int -CMIDI_open (int dev, struct fileinfo *file) -{ - - int mode, err, retval; - - dev = dev >> 4; - - mode = file->mode & O_ACCMODE; - - - if (generic_midi_busy[dev]) - return (RET_ERROR(EBUSY)); - - - if (dev >= num_generic_midis) - { - printk(" MIDI device %d not installed.\n", dev); - return (ENXIO); - } - - if (!generic_midi_devs[dev]) - { - printk(" MIDI device %d not initialized\n",dev); - return (ENXIO); - } - - /* If all good and healthy, go ahead and issue call! */ - - - retval = generic_midi_devs[dev]->open (dev, mode) ; - - /* If everything ok, set device as busy */ - - if ( retval >= 0 ) - generic_midi_busy[dev] = 1; - - return ( retval ); - -} - -int -CMIDI_write (int dev, struct fileinfo *file, snd_rw_buf * buf, int count) -{ - - int retval; - - dev = dev >> 4; - - if (dev >= num_generic_midis) - { - printk(" MIDI device %d not installed.\n", dev); - return (ENXIO); - } - - /* Make double sure of healthiness -- doubt - * Need we check this again?? - * - */ - - if (!generic_midi_devs[dev]) - { - printk(" MIDI device %d not initialized\n",dev); - return (ENXIO); - } - - /* If all good and healthy, go ahead and issue call! */ - - - retval = generic_midi_devs[dev]->write (dev, buf); - - return ( retval ); - -} - -int -CMIDI_read (int dev, struct fileinfo *file, snd_rw_buf *buf, int count) -{ - int retval; - - dev = dev >> 4; - - if (dev >= num_generic_midis) - { - printk(" MIDI device %d not installed.\n", dev); - return (ENXIO); - } - - /* Make double sure of healthiness -- doubt - * Need we check this again?? - * - */ - - if (!generic_midi_devs[dev]) - { - printk(" MIDI device %d not initialized\n",dev); - return (ENXIO); - } - - /* If all good and healthy, go ahead and issue call! */ - - - retval = generic_midi_devs[dev]->read(dev,buf); - - return (retval); - -} - -int -CMIDI_close (int dev, struct fileinfo *file) -{ - - int retval; - dev = dev >> 4; - - if (dev >= num_generic_midis) - { - printk(" MIDI device %d not installed.\n", dev); - return (ENXIO); - } - - /* Make double sure of healthiness -- doubt - * Need we check this again?? - * - */ - - if (!generic_midi_devs[dev]) - { - printk(" MIDI device %d not initialized\n",dev); - return (ENXIO); - } - - /* If all good and healthy, go ahead and issue call! */ - - - generic_midi_devs[dev]->close(dev); - - generic_midi_busy[dev] = 0; /* Free the device */ - - return (0) ; - -} - -#endif - -#endif diff --git a/sys/i386/isa/sound/pas.h b/sys/i386/isa/sound/pas.h deleted file mode 100644 index 4dadea3..0000000 --- a/sys/i386/isa/sound/pas.h +++ /dev/null @@ -1,249 +0,0 @@ -/* */ -/* Port addresses and bit fields for the Media Vision Pro AudioSpectrum second generation sound cards. */ -/* */ -/* Feel free to use this header file in any application you create that has support for the Media Vision */ -/* Pro AudioSpectrum second generation sound cards. Other uses prohibited without prior permission. */ -/* */ -/* - cmetz@thor.tjhsst.edu */ -/* */ -/* Notes: */ -/* */ -/* * All of these ports go into the MVD101 multimedia controller chip, which then signals the other chips to do */ -/* the actual work. Many ports like the FM ones functionally attach directly to the destination chip though */ -/* they don't actually have a direct connection. */ -/* */ -/* * The PAS2 series cards have an MVD101 multimedia controller chip, the original PAS cards don't. The original */ -/* PAS cards are pretty defunct now, so no attempt is made here to support them. */ -/* */ -/* * The PAS2 series cards are all really different at the hardware level, though the MVD101 hides some of the */ -/* incompatibilities, there still are differences that need to be accounted for. */ -/* */ -/* Card CD-ROM interface PCM chip Mixer chip FM chip */ -/* PAS Plus Sony proprietary (Crystal?) 8-bit DAC National OPL3 */ -/* PAS 16 Zilog SCSI MVA416 16-bit Codec MVA508 OPL3 */ -/* CDPC Sony proprietary Sony 16-bit Codec National OPL3 */ -/* Fusion CD 16 Sony proprietary MVA416 16-bit Codec MVA508 OPL3 */ -/* Fusion CD Sony proprietary (Crystal?) 8-bit DAC National OPL3 */ -/* */ -#define PAS_DEFAULT_BASE 0x388 - -/* Symbolic Name Value R W Subsystem Description */ -#define SPEAKER_CONTROL 0x61 /* W PC speaker Control register */ -#define SPEAKER_CONTROL_GHOST 0x738B /* R W PC speaker Control ghost register */ -#define SPEAKER_TIMER_CONTROL 0x43 /* W PC speaker Timer control register */ -#define SPEAKER_TIMER_CONTROL_GHOST 0x778B /* R W PC speaker Timer control register ghost */ -#define SPEAKER_TIMER_DATA 0x42 /* W PC speaker Timer data register */ -#define SPEAKER_TIMER_DATA_GHOST 0x138A /* R W PC speaker Timer data register ghost */ - -#define WARM_BOOT 0x41 /* W Control Used to detect system warm boot */ -#define WARM_BOOT_GHOST 0x7789 /* ? W Control Use to get the card to fake warm boot */ -#define MASTER_DECODE 0x9A01 /* W Control Address >> 2 of card base address */ -#define PRESCALE_DIVIDER 0xBF8A /* R W PCM Ration between Codec clock and master clock */ -#define WAIT_STATE 0xBF88 /* R W Control Four-bit bus wait-state count (~140ns ea.) */ -#define BOARD_REV_ID 0x2789 /* R Control Extended Board Revision ID */ - -#define SYSTEM_CONFIGURATION_1 0x8388 /* R W Control */ - #define S_C_1_PCS_ENABLE 0x01 /* R W PC speaker 1=enable, 0=disable PC speaker emulation */ - #define S_C_1_PCM_CLOCK_SELECT 0x02 /* R W PCM 1=14.31818Mhz/12, 0=28.224Mhz master clock */ - #define S_C_1_FM_EMULATE_CLOCK 0x04 /* R W FM 1=use 28.224Mhz/2, 0=use 14.31818Mhz clock */ - #define S_C_1_PCS_STEREO 0x10 /* R W PC speaker 1=enable PC speaker stereo effect, 0=disable */ - #define S_C_1_PCS_REALSOUND 0x20 /* R W PC speaker 1=enable RealSound enhancement, 0=disable */ - #define S_C_1_FORCE_EXT_RESET 0x40 /* R W Control Force external reset */ - #define S_C_1_FORCE_INT_RESET 0x80 /* R W Control Force internal reset */ -#define SYSTEM_CONFIGURATION_2 0x8389 /* R W Control */ - #define S_C_2_PCM_OVERSAMPLING 0x03 /* R W PCM 00=0x, 01=2x, 10=4x, 11=reserved */ - #define S_C_2_PCM_16_BIT 0x04 /* R W PCM 1=16-bit, 0=8-bit samples */ -#define SYSTEM_CONFIGURATION_3 0x838A /* R W Control */ - #define S_C_3_PCM_CLOCK_SELECT 0x02 /* R W PCM 1=use 1.008Mhz clock for PCM, 0=don't */ -#define SYSTEM_CONFIGURATION_4 0x838B /* R W Control CD-ROM interface controls */ - -#define IO_CONFIGURATION_1 0xF388 /* R W Control */ - #define I_C_1_BOOT_RESET_ENABLE 0x80 /* R W Control 1=reset board on warm boot, 0=don't */ -#define IO_CONFIGURATION_2 0xF389 /* R W Control */ - #define I_C_2_PCM_DMA_DISABLED 0x00 /* R W PCM PCM DMA disabled */ -#define IO_CONFIGURATION_3 0xF38A /* R W Control */ - #define I_C_3_PCM_IRQ_DISABLED 0x00 /* R W PCM PCM IRQ disabled */ - -#define COMPATIBILITY_ENABLE 0xF788 /* R W Control */ - #define C_E_MPU401_ENABLE 0x01 /* R W MIDI 1=enable, 0=disable MPU401 MIDI emulation */ - #define C_E_SB_ENABLE 0x02 /* R W PCM 1=enable, 0=disable Sound Blaster emulation */ - #define C_E_SB_ACTIVE 0x04 /* R PCM "Sound Blaster Interrupt active" */ - #define C_E_MPU401_ACTIVE 0x08 /* R MIDI "MPU UART mode active" */ - #define C_E_PCM_COMPRESSION 0x10 /* R W PCM 1=enable, 0=disabled compression */ -#define EMULATION_ADDRESS 0xF789 /* R W Control */ - #define E_A_SB_BASE 0x0f /* R W PCM bits A4-A7 for SB base port */ - #define E_A_MPU401_BASE 0xf0 /* R W MIDI bits A4-A7 for MPU401 base port */ -#define EMULATION_CONFIGURATION 0xFB8A /* R W ***** Only valid on newer PAS2 cards (?) ***** */ - #define E_C_MPU401_IRQ 0x07 /* R W MIDI MPU401 emulation IRQ */ - #define E_C_SB_IRQ 0x38 /* R W PCM SB emulation IRQ */ - #define E_C_SB_DMA 0xC0 /* R W PCM SB emulation DMA */ - -#define OPERATION_MODE_1 0xEF8B /* R Control */ - #define O_M_1_CDROM_TYPE 0x03 /* R CD-ROM 3=SCSI, 2=Sony, 0=no CD-ROM interface */ - #define O_M_1_FM_TYPE 0x04 /* R FM 1=sterero, 0=mono FM chip */ - #define O_M_1_PCM_TYPE 0x08 /* R PCM 1=16-bit Codec, 0=8-bit DAC */ -#define OPERATION_MODE_2 0xFF8B /* R Control */ - #define O_M_2_PCS_ENABLED 0x02 /* R PC speaker PC speaker emulation 1=enabled, 0=disabled */ - #define O_M_2_BUS_TIMING 0x10 /* R Control 1=AT bus timing, 0=XT bus timing */ - #define O_M_2_BOARD_REVISION 0xe0 /* R Control Board revision */ - -#define INTERRUPT_MASK 0x0B8B /* R W Control */ - #define I_M_FM_LEFT_IRQ_ENABLE 0x01 /* R W FM Enable FM left interrupt */ - #define I_M_FM_RIGHT_IRQ_ENABLE 0x02 /* R W FM Enable FM right interrupt */ - #define I_M_PCM_RATE_IRQ_ENABLE 0x04 /* R W PCM Enable Sample Rate interrupt */ - #define I_M_PCM_BUFFER_IRQ_ENABLE 0x08 /* R W PCM Enable Sample Buffer interrupt */ - #define I_M_MIDI_IRQ_ENABLE 0x10 /* R W MIDI Enable MIDI interrupt */ - #define I_M_BOARD_REV 0xE0 /* R Control Board revision */ - -#define INTERRUPT_STATUS 0x0B89 /* R W Control */ - #define I_S_FM_LEFT_IRQ 0x01 /* R W FM Left FM Interrupt Pending */ - #define I_S_FM_RIGHT_IRQ 0x02 /* R W FM Right FM Interrupt Pending */ - #define I_S_PCM_SAMPLE_RATE_IRQ 0x04 /* R W PCM Sample Rate Interrupt Pending */ - #define I_S_PCM_SAMPLE_BUFFER_IRQ 0x08 /* R W PCM Sample Buffer Interrupt Pending */ - #define I_S_MIDI_IRQ 0x10 /* R W MIDI MIDI Interrupt Pending */ - #define I_S_PCM_CHANNEL 0x20 /* R W PCM 1=right, 0=left */ - #define I_S_RESET_ACTIVE 0x40 /* R W Control Reset is active (Timed pulse not finished) */ - #define I_S_PCM_CLIPPING 0x80 /* R W PCM Clipping has occurred */ - -#define FILTER_FREQUENCY 0x0B8A /* R W Control */ - #define F_F_FILTER_DISABLED 0x00 /* R W Mixer No filter */ -#if 0 - struct { /* R W Mixer Filter translation */ - unsigned int freq:24; - unsigned int value:8; - } F_F_FILTER_translate[] = - { { 73500, 0x01 }, /* 73500Hz - divide by 16 */ - { 65333, 0x02 }, /* 65333Hz - divide by 18 */ - { 49000, 0x09 }, /* 49000Hz - divide by 24 */ - { 36750, 0x11 }, /* 36750Hz - divide by 32 */ - { 24500, 0x19 }, /* 24500Hz - divide by 48 */ - { 18375, 0x07 }, /* 18375Hz - divide by 64 */ - { 12783, 0x0f }, /* 12783Hz - divide by 92 */ - { 12250, 0x04 }, /* 12250Hz - divide by 96 */ - { 9188, 0x17 }, /* 9188Hz - divide by 128 */ - { 6125, 0x1f }, /* 6125Hz - divide by 192 */ - }; -#endif - #define F_F_MIXER_UNMUTE 0x20 /* R W Mixer 1=disable, 0=enable board mute */ - #define F_F_PCM_RATE_COUNTER 0x40 /* R W PCM 1=enable, 0=disable sample rate counter */ - #define F_F_PCM_BUFFER_COUNTER 0x80 /* R W PCM 1=enable, 0=disable sample buffer counter */ - -#define PAS_NONE 0 -#define PAS_PLUS 1 -#define PAS_CDPC 2 -#define PAS_16 3 - -#ifdef DEFINE_TRANSLATIONS - char I_C_2_PCM_DMA_translate[] = /* R W PCM PCM DMA channel value translations */ - { 4, 1, 2, 3, 0, 5, 6, 7 }; - char I_C_3_PCM_IRQ_translate[] = /* R W PCM PCM IRQ level value translation */ - { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 }; - char E_C_MPU401_IRQ_translate[] = /* R W MIDI MPU401 emulation IRQ value translation */ - { 0x00, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x05, 0x06, 0x07 }; - char E_C_SB_IRQ_translate[] = /* R W PCM SB emulation IRQ translate */ - { 0x00, 0x00, 0x08, 0x10, 0x00, 0x18, 0x00, 0x20, 0x00, 0x00, 0x28, 0x30, 0x38 }; - char E_C_SB_DMA_translate[] = /* R W PCM SB emulation DMA translate */ - { 0x00, 0x40, 0x80, 0xC0 }; - char O_M_1_to_card[] = /* R W Control Translate (OM1 & 0x0f) to card type */ - { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 3, 0, 2, 3 }; -#else - extern char I_C_2_PCM_DMA_translate[]; /* R W PCM PCM DMA channel value translations */ - extern char I_C_3_PCM_IRQ_translate[]; /* R W PCM PCM IRQ level value translation */ - extern char E_C_MPU401_IRQ_translate[]; /* R W MIDI MPU401 emulation IRQ value translation */ - extern char E_C_SB_IRQ_translate[]; /* R W PCM SB emulation IRQ translate */ - extern char E_C_SB_DMA_translate[]; /* R W PCM SB emulation DMA translate */ - extern char O_M_1_to_card[]; /* R W Control Translate (OM1 & 0x0f) to card type */ -#endif - -#define PARALLEL_MIXER 0x078B /* W Mixer Documented for MVD101 as FM Mono Right decode?? */ - #define P_M_MV508_ADDRESS 0x80 /* W Mixer MVD508 Address/mixer select */ - #define P_M_MV508_DATA 0x00 - #define P_M_MV508_LEFT 0x20 /* W Mixer MVD508 Left channel select */ - #define P_M_MV508_RIGHT 0x40 /* W Mixer MVD508 Right channel select */ - #define P_M_MV508_BOTH 0x00 /* W Mixer MVD508 Both channel select */ - #define P_M_MV508_MIXER 0x10 /* W Mixer MVD508 Select a mixer (rather than a volume) */ - #define P_M_MV508_VOLUME 0x00 - - #define P_M_MV508_INPUTMIX 0x20 /* W Mixer MVD508 Select mixer A */ - #define P_M_MV508_OUTPUTMIX 0x00 /* W Mixer MVD508 Select mixer B */ - - #define P_M_MV508_MASTER_A 0x01 /* W Mixer MVD508 Master volume control A (output) */ - #define P_M_MV508_MASTER_B 0x02 /* W Mixer MVD508 Master volume control B (DSP input) */ - #define P_M_MV508_BASS 0x03 /* W Mixer MVD508 Bass control */ - #define P_M_MV508_TREBLE 0x04 /* W Mixer MVD508 Treble control */ - #define P_M_MV508_MODE 0x05 /* W Mixer MVD508 Master mode control */ - - #define P_M_MV508_LOUDNESS 0x04 /* W Mixer MVD508 Mode control - Loudness filter */ - #define P_M_MV508_ENHANCE_BITS 0x03 - #define P_M_MV508_ENHANCE_NONE 0x00 /* W Mixer MVD508 Mode control - No stereo enhancement */ - #define P_M_MV508_ENHANCE_40 0x01 /* W Mixer MVD508 Mode control - 40% stereo enhancement */ - #define P_M_MV508_ENHANCE_60 0x02 /* W Mixer MVD508 Mode control - 60% stereo enhancement */ - #define P_M_MV508_ENHANCE_80 0x03 /* W Mixer MVD508 Mode control - 80% stereo enhancement */ - - #define P_M_MV508_FM 0x00 /* W Mixer MVD508 Channel 0 - FM */ - #define P_M_MV508_IMIXER 0x01 /* W Mixer MVD508 Channel 1 - Input mixer (rec monitor) */ - #define P_M_MV508_LINE 0x02 /* W Mixer MVD508 Channel 2 - Line in */ - #define P_M_MV508_CDROM 0x03 /* W Mixer MVD508 Channel 3 - CD-ROM */ - #define P_M_MV508_MIC 0x04 /* W Mixer MVD508 Channel 4 - Microphone */ - #define P_M_MV508_PCM 0x05 /* W Mixer MVD508 Channel 5 - PCM */ - #define P_M_MV508_SPEAKER 0x06 /* W Mixer MVD508 Channel 6 - PC Speaker */ - #define P_M_MV508_SB 0x07 /* W Mixer MVD508 Channel 7 - SB DSP */ - -#define SERIAL_MIXER 0xB88 /* R W Control Serial mixer control (used other ways) */ - #define S_M_PCM_RESET 0x01 /* R W PCM Codec/DSP reset */ - #define S_M_FM_RESET 0x02 /* R W FM FM chip reset */ - #define S_M_SB_RESET 0x04 /* R W PCM SB emulation chip reset */ - #define S_M_MIXER_RESET 0x10 /* R W Mixer Mixer chip reset */ - #define S_M_INTEGRATOR_ENABLE 0x40 /* R W Speaker Enable PC speaker integrator (FORCE RealSound) */ - #define S_M_OPL3_DUAL_MONO 0x80 /* R W FM Set the OPL-3 to dual mono mode */ - -#define PCM_CONTROL 0xF8A /* R W PCM PCM Control Register */ - #define P_C_MIXER_CROSS_FIELD 0x0f - #define P_C_MIXER_CROSS_R_TO_R 0x01 /* R W Mixer Connect Right to Right */ - #define P_C_MIXER_CROSS_L_TO_R 0x02 /* R W Mixer Connect Left to Right */ - #define P_C_MIXER_CROSS_R_TO_L 0x04 /* R W Mixer Connect Right to Left */ - #define P_C_MIXER_CROSS_L_TO_L 0x08 /* R W Mixer Connect Left to Left */ - #define P_C_PCM_DAC_MODE 0x10 /* R W PCM Playback (DAC) mode */ - #define P_C_PCM_ADC_MODE 0x00 /* R W PCM Record (ADC) mode */ - #define P_C_PCM_MONO 0x20 /* R W PCM Mono mode */ - #define P_C_PCM_STEREO 0x00 /* R W PCM Stereo mode */ - #define P_C_PCM_ENABLE 0x40 /* R W PCM Enable PCM engine */ - #define P_C_PCM_DMA_ENABLE 0x80 /* R W PCM Enable DRQ */ - -#define SAMPLE_COUNTER_CONTROL 0x138B /* R W PCM Sample counter control register */ - #define S_C_C_SQUARE_WAVE 0x04 /* R W PCM Square wave generator (use for sample rate) */ - #define S_C_C_RATE 0x06 /* R W PCM Rate generator (use for sample buffer count) */ - #define S_C_C_LSB_THEN_MSB 0x30 /* R W PCM Change all 16 bits, LSB first, then MSB */ - - /* MVD101 and SDK documentations have S_C_C_SAMPLE_RATE and S_C_C_SAMPLE_BUFFER transposed. Only one works :-) */ - #define S_C_C_SAMPLE_RATE 0x00 /* R W PCM Select sample rate timer */ - #define S_C_C_SAMPLE_BUFFER 0x40 /* R W PCM Select sample buffer counter */ - - #define S_C_C_PC_SPEAKER 0x80 /* R W PCM Select PC speaker counter */ - -#define SAMPLE_RATE_TIMER 0x1388 /* W PCM Sample rate timer register (PCM wait interval) */ -#define SAMPLE_BUFFER_COUNTER 0x1389 /* R W PCM Sample buffer counter (DMA buffer size) */ - -#define MIDI_CONTROL 0x178b /* R W MIDI Midi control register */ - #define M_C_ENA_TSTAMP_IRQ 0x01 /* R W MIDI Enable Time Stamp Interrupts */ - #define M_C_ENA_TME_COMP_IRQ 0x02 /* R W MIDI Enable time compare interrupts */ - #define M_C_ENA_INPUT_IRQ 0x04 /* R W MIDI Enable input FIFO interrupts */ - #define M_C_ENA_OUTPUT_IRQ 0x08 /* R W MIDI Enable output FIFO interrupts */ - #define M_C_ENA_OUTPUT_HALF_IRQ 0x10 /* R W MIDI Enable output FIFO half full interrupts */ - #define M_C_RESET_INPUT_FIFO 0x20 /* R W MIDI Reset input FIFO pointer */ - #define M_C_RESET_OUTPUT_FIFO 0x40 /* R W MIDI Reset output FIFO pointer */ - #define M_C_ENA_THRU_MODE 0x80 /* R W MIDI Echo input to output (THRU) */ - -#define MIDI_STATUS 0x1B88 /* R W MIDI Midi (interrupt) status register */ - #define M_S_TIMESTAMP 0x01 /* R W MIDI Midi time stamp interrupt occurred */ - #define M_S_COMPARE 0x02 /* R W MIDI Midi compare time interrupt occurred */ - #define M_S_INPUT_AVAIL 0x04 /* R W MIDI Midi input data available interrupt occurred */ - #define M_S_OUTPUT_EMPTY 0x08 /* R W MIDI Midi output FIFO empty interrupt occurred */ - #define M_S_OUTPUT_HALF_EMPTY 0x10 /* R W MIDI Midi output FIFO half empty interrupt occurred */ - #define M_S_INPUT_OVERRUN 0x20 /* R W MIDI Midi input overrun error occurred */ - #define M_S_OUTPUT_OVERRUN 0x40 /* R W MIDI Midi output overrun error occurred */ - #define M_S_FRAMING_ERROR 0x80 /* R W MIDI Midi input framing error occurred */ - -#define MIDI_FIFO_STATUS 0x1B89 /* R W MIDI Midi fifo status */ -#define MIDI_DATA 0x178A /* R W MIDI Midi data register */ -#define MIDI_INPUT_AVAILABLE 0x0f /* RW MIDI */ diff --git a/sys/i386/isa/sound/pro_midi.c b/sys/i386/isa/sound/pro_midi.c deleted file mode 100644 index b7f6b9a..0000000 --- a/sys/i386/isa/sound/pro_midi.c +++ /dev/null @@ -1,155 +0,0 @@ -/* UWM -- comments to soft-eng@cs.uwm.edu */ -#define ALL_EXTERNAL_TO_ME -#include "sound_config.h" - -#ifdef CONFIGURE_SOUNDCARD - -#include "pas.h" -#define ESUCCESS 0 - -#if !defined(EXCLUDE_PRO_MIDI) && !defined(EXCLUDE_CHIP_MIDI) - - -/** Structure for handling operations **/ - - -static struct generic_midi_operations pro_midi_operations = { - - {"Pro_Audio_Spectrum 16 MV101", 0}, - pro_midi_open, - pro_midi_close, - pro_midi_write, - pro_midi_read -}; - -/* - * Note! Note! Note! - * Follow the same model for any other attach function you - * may write - */ - -long pro_midi_attach( long mem_start) -{ - pro_midi_dev = num_generic_midis; - generic_midi_devs[num_generic_midis++] = &pro_midi_operations; - return mem_start; -} - -int pro_midi_open(int dev, int mode) -{ - - int intr_mask, s; - - - s = splhigh(); - - - /* Reset the input and output FIFO pointers */ - - - outb(MIDI_CONTROL,M_C_RESET_INPUT_FIFO | M_C_RESET_OUTPUT_FIFO); - - /* Get the interrupt status */ - - intr_mask = inb(INTERRUPT_MASK); - - - /* Enable MIDI IRQ */ - - intr_mask |= I_M_MIDI_IRQ_ENABLE; - outb(INTERRUPT_MASK, intr_mask); - - - /* Enable READ/WRITE on MIDI port. This part is quite unsure though */ - - outb(MIDI_CONTROL,M_C_ENA_OUTPUT_IRQ | M_C_ENA_INPUT_IRQ); - - /* Acknowledge pending interrupts */ - - outb(MIDI_STATUS,0xff); - - - splx(s); - - return(ESUCCESS); - - -} - - -void pro_midi_close(int dev) -{ - - int intr_mask; - - /* Clean up */ - - outb(MIDI_CONTROL,M_C_RESET_INPUT_FIFO | M_C_RESET_OUTPUT_FIFO); - intr_mask = inb(INTERRUPT_MASK); - intr_mask &= ~I_M_MIDI_IRQ_ENABLE; - outb(INTERRUPT_MASK,intr_mask); - - return; -} - -int pro_midi_write(int dev, struct uio *uio) -{ - - int s; - unsigned char data; - - /* printf("midi: Going to do write routine..\n"); */ - while(uio->uio_resid) { - - if ( uiomove(&data,1,uio) ) return(ENOTTY); - - s = splhigh(); - - DELAY(30); - outb(MIDI_DATA,data); - DELAY(70); /* Ze best pause.. find a better one if - * you can :) - */ - splx(s); - } - - return(ESUCCESS); - -} - - -int pro_midi_read(int dev, struct uio *uio) -{ - - int s; - unsigned char data; - - s = splhigh(); - - /* For each uio_iov[] entry .... */ - - while (uio->uio_resid) { - - if((( inb(MIDI_STATUS) & M_S_INPUT_AVAIL) == 0 ) && - ((inb(MIDI_FIFO_STATUS) & MIDI_INPUT_AVAILABLE) == 0 ) ) - - data = 0xfe; - else - data = inb(MIDI_DATA); - - if ( uiomove(&data, 1 , uio)) { - - printf("midi: Bad copyout()!\n"); - return(ENOTTY); - - } - - } - splx(s); - return(ESUCCESS); - -} - -#endif - -#endif diff --git a/sys/i386/isa/sound/sb16_dsp.c b/sys/i386/isa/sound/sb16_dsp.c new file mode 100644 index 0000000..8787b27 --- /dev/null +++ b/sys/i386/isa/sound/sb16_dsp.c @@ -0,0 +1,641 @@ +/* + * sound/sb16_dsp.c + * + * The low level driver for the SoundBlaster DSP chip. + * + * (C) 1993 J. Schubert (jsb@sth.ruhr-uni-bochum.de) + * + * based on SB-driver by (C) Hannu Savolainen + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#define DEB(x) +#define DEB1(x) +/* + #define DEB_DMARES + */ +#include "sound_config.h" +#include "sb.h" +#include "sb_mixer.h" + +#if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_SB16) && !defined(EXCLUDE_SB) && !defined(EXCLUDE_AUDIO) && !defined(EXCLUDE_SBPRO) + +extern int sbc_base; + +static int sb16_dsp_ok = 0; /* Set to 1 after successful initialization */ +static int dsp_16bit = 0; +static int dsp_stereo = 0; +static int dsp_current_speed = 8000; /*DSP_DEFAULT_SPEED; */ +static int dsp_busy = 0; +static int dma16, dma8; +static unsigned long dsp_count = 0; + +static int irq_mode = IMODE_NONE; /* IMODE_INPUT, IMODE_OUTPUT or + + IMODE_NONE */ +static int my_dev = 0; + +static volatile int intr_active = 0; + +static int sb16_dsp_open (int dev, int mode); +static void sb16_dsp_close (int dev); +static void sb16_dsp_output_block (int dev, unsigned long buf, int count, int intrflag, int dma_restart); +static void sb16_dsp_start_input (int dev, unsigned long buf, int count, int intrflag, int dma_restart); +static int sb16_dsp_ioctl (int dev, unsigned int cmd, unsigned int arg, int local); +static int sb16_dsp_prepare_for_input (int dev, int bsize, int bcount); +static int sb16_dsp_prepare_for_output (int dev, int bsize, int bcount); +static void sb16_dsp_reset (int dev); +static void sb16_dsp_halt (int dev); +static int dsp_set_speed (int); +static int dsp_set_stereo (int); +static void dsp_cleanup (void); +int sb_reset_dsp (void); + +static struct audio_operations sb16_dsp_operations = +{ + "SoundBlaster 16", + sb16_dsp_open, + sb16_dsp_close, + sb16_dsp_output_block, + sb16_dsp_start_input, + sb16_dsp_ioctl, + sb16_dsp_prepare_for_input, + sb16_dsp_prepare_for_output, + sb16_dsp_reset, + sb16_dsp_halt, + NULL, + NULL +}; + +static int +sb_dsp_command01 (unsigned char val) +{ + int i = 1 << 16; + + while (--i & (!INB (DSP_STATUS) & 0x80)); + if (!i) + printk ("SB16 sb_dsp_command01 Timeout\n"); + return sb_dsp_command (val); +} + +static int +wait_data_avail (int t) +{ + int loopc = 5000000; + + t += GET_TIME (); + do + { + if (INB (DSP_DATA_AVAIL) & 0x80) + return 1; + } + while (--loopc && GET_TIME () < t); + printk ("!data_avail l=%d\n", loopc); + return 0; +} + +static int +read_dsp (int t) +{ + if (!wait_data_avail (t)) + return -1; + else + return INB (DSP_READ); +} + +static int +dsp_ini2 (void) +{ +#if 0 + /* sb_setmixer(0x83, sb_getmixer(0x83) | 0x03); */ + sb_dsp_command (0xe2); + sb_dsp_command (0x76); /* E0 ??? */ + sb_dsp_command (0xe2); + sb_dsp_command (0x30); /* A0 ??? */ + sb_dsp_command (0xe4); + sb_dsp_command (0xaa); + sb_dsp_command (0xe8); + if (read_dsp (100) != 0xaa) + printk ("Error dsp_ini2\n"); +#endif + return 0; +} +/* + static char *dsp_getmessage(unsigned char command,int maxn) + { + static char buff[100]; + int n=0; + + sb_dsp_command(command); + while(n 44100) + mode = 44100; + dsp_current_speed = mode; + } + return mode; +} + +static int +dsp_set_stereo (int mode) +{ + DEB (printk ("dsp_set_stereo(%d)\n", mode)); + + dsp_stereo = mode; + + return mode; +} + +static int +dsp_set_bits (int arg) +{ + DEB (printk ("dsp_set_bits(%d)\n", arg)); + + if (arg) + switch (arg) + { + case 8: + dsp_16bit = 0; + break; + case 16: + dsp_16bit = 1; + break; + default: + return RET_ERROR (EINVAL); + } + return dsp_16bit ? 16 : 8; +} + +static int +sb16_dsp_ioctl (int dev, unsigned int cmd, unsigned int arg, int local) +{ + switch (cmd) + { + case SOUND_PCM_WRITE_RATE: + if (local) + return dsp_set_speed (arg); + return IOCTL_OUT (arg, dsp_set_speed (IOCTL_IN (arg))); + + case SOUND_PCM_READ_RATE: + if (local) + return dsp_current_speed; + return IOCTL_OUT (arg, dsp_current_speed); + + case SNDCTL_DSP_STEREO: + if (local) + return dsp_set_stereo (arg); + return IOCTL_OUT (arg, dsp_set_stereo (IOCTL_IN (arg))); + + case SOUND_PCM_WRITE_CHANNELS: + if (local) + return dsp_set_stereo (arg - 1) + 1; + return IOCTL_OUT (arg, dsp_set_stereo (IOCTL_IN (arg) - 1) + 1); + + case SOUND_PCM_READ_CHANNELS: + if (local) + return dsp_stereo + 1; + return IOCTL_OUT (arg, dsp_stereo + 1); + + case SNDCTL_DSP_SAMPLESIZE: + if (local) + return dsp_set_bits (arg); + return IOCTL_OUT (arg, dsp_set_bits (IOCTL_IN (arg))); + + case SOUND_PCM_READ_BITS: + if (local) + return dsp_16bit ? 16 : 8; + return IOCTL_OUT (arg, dsp_16bit ? 16 : 8); + + case SOUND_PCM_WRITE_FILTER: /* NOT YET IMPLEMENTED */ + if (IOCTL_IN (arg) > 1) + return IOCTL_OUT (arg, RET_ERROR (EINVAL)); + default: + return RET_ERROR (EINVAL); + } + + return RET_ERROR (EINVAL); +} + +static int +sb16_dsp_open (int dev, int mode) +{ + int retval; + + DEB (printk ("sb16_dsp_open()\n")); + if (!sb16_dsp_ok) + { + printk ("SB16 Error: SoundBlaster board not installed\n"); + return RET_ERROR (ENXIO); + } + + if (intr_active) + return RET_ERROR (EBUSY); + + retval = sb_get_irq (); + if (retval < 0) + return retval; + + if (ALLOC_DMA_CHN (dma8)) + { + printk ("SB16: Unable to grab DMA%d\n", dma8); + sb_free_irq (); + return RET_ERROR (EBUSY); + } + + if (dma16 != dma8) + if (ALLOC_DMA_CHN (dma16)) + { + printk ("SB16: Unable to grab DMA%d\n", dma16); + sb_free_irq (); + RELEASE_DMA_CHN (dma8); + return RET_ERROR (EBUSY); + } + + dsp_ini2 (); + + irq_mode = IMODE_NONE; + dsp_busy = 1; + + return 0; +} + +static void +sb16_dsp_close (int dev) +{ + unsigned long flags; + + DEB (printk ("sb16_dsp_close()\n")); + sb_dsp_command01 (0xd9); + sb_dsp_command01 (0xd5); + + DISABLE_INTR (flags); + RELEASE_DMA_CHN (dma8); + + if (dma16 != dma8) + RELEASE_DMA_CHN (dma16); + sb_free_irq (); + dsp_cleanup (); + dsp_busy = 0; + RESTORE_INTR (flags); +} + +static void +sb16_dsp_output_block (int dev, unsigned long buf, int count, int intrflag, int dma_restart) +{ + unsigned long flags, cnt; + + cnt = count; + if (dsp_16bit) + cnt >>= 1; + cnt--; + +#ifdef DEB_DMARES + printk ("output_block: %x %d %d\n", buf, count, intrflag); + if (intrflag) + { + int pos, chan = sound_dsp_dmachan[dev]; + + DISABLE_INTR (flags); + clear_dma_ff (chan); + disable_dma (chan); + pos = get_dma_residue (chan); + enable_dma (chan); + RESTORE_INTR (flags); + printk ("dmapos=%d %x\n", pos, pos); + } +#endif + if (sound_dma_automode[dev] && + intrflag && + cnt == dsp_count) + { + irq_mode = IMODE_OUTPUT; + intr_active = 1; + return; /* Auto mode on. No need to react */ + } + DISABLE_INTR (flags); + + if (dma_restart) + { + sb16_dsp_halt (dev); + DMAbuf_start_dma (dev, buf, count, DMA_MODE_WRITE); + } + sb_dsp_command (0x41); + sb_dsp_command ((unsigned char) ((dsp_current_speed >> 8) & 0xff)); + sb_dsp_command ((unsigned char) (dsp_current_speed & 0xff)); + sb_dsp_command ((unsigned char) (dsp_16bit ? 0xb6 : 0xc6)); + sb_dsp_command ((unsigned char) ((dsp_stereo ? 0x20 : 0) + + (dsp_16bit ? 0x10 : 0))); + sb_dsp_command01 ((unsigned char) (cnt & 0xff)); + sb_dsp_command ((unsigned char) (cnt >> 8)); + /* sb_dsp_command (0); + sb_dsp_command (0); */ + + RESTORE_INTR (flags); + dsp_count = cnt; + irq_mode = IMODE_OUTPUT; + intr_active = 1; +} + +static void +sb16_dsp_start_input (int dev, unsigned long buf, int count, int intrflag, int dma_restart) +{ + unsigned long flags, cnt; + + cnt = count; + if (dsp_16bit) + cnt >>= 1; + cnt--; + +#ifdef DEB_DMARES + printk ("start_input: %x %d %d\n", buf, count, intrflag); + if (intrflag) + { + int pos, chan = sound_dsp_dmachan[dev]; + + DISABLE_INTR (flags); + clear_dma_ff (chan); + disable_dma (chan); + pos = get_dma_residue (chan); + enable_dma (chan); + RESTORE_INTR (flags); + printk ("dmapos=%d %x\n", pos, pos); + } +#endif + if (sound_dma_automode[dev] && + intrflag && + cnt == dsp_count) + { + irq_mode = IMODE_INPUT; + intr_active = 1; + return; /* Auto mode on. No need to react */ + } + DISABLE_INTR (flags); + + if (dma_restart) + { + sb16_dsp_halt (dev); + DMAbuf_start_dma (dev, buf, count, DMA_MODE_READ); + } + + sb_dsp_command (0x42); + sb_dsp_command ((unsigned char) ((dsp_current_speed >> 8) & 0xff)); + sb_dsp_command ((unsigned char) (dsp_current_speed & 0xff)); + sb_dsp_command ((unsigned char) (dsp_16bit ? 0xbe : 0xce)); + sb_dsp_command ((unsigned char) ((dsp_stereo ? 0x20 : 0) + + (dsp_16bit ? 0x10 : 0))); + sb_dsp_command01 ((unsigned char) (cnt & 0xff)); + sb_dsp_command ((unsigned char) (cnt >> 8)); + + /* sb_dsp_command (0); + sb_dsp_command (0); */ + RESTORE_INTR (flags); + dsp_count = cnt; + irq_mode = IMODE_INPUT; + intr_active = 1; +} + +static int +sb16_dsp_prepare_for_input (int dev, int bsize, int bcount) +{ + sound_dsp_dmachan[my_dev] = dsp_16bit ? dma16 : dma8; + dsp_count = 0; + dsp_cleanup (); + return 0; +} + +static int +sb16_dsp_prepare_for_output (int dev, int bsize, int bcount) +{ + sound_dsp_dmachan[my_dev] = dsp_16bit ? dma16 : dma8; + dsp_count = 0; + dsp_cleanup (); + return 0; +} + +static void +dsp_cleanup (void) +{ + irq_mode = IMODE_NONE; + intr_active = 0; +} + +static void +sb16_dsp_reset (int dev) +{ + unsigned long flags; + + DISABLE_INTR (flags); + + sb_reset_dsp (); + dsp_cleanup (); + + RESTORE_INTR (flags); +} + +static void +sb16_dsp_halt (int dev) +{ + if (dsp_16bit) + { + sb_dsp_command01 (0xd9); + sb_dsp_command01 (0xd5); + } + else + { + sb_dsp_command01 (0xda); + sb_dsp_command01 (0xd0); + } +} + +static void +set_irq_hw (int level) +{ + int ival; + + switch (level) + { + case 5: + ival = 2; + break; + case 7: + ival = 4; + break; + case 10: + ival = 8; + break; + default: + printk ("SB16_IRQ_LEVEL %d does not exist\n", level); + return; + } + sb_setmixer (IRQ_NR, ival); +} + +long +sb16_dsp_init (long mem_start, struct address_info *hw_config) +{ + int i, major, minor; + + major = minor = 0; + sb_dsp_command (0xe1); /* Get version */ + + for (i = 1000; i; i--) + { + if (INB (DSP_DATA_AVAIL) & 0x80) + { /* wait for Data Ready */ + if (major == 0) + major = INB (DSP_READ); + else + { + minor = INB (DSP_READ); + break; + } + } + } + +#ifndef SCO + sprintf (sb16_dsp_operations.name, "SoundBlaster 16 %d.%d", major, minor); +#endif + + printk ("snd6: <%s>", sb16_dsp_operations.name); + + if (num_dspdevs < MAX_DSP_DEV) + { + dsp_devs[my_dev = num_dspdevs++] = &sb16_dsp_operations; + sound_dsp_dmachan[my_dev] = hw_config->dma; + sound_buffcounts[my_dev] = 1; + sound_buffsizes[my_dev] = DSP_BUFFSIZE; + sound_dma_automode[my_dev] = 1; + } + else + printk ("SB: Too many DSP devices available\n"); + sb16_dsp_ok = 1; + return mem_start; +} + +int +sb16_dsp_detect (struct address_info *hw_config) +{ + struct address_info *sb_config; + + if (sb16_dsp_ok) + return 1; /* Already initialized */ + + if (!(sb_config = sound_getconf (SNDCARD_SB))) + { + printk ("SB16 Error: Plain SB not configured\n"); + return 0; + } + + if (sbc_base != hw_config->io_base) + printk ("Warning! SB16 I/O != SB I/O\n"); + + /* sb_setmixer(OPSW,0xf); + if(sb_getmixer(OPSW)!=0xf) + return 0; */ + + if (!sb_reset_dsp ()) + return 0; + + if (hw_config->irq != sb_config->irq) + { + printk ("SB16 Error: Invalid IRQ number %d/%d\n", + sb_config->irq, hw_config->irq); + return 0; + } + + if (hw_config->dma < 4) + if (hw_config->dma != sb_config->dma) + { + printk ("SB16 Error: Invalid DMA channel %d/%d\n", + sb_config->dma, hw_config->dma); + return 0; + } + + dma16 = hw_config->dma; + dma8 = sb_config->dma; + set_irq_hw (hw_config->irq); + sb_setmixer (DMA_NR, (1 << hw_config->dma) | (1 << sb_config->dma)); + + DEB (printk ("SoundBlaster 16: IRQ %d DMA %d OK\n", hw_config->irq, hw_config->dma)); + +/* + dsp_showmessage(0xe3,99); + */ + sb16_dsp_ok = 1; + return 1; +} + +void +sb16_dsp_interrupt (int unused) +{ + int data; + + data = INB (DSP_DATA_AVL16); /* Interrupt acknowledge */ + + if (intr_active) + switch (irq_mode) + { + case IMODE_OUTPUT: + intr_active = 0; + DMAbuf_outputintr (my_dev, 1); + break; + + case IMODE_INPUT: + intr_active = 0; + DMAbuf_inputintr (my_dev); + break; + + default: + printk ("SoundBlaster: Unexpected interrupt\n"); + } +} +#endif diff --git a/sys/i386/isa/sound/sb16_midi.c b/sys/i386/isa/sound/sb16_midi.c new file mode 100644 index 0000000..f7a61a6 --- /dev/null +++ b/sys/i386/isa/sound/sb16_midi.c @@ -0,0 +1,314 @@ +/* + * sound/sb16_midi.c + * + * The low level driver for the MPU-401 UART emulation of the SB16. + * + * Copyright by Hannu Savolainen 1993 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sound_config.h" + +#ifdef CONFIGURE_SOUNDCARD + +#if !defined(EXCLUDE_SB) && !defined(EXCLUDE_SB16) && !defined(EXCLUDE_MIDI) + +#define DATAPORT (sb16midi_base) /* MPU-401 Data I/O Port on IBM */ +#define COMDPORT (sb16midi_base+1) /* MPU-401 Command Port on IBM */ +#define STATPORT (sb16midi_base+1) /* MPU-401 Status Port on IBM */ + +#define sb16midi_status() INB(STATPORT) +#define input_avail() (!(sb16midi_status()&INPUT_AVAIL)) +#define output_ready() (!(sb16midi_status()&OUTPUT_READY)) +#define sb16midi_cmd(cmd) OUTB(cmd, COMDPORT) +#define sb16midi_read() INB(DATAPORT) +#define sb16midi_write(byte) OUTB(byte, DATAPORT) + +#define OUTPUT_READY 0x40 /* Mask for Data Read Redy Bit */ +#define INPUT_AVAIL 0x80 /* Mask for Data Send Ready Bit */ +#define MPU_ACK 0xFE /* MPU-401 Acknowledge Response */ +#define MPU_RESET 0xFF /* MPU-401 Total Reset Command */ +#define UART_MODE_ON 0x3F /* MPU-401 "Dumb UART Mode" */ + +static int sb16midi_opened = 0; +static int sb16midi_base = 0x330; +static int sb16midi_detected = 0; +static int my_dev; + +static int reset_sb16midi (void); +static void (*midi_input_intr) (int dev, unsigned char data); + +static void +sb16midi_input_loop (void) +{ + int count; + + count = 10; + + while (count) /* Not timed out */ + if (input_avail ()) + { + unsigned char c = sb16midi_read (); + + count = 100; + + if (sb16midi_opened & OPEN_READ) + midi_input_intr (my_dev, c); + } + else + while (!input_avail () && count) + count--; +} + +void +sb16midiintr (int unit) +{ + if (input_avail ()) + sb16midi_input_loop (); +} + +/* + * It looks like there is no input interrupts in the UART mode. Let's try + * polling. + */ + +static void +poll_sb16midi (unsigned long dummy) +{ + unsigned long flags; + + DEFINE_TIMER (sb16midi_timer, poll_sb16midi); + + if (!(sb16midi_opened & OPEN_READ)) + return; /* No longer required */ + + DISABLE_INTR (flags); + + if (input_avail ()) + sb16midi_input_loop (); + + ACTIVATE_TIMER (sb16midi_timer, poll_sb16midi, 1); /* Come back later */ + + RESTORE_INTR (flags); +} + +static int +sb16midi_open (int dev, int mode, + void (*input) (int dev, unsigned char data), + void (*output) (int dev) +) +{ + if (sb16midi_opened) + { + return RET_ERROR (EBUSY); + } + + sb16midi_input_loop (); + + midi_input_intr = input; + sb16midi_opened = mode; + poll_sb16midi (0); /* Enable input polling */ + + return 0; +} + +static void +sb16midi_close (int dev) +{ + sb16midi_opened = 0; +} + +static int +sb16midi_out (int dev, unsigned char midi_byte) +{ + int timeout; + unsigned long flags; + + /* + * Test for input since pending input seems to block the output. + */ + + DISABLE_INTR (flags); + + if (input_avail ()) + sb16midi_input_loop (); + + RESTORE_INTR (flags); + + /* + * Sometimes it takes about 13000 loops before the output becomes ready + * (After reset). Normally it takes just about 10 loops. + */ + + for (timeout = 30000; timeout > 0 && !output_ready (); timeout--); /* Wait */ + + if (!output_ready ()) + { + printk ("MPU-401: Timeout\n"); + return 0; + } + + sb16midi_write (midi_byte); + return 1; +} + +static int +sb16midi_command (int dev, unsigned char midi_byte) +{ + return 1; +} + +static int +sb16midi_start_read (int dev) +{ + return 0; +} + +static int +sb16midi_end_read (int dev) +{ + return 0; +} + +static int +sb16midi_ioctl (int dev, unsigned cmd, unsigned arg) +{ + return RET_ERROR (EINVAL); +} + +static void +sb16midi_kick (int dev) +{ +} + +static int +sb16midi_buffer_status (int dev) +{ + return 0; /* No data in buffers */ +} + +static struct midi_operations sb16midi_operations = +{ + {"SoundBlaster MPU-401", 0, 0, SNDCARD_SB16MIDI}, + sb16midi_open, + sb16midi_close, + sb16midi_ioctl, + sb16midi_out, + sb16midi_start_read, + sb16midi_end_read, + sb16midi_kick, + sb16midi_command, + sb16midi_buffer_status +}; + + +long +attach_sb16midi (long mem_start, struct address_info *hw_config) +{ + int ok, timeout; + unsigned long flags; + + sb16midi_base = hw_config->io_base; + + if (!sb16midi_detected) + return RET_ERROR (EIO); + + DISABLE_INTR (flags); + for (timeout = 30000; timeout < 0 && !output_ready (); timeout--); /* Wait */ + sb16midi_cmd (UART_MODE_ON); + + ok = 0; + for (timeout = 50000; timeout > 0 && !ok; timeout--) + if (input_avail ()) + if (sb16midi_read () == MPU_ACK) + ok = 1; + + RESTORE_INTR (flags); + + printk ("snd7: "); + + my_dev = num_midis; + midi_devs[num_midis++] = &sb16midi_operations; + return mem_start; +} + +static int +reset_sb16midi (void) +{ + unsigned long flags; + int ok, timeout, n; + + /* + * Send the RESET command. Try again if no success at the first time. + */ + + ok = 0; + + DISABLE_INTR (flags); + + for (n = 0; n < 2 && !ok; n++) + { + for (timeout = 30000; timeout < 0 && !output_ready (); timeout--); /* Wait */ + sb16midi_cmd (MPU_RESET); /* Send MPU-401 RESET Command */ + + /* + * Wait at least 25 msec. This method is not accurate so let's make the + * loop bit longer. Cannot sleep since this is called during boot. + */ + + for (timeout = 50000; timeout > 0 && !ok; timeout--) + if (input_avail ()) + if (sb16midi_read () == MPU_ACK) + ok = 1; + + } + + sb16midi_opened = 0; + if (ok) + sb16midi_input_loop (); /* Flush input before enabling interrupts */ + + RESTORE_INTR (flags); + + return ok; +} + + +int +probe_sb16midi (struct address_info *hw_config) +{ + int ok = 0; + + sb16midi_base = hw_config->io_base; + + if (sb_get_irq () < 0) + return 0; + + ok = reset_sb16midi (); + + sb16midi_detected = ok; + return ok; +} + +#endif + +#endif diff --git a/sys/i386/isa/sound/sb_midi.c b/sys/i386/isa/sound/sb_midi.c new file mode 100644 index 0000000..2b0ab52 --- /dev/null +++ b/sys/i386/isa/sound/sb_midi.c @@ -0,0 +1,198 @@ +/* + * sound/sb_dsp.c + * + * The low level driver for the SoundBlaster DS chips. + * + * Copyright by Hannu Savolainen 1993 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sound_config.h" + +#if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_SB) && !defined(EXCLUDE_MIDI) + +#include "sb.h" +#undef SB_TEST_IRQ + +/* + * The DSP channel can be used either for input or output. Variable + * 'sb_irq_mode' will be set when the program calls read or write first time + * after open. Current version doesn't support mode changes without closing + * and reopening the device. Support for this feature may be implemented in a + * future version of this driver. + */ + +extern int sb_dsp_ok; /* Set to 1 after successful initialization */ + +extern int sb_midi_mode; +extern int sb_midi_busy; /* 1 if the process has output to MIDI */ +extern int sb_dsp_busy; +extern int sb_dsp_highspeed; + +extern volatile int sb_irq_mode; /* IMODE_INPUT, IMODE_OUTPUT + + * or IMODE_NONE */ +extern int sb_dsp_model; /* 1=SB, 2=SB Pro */ +extern int sb_duplex_midi; +extern int sb_intr_active; + +static int +sb_midi_open (int dev, int mode, + void (*input) (int dev, unsigned char data), + void (*output) (int dev) +) +{ + int ret; + + if (!sb_dsp_ok) + { + printk ("SB Error: MIDI hardware not installed\n"); + return RET_ERROR (ENXIO); + } + + if (mode != OPEN_WRITE && !sb_duplex_midi) + { + if (num_midis == 1) + printk ("SoundBlaster: Midi input not currently supported\n"); + return RET_ERROR (EPERM); + } + + sb_midi_mode = NORMAL_MIDI; + if (mode != OPEN_WRITE) + { + if (sb_dsp_busy || sb_intr_active) + return RET_ERROR (EBUSY); + sb_midi_mode = UART_MIDI; + } + + if (sb_dsp_highspeed) + { + printk ("SB Error: Midi output not possible during stereo or high speed audio\n"); + return RET_ERROR (EBUSY); + } + + if (sb_midi_mode == UART_MIDI) + { + sb_irq_mode = IMODE_MIDI; + + sb_reset_dsp (); + + if (!sb_dsp_command (0x35)) + return RET_ERROR (EIO); /* Enter the UART mode */ + sb_intr_active = 1; + + if ((ret = sb_get_irq ()) < 0) + { + sb_reset_dsp (); + return 0; /* IRQ not free */ + } + } + + sb_midi_busy = 1; + + return 0; +} + +static void +sb_midi_close (int dev) +{ + if (sb_midi_mode == UART_MIDI) + { + sb_reset_dsp (); /* The only way to kill the UART mode */ + sb_free_irq (); + } + sb_intr_active = 0; + sb_midi_busy = 0; +} + +static int +sb_midi_out (int dev, unsigned char midi_byte) +{ + unsigned long flags; + + sb_midi_busy = 1; /* Kill all notes after close */ + + if (sb_midi_mode == NORMAL_MIDI) + { + DISABLE_INTR (flags); + if (sb_dsp_command (0x38)) + sb_dsp_command (midi_byte); + else + printk ("SB Error: Unable to send a MIDI byte\n"); + RESTORE_INTR (flags); + } + else + sb_dsp_command (midi_byte); /* UART write */ + + return 1; +} + +static int +sb_midi_start_read (int dev) +{ + if (sb_midi_mode != UART_MIDI) + { + printk ("SoundBlaster: MIDI input not implemented.\n"); + return RET_ERROR (EPERM); + } + return 0; +} + +static int +sb_midi_end_read (int dev) +{ + if (sb_midi_mode == UART_MIDI) + { + sb_reset_dsp (); + sb_intr_active = 0; + } + return 0; +} + +static int +sb_midi_ioctl (int dev, unsigned cmd, unsigned arg) +{ + return RET_ERROR (EPERM); +} + +static struct midi_operations sb_midi_operations = +{ + {"SoundBlaster", 0, 0, SNDCARD_SB}, + sb_midi_open, + sb_midi_close, + sb_midi_ioctl, + sb_midi_out, + sb_midi_start_read, + sb_midi_end_read, + NULL, /* Kick */ + NULL, /* command */ + NULL /* buffer_status */ +}; + +void +sb_midi_init (int model) +{ + midi_devs[num_midis++] = &sb_midi_operations; +} + +#endif diff --git a/sys/i386/isa/sound/sb_mixer.c b/sys/i386/isa/sound/sb_mixer.c new file mode 100644 index 0000000..089a2af --- /dev/null +++ b/sys/i386/isa/sound/sb_mixer.c @@ -0,0 +1,359 @@ + +/* + * sound/sb_mixer.c + * + * The low level mixer driver for the SoundBlaster Pro and SB16 cards. + * + * Copyright by Hannu Savolainen 1993 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sound_config.h" + +#if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_SB) && !defined(EXCLUDE_SBPRO) +#define __SB_MIXER_C__ + +#include "sb.h" +#include "sb_mixer.h" +#undef SB_TEST_IRQ + +extern int sbc_base; + +static int mixer_initialized = 0; + +static int supported_rec_devices; +static int supported_devices; +static int recmask = 0; +static int mixer_model; +static int mixer_caps; +static mixer_tab *iomap; + +void +sb_setmixer (unsigned int port, unsigned int value) +{ + unsigned long flags; + + DISABLE_INTR (flags); + OUTB ((unsigned char) (port & 0xff), MIXER_ADDR); /* Select register */ + tenmicrosec (); + OUTB ((unsigned char) (value & 0xff), MIXER_DATA); + tenmicrosec (); + RESTORE_INTR (flags); +} + +int +sb_getmixer (unsigned int port) +{ + int val; + unsigned long flags; + + DISABLE_INTR (flags); + OUTB ((unsigned char) (port & 0xff), MIXER_ADDR); /* Select register */ + tenmicrosec (); + val = INB (MIXER_DATA); + tenmicrosec (); + RESTORE_INTR (flags); + + return val; +} + +void +sb_mixer_set_stereo (int mode) +{ + if (!mixer_initialized) + return; + + sb_setmixer (OUT_FILTER, ((sb_getmixer (OUT_FILTER) & ~STEREO_DAC) + | (mode ? STEREO_DAC : MONO_DAC))); +} + +static int +detect_mixer (void) +{ + /* + * Detect the mixer by changing parameters of two volume channels. If the + * values read back match with the values written, the mixer is there (is + * it?) + */ + sb_setmixer (FM_VOL, 0xff); + sb_setmixer (VOC_VOL, 0x33); + + if (sb_getmixer (FM_VOL) != 0xff) + return 0; /* No match */ + if (sb_getmixer (VOC_VOL) != 0x33) + return 0; + + return 1; +} + +static void +change_bits (unsigned char *regval, int dev, int chn, int newval) +{ + unsigned char mask; + int shift; + + mask = (1 << (*iomap)[dev][chn].nbits) - 1; + newval = ((newval * mask) + 50) / 100; /* Scale it */ + + shift = (*iomap)[dev][chn].bitoffs - (*iomap)[dev][LEFT_CHN].nbits + 1; + + *regval &= ~(mask << shift); /* Filter out the previous value */ + *regval |= (newval & mask) << shift; /* Set the new value */ +} + +static int +sb_mixer_get (int dev) +{ + if (!((1 << dev) & supported_devices)) + return RET_ERROR (EINVAL); + + return levels[dev]; +} + +static int +sb_mixer_set (int dev, int value) +{ + int left = value & 0x000000ff; + int right = (value & 0x0000ff00) >> 8; + + int regoffs; + unsigned char val; + + if (left > 100) + left = 100; + if (right > 100) + right = 100; + + if (dev > 31) + return RET_ERROR (EINVAL); + + if (!(supported_devices & (1 << dev))) /* Not supported */ + return RET_ERROR (EINVAL); + + regoffs = (*iomap)[dev][LEFT_CHN].regno; + + if (regoffs == 0) + return RET_ERROR (EINVAL); + + val = sb_getmixer (regoffs); + change_bits (&val, dev, LEFT_CHN, left); + + levels[dev] = left | (left << 8); + + if ((*iomap)[dev][RIGHT_CHN].regno != regoffs) /* Change register */ + { + sb_setmixer (regoffs, val); /* Save the old one */ + regoffs = (*iomap)[dev][RIGHT_CHN].regno; + + if (regoffs == 0) + return left | (left << 8); /* Just left channel present */ + + val = sb_getmixer (regoffs); /* Read the new one */ + } + + change_bits (&val, dev, RIGHT_CHN, right); + sb_setmixer (regoffs, val); + + levels[dev] = left | (right << 8); + return left | (right << 8); +} + +static void +set_recsrc (int src) +{ + sb_setmixer (RECORD_SRC, (sb_getmixer (RECORD_SRC) & ~7) | (src & 0x7)); +} + +static int +set_recmask (int mask) +{ + int devmask, i; + unsigned char regimageL, regimageR; + + devmask = mask & supported_rec_devices; + + switch (mixer_model) + { + case 3: + + if (devmask != SOUND_MASK_MIC && + devmask != SOUND_MASK_LINE && + devmask != SOUND_MASK_CD) + { /* More than one devices selected. Drop the + * previous selection */ + devmask &= ~recmask; + } + + if (devmask != SOUND_MASK_MIC && + devmask != SOUND_MASK_LINE && + devmask != SOUND_MASK_CD) + { /* More than one devices selected. Default to + * mic */ + devmask = SOUND_MASK_MIC; + } + + + if (devmask ^ recmask) /* Input source changed */ + { + switch (devmask) + { + + case SOUND_MASK_MIC: + set_recsrc (SRC_MIC); + break; + + case SOUND_MASK_LINE: + set_recsrc (SRC_LINE); + break; + + case SOUND_MASK_CD: + set_recsrc (SRC_CD); + break; + + default: + set_recsrc (SRC_MIC); + } + } + + break; + + case 4: + if (!devmask) + devmask = SOUND_MASK_MIC; + + regimageL = regimageR = 0; + for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) + if ((1 << i) & devmask) + { + regimageL |= sb16_recmasks_L[i]; + regimageR |= sb16_recmasks_R[i]; + } + sb_setmixer (SB16_IMASK_L, regimageL); + sb_setmixer (SB16_IMASK_R, regimageR); + break; + } + + recmask = devmask; + return recmask; +} + +static int +sb_mixer_ioctl (int dev, unsigned int cmd, unsigned int arg) +{ + if (((cmd >> 8) & 0xff) == 'M') + { + if (cmd & IOC_IN) + switch (cmd & 0xff) + { + case SOUND_MIXER_RECSRC: + return IOCTL_OUT (arg, set_recmask (IOCTL_IN (arg))); + break; + + default: + return IOCTL_OUT (arg, sb_mixer_set (cmd & 0xff, IOCTL_IN (arg))); + } + else + switch (cmd & 0xff) /* Return parameters */ + { + + case SOUND_MIXER_RECSRC: + return IOCTL_OUT (arg, recmask); + break; + + case SOUND_MIXER_DEVMASK: + return IOCTL_OUT (arg, supported_devices); + break; + + case SOUND_MIXER_STEREODEVS: + return IOCTL_OUT (arg, supported_devices & + ~(SOUND_MASK_MIC | SOUND_MASK_SPEAKER)); + break; + + case SOUND_MIXER_RECMASK: + return IOCTL_OUT (arg, supported_rec_devices); + break; + + case SOUND_MIXER_CAPS: + return IOCTL_OUT (arg, mixer_caps); + break; + + default: + return IOCTL_OUT (arg, sb_mixer_get (cmd & 0xff)); + } + } + else + return RET_ERROR (EINVAL); +} + +static struct mixer_operations sb_mixer_operations = +{ + sb_mixer_ioctl +}; + +static void +sb_mixer_reset (void) +{ + int i; + + for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) + sb_mixer_set (i, levels[i]); + set_recmask (SOUND_MASK_MIC); +} + +void +sb_mixer_init (int major_model) +{ + sb_setmixer (0x00, 0); /* Reset mixer */ + + if (!detect_mixer ()) + return; /* No mixer. Why? */ + + mixer_initialized = 1; + mixer_model = major_model; + + switch (major_model) + { + case 3: + mixer_caps = SOUND_CAP_EXCL_INPUT; + supported_devices = SBPRO_MIXER_DEVICES; + supported_rec_devices = SBPRO_RECORDING_DEVICES; + iomap = &sbpro_mix; + break; + + case 4: + mixer_caps = 0; + supported_devices = SB16_MIXER_DEVICES; + supported_rec_devices = SB16_RECORDING_DEVICES; + iomap = &sb16_mix; + break; + + default: + printk ("SB Warning: Unsupported mixer type\n"); + return; + } + + mixer_devs[num_mixers++] = &sb_mixer_operations; + sb_mixer_reset (); +} + +#endif diff --git a/sys/i386/isa/sound/sb_mixer.h b/sys/i386/isa/sound/sb_mixer.h new file mode 100644 index 0000000..304af642 --- /dev/null +++ b/sys/i386/isa/sound/sb_mixer.h @@ -0,0 +1,172 @@ +/* + * sound/sb_mixer.h + * + * Definitions for the SB Pro and SB16 mixers + * + * Copyright by Hannu Savolainen 1993 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ +#define SBPRO_RECORDING_DEVICES (SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD) + +#define SBPRO_MIXER_DEVICES (SOUND_MASK_SYNTH | SOUND_MASK_PCM | SOUND_MASK_LINE | SOUND_MASK_MIC | \ + SOUND_MASK_CD | SOUND_MASK_VOLUME) + +#define SB16_RECORDING_DEVICES (SOUND_MASK_SYNTH | SOUND_MASK_LINE | SOUND_MASK_MIC | \ + SOUND_MASK_CD) + +#define SB16_MIXER_DEVICES (SOUND_MASK_SYNTH | SOUND_MASK_PCM | SOUND_MASK_SPEAKER | SOUND_MASK_LINE | SOUND_MASK_MIC | \ + SOUND_MASK_CD | SOUND_MASK_RECLEV | \ + SOUND_MASK_VOLUME | SOUND_MASK_BASS | SOUND_MASK_TREBLE) + +/* + * Mixer registers + * + * NOTE! RECORD_SRC == IN_FILTER + */ + +/* + * Mixer registers of SB Pro + */ +#define VOC_VOL 0x04 +#define MIC_VOL 0x0A +#define MIC_MIX 0x0A +#define RECORD_SRC 0x0C +#define IN_FILTER 0x0C +#define OUT_FILTER 0x0E +#define MASTER_VOL 0x22 +#define FM_VOL 0x26 +#define CD_VOL 0x28 +#define LINE_VOL 0x2E +#define IRQ_NR 0x80 +#define DMA_NR 0x81 +#define IRQ_STAT 0x82 +#define OPSW 0x3c + +#define FREQ_HI (1 << 3)/* Use High-frequency ANFI filters */ +#define FREQ_LOW 0 /* Use Low-frequency ANFI filters */ +#define FILT_ON 0 /* Yes, 0 to turn it on, 1 for off */ +#define FILT_OFF (1 << 5) + +#define MONO_DAC 0x00 +#define STEREO_DAC 0x02 + +/* + * Mixer registers of SB16 + */ +#define SB16_IMASK_L 0x3d +#define SB16_IMASK_R 0x3e + +#define LEFT_CHN 0 +#define RIGHT_CHN 1 + +struct mixer_def { + unsigned int regno: 8; + unsigned int bitoffs:4; + unsigned int nbits:4; +}; + + +typedef struct mixer_def mixer_tab[32][2]; +typedef struct mixer_def mixer_ent; + +#define MIX_ENT(name, reg_l, bit_l, len_l, reg_r, bit_r, len_r) \ + {{reg_l, bit_l, len_l}, {reg_r, bit_r, len_r}} + +#ifdef __SB_MIXER_C__ +mixer_tab sbpro_mix = { +MIX_ENT(SOUND_MIXER_VOLUME, 0x22, 7, 4, 0x22, 3, 4), +MIX_ENT(SOUND_MIXER_BASS, 0x00, 0, 0, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_TREBLE, 0x00, 0, 0, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_SYNTH, 0x26, 7, 4, 0x26, 3, 4), +MIX_ENT(SOUND_MIXER_PCM, 0x04, 7, 4, 0x04, 3, 4), +MIX_ENT(SOUND_MIXER_SPEAKER, 0x00, 0, 0, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_LINE, 0x2e, 7, 4, 0x2e, 3, 4), +MIX_ENT(SOUND_MIXER_MIC, 0x0a, 2, 3, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_CD, 0x28, 7, 4, 0x28, 3, 4), +MIX_ENT(SOUND_MIXER_IMIX, 0x00, 0, 0, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_ALTPCM, 0x00, 0, 0, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_RECLEV, 0x00, 0, 0, 0x00, 0, 0) +}; + +mixer_tab sb16_mix = { +MIX_ENT(SOUND_MIXER_VOLUME, 0x30, 7, 5, 0x31, 7, 5), +MIX_ENT(SOUND_MIXER_BASS, 0x46, 7, 4, 0x47, 7, 4), +MIX_ENT(SOUND_MIXER_TREBLE, 0x44, 7, 4, 0x45, 7, 4), +MIX_ENT(SOUND_MIXER_SYNTH, 0x34, 7, 5, 0x35, 7, 5), +MIX_ENT(SOUND_MIXER_PCM, 0x32, 7, 5, 0x33, 7, 5), +MIX_ENT(SOUND_MIXER_SPEAKER, 0x3b, 7, 2, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_LINE, 0x38, 7, 5, 0x39, 7, 5), +MIX_ENT(SOUND_MIXER_MIC, 0x3a, 7, 5, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_CD, 0x36, 7, 5, 0x37, 7, 5), +MIX_ENT(SOUND_MIXER_IMIX, 0x00, 0, 0, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_ALTPCM, 0x00, 0, 0, 0x00, 0, 0), +MIX_ENT(SOUND_MIXER_RECLEV, 0x3f, 7, 2, 0x40, 7, 2) +}; + +static unsigned short levels[SOUND_MIXER_NRDEVICES] = +{ + 0x5a5a, /* Master Volume */ + 0x3232, /* Bass */ + 0x3232, /* Treble */ + 0x4b4b, /* FM */ + 0x4b4b, /* PCM */ + 0x4b4b, /* PC Speaker */ + 0x4b4b, /* Ext Line */ + 0x0000, /* Mic */ + 0x4b4b, /* CD */ + 0x4b4b, /* Recording monitor */ + 0x4b4b, /* SB PCM */ + 0x4b4b}; /* Recording level */ + +static unsigned char sb16_recmasks_L[SOUND_MIXER_NRDEVICES] = +{ + 0x00, /* SOUND_MIXER_VOLUME */ + 0x00, /* SOUND_MIXER_BASS */ + 0x00, /* SOUND_MIXER_TREBLE */ + 0x40, /* SOUND_MIXER_SYNTH */ + 0x00, /* SOUND_MIXER_PCM */ + 0x00, /* SOUND_MIXER_SPEAKER */ + 0x10, /* SOUND_MIXER_LINE */ + 0x01, /* SOUND_MIXER_MIC */ + 0x04, /* SOUND_MIXER_CD */ + 0x00, /* SOUND_MIXER_IMIX */ + 0x00, /* SOUND_MIXER_ALTPCM */ + 0x00 /* SOUND_MIXER_RECLEV */ +}; + +static unsigned char sb16_recmasks_R[SOUND_MIXER_NRDEVICES] = +{ + 0x00, /* SOUND_MIXER_VOLUME */ + 0x00, /* SOUND_MIXER_BASS */ + 0x00, /* SOUND_MIXER_TREBLE */ + 0x20, /* SOUND_MIXER_SYNTH */ + 0x00, /* SOUND_MIXER_PCM */ + 0x00, /* SOUND_MIXER_SPEAKER */ + 0x08, /* SOUND_MIXER_LINE */ + 0x01, /* SOUND_MIXER_MIC */ + 0x02, /* SOUND_MIXER_CD */ + 0x00, /* SOUND_MIXER_IMIX */ + 0x00, /* SOUND_MIXER_ALTPCM */ + 0x00 /* SOUND_MIXER_RECLEV */ +}; +#endif diff --git a/sys/i386/isa/sound/sound_switch.c b/sys/i386/isa/sound/sound_switch.c new file mode 100644 index 0000000..52120d5 --- /dev/null +++ b/sys/i386/isa/sound/sound_switch.c @@ -0,0 +1,444 @@ +/* + * sound/sound_switch.c + * + * The system call switch + * + * Copyright by Hannu Savolainen 1993 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sound_config.h" + +#ifdef CONFIGURE_SOUNDCARD + +struct sbc_device + { + int usecount; + }; + +static struct sbc_device sbc_devices[SND_NDEVS] = +{ + {0}}; + +static int in_use = 0; /* Total # of open device files (excluding + + * minor 0) */ + +/* + * /dev/sndstatus -device + */ +static char *status_buf = NULL; +static int status_len, status_ptr; +static int status_busy = 0; + +static int +put_status (char *s) +{ + int l; + + for (l = 0; l < 256, s[l]; l++); /* l=strlen(s); */ + + if (status_len + l >= 4000) + return 0; + + memcpy (&status_buf[status_len], s, l); + status_len += l; + + return 1; +} + +static int +put_status_int (unsigned int val, int radix) +{ + int l, v; + + static char hx[] = "0123456789abcdef"; + char buf[11]; + + if (!val) + return put_status ("0"); + + l = 0; + buf[10] = 0; + + while (val) + { + v = val % radix; + val = val / radix; + + buf[9 - l] = hx[v]; + l++; + } + + if (status_len + l >= 4000) + return 0; + + memcpy (&status_buf[status_len], &buf[10 - l], l); + status_len += l; + + return 1; +} + +static void +init_status (void) +{ + /* + * Write the status information to the status_buf and update status_len. + * There is a limit of 4000 bytes for the data. + */ + + int i; + + status_ptr = 0; + + put_status ("Sound Driver:" SOUND_VERSION_STRING + " (" SOUND_CONFIG_DATE " " SOUND_CONFIG_BY "@" + SOUND_CONFIG_HOST "." SOUND_CONFIG_DOMAIN ")" + "\n"); + + if (!put_status ("Config options: ")) + return; + if (!put_status_int (SELECTED_SOUND_OPTIONS, 16)) + return; + + if (!put_status ("\n\nHW config: \n")) + return; + + for (i = 0; i < (num_sound_drivers - 1); i++) + { + if (!supported_drivers[i].enabled) + if (!put_status ("(")) + return; + + if (!put_status ("Type ")) + return; + if (!put_status_int (supported_drivers[i].card_type, 10)) + return; + if (!put_status (": ")) + return; + if (!put_status (supported_drivers[i].name)) + return; + if (!put_status (" at 0x")) + return; + if (!put_status_int (supported_drivers[i].config.io_base, 16)) + return; + if (!put_status (" irq ")) + return; + if (!put_status_int (supported_drivers[i].config.irq, 10)) + return; + if (!put_status (" drq ")) + return; + if (!put_status_int (supported_drivers[i].config.dma, 10)) + return; + + if (!supported_drivers[i].enabled) + if (!put_status (")")) + return; + + if (!put_status ("\n")) + return; + } + + if (!put_status ("\nPCM devices:\n")) + return; + + for (i = 0; i < num_dspdevs; i++) + { + if (!put_status_int (i, 10)) + return; + if (!put_status (": ")) + return; + if (!put_status (dsp_devs[i]->name)) + return; + if (!put_status ("\n")) + return; + } + + if (!put_status ("\nSynth devices:\n")) + return; + + for (i = 0; i < num_synths; i++) + { + if (!put_status_int (i, 10)) + return; + if (!put_status (": ")) + return; + if (!put_status (synth_devs[i]->info->name)) + return; + if (!put_status ("\n")) + return; + } + + if (!put_status ("\nMidi devices:\n")) + return; + + for (i = 0; i < num_midis; i++) + { + if (!put_status_int (i, 10)) + return; + if (!put_status (": ")) + return; + if (!put_status (midi_devs[i]->info.name)) + return; + if (!put_status ("\n")) + return; + } + + if (num_mixers) + { + if (!put_status ("\nMixer(s) installed\n")) + return; + } + else + { + if (!put_status ("\nNo mixers installed\n")) + return; + } +} + +static int +read_status (snd_rw_buf * buf, int count) +{ + /* + * Return at most 'count' bytes from the status_buf. + */ + int l, c; + + l = count; + c = status_len - status_ptr; + + if (l > c) + l = c; + if (l <= 0) + return 0; + + COPY_TO_USER (buf, 0, &status_buf[status_ptr], l); + status_ptr += l; + + return l; +} + +int +sound_read_sw (int dev, struct fileinfo *file, snd_rw_buf * buf, int count) +{ + DEB (printk ("sound_read_sw(dev=%d, count=%d)\n", dev, count)); + + switch (dev & 0x0f) + { + case SND_DEV_STATUS: + return read_status (buf, count); + break; + + case SND_DEV_DSP: + case SND_DEV_DSP16: + case SND_DEV_AUDIO: + return audio_read (dev, file, buf, count); + break; + + case SND_DEV_SEQ: + return sequencer_read (dev, file, buf, count); + break; + +#ifndef EXCLUDE_MPU401 + case SND_DEV_MIDIN: + return MIDIbuf_read (dev, file, buf, count); +#endif + + default: + printk ("Sound: Undefined minor device %d\n", dev); + } + + return RET_ERROR (EPERM); +} + +int +sound_write_sw (int dev, struct fileinfo *file, snd_rw_buf * buf, int count) +{ + + DEB (printk ("sound_write_sw(dev=%d, count=%d)\n", dev, count)); + + switch (dev & 0x0f) + { + + case SND_DEV_SEQ: + return sequencer_write (dev, file, buf, count); + break; + + case SND_DEV_DSP: + case SND_DEV_DSP16: + case SND_DEV_AUDIO: + return audio_write (dev, file, buf, count); + break; + + default: + return RET_ERROR (EPERM); + } + + return count; +} + +int +sound_open_sw (int dev, struct fileinfo *file) +{ + int retval; + + DEB (printk ("sound_open_sw(dev=%d) : usecount=%d\n", dev, sbc_devices[dev].usecount)); + + if ((dev >= SND_NDEVS) || (dev < 0)) + { + printk ("Invalid minor device %d\n", dev); + return RET_ERROR (ENXIO); + } + + switch (dev & 0x0f) + { + case SND_DEV_STATUS: + if (status_busy) + return RET_ERROR (EBUSY); + status_busy = 1; + if ((status_buf = (char *) KERNEL_MALLOC (4000)) == NULL) + return RET_ERROR (EIO); + status_len = status_ptr = 0; + init_status (); + break; + + case SND_DEV_CTL: + return 0; + break; + + case SND_DEV_SEQ: + if ((retval = sequencer_open (dev, file)) < 0) + return retval; + break; + +#ifndef EXCLUDE_MPU401 + case SND_DEV_MIDIN: + if ((retval = MIDIbuf_open (dev, file)) < 0) + return retval; + break; +#endif + + case SND_DEV_DSP: + case SND_DEV_DSP16: + case SND_DEV_AUDIO: + if ((retval = audio_open (dev, file)) < 0) + return retval; + break; + + default: + printk ("Invalid minor device %d\n", dev); + return RET_ERROR (ENXIO); + } + + sbc_devices[dev].usecount++; + in_use++; + + return 0; +} + +void +sound_release_sw (int dev, struct fileinfo *file) +{ + + DEB (printk ("sound_release_sw(dev=%d)\n", dev)); + + switch (dev & 0x0f) + { + case SND_DEV_STATUS: + if (status_buf) + KERNEL_FREE (status_buf); + status_buf = NULL; + status_busy = 0; + break; + + case SND_DEV_CTL: + break; + + case SND_DEV_SEQ: + sequencer_release (dev, file); + break; + +#ifndef EXCLUDE_MPU401 + case SND_DEV_MIDIN: + MIDIbuf_release (dev, file); + break; +#endif + + case SND_DEV_DSP: + case SND_DEV_DSP16: + case SND_DEV_AUDIO: + audio_release (dev, file); + break; + + default: + printk ("Sound error: Releasing unknown device 0x%02x\n", dev); + } + + sbc_devices[dev].usecount--; + in_use--; +} + +int +sound_ioctl_sw (int dev, struct fileinfo *file, + unsigned int cmd, unsigned long arg) +{ + DEB (printk ("sound_ioctl_sw(dev=%d, cmd=0x%x, arg=0x%x)\n", dev, cmd, arg)); + + switch (dev & 0x0f) + { + + case SND_DEV_CTL: + + if (!num_mixers) + return RET_ERROR (ENXIO); + + if ((dev >> 4) >= num_mixers) + return RET_ERROR (ENXIO); + + return mixer_devs[dev >> 4]->ioctl (dev >> 4, cmd, arg); + break; + + case SND_DEV_SEQ: + return sequencer_ioctl (dev, file, cmd, arg); + break; + + case SND_DEV_DSP: + case SND_DEV_DSP16: + case SND_DEV_AUDIO: + return audio_ioctl (dev, file, cmd, arg); + break; + +#ifndef EXCLUDE_MPU401 + case SND_DEV_MIDIN: + return MIDIbuf_ioctl (dev, file, cmd, arg); + break; +#endif + + default: + return RET_ERROR (EPERM); + break; + } + + return RET_ERROR (EPERM); +} +#endif diff --git a/sys/i386/isa/spkr.c b/sys/i386/isa/spkr.c deleted file mode 100644 index 7b82f16..0000000 --- a/sys/i386/isa/spkr.c +++ /dev/null @@ -1,523 +0,0 @@ -/* - * spkr.c -- device driver for console speaker on 80386 - * - * v1.1 by Eric S. Raymond (esr@snark.thyrsus.com) Feb 1990 - * modified for 386bsd by Andrew A. Chernov - * 386bsd only clean version, all SYSV stuff removed - * use hz value from param.c - * - * $Id$ - */ - -#include "speaker.h" - -#if NSPEAKER > 0 - -#include "param.h" -#include "systm.h" -#include "kernel.h" -#include "errno.h" -#include "buf.h" -#include "uio.h" -#include "spkr.h" - -/**************** MACHINE DEPENDENT PART STARTS HERE ************************* - * - * This section defines a function tone() which causes a tone of given - * frequency and duration from the 80x86's console speaker. - * Another function endtone() is defined to force sound off, and there is - * also a rest() entry point to do pauses. - * - * Audible sound is generated using the Programmable Interval Timer (PIT) and - * Programmable Peripheral Interface (PPI) attached to the 80x86's speaker. The - * PPI controls whether sound is passed through at all; the PIT's channel 2 is - * used to generate clicks (a square wave) of whatever frequency is desired. - */ - -/* - * PIT and PPI port addresses and control values - * - * Most of the magic is hidden in the TIMER_PREP value, which selects PIT - * channel 2, frequency LSB first, square-wave mode and binary encoding. - * The encoding is as follows: - * - * +----------+----------+---------------+-----+ - * | 1 0 | 1 1 | 0 1 1 | 0 | - * | SC1 SC0 | RW1 RW0 | M2 M1 M0 | BCD | - * +----------+----------+---------------+-----+ - * Counter Write Mode 3 Binary - * Channel 2 LSB first, (Square Wave) Encoding - * MSB second - */ -#define PPI 0x61 /* port of Programmable Peripheral Interface */ -#define PPI_SPKR 0x03 /* turn these PPI bits on to pass sound */ -#define PIT_CTRL 0x43 /* PIT control address */ -#define PIT_COUNT 0x42 /* PIT count address */ -#define PIT_MODE 0xB6 /* set timer mode for sound generation */ - -/* - * Magic numbers for timer control. - */ -#define TIMER_CLK 1193180L /* corresponds to 18.2 MHz tick rate */ - -static int endtone() -/* turn off the speaker, ending current tone */ -{ - wakeup((caddr_t)endtone); - outb(PPI, inb(PPI) & ~PPI_SPKR); -} - -static void tone(hz, ticks) -/* emit tone of frequency hz for given number of ticks */ -unsigned int hz, ticks; -{ - unsigned int divisor = TIMER_CLK / hz; - int sps; - -#ifdef DEBUG - printf("tone: hz=%d ticks=%d\n", hz, ticks); -#endif /* DEBUG */ - - /* set timer to generate clicks at given frequency in Hertz */ - sps = spltty(); - outb(PIT_CTRL, PIT_MODE); /* prepare timer */ - outb(PIT_COUNT, (unsigned char) divisor); /* send lo byte */ - outb(PIT_COUNT, (divisor >> 8)); /* send hi byte */ - splx(sps); - - /* turn the speaker on */ - outb(PPI, inb(PPI) | PPI_SPKR); - - /* - * Set timeout to endtone function, then give up the timeslice. - * This is so other processes can execute while the tone is being - * emitted. - */ - timeout((caddr_t)endtone, (caddr_t)NULL, ticks); - sleep((caddr_t)endtone, PZERO - 1); -} - -static int endrest() -/* end a rest */ -{ - wakeup((caddr_t)endrest); -} - -static void rest(ticks) -/* rest for given number of ticks */ -int ticks; -{ - /* - * Set timeout to endrest function, then give up the timeslice. - * This is so other processes can execute while the rest is being - * waited out. - */ -#ifdef DEBUG - printf("rest: %d\n", ticks); -#endif /* DEBUG */ - timeout((caddr_t)endrest, (caddr_t)NULL, ticks); - sleep((caddr_t)endrest, PZERO - 1); -} - -/**************** PLAY STRING INTERPRETER BEGINS HERE ********************** - * - * Play string interpretation is modelled on IBM BASIC 2.0's PLAY statement; - * M[LNS] are missing and the ~ synonym and octave-tracking facility is added. - * Requires tone(), rest(), and endtone(). String play is not interruptible - * except possibly at physical block boundaries. - */ - -typedef int bool; -#define TRUE 1 -#define FALSE 0 - -#define toupper(c) ((c) - ' ' * (((c) >= 'a') && ((c) <= 'z'))) -#define isdigit(c) (((c) >= '0') && ((c) <= '9')) -#define dtoi(c) ((c) - '0') - -static int octave; /* currently selected octave */ -static int whole; /* whole-note time at current tempo, in ticks */ -static int value; /* whole divisor for note time, quarter note = 1 */ -static int fill; /* controls spacing of notes */ -static bool octtrack; /* octave-tracking on? */ -static bool octprefix; /* override current octave-tracking state? */ - -/* - * Magic number avoidance... - */ -#define SECS_PER_MIN 60 /* seconds per minute */ -#define WHOLE_NOTE 4 /* quarter notes per whole note */ -#define MIN_VALUE 64 /* the most we can divide a note by */ -#define DFLT_VALUE 4 /* default value (quarter-note) */ -#define FILLTIME 8 /* for articulation, break note in parts */ -#define STACCATO 6 /* 6/8 = 3/4 of note is filled */ -#define NORMAL 7 /* 7/8ths of note interval is filled */ -#define LEGATO 8 /* all of note interval is filled */ -#define DFLT_OCTAVE 4 /* default octave */ -#define MIN_TEMPO 32 /* minimum tempo */ -#define DFLT_TEMPO 120 /* default tempo */ -#define MAX_TEMPO 255 /* max tempo */ -#define NUM_MULT 3 /* numerator of dot multiplier */ -#define DENOM_MULT 2 /* denominator of dot multiplier */ - -/* letter to half-tone: A B C D E F G */ -static int notetab[8] = {9, 11, 0, 2, 4, 5, 7}; - -/* - * This is the American Standard A440 Equal-Tempered scale with frequencies - * rounded to nearest integer. Thank Goddess for the good ol' CRC Handbook... - * our octave 0 is standard octave 2. - */ -#define OCTAVE_NOTES 12 /* semitones per octave */ -static int pitchtab[] = -{ -/* C C# D D# E F F# G G# A A# B*/ -/* 0 */ 65, 69, 73, 78, 82, 87, 93, 98, 103, 110, 117, 123, -/* 1 */ 131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247, -/* 2 */ 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, -/* 3 */ 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988, -/* 4 */ 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1975, -/* 5 */ 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951, -/* 6 */ 4186, 4435, 4698, 4978, 5274, 5588, 5920, 6272, 6644, 7040, 7459, 7902, -}; - -static void playinit() -{ - octave = DFLT_OCTAVE; - whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO; - fill = NORMAL; - value = DFLT_VALUE; - octtrack = FALSE; - octprefix = TRUE; /* act as though there was an initial O(n) */ -} - -static void playtone(pitch, value, sustain) -/* play tone of proper duration for current rhythm signature */ -int pitch, value, sustain; -{ - register int sound, silence, snum = 1, sdenom = 1; - - /* this weirdness avoids floating-point arithmetic */ - for (; sustain; sustain--) - { - snum *= NUM_MULT; - sdenom *= DENOM_MULT; - } - - if (pitch == -1) - rest(whole * snum / (value * sdenom)); - else - { - sound = (whole * snum) / (value * sdenom) - - (whole * (FILLTIME - fill)) / (value * FILLTIME); - silence = whole * (FILLTIME-fill) * snum / (FILLTIME * value * sdenom); - -#ifdef DEBUG - printf("playtone: pitch %d for %d ticks, rest for %d ticks\n", - pitch, sound, silence); -#endif /* DEBUG */ - - tone(pitchtab[pitch], sound); - if (fill != LEGATO) - rest(silence); - } -} - -static int abs(n) -int n; -{ - if (n < 0) - return(-n); - else - return(n); -} - -static void playstring(cp, slen) -/* interpret and play an item from a notation string */ -char *cp; -size_t slen; -{ - int pitch, lastpitch = OCTAVE_NOTES * DFLT_OCTAVE; - -#define GETNUM(cp, v) for(v=0; isdigit(cp[1]) && slen > 0; ) \ - {v = v * 10 + (*++cp - '0'); slen--;} - for (; slen--; cp++) - { - int sustain, timeval, tempo; - register char c = toupper(*cp); - -#ifdef DEBUG - printf("playstring: %c (%x)\n", c, c); -#endif /* DEBUG */ - - switch (c) - { - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': - - /* compute pitch */ - pitch = notetab[c - 'A'] + octave * OCTAVE_NOTES; - - /* this may be followed by an accidental sign */ - if (cp[1] == '#' || cp[1] == '+') - { - ++pitch; - ++cp; - slen--; - } - else if (cp[1] == '-') - { - --pitch; - ++cp; - slen--; - } - - /* - * If octave-tracking mode is on, and there has been no octave- - * setting prefix, find the version of the current letter note - * closest to the last regardless of octave. - */ - if (octtrack && !octprefix) - { - if (abs(pitch-lastpitch) > abs(pitch+OCTAVE_NOTES-lastpitch)) - { - ++octave; - pitch += OCTAVE_NOTES; - } - - if (abs(pitch-lastpitch) > abs((pitch-OCTAVE_NOTES)-lastpitch)) - { - --octave; - pitch -= OCTAVE_NOTES; - } - } - octprefix = FALSE; - lastpitch = pitch; - - /* ...which may in turn be followed by an override time value */ - GETNUM(cp, timeval); - if (timeval <= 0 || timeval > MIN_VALUE) - timeval = value; - - /* ...and/or sustain dots */ - for (sustain = 0; cp[1] == '.'; cp++) - { - slen--; - sustain++; - } - - /* time to emit the actual tone */ - playtone(pitch, timeval, sustain); - break; - - case 'O': - if (cp[1] == 'N' || cp[1] == 'n') - { - octprefix = octtrack = FALSE; - ++cp; - slen--; - } - else if (cp[1] == 'L' || cp[1] == 'l') - { - octtrack = TRUE; - ++cp; - slen--; - } - else - { - GETNUM(cp, octave); - if (octave >= sizeof(pitchtab) / OCTAVE_NOTES) - octave = DFLT_OCTAVE; - octprefix = TRUE; - } - break; - - case '>': - if (octave < sizeof(pitchtab) / OCTAVE_NOTES - 1) - octave++; - octprefix = TRUE; - break; - - case '<': - if (octave > 0) - octave--; - octprefix = TRUE; - break; - - case 'N': - GETNUM(cp, pitch); - for (sustain = 0; cp[1] == '.'; cp++) - { - slen--; - sustain++; - } - playtone(pitch - 1, value, sustain); - break; - - case 'L': - GETNUM(cp, value); - if (value <= 0 || value > MIN_VALUE) - value = DFLT_VALUE; - break; - - case 'P': - case '~': - /* this may be followed by an override time value */ - GETNUM(cp, timeval); - if (timeval <= 0 || timeval > MIN_VALUE) - timeval = value; - for (sustain = 0; cp[1] == '.'; cp++) - { - slen--; - sustain++; - } - playtone(-1, timeval, sustain); - break; - - case 'T': - GETNUM(cp, tempo); - if (tempo < MIN_TEMPO || tempo > MAX_TEMPO) - tempo = DFLT_TEMPO; - whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / tempo; - break; - - case 'M': - if (cp[1] == 'N' || cp[1] == 'n') - { - fill = NORMAL; - ++cp; - slen--; - } - else if (cp[1] == 'L' || cp[1] == 'l') - { - fill = LEGATO; - ++cp; - slen--; - } - else if (cp[1] == 'S' || cp[1] == 's') - { - fill = STACCATO; - ++cp; - slen--; - } - break; - } - } -} - -/******************* UNIX DRIVER HOOKS BEGIN HERE ************************** - * - * This section implements driver hooks to run playstring() and the tone(), - * endtone(), and rest() functions defined above. - */ - -static int spkr_active; /* exclusion flag */ -static struct buf *spkr_inbuf; /* incoming buf */ - -int spkropen(dev) -dev_t dev; -{ -#ifdef DEBUG - printf("spkropen: entering with dev = %x\n", dev); -#endif /* DEBUG */ - - if (minor(dev) != 0) - return(ENXIO); - else if (spkr_active) - return(EBUSY); - else - { - playinit(); - spkr_inbuf = geteblk(DEV_BSIZE); - spkr_active = 1; - } - return(0); -} - -int spkrwrite(dev, uio) -dev_t dev; -struct uio *uio; -{ - register unsigned n; - char *cp; - int error; -#ifdef DEBUG - printf("spkrwrite: entering with dev = %x, count = %d\n", - dev, uio->uio_resid); -#endif /* DEBUG */ - - if (minor(dev) != 0) - return(ENXIO); - else - { - n = MIN(DEV_BSIZE, uio->uio_resid); - cp = spkr_inbuf->b_un.b_addr; - error = uiomove(cp, n, uio); - if (!error) - playstring(cp, n); - return(error); - } -} - -int spkrclose(dev) -dev_t dev; -{ -#ifdef DEBUG - printf("spkrclose: entering with dev = %x\n", dev); -#endif /* DEBUG */ - - if (minor(dev) != 0) - return(ENXIO); - else - { - endtone(); - brelse(spkr_inbuf); - spkr_active = 0; - } - return(0); -} - -int spkrioctl(dev, cmd, cmdarg) -dev_t dev; -int cmd; -caddr_t cmdarg; -{ -#ifdef DEBUG - printf("spkrioctl: entering with dev = %x, cmd = %x\n", dev, cmd); -#endif /* DEBUG */ - - if (minor(dev) != 0) - return(ENXIO); - else if (cmd == SPKRTONE) - { - tone_t *tp = (tone_t *)cmdarg; - - if (tp->frequency == 0) - rest(tp->duration); - else - tone(tp->frequency, tp->duration); - } - else if (cmd == SPKRTUNE) - { - tone_t *tp = (tone_t *)(*(caddr_t *)cmdarg); - tone_t ttp; - int error; - - for (; ; tp++) { - error = copyin(tp, &ttp, sizeof(tone_t)); - if (error) - return(error); - if (ttp.duration == 0) - break; - if (ttp.frequency == 0) - rest(ttp.duration); - else - tone(ttp.frequency, ttp.duration); - } - } - else - return(EINVAL); - return(0); -} - -#endif /* NSPEAKER > 0 */ -/* spkr.c ends here */ diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c deleted file mode 100644 index e639252..0000000 --- a/sys/i386/isa/syscons.c +++ /dev/null @@ -1,2415 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz and Don Ahn. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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: @(#)pccons.c 5.11 (Berkeley) 5/21/91 - * from: @(#)syscons.c 1.0 930928 - * $Id: syscons.c,v 1.13 1993/10/16 13:46:23 rgrimes Exp $ - * - * Heavily modified by Søren Schmidt (sos@login.dkuug.dk) to provide: - * - * virtual consoles, SYSV ioctl's, ANSI emulation - */ - -#define STAR_SAVER -/* #define FAT_CURSOR /* This breaks on some CGA displays */ - -#include "param.h" -#include "conf.h" -#include "ioctl.h" -#include "proc.h" -#include "user.h" -#include "tty.h" -#include "uio.h" -#include "callout.h" -#include "systm.h" -#include "kernel.h" -#include "syslog.h" -#include "errno.h" -#include "machine/console.h" -#include "malloc.h" -#include "i386/isa/icu.h" -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "machine/pc/display.h" -#include "i386/i386/cons.h" -#include "machine/psl.h" -#include "machine/frame.h" -#include "sc.h" -#include "ddb.h" -#include "iso8859.font" -#include "kbdtables.h" - -#if NSC > 0 -#ifndef NCONS -#define NCONS 12 -#endif - -/* status flags */ -#define LOCK_KEY_MASK 0x0000F -#define LED_MASK 0x00007 -#define UNKNOWN_MODE 0x00010 -#define KBD_RAW_MODE 0x00020 -#define SWITCH_WAIT_REL 0x00040 -#define SWITCH_WAIT_ACQ 0x00080 - -/* virtual video memory addresses */ -#define MONO_BUF (KERNBASE + 0xB0000) -#define CGA_BUF (KERNBASE + 0xB8000) -#define VGA_BUF (KERNBASE + 0xA0000) -#define VIDEOMEM 0x000A0000 -#define MEMSIZE 0x00020000 - -/* misc defines */ -#define MAX_ESC_PAR 3 -#define TEXT80x25 1 -#define TEXT80x50 2 -#define COL 80 -#define ROW 25 -#ifndef XTALSPEED -#define XTALSPEED 1193182 /* should be in isa.h */ -#endif - -/* defines related to hardware addresses */ -#define MONO_BASE 0x3B4 /* crt controller base mono */ -#define COLOR_BASE 0x3D4 /* crt controller base color */ -#define ATC IO_VGA+0x00 /* attribute controller */ -#define TSIDX IO_VGA+0x04 /* timing sequencer idx */ -#define TSREG IO_VGA+0x05 /* timing sequencer data */ -#define PIXMASK IO_VGA+0x06 /* pixel write mask */ -#define PALRADR IO_VGA+0x07 /* palette read address */ -#define PALWADR IO_VGA+0x08 /* palette write address */ -#define PALDATA IO_VGA+0x09 /* palette data register */ -#define GDCIDX IO_VGA+0x0E /* graph data controller idx */ -#define GDCREG IO_VGA+0x0F /* graph data controller data */ - -typedef struct term_stat { - int esc; /* processing escape sequence */ - int n_par; /* # of parameters to ESC */ - int last_par; /* last parameter # */ - int par[MAX_ESC_PAR]; /* contains ESC parameters */ - int attr; /* current attributes */ - int std_attr; /* normal attributes */ - int rev_attr; /* reverse attributes */ -} term_stat; - -typedef struct scr_stat { - u_short *crt_base; /* address of screen memory */ - u_short *scr; /* buffer when off screen */ - u_short *crtat; /* cursor address */ - int posx; /* current X position */ - int posy; /* current Y position */ - int max_posx; /* X size */ - int max_posy; /* X size */ - term_stat term; /* terminal emulation stuff */ - char cursor_start; /* cursor start line # */ - char cursor_end; /* cursor start end # */ - u_char border; /* border color */ - u_short bell_duration; - u_short bell_pitch; - u_short status; /* status (bitfield) */ - u_short mode; /* mode */ - pid_t pid; /* pid of controlling proc */ - struct proc *proc; /* proc* of controlling proc */ - struct vt_mode smode; /* switch mode */ -} scr_stat; - -typedef struct default_attr { - int std_attr; /* normal attributes */ - int rev_attr; /* reverse attributes */ -} default_attr; - -static default_attr user_default = { - (FG_LIGHTGREY | BG_BLACK) << 8, - (FG_BLACK | BG_LIGHTGREY) << 8 -}; - -static default_attr kernel_default = { - (FG_WHITE | BG_BLACK) << 8, - (FG_BLACK | BG_LIGHTGREY) << 8 -}; - -static default_attr *current_default; - -static scr_stat cons_scr_stat[NCONS]; -static scr_stat *cur_scr_stat = &cons_scr_stat[0]; -static scr_stat *new_scp, *old_scp; -static term_stat kernel_console; -static int switch_in_progress = 0; - -u_short *Crtat = (u_short *)MONO_BUF; -static u_short *crtat = 0; -static u_int crtc_addr = MONO_BASE; -static char crtc_vga = 0; -static u_char shfts = 0, ctls = 0, alts = 0, agrs = 0; -static u_char nlkcnt = 0, clkcnt = 0, slkcnt = 0, alkcnt = 0; -static char palette[3*256]; -static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab); -static int cur_cursor_pos = -1; -static char in_putc, nx_scr; -static char saved_console = -1; /* saved console number */ -static long scrn_blank_time = 0; /* screen saver timout value */ -static int scrn_blanked = 0; /* screen saver active flag */ -static long scrn_time_stamp; -static u_char scr_map[256]; - -struct tty pccons[NCONS]; -struct tty *cur_pccons = &pccons[0]; -struct tty *new_pccons; - -extern int hz; -extern struct timeval time; - -#define CSF_ACTIVE 0x1 /* timeout active */ -#define CSF_POLLING 0x2 /* polling for input */ - -struct pcconsoftc { - char cs_flags; - char cs_lastc; /* last char sent */ - int cs_timo; /* timeouts since interrupt */ - u_long cs_wedgecnt; /* times restarted */ -} pcconsoftc = {0, 0, 0, 0}; - - -/* special characters */ -#define bs 8 -#define lf 10 -#define cr 13 -#define cntlc 3 -#define del 0177 -#define cntld 4 - -/* function prototypes */ -int pcprobe(struct isa_device *dev); -int pcattach(struct isa_device *dev); -int pcopen(dev_t dev, int flag, int mode, struct proc *p); -int pcclose(dev_t dev, int flag, int mode, struct proc *p); -int pcread(dev_t dev, struct uio *uio, int flag); -int pcwrite(dev_t dev, struct uio *uio, int flag); -int pcparam(struct tty *tp, struct termios *t); -int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p); -int pcxint(dev_t dev); -int pcstart(struct tty *tp); -int pccnprobe(struct consdev *cp); -int pccninit(struct consdev *cp); -int pccnputc(dev_t dev, char c); -int pccngetc(dev_t dev); -int scintr(dev_t dev, int irq, int cpl); -void scrn_saver(int test); -static struct tty *get_pccons(dev_t dev); -static scr_stat *get_scr_stat(dev_t dev); -static int get_scr_num(scr_stat *scp); -static void cursor_shape(int start, int end); -static void get_cursor_shape(int *start, int *end); -static void cursor_pos(void); -static void clear_screen(scr_stat *scp); -static switch_scr(u_int next_scr); -static void exchange_scr(void); -static void move_crsr(scr_stat *scp, int x, int y); -static void move_up(u_short *s, u_short *d, u_int len); -static void move_down(u_short *s, u_short *d, u_int len); -static void scan_esc(scr_stat *scp, u_char c); -static void ansi_put(scr_stat *scp, u_char c); -void consinit(void); -static void sput(u_char c); -static u_char *get_fstr(u_int c, u_int *len); -static update_leds(int which); -void reset_cpu(void); -u_int sgetc(int noblock); -int pcmmap(dev_t dev, int offset, int nprot); -int getchar(void); -static void kbd_wait(void); -static void kbd_cmd(u_char command); -static void set_mode(scr_stat *scp); -static void set_border(int color); -static load_font(int segment, int size, char* font); -static void save_palette(void); -static void load_palette(void); -static change_winsize(struct tty *tp, int x, int y); - -struct isa_driver scdriver = { - pcprobe, pcattach, "sc", -}; - - -int pcprobe(struct isa_device *dev) -{ - u_char c; - int again = 0; - - /* Enable interrupts and keyboard controller */ - kbd_wait(); - outb(KB_STAT, KB_WRITE); - kbd_cmd(0x4D); - - /* Start keyboard stuff RESET */ - kbd_cmd(KB_RESET); - while ((c=inb(KB_DATA)) != KB_ACK) { - if ((c == 0xFE) || (c == 0xFF)) { - if (!again) - printf("KEYBOARD disconnected: RECONNECT \n"); - kbd_cmd(KB_RESET); - again = 1; - } - } - kbd_wait(); - return (IO_KBDSIZE); -} - - -int pcattach(struct isa_device *dev) -{ - scr_stat *scp; - int start = -1, end = -1, i; - - if (crtc_vga) - if (crtc_addr == MONO_BASE) - printf("VGA mono"); - else - printf("VGA color"); - else - if (crtc_addr == MONO_BASE) - printf("MDA/hercules"); - else - printf("CGA/EGA"); - - if (NCONS > 1) - printf(" <%d virtual consoles>\n", NCONS); - else - printf("\n"); -#ifdef FAT_CURSOR - start = 0; - end = 18; -#endif - if (crtc_vga) { -#ifndef FAT_CURSOR - get_cursor_shape(&start, &end); -#endif - save_palette(); - load_font(0, 16, font_8x16); - load_font(1, 8, font_8x8); - load_font(2, 14, font_8x14); - } - current_default = &user_default; - for (i = 0; i < NCONS; i++) { - scp = &cons_scr_stat[i]; - scp->scr = (u_short *)malloc(COL * ROW * 2, M_DEVBUF, M_NOWAIT); - scp->mode = TEXT80x25; - scp->term.esc = 0; - scp->term.std_attr = current_default->std_attr; - scp->term.rev_attr = current_default->rev_attr; - scp->term.attr = scp->term.std_attr; - scp->border = BG_BLACK; - scp->cursor_start = start; - scp->cursor_end = end; - scp->max_posx = COL; - scp->max_posy = ROW; - scp->bell_pitch = 800; - scp->bell_duration = 10; - scp->status = 0; - scp->pid = 0; - scp->proc = NULL; - scp->smode.mode = VT_AUTO; - if (i > 0) { - scp->crt_base = scp->crtat = scp->scr; - fillw(scp->term.attr|scr_map[0x20], scp->scr, COL*ROW); - } - } - /* get cursor going */ -#ifdef FAT_CURSOR - cursor_shape(cons_scr_stat[0].cursor_start, - cons_scr_stat[0].cursor_end); -#endif - cursor_pos(); -} - - -static struct tty *get_pccons(dev_t dev) -{ - int i = minor(dev); - - if (i >= NCONS) - return(NULL); - return(&pccons[i]); -} - - -static scr_stat *get_scr_stat(dev_t dev) -{ - int i = minor(dev); - - if (i >= NCONS) - return(NULL); - return(&cons_scr_stat[i]); -} - - -static int get_scr_num(scr_stat *scp) /* allways call with legal scp !! */ -{ - int i = 0; - - while ((i < NCONS) && (cur_scr_stat != &cons_scr_stat[i])) i++; - return i; -} - -pcopen(dev_t dev, int flag, int mode, struct proc *p) -{ - struct tty *tp = get_pccons(dev); - - if (!tp) - return(ENXIO); - tp->t_oproc = pcstart; - tp->t_param = pcparam; - tp->t_dev = dev; - if ((tp->t_state & TS_ISOPEN) == 0) { - tp->t_state |= TS_WOPEN; - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; - pcparam(tp, &tp->t_termios); - ttsetwater(tp); - } else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0) - return(EBUSY); - tp->t_state |= TS_CARR_ON; - return((*linesw[tp->t_line].l_open)(dev, tp)); -} - - -pcclose(dev_t dev, int flag, int mode, struct proc *p) -{ - struct tty *tp = get_pccons(dev); - struct scr_stat *scp; - - if (!tp) - return(ENXIO); - scp = get_scr_stat(tp->t_dev); - scp->pid = 0; - scp->proc = NULL; - scp->smode.mode = VT_AUTO; - (*linesw[tp->t_line].l_close)(tp, flag); - ttyclose(tp); - return(0); -} - - -pcread(dev_t dev, struct uio *uio, int flag) -{ - struct tty *tp = get_pccons(dev); - - if (!tp) - return(ENXIO); - return((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - - -pcwrite(dev_t dev, struct uio *uio, int flag) -{ - struct tty *tp = get_pccons(dev); - - if (!tp) - return(ENXIO); - return((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - - -/* - * Got a console interrupt, keyboard action ! - * Catch the character, and see who it goes to. - */ -scintr(dev_t dev, int irq, int cpl) -{ - int c, len; - u_char *cp; - - /* make screensaver happy */ - scrn_time_stamp = time.tv_sec; - if (scrn_blanked) - scrn_saver(0); - c = sgetc(1); - if (c & 0x100) - return; - if ((cur_pccons->t_state & TS_ISOPEN) == 0) - return; - if (pcconsoftc.cs_flags & CSF_POLLING) - return; - if (c < 0x100) - (*linesw[cur_pccons->t_line].l_rint)(c & 0xFF, cur_pccons); - else if (cp = get_fstr((u_int)c, (u_int *)&len)) { - while (len-- > 0) - (*linesw[cur_pccons->t_line].l_rint) - (*cp++ & 0xFF, cur_pccons); - } -} - - -/* - * Set line parameters - */ -pcparam(struct tty *tp, struct termios *t) -{ - int cflag = t->c_cflag; - - /* and copy to tty */ - tp->t_ispeed = t->c_ispeed; - tp->t_ospeed = t->c_ospeed; - tp->t_cflag = cflag; - return(0); -} - - -pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) -{ - int i, error; - struct tty *tp; - struct syscframe *fp; - scr_stat *scp; - - tp = get_pccons(dev); - if (!tp) - return ENXIO; - scp = get_scr_stat(tp->t_dev); - - switch (cmd) { /* process console hardware related ioctl's */ - - case CONS_BLANKTIME: /* set screen saver timeout (0 = no saver) */ - scrn_blank_time = *(int*)data; - return 0; - - case CONS_80x25TEXT: /* set 80x25 text mode */ - if (!crtc_vga) - return ENXIO; - scp->mode = TEXT80x25; - scp->max_posy = 25; - free(scp->scr, M_DEVBUF); - scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2, - M_DEVBUF, M_NOWAIT); - if (scp != cur_scr_stat) - scp->crt_base = scp->scr; - set_mode(scp); - clear_screen(scp); - change_winsize(tp, scp->max_posx, scp->max_posy); - return 0; - - case CONS_80x50TEXT: /* set 80x50 text mode */ - if (!crtc_vga) - return ENXIO; - scp->mode = TEXT80x50; - scp->max_posy = 50; - free(scp->scr, M_DEVBUF); - scp->scr = (u_short *)malloc(scp->max_posx*scp->max_posy*2, - M_DEVBUF, M_NOWAIT); - if (scp != cur_scr_stat) - scp->crt_base = scp->scr; - set_mode(scp); - clear_screen(scp); - change_winsize(tp, scp->max_posx, scp->max_posy); - return 0; - - case CONS_GETVERS: /* get version number */ - *(int*)data = 0x100; /* version 1.0 */ - return 0; - - case CONS_GETINFO: /* get current (virtual) console info */ - if (*data == sizeof(struct vid_info)) { - vid_info_t *ptr = (vid_info_t*)data; - ptr->m_num = get_scr_num(scp); - ptr->mv_col = scp->posx; - ptr->mv_row = scp->posy; - ptr->mv_csz = scp->max_posx; - ptr->mv_rsz = scp->max_posy; - ptr->mv_norm.fore = (scp->term.std_attr & 0x0f00)>>8; - ptr->mv_norm.back = (scp->term.std_attr & 0xf000)>>12; - ptr->mv_rev.fore = (scp->term.rev_attr & 0x0f00)>>8; - ptr->mv_rev.back = (scp->term.rev_attr & 0xf000)>>12; - ptr->mv_grfc.fore = 0; /* not supported */ - ptr->mv_grfc.back = 0; /* not supported */ - ptr->mv_ovscan = scp->border; - ptr->mk_keylock = scp->status & LOCK_KEY_MASK; - return 0; - } - return EINVAL; - - case VT_SETMODE: /* set screen switcher mode */ - bcopy(data, &scp->smode, sizeof(struct vt_mode)); - if (scp->smode.mode == VT_PROCESS) { - scp->proc = p; - scp->pid = scp->proc->p_pid; - } - return 0; - - case VT_GETMODE: /* get screen switcher mode */ - bcopy(&scp->smode, data, sizeof(struct vt_mode)); - return 0; - - case VT_RELDISP: /* screen switcher ioctl */ - switch(*data) { - case VT_FALSE: /* user refuses to release screen, abort */ - if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) { - old_scp->status &= ~SWITCH_WAIT_REL; - switch_in_progress = 0; - return 0; - } - return EINVAL; - - case VT_TRUE: /* user has released screen, go on */ - if (scp == old_scp && (scp->status & SWITCH_WAIT_REL)) { - scp->status &= ~SWITCH_WAIT_REL; - exchange_scr(); - if (new_scp->smode.mode == VT_PROCESS) { - new_scp->status |= SWITCH_WAIT_ACQ; - psignal(new_scp->proc, - new_scp->smode.acqsig); - } - else - switch_in_progress = 0; - return 0; - } - return EINVAL; - - case VT_ACKACQ: /* acquire acknowledged, switch completed */ - if (scp == new_scp && (scp->status & SWITCH_WAIT_ACQ)) { - scp->status &= ~SWITCH_WAIT_ACQ; - switch_in_progress = 0; - return 0; - } - return EINVAL; - - default: - return EINVAL; - } - /* NOT REACHED */ - - case VT_OPENQRY: /* return free virtual console */ - for (i = 0; i < NCONS; i++) - if (!(pccons[i].t_state & TS_ISOPEN)) { - *data = i + 1; - return 0; - } - return EINVAL; - /* NOT REACHED */ - - case VT_GETACTIVE: /* return number of active virtual console */ - *data = get_scr_num(scp) + 1; - return 0; - - case VT_ACTIVATE: /* switch to screen *data */ - return switch_scr((*data) - 1); - - case VT_WAITACTIVE: /* wait for switch to occur */ - if (*data > NCONS) - return EINVAL; - if (minor(dev) == (*data) - 1) - return 0; - if (*data == 0) { - if (scp == cur_scr_stat) - return 0; - while ((error=tsleep(&scp->smode, - PZERO|PCATCH, "waitvt", 0)) - == ERESTART) ; - } - else - while ((error=tsleep(&cons_scr_stat[*data].smode, - PZERO|PCATCH, "waitvt", 0)) - == ERESTART) ; - return error; - - case KDENABIO: /* allow io operations */ - fp = (struct syscframe *)p->p_regs; - fp->sf_eflags |= PSL_IOPL; - return 0; - - case KDDISABIO: /* disallow io operations (default) */ - fp = (struct syscframe *)p->p_regs; - fp->sf_eflags &= ~PSL_IOPL; - return 0; - - case KDSETMODE: /* set current mode of this (virtual) console */ - switch (*data) { - case KD_TEXT: /* switch to TEXT (known) mode */ - /* restore fonts & palette ! */ - if (crtc_vga) { - load_font(0, 16, font_8x16); - load_font(1, 8, font_8x8); - load_font(2, 14, font_8x14); - load_palette(); - } - /* FALL THROUGH */ - - case KD_TEXT1: /* switch to TEXT (known) mode */ - /* no restore fonts & palette */ - scp->status &= ~UNKNOWN_MODE; - set_mode(scp); - clear_screen(scp); - return 0; - - case KD_GRAPHICS:/* switch to GRAPHICS (unknown) mode */ - scp->status |= UNKNOWN_MODE; - return 0; - default: - return EINVAL; - } - /* NOT REACHED */ - - case KDGETMODE: /* get current mode of this (virtual) console */ - *data = (scp->status & UNKNOWN_MODE) ? KD_GRAPHICS : KD_TEXT; - return 0; - - case KDSBORDER: /* set border color of this (virtual) console */ - if (!crtc_vga) - return ENXIO; - scp->border = *data; - if (scp == cur_scr_stat) - set_border(scp->border); - return 0; - - case KDSKBSTATE: /* set keyboard state (locks) */ - if (*data >= 0 && *data <= LOCK_KEY_MASK) { - scp->status &= ~LOCK_KEY_MASK; - scp->status |= *data; - if (scp == cur_scr_stat) - update_leds(scp->status & LED_MASK); - return 0; - } - return EINVAL; - - case KDGKBSTATE: /* get keyboard state (locks) */ - *data = scp->status & LOCK_KEY_MASK; - return 0; - - case KDSETRAD: /* set keyboard repeat & delay rates */ - if (*(u_char*)data < 0x80) { - kbd_cmd(KB_SETRAD); - kbd_cmd(*data & 0x7f); - return 0; - } - return EINVAL; - - case KDSKBMODE: /* set keyboard mode */ - switch (*data) { - case K_RAW: /* switch to RAW scancode mode */ - scp->status |= KBD_RAW_MODE; - return 0; - - case K_XLATE: /* switch to XLT ascii mode */ - scp->status &= ~KBD_RAW_MODE; - return 0; - default: - return EINVAL; - } - /* NOT REACHED */ - - case KDGKBMODE: /* get keyboard mode */ - *data = (scp->status & KBD_RAW_MODE) ? K_RAW : K_XLATE; - return 0; - - case KDMKTONE: /* sound the bell */ - if (scp == cur_scr_stat) - sysbeep(scp->bell_pitch, scp->bell_duration); - return 0; - - case KIOCSOUND: /* make tone (*data) hz */ - if (scp == cur_scr_stat) { - if (*(int*)data) { - int pitch = XTALSPEED/(*(int*)data); - /* enable counter 2 */ - outb(0x61, inb(0x61) | 3); - /* set command for counter 2, 2 byte write */ - outb(0x43, 0xb6); - /* set pitch */ - outb(0x42, pitch); - outb(0x42, (pitch>>8)); - } - else { - /* disable counter 2 */ - outb(0x61, inb(0x61) & 0xFC); - } - } - return 0; - - case KDGKBTYPE: /* get keyboard type */ - *data = 0; /* type not known (yet) */ - return 0; - - case KDSETLED: /* set keyboard LED status */ - if (*data >= 0 && *data <= LED_MASK) { - scp->status &= ~LED_MASK; - scp->status |= *data; - if (scp == cur_scr_stat) - update_leds(scp->status & LED_MASK); - return 0; - } - return EINVAL; - - case KDGETLED: /* get keyboard LED status */ - *data = scp->status & LED_MASK; - return 0; - - case GETFKEY: /* get functionkey string */ - if (*(u_short*)data < n_fkey_tab) { - fkeyarg_t *ptr = (fkeyarg_t*)data; - bcopy(&fkey_tab[ptr->keynum].str, - ptr->keydef, - fkey_tab[ptr->keynum].len); - ptr->flen = fkey_tab[ptr->keynum].len; - return 0; - } - else - return EINVAL; - - case SETFKEY: /* set functionkey string */ - if (*(u_short*)data < n_fkey_tab) { - fkeyarg_t *ptr = (fkeyarg_t*)data; - bcopy(ptr->keydef, - &fkey_tab[ptr->keynum].str, - min(ptr->flen, MAXFK)); - fkey_tab[ptr->keynum].len = min(ptr->flen, MAXFK); - return 0; - } - else - return EINVAL; - - case GIO_SCRNMAP: /* get output translation table */ - bcopy(&scr_map, data, sizeof(scr_map)); - return 0; - - case PIO_SCRNMAP: /* set output translation table */ - bcopy(data, &scr_map, sizeof(scr_map)); - return 0; - - case GIO_KEYMAP: /* get keyboard translation table */ - bcopy(&key_map, data, sizeof(key_map)); - return 0; - - case PIO_KEYMAP: /* set keyboard translation table */ - bcopy(data, &key_map, sizeof(key_map)); - return 0; - - case PIO_FONT8x8: /* set 8x8 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(data, &font_8x8, sizeof(font_8x8)); - load_font(1, 8, font_8x8); - return 0; - - case GIO_FONT8x8: /* get 8x8 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(&font_8x8, data, sizeof(font_8x8)); - return 0; - - case PIO_FONT8x14: /* set 8x14 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(data, &font_8x14, sizeof(font_8x14)); - load_font(2, 14, font_8x14); - return 0; - - case GIO_FONT8x14: /* get 8x14 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(&font_8x14, data, sizeof(font_8x14)); - return 0; - - case PIO_FONT8x16: /* set 8x16 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(data, &font_8x16, sizeof(font_8x16)); - load_font(0, 16, font_8x16); - return 0; - - case GIO_FONT8x16: /* get 8x16 dot font */ - if (!crtc_vga) - return ENXIO; - bcopy(&font_8x16, data, sizeof(font_8x16)); - return 0; - - case CONSOLE_X_MODE_ON: /* just to be compatible */ - if (saved_console < 0) { - saved_console = get_scr_num(cur_scr_stat); - switch_scr(minor(dev)); - fp = (struct syscframe *)p->p_regs; - fp->sf_eflags |= PSL_IOPL; - scp->status |= UNKNOWN_MODE; - scp->status |= KBD_RAW_MODE; - return 0; - } - return EAGAIN; - - case CONSOLE_X_MODE_OFF:/* just to be compatible */ - fp = (struct syscframe *)p->p_regs; - fp->sf_eflags &= ~PSL_IOPL; - if (crtc_vga) { - load_font(0, 16, font_8x16); - load_font(1, 8, font_8x8); - load_font(2, 14, font_8x14); - load_palette(); - } - scp->status &= ~UNKNOWN_MODE; - set_mode(scp); - clear_screen(scp); - scp->status &= ~KBD_RAW_MODE; - switch_scr(saved_console); - saved_console = -1; - return 0; - - case CONSOLE_X_BELL: /* more compatibility */ - /* - * if set, data is a pointer to a length 2 array of - * integers. data[0] is the pitch in Hz and data[1] - * is the duration in msec. - */ - if (data) - sysbeep(XTALSPEED/((int*)data)[0], ((int*)data)[1]*hz/3000); - else - sysbeep(0x31b, hz/4); - return 0; - - default: - break; - } - - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag); - if (error >= 0) - return(error); - error = ttioctl(tp, cmd, data, flag); - if (error >= 0) - return(error); - return(ENOTTY); -} - - -pcxint(dev_t dev) -{ - pccons[minor(dev)].t_state &= ~TS_BUSY; - pcconsoftc.cs_timo = 0; - if (pccons[minor(dev)].t_line) - (*linesw[pccons[minor(dev)].t_line].l_start) - (&pccons[minor(dev)]); - else - pcstart(&pccons[minor(dev)]); -} - - -pcstart(struct tty *tp) -{ - int c, s; - scr_stat *scp = get_scr_stat(tp->t_dev); - - s = spltty(); - if (!(tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))) - for (;;) { - if (RB_LEN(&tp->t_out) <= tp->t_lowat) { - if (tp->t_state & TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_out); - } - if (tp->t_wsel) { - selwakeup(tp->t_wsel, - tp->t_state & TS_WCOLL); - tp->t_wsel = 0; - tp->t_state &= ~TS_WCOLL; - } - } - if (RB_LEN(&tp->t_out) == 0) - break; - if (scp->status & SLKED) - break; - c = getc(&tp->t_out); - tp->t_state |= TS_BUSY; - splx(s); - ansi_put(scp, c); - s = spltty(); - tp->t_state &= ~TS_BUSY; - } - splx(s); -} - - -pccnprobe(struct consdev *cp) -{ - int maj; - - /* locate the major number */ - for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == pcopen) - break; - - /* initialize required fields */ - cp->cn_dev = makedev(maj, 0); - cp->cn_tp = &pccons[0]; - cp->cn_pri = CN_INTERNAL; -} - - -pccninit(struct consdev *cp) -{ -} - - -pccnputc(dev_t dev, char c) -{ - int pos; - - if (cur_scr_stat->status & UNKNOWN_MODE) - return; - if (c == '\n') - sput('\r'); - sput(c); - pos = cur_scr_stat->crtat - cur_scr_stat->crt_base; - if (pos != cur_cursor_pos) { - cur_cursor_pos = pos; - outb(crtc_addr,14); - outb(crtc_addr+1,pos >> 8); - outb(crtc_addr,15); - outb(crtc_addr+1,pos&0xff); - } -} - - -pccngetc(dev_t dev) -{ - int c, s; - - s = spltty(); /* block scintr while we poll */ - c = sgetc(0); - splx(s); - if (c == '\r') c = '\n'; - return(c); -} - -#if !defined(STAR_SAVER) && !defined(SNAKE_SAVER) - -void scrn_saver(int test) -{ - u_char val; - - if (test) { - scrn_blanked = 1; - outb(TSIDX, 0x01); val = inb(TSREG); - outb(TSIDX, 0x01); outb(TSREG, val | 0x20); - } - else { - scrn_blanked = 0; - outb(TSIDX, 0x01); val = inb(TSREG); - outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); - } -} -#endif -#if defined(STAR_SAVER) || defined(SNAKE_SAVER) - -static u_long rand_next = 1; - -static rand() -{ - return ((rand_next = rand_next * 1103515245 + 12345) & 0x7FFFFFFF); -} -#endif -#ifdef STAR_SAVER -/* - * Alternate saver that got its inspiration from a well known utility - * package for an unfamous OS. - */ - -#define NUM_STARS 50 - -void scrn_saver(int test) -{ - scr_stat *scp = cur_scr_stat; - int cell, i; - char pattern[] = {"...........++++*** "}; - char colors[] = {FG_DARKGREY, FG_LIGHTGREY, - FG_WHITE, FG_LIGHTCYAN}; - static u_short stars[NUM_STARS][2]; - - if (test) { - if (!scrn_blanked) { - bcopy(Crtat, scp->scr, - scp->max_posx * scp->max_posy * 2); - fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20], Crtat, - scp->max_posx * scp->max_posy); - set_border(0); - i = scp->max_posy * scp->max_posx + 5; - outb(crtc_addr, 14); - outb(crtc_addr+1, i >> 8); - outb(crtc_addr, 15); - outb(crtc_addr+1, i & 0xff); - scrn_blanked = 1; - for(i=0; imax_posx*scp->max_posy); - stars[i][1] = 0; - } - } - cell = rand() % NUM_STARS; - *((u_short*)(Crtat + stars[cell][0])) = - scr_map[pattern[stars[cell][1]]] | - colors[rand()%sizeof(colors)] << 8; - if ((stars[cell][1]+=(rand()%4)) >= sizeof(pattern)-1) { - stars[cell][0] = rand() % (scp->max_posx*scp->max_posy); - stars[cell][1] = 0; - } - } - else { - if (scrn_blanked) { - bcopy(scp->scr, Crtat, scp->max_posx*scp->max_posy*2); - cur_cursor_pos = -1; - set_border(scp->border); - scrn_blanked = 0; - } - } -} -#endif -#ifdef SNAKE_SAVER -/* - * alternative screen saver for cards that do not like blanking - */ - -void scrn_saver(int test) -{ - const char saves[] = {"FreeBSD"}; - static u_char *savs[sizeof(saves)-1]; - static int dirx, diry; - int f; - scr_stat *scp = cur_scr_stat; - - if (test) { - if (!scrn_blanked) { - bcopy(Crtat, scp->scr, - scp->max_posx * scp->max_posy * 2); - fillw((FG_LIGHTGREY|BG_BLACK)<<8 | scr_map[0x20], Crtat, - scp->max_posx * scp->max_posy); - set_border(0); - dirx = (scp->posx ? 1 : -1); - diry = (scp->posy ? - scp->max_posx : -scp->max_posx); - for (f=0; f< sizeof(saves)-1; f++) - savs[f] = (u_char *)Crtat + 2 * - (scp->posx+scp->posy*scp->max_posx); - *(savs[0]) = scr_map[*saves]; - f = scp->max_posy * scp->max_posx + 5; - outb(crtc_addr, 14); - outb(crtc_addr+1, f >> 8); - outb(crtc_addr, 15); - outb(crtc_addr+1, f & 0xff); - scrn_blanked = 1; - } - if (scrn_blanked++ < 4) - return; - scrn_blanked = 1; - *(savs[sizeof(saves)-2]) = scr_map[0x20]; - for (f=sizeof(saves)-2; f > 0; f--) - savs[f] = savs[f-1]; - f = (savs[0] - (u_char *)Crtat) / 2; - if ((f % scp->max_posx) == 0 || - (f % scp->max_posx) == scp->max_posx - 1 || - (rand() % 50) == 0) - dirx = -dirx; - if ((f / scp->max_posx) == 0 || - (f / scp->max_posx) == scp->max_posy - 1 || - (rand() % 20) == 0) - diry = -diry; - savs[0] += 2*dirx + 2*diry; - for (f=sizeof(saves)-2; f>=0; f--) - *(savs[f]) = scr_map[saves[f]]; - } - else { - if (scrn_blanked) { - bcopy(scp->scr, Crtat, - scp->max_posx * scp->max_posy * 2); - cur_cursor_pos = -1; - set_border(scp->border); - scrn_blanked = 0; - } - } -} -#endif - -static void cursor_shape(int start, int end) -{ - outb(crtc_addr, 10); - outb(crtc_addr+1, start & 0xFF); - outb(crtc_addr, 11); - outb(crtc_addr+1, end & 0xFF); -} - - -static void get_cursor_shape(int *start, int *end) -{ - outb(crtc_addr, 10); - *start = inb(crtc_addr+1) & 0x1F; - outb(crtc_addr, 11); - *end = inb(crtc_addr+1) & 0x1F; -} - - -static void cursor_pos(void) -{ - int pos; - - if (cur_scr_stat->status & UNKNOWN_MODE) - return; - if (scrn_blank_time && (time.tv_sec > scrn_time_stamp+scrn_blank_time)) - scrn_saver(1); - pos = cur_scr_stat->crtat - cur_scr_stat->crt_base; - if (!scrn_blanked && pos != cur_cursor_pos) { - cur_cursor_pos = pos; - outb(crtc_addr, 14); - outb(crtc_addr+1, pos>>8); - outb(crtc_addr, 15); - outb(crtc_addr+1, pos&0xff); - } - timeout(cursor_pos, 0, hz/20); -} - - -static void clear_screen(scr_stat *scp) -{ - move_crsr(scp, 0, 0); - fillw(scp->term.attr | scr_map[0x20], scp->crt_base, - scp->max_posx * scp->max_posy); -} - - -static switch_scr(u_int next_scr) -{ - if (in_putc) { /* don't switch if in putc */ - nx_scr = next_scr+1; - return 0; - } - if (switch_in_progress && - (cur_scr_stat->proc != pfind(cur_scr_stat->pid))) - switch_in_progress = 0; - if (next_scr >= NCONS || switch_in_progress) { - sysbeep(800, hz/4); - return -1; - } - switch_in_progress = 1; - old_scp = cur_scr_stat; - new_scp = &cons_scr_stat[next_scr]; - wakeup(&new_scp->smode); - if (new_scp == old_scp) { - switch_in_progress = 0; - return 0; - } - new_pccons = &pccons[next_scr]; - - /* has controlling process died? */ - if (old_scp->proc && (old_scp->proc != pfind(old_scp->pid))) - old_scp->smode.mode = VT_AUTO; - if (new_scp->proc && (new_scp->proc != pfind(new_scp->pid))) - new_scp->smode.mode = VT_AUTO; - - /* check the modes and switch approbiatly */ - if (old_scp->smode.mode == VT_PROCESS) { - old_scp->status |= SWITCH_WAIT_REL; - psignal(old_scp->proc, old_scp->smode.relsig); - } - else { - exchange_scr(); - if (new_scp->smode.mode == VT_PROCESS) { - new_scp->status |= SWITCH_WAIT_ACQ; - psignal(new_scp->proc, new_scp->smode.acqsig); - } - else - switch_in_progress = 0; - } - return 0; -} - - -static void exchange_scr(void) -{ - bcopy(Crtat, old_scp->scr, old_scp->max_posx * old_scp->max_posy * 2); - old_scp->crt_base = old_scp->scr; - move_crsr(old_scp, old_scp->posx, old_scp->posy); - cur_scr_stat = new_scp; - cur_pccons = new_pccons; - if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE) - shfts = ctls = alts = 0; - update_leds(new_scp->status & LED_MASK); - set_mode(new_scp); - new_scp->crt_base = Crtat; - move_crsr(new_scp, new_scp->posx, new_scp->posy); - bcopy(new_scp->scr, Crtat, new_scp->max_posx * new_scp->max_posy * 2); - nx_scr = 0; -} - - -static void move_crsr(scr_stat *scp, int x, int y) -{ - if (x < 0 || y < 0 || x >= scp->max_posx || y >= scp->max_posy) - return; - scp->posx = x; - scp->posy = y; - scp->crtat = scp->crt_base + scp->posy * scp->max_posx + scp->posx; -} - - -static void move_up(u_short *s, u_short *d, u_int len) -{ - s += len; - d += len; - while (len-- > 0) - *--d = *--s; -} - - -static void move_down(u_short *s, u_short *d, u_int len) -{ - while (len-- > 0) - *d++ = *s++; -} - - -static void scan_esc(scr_stat *scp, u_char c) -{ - static u_char ansi_col[16] = - {0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15}; - int i, n; - u_short *src, *dst, count; - - if (scp->term.esc == 1) { - switch (c) { - - case '[': /* Start ESC [ sequence */ - scp->term.esc = 2; - scp->term.last_par = -1; - for (i = scp->term.n_par; i < MAX_ESC_PAR; i++) - scp->term.par[i] = 1; - scp->term.n_par = 0; - return; - - case 'M': /* Move cursor up 1 line, scroll if at top */ - if (scp->posy > 0) - move_crsr(scp, scp->posx, scp->posy - 1); - else { - move_up(scp->crt_base, - scp->crt_base + scp->max_posx, - (scp->max_posy - 1) * scp->max_posx); - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base, scp->max_posx); - } - break; -#if notyet - case 'Q': - scp->term.esc = 4; - break; -#endif - case 'c': /* Clear screen & home */ - clear_screen(scp); - break; - } - } - else if (scp->term.esc == 2) { - if (c >= '0' && c <= '9') { - if (scp->term.n_par < MAX_ESC_PAR) { - if (scp->term.last_par != scp->term.n_par) { - scp->term.last_par = scp->term.n_par; - scp->term.par[scp->term.n_par] = 0; - } - else - scp->term.par[scp->term.n_par] *= 10; - scp->term.par[scp->term.n_par] += c - '0'; - return; - } - } - scp->term.n_par = scp->term.last_par + 1; - switch (c) { - - case ';': - if (scp->term.n_par < MAX_ESC_PAR) - return; - break; - - case '=': - scp->term.esc = 3; - scp->term.last_par = -1; - for (i = scp->term.n_par; i < MAX_ESC_PAR; i++) - scp->term.par[i] = 1; - scp->term.n_par = 0; - return; - - case 'A': /* up n rows */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx, scp->posy - n); - break; - - case 'B': /* down n rows */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx, scp->posy + n); - break; - - case 'C': /* right n columns */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx + n, scp->posy); - break; - - case 'D': /* left n columns */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx - n, scp->posy); - break; - - case 'E': /* cursor to start of line n lines down */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, 0, scp->posy + n); - break; - - case 'F': /* cursor to start of line n lines up */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, 0, scp->posy - n); - break; - - case 'f': /* System V consoles .. */ - case 'H': /* Cursor move */ - if (scp->term.n_par == 0) - move_crsr(scp, 0, 0); - else if (scp->term.n_par == 2) - move_crsr(scp, scp->term.par[1] - 1, - scp->term.par[0] - 1); - break; - - case 'J': /* Clear all or part of display */ - if (scp->term.n_par == 0) - n = 0; - else - n = scp->term.par[0]; - switch (n) { - case 0: /* clear form cursor to end of display */ - fillw(scp->term.attr | scr_map[0x20], - scp->crtat, scp->crt_base + - scp->max_posx * scp->max_posy - - scp->crtat); - break; - case 1: /* clear from beginning of display to cursor */ - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base, - scp->crtat - scp->crt_base); - break; - case 2: /* clear entire display */ - clear_screen(scp); - break; - } - break; - - case 'K': /* Clear all or part of line */ - if (scp->term.n_par == 0) - n = 0; - else - n = scp->term.par[0]; - switch (n) { - case 0: /* clear form cursor to end of line */ - fillw(scp->term.attr | scr_map[0x20], - scp->crtat, scp->max_posx - scp->posx); - break; - case 1: /* clear from beginning of line to cursor */ - fillw(scp->term.attr|scr_map[0x20], - scp->crtat - (scp->max_posx - scp->posx), - (scp->max_posx - scp->posx) + 1); - break; - case 2: /* clear entire line */ - fillw(scp->term.attr|scr_map[0x20], - scp->crtat - (scp->max_posx - scp->posx), - scp->max_posx); - break; - } - break; - - case 'L': /* Insert n lines */ - n = scp->term.par[0]; if (n < 1) n = 1; - if (n > scp->max_posy - scp->posy) - n = scp->max_posy - scp->posy; - src = scp->crt_base + scp->posy * scp->max_posx; - dst = src + n * scp->max_posx; - count = scp->max_posy - (scp->posy + n); - move_up(src, dst, count * scp->max_posx); - fillw(scp->term.attr | scr_map[0x20], src, - n * scp->max_posx); - break; - - case 'M': /* Delete n lines */ - n = scp->term.par[0]; if (n < 1) n = 1; - if (n > scp->max_posy - scp->posy) - n = scp->max_posy - scp->posy; - dst = scp->crt_base + scp->posy * scp->max_posx; - src = dst + n * scp->max_posx; - count = scp->max_posy - (scp->posy + n); - move_down(src, dst, count * scp->max_posx); - src = dst + count * scp->max_posx; - fillw(scp->term.attr | scr_map[0x20], src, - n * scp->max_posx); - break; - - case 'P': /* Delete n chars */ - n = scp->term.par[0]; if (n < 1) n = 1; - if (n > scp->max_posx - scp->posx) - n = scp->max_posx - scp->posx; - dst = scp->crtat; - src = dst + n; - count = scp->max_posx - (scp->posx + n); - move_down(src, dst, count); - src = dst + count; - fillw(scp->term.attr | scr_map[0x20], src, n); - break; - - case '@': /* Insert n chars */ - n = scp->term.par[0]; if (n < 1) n = 1; - if (n > scp->max_posx - scp->posx) - n = scp->max_posx - scp->posx; - src = scp->crtat; - dst = src + n; - count = scp->max_posx - (scp->posx + n); - move_up(src, dst, count); - fillw(scp->term.attr | scr_map[0x20], src, n); - break; - - case 'S': /* scroll up n lines */ - n = scp->term.par[0]; if (n < 1) n = 1; - bcopy(scp->crt_base + (scp->max_posx * n), - scp->crt_base, - scp->max_posx * (scp->max_posy - n) * - sizeof(u_short)); - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base + scp->max_posx * - (scp->max_posy - 1), - scp->max_posx); - break; - - case 'T': /* scroll down n lines */ - n = scp->term.par[0]; if (n < 1) n = 1; - bcopy(scp->crt_base, - scp->crt_base + (scp->max_posx * n), - scp->max_posx * (scp->max_posy - n) * - sizeof(u_short)); - fillw(scp->term.attr | scr_map[0x20], scp->crt_base, - scp->max_posx); - break; - - case 'X': /* delete n characters in line */ - n = scp->term.par[0]; if (n < 1) n = 1; - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base + scp->posx + - ((scp->max_posx*scp->posy) * sizeof(u_short)), n); - break; - - case 'Z': /* move n tabs backwards */ - n = scp->term.par[0]; if (n < 1) n = 1; - if ((i = scp->posx & 0xf8) == scp->posx) - i -= 8*n; - else - i -= 8*(n-1); - if (i < 0) - i = 0; - move_crsr(scp, i, scp->posy); - break; - - case '`': /* move cursor to column n */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, n, scp->posy); - break; - - case 'a': /* move cursor n columns to the right */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx + n, scp->posy); - break; - - case 'd': /* move cursor to row n */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx, n); - break; - - case 'e': /* move cursor n rows down */ - n = scp->term.par[0]; if (n < 1) n = 1; - move_crsr(scp, scp->posx, scp->posy + n); - break; - - case 'm': /* change attribute */ - if (scp->term.n_par == 0) - n = 0; - else - n = scp->term.par[0]; - switch (n) { - case 0: /* back to normal */ - scp->term.attr = scp->term.std_attr; - break; - case 1: /* highlight (bold) */ - scp->term.attr &= 0xFF00; - scp->term.attr |= 0x0800; - break; - case 4: /* highlight (underline) */ - scp->term.attr &= 0x0F00; - scp->term.attr |= 0x0800; - break; - case 5: /* blink */ - scp->term.attr &= 0xFF00; - scp->term.attr |= 0x8000; - break; - case 7: /* reverse video */ - scp->term.attr = scp->term.rev_attr; - break; - case 30: case 31: case 32: case 33: /* set fg color */ - case 34: case 35: case 36: case 37: - scp->term.attr = (scp->term.attr & 0xF0FF) - | (ansi_col[(n - 30) & 7] << 8); - break; - case 40: case 41: case 42: case 43: /* set bg color */ - case 44: case 45: case 46: case 47: - scp->term.attr = (scp->term.attr & 0x0FFF) - | (ansi_col[(n - 40) & 7] << 12); - break; - } - break; - - case 'x': - if (scp->term.n_par == 0) - n = 0; - else - n = scp->term.par[0]; - switch (n) { - case 0: /* reset attributes */ - scp->term.attr = scp->term.std_attr = - current_default->std_attr; - scp->term.rev_attr = current_default->rev_attr; - break; - case 1: /* set ansi background */ - scp->term.attr = scp->term.std_attr = - (scp->term.std_attr & 0x0F00) | - (ansi_col[(scp->term.par[1])&0x0F]<<12); - break; - case 2: /* set ansi foreground */ - scp->term.attr = scp->term.std_attr = - (scp->term.std_attr & 0xF000) | - (ansi_col[(scp->term.par[1])&0x0F]<<8); - break; - case 3: /* set ansi attribute directly */ - scp->term.attr = scp->term.std_attr = - (scp->term.par[1]&0xFF)<<8; - break; - case 5: /* set ansi reverse video background */ - scp->term.rev_attr = - (scp->term.rev_attr & 0x0F00) | - (ansi_col[(scp->term.par[1])&0x0F]<<12); - break; - case 6: /* set ansi reverse video foreground */ - scp->term.rev_attr = - (scp->term.rev_attr & 0xF000) | - (ansi_col[(scp->term.par[1])&0x0F]<<8); - break; - case 7: /* set ansi reverse video directly */ - scp->term.rev_attr = (scp->term.par[1]&0xFF)<<8; - break; - } - break; - - case 'z': /* switch to (virtual) console n */ - if (scp->term.n_par == 1) - switch_scr(scp->term.par[0]); - break; - } - } - else if (scp->term.esc == 3) { - if (c >= '0' && c <= '9') { - if (scp->term.n_par < MAX_ESC_PAR) { - if (scp->term.last_par != scp->term.n_par) { - scp->term.last_par = scp->term.n_par; - scp->term.par[scp->term.n_par] = 0; - } - else - scp->term.par[scp->term.n_par] *= 10; - scp->term.par[scp->term.n_par] += c - '0'; - return; - } - } - scp->term.n_par = scp->term.last_par + 1; - switch (c) { - - case ';': - if (scp->term.n_par < MAX_ESC_PAR) - return; - break; - - case 'A': /* set display border color */ - if (scp->term.n_par == 1) - scp->border=scp->term.par[0] & 0xff; - if (scp == cur_scr_stat) - set_border(scp->border); - break; - - case 'B': /* set bell pitch and duration */ - if (scp->term.n_par == 2) { - scp->bell_pitch = scp->term.par[0]; - scp->bell_duration = scp->term.par[1]*10; - } - break; - - case 'C': /* set cursor shape (start & end line) */ - if (scp->term.n_par == 2) { - scp->cursor_start = scp->term.par[0] & 0x1F; - scp->cursor_end = scp->term.par[1] & 0x1F; - if (scp == cur_scr_stat) - cursor_shape(scp->cursor_start, - scp->cursor_end); - } - break; - - case 'F': /* set ansi foreground */ - if (scp->term.n_par == 1) - scp->term.attr = scp->term.std_attr = - (scp->term.std_attr & 0xF000) - | ((scp->term.par[0] & 0x0F) << 8); - break; - - case 'G': /* set ansi background */ - if (scp->term.n_par == 1) - scp->term.attr = scp->term.std_attr = - (scp->term.std_attr & 0x0F00) - | ((scp->term.par[0] & 0x0F) << 12); - break; - - case 'H': /* set ansi reverse video foreground */ - if (scp->term.n_par == 1) - scp->term.rev_attr = - (scp->term.rev_attr & 0xF000) - | ((scp->term.par[0] & 0x0F) << 8); - break; - - case 'I': /* set ansi reverse video background */ - if (scp->term.n_par == 1) - scp->term.rev_attr = - (scp->term.rev_attr & 0x0F00) - | ((scp->term.par[0] & 0x0F) << 12); - break; - } - } - scp->term.esc = 0; -} - - -static void ansi_put(scr_stat *scp, u_char c) -{ - if (scp->status & UNKNOWN_MODE) - return; - - /* make screensaver happy */ - if (scp == cur_scr_stat) { - scrn_time_stamp = time.tv_sec; - if (scrn_blanked) - scrn_saver(0); - } - in_putc++; - if (scp->term.esc) - scan_esc(scp, c); - else switch(c) { - case 0x1B: /* start escape sequence */ - scp->term.esc = 1; - scp->term.n_par = 0; - break; - case 0x07: - if (scp == cur_scr_stat) - sysbeep(scp->bell_pitch, scp->bell_duration); - break; - case '\t': /* non-destructive tab */ - scp->crtat += (8 - scp->posx % 8); - scp->posx += (8 - scp->posx % 8); - break; - case '\b': /* non-destructive backspace */ - if (scp->crtat > scp->crt_base) { - scp->crtat--; - if (scp->posx > 0) - scp->posx--; - else { - scp->posx += scp->max_posx - 1; - scp->posy--; - } - } - break; - case '\r': /* return to pos 0 */ - move_crsr(scp, 0, scp->posy); - break; - case '\n': /* newline, same pos */ - scp->crtat += scp->max_posx; - scp->posy++; - break; - case '\f': /* form feed, clears screen */ - clear_screen(scp); - break; - default: - /* Print only printables */ - *scp->crtat = (scp->term.attr | scr_map[c]); - scp->crtat++; - if (++scp->posx >= scp->max_posx) { - scp->posx = 0; - scp->posy++; - } - break; - } - if (scp->crtat >= scp->crt_base + scp->max_posy * scp->max_posx) { - bcopy(scp->crt_base + scp->max_posx, scp->crt_base, - scp->max_posx * (scp->max_posy - 1) * sizeof(u_short)); - fillw(scp->term.attr | scr_map[0x20], - scp->crt_base + scp->max_posx * (scp->max_posy - 1), - scp->max_posx); - scp->crtat -= scp->max_posx; - scp->posy--; - } - in_putc--; - if (nx_scr) - switch_scr(nx_scr - 1); -} - - -void consinit(void) -{ - u_short volatile *cp = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short), was; - unsigned cursorat; - int i; - - /* - * catch that once in a blue moon occurence when consinit is called - * TWICE, adding the CGA_BUF offset again -> poooff - */ - if (crtat != 0) - return; - /* - * Crtat initialized to point to MONO buffer, if not present change - * to CGA_BUF offset. ONLY ADD the difference since locore.s adds - * in the remapped offset at the right time - */ - was = *cp; - *cp = (u_short) 0xA55A; - if (*cp != 0xA55A) { - crtc_addr = MONO_BASE; - } else { - *cp = was; - crtc_addr = COLOR_BASE; - Crtat = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short); - } - - /* Extract cursor location */ - outb(crtc_addr,14); - cursorat = inb(crtc_addr+1)<<8 ; - outb(crtc_addr,15); - cursorat |= inb(crtc_addr+1); - crtat = Crtat + cursorat; - - /* is this a VGA or higher ? */ - outb(crtc_addr, 7); - if (inb(crtc_addr) == 7) - crtc_vga = 1; - - current_default = &user_default; - cons_scr_stat[0].crtat = crtat; - cons_scr_stat[0].crt_base = Crtat; - cons_scr_stat[0].term.esc = 0; - cons_scr_stat[0].term.std_attr = current_default->std_attr; - cons_scr_stat[0].term.rev_attr = current_default->rev_attr; - cons_scr_stat[0].term.attr = current_default->std_attr; - cons_scr_stat[0].posx = cursorat % COL; - cons_scr_stat[0].posy = cursorat / COL; - cons_scr_stat[0].border = BG_BLACK;; - cons_scr_stat[0].max_posx = COL; - cons_scr_stat[0].max_posy = ROW; - cons_scr_stat[0].status = 0; - cons_scr_stat[0].pid = 0; - cons_scr_stat[0].proc = NULL; - cons_scr_stat[0].smode.mode = VT_AUTO; - cons_scr_stat[0].bell_pitch = 800; - cons_scr_stat[0].bell_duration = 10; - kernel_console.esc = 0; - kernel_console.std_attr = kernel_default.std_attr; - kernel_console.rev_attr = kernel_default.rev_attr; - kernel_console.attr = kernel_default.std_attr; - /* initialize mapscrn array to */ - for (i=0; iterm; - scp->term = kernel_console; - current_default = &kernel_default; - ansi_put(scp, c); - kernel_console = scp->term; - current_default = &user_default; - scp->term = save; -} - - -static u_char *get_fstr(u_int c, u_int *len) -{ - u_int i; - - if (!(c & FKEY)) - return(NULL); - i = (c & 0xFF) - F_FN; - if (i > n_fkey_tab) - return(NULL); - *len = fkey_tab[i].len; - return(fkey_tab[i].str); -} - - -static update_leds(int which) -{ - u_char xlate_leds[8] = { 0, 4, 2, 6, 1, 5, 3, 7 }; - - kbd_cmd(KB_SETLEDS); /* LED Command */ - kbd_cmd(xlate_leds[which & LED_MASK]); - kbd_wait(); -} - - -volatile void reset_cpu(void) -{ - while (1) { - kbd_cmd(KB_RESET_CPU); /* Reset Command */ - DELAY(4000000); - kbd_cmd(KB_RESET); /* Keyboard Reset Command */ - } -} - - -/* - * sgetc(noblock) : get a character from the keyboard. - * If noblock = 0 wait until a key is gotten. Otherwise return a 0x100. - */ -u_int sgetc(int noblock) -{ - u_char val, code, release; - u_int state, action; - struct key_t *key; - static u_char esc_flag = 0, compose = 0; - static u_int chr = 0; - -next_code: - kbd_wait(); - /* First see if there is something in the keyboard port */ - if (inb(KB_STAT) & KB_BUF_FULL) - val = inb(KB_DATA); - else if (noblock) - return(0x100); - else - goto next_code; - - if (cur_scr_stat->status & KBD_RAW_MODE) - return val; - - code = val & 0x7F; - release = val & 0x80; - - /* Check for cntl-alt-del */ - if ((code == 83) && ctls && alts) - cpu_reset(); -#if NDDB > 0 - /* Check for cntl-alt-esc */ - if ((val == 1) && ctls && alts) { - /* if debugger called, try to switch to console 0 */ - if (cur_scr_stat->smode.mode == VT_AUTO && - cons_scr_stat[0].smode.mode == VT_AUTO) - switch_scr(0); - Debugger(); - return(0x100); - } -#endif - switch (esc_flag) { - case 0x00: /* normal scancode */ - switch(code) { - case 0x38: /* left alt (compose key) */ - if (release && compose) { - compose = 0; - if (chr > 255) { - sysbeep(500, hz/4); - chr = 0; - } - } - else { - if (!compose) { - compose = 1; - chr = 0; - } - } - break; - case 0x60: - case 0x61: - esc_flag = code; - goto next_code; - } - break; - case 0x60: /* 0xE0 prefix */ - esc_flag = 0; - switch (code) { - case 0x1c: /* right enter key */ - code = 0x59; - break; - case 0x1d: /* right ctrl key */ - code = 0x5a; - break; - case 0x35: /* keypad divide key */ - code = 0x5b; - break; - case 0x37: /* print scrn key */ - code = 0x5c; - break; - case 0x38: /* right alt key (alt gr) */ - code = 0x5d; - break; - case 0x47: /* grey home key */ - code = 0x5e; - break; - case 0x48: /* grey up arrow key */ - code = 0x5f; - break; - case 0x49: /* grey page up key */ - code = 0x60; - break; - case 0x4b: /* grey left arrow key */ - code = 0x61; - break; - case 0x4d: /* grey right arrow key */ - code = 0x62; - break; - case 0x4f: /* grey end key */ - code = 0x63; - break; - case 0x50: /* grey down arrow key */ - code = 0x64; - break; - case 0x51: /* grey page down key */ - code = 0x65; - break; - case 0x52: /* grey insert key */ - code = 0x66; - break; - case 0x53: /* grey delete key */ - code = 0x67; - break; - default: /* ignore everything else */ - goto next_code; - } - break; - case 0x61: /* 0xE1 prefix */ - esc_flag = 0; - if (code == 0x1D) - esc_flag = 0x1D; - goto next_code; - /* NOT REACHED */ - case 0x1D: /* pause / break */ - esc_flag = 0; - if (code != 0x45) - goto next_code; - code = 0x68; - break; - } - - if (compose) { - switch (code) { - case 0x47: - case 0x48: /* keypad 7,8,9 */ - case 0x49: - if (!release) - chr = (code - 0x40) + chr*10; - goto next_code; - case 0x4b: - case 0x4c: /* keypad 4,5,6 */ - case 0x4d: - if (!release) - chr = (code - 0x47) + chr*10; - goto next_code; - case 0x4f: - case 0x50: /* keypad 1,2,3 */ - case 0x51: - if (!release) - chr = (code - 0x4e) + chr*10; - goto next_code; - case 0x52: /* keypad 0 */ - if (!release) - chr *= 10; - goto next_code; - case 0x38: /* left alt key */ - break; - default: - if (chr) { - compose = chr = 0; - sysbeep(500, hz/4); - goto next_code; - } - break; - } - } - - state = (shfts ? 1 : 0 ) | (2 * (ctls ? 1 : 0)) | (4 * (alts ? 1 : 0)); - if ((!agrs && (cur_scr_stat->status & ALKED)) - || (agrs && !(cur_scr_stat->status & ALKED))) - code += ALTGR_OFFSET; - key = &key_map.key[code]; - if ( ((key->flgs & FLAG_LOCK_C) && (cur_scr_stat->status & CLKED)) - || ((key->flgs & FLAG_LOCK_N) && (cur_scr_stat->status & NLKED)) ) - state ^= 1; - - /* Check for make/break */ - action = key->map[state]; - if (release) { /* key released */ - if (key->spcl & 0x80) { - switch (action) { - case LSH: - shfts &= ~1; - break; - case RSH: - shfts &= ~2; - break; - case LCTR: - ctls &= ~1; - break; - case RCTR: - ctls &= ~2; - break; - case LALT: - alts &= ~1; - break; - case RALT: - alts &= ~2; - break; - case NLK: - nlkcnt = 0; - break; - case CLK: - clkcnt = 0; - break; - case SLK: - slkcnt = 0; - break; - case ASH: - agrs = 0; - break; - case ALK: - alkcnt = 0; - break; - } - } - if (chr && !compose) { - action = chr; - chr = 0; - return (action); - } - } else { - /* key pressed */ - if (key->spcl & (0x80>>state)) { - switch (action) { - /* LOCKING KEYS */ - case NLK: - if (!nlkcnt) { - nlkcnt++; - if (cur_scr_stat->status & NLKED) - cur_scr_stat->status &= ~NLKED; - else - cur_scr_stat->status |= NLKED; - update_leds(cur_scr_stat->status & LED_MASK); - } - break; - case CLK: - if (!clkcnt) { - clkcnt++; - if (cur_scr_stat->status & CLKED) - cur_scr_stat->status &= ~CLKED; - else - cur_scr_stat->status |= CLKED; - update_leds(cur_scr_stat->status & LED_MASK); - } - break; - case SLK: - if (!slkcnt) { - slkcnt++; - if (cur_scr_stat->status & SLKED) { - cur_scr_stat->status &= ~SLKED; - pcstart(&pccons[get_scr_num(cur_scr_stat)]); - } - else - cur_scr_stat->status |= SLKED; - update_leds(cur_scr_stat->status & LED_MASK); - } - break; - case ALK: - if (!alkcnt) { - alkcnt++; - if (cur_scr_stat->status & ALKED) - cur_scr_stat->status &= ~ALKED; - else - cur_scr_stat->status |= ALKED; - } - break; - - /* NON-LOCKING KEYS */ - case LSH: - shfts |= 1; - break; - case RSH: - shfts |= 2; - break; - case LCTR: - ctls |= 1; - break; - case RCTR: - ctls |= 2; - break; - case LALT: - alts |= 1; - break; - case RALT: - alts |= 2; - break; - case ASH: - agrs = 1; - break; - case NOP: - break; - default: - if (action >= F_SCR && action <= L_SCR) { - switch_scr(action - F_SCR); - break; - } - if (action >= F_FN && action <= L_FN) { - return(action | FKEY); - } - return(action); - } - } - else return(action); - } - goto next_code; -} - -/* July '93, jkh. Added in for init_main.c */ -void cons_highlight() -{ - cons_scr_stat[0].term.attr &= 0xFF00; - cons_scr_stat[0].term.attr |= 0x0800; -} - -void cons_normal() -{ - cons_scr_stat[0].term.attr = cons_scr_stat[0].term.std_attr; -} - -int getchar(void) -{ - char thechar; - int s; - - pcconsoftc.cs_flags |= CSF_POLLING; - s = splhigh(); - sput('>'); - thechar = (char) sgetc(0); - pcconsoftc.cs_flags &= ~CSF_POLLING; - splx(s); - switch (thechar) { - default: - if (thechar >= scr_map[0x20]) - sput(thechar); - return(thechar); - case cr: - case lf: - sput(cr); sput(lf); - return(lf); - case bs: - case del: - sput(bs); sput(scr_map[0x20]); sput(bs); - return(thechar); - case cntld: - sput('^'); sput('D'); sput('\r'); sput('\n'); - return(0); - } -} - - -int pcmmap(dev_t dev, int offset, int nprot) -{ - if (offset > 0x20000) - return EINVAL; - return i386_btop((VIDEOMEM + offset)); -} - - -static void kbd_wait(void) -{ - int i; - for (i=0; i<10000; i++) - if ((inb(KB_STAT) & KB_READY) == 0) - break; -} - - -static void kbd_cmd(u_char command) -{ - kbd_wait(); - outb(KB_DATA, command); -} - - -static void set_mode(scr_stat *scp) -{ - u_char byte; - int s; - - if (scp != cur_scr_stat) - return; - - /* (re)activate cursor */ - untimeout(cursor_pos, 0); - cursor_pos(); - - /* change cursor type if set */ - if (scp->cursor_start != -1 && scp->cursor_end != -1) - cursor_shape(scp->cursor_start, scp->cursor_end); - - /* mode change only on VGA's */ - if (!crtc_vga) - return; - - /* setup video hardware for the given mode */ - s = splhigh(); - switch(scp->mode) { - case TEXT80x25: - outb(crtc_addr, 9); byte = inb(crtc_addr+1); - outb(crtc_addr, 9); outb(crtc_addr+1, byte | 0x0F); - outb(TSIDX, 0x03); outb(TSREG, 0x00); /* select font 0 */ - break; - case TEXT80x50: - outb(crtc_addr, 9); byte = inb(crtc_addr+1); - outb(crtc_addr, 9); outb(crtc_addr+1, (byte & 0xF0) | 0x07); - outb(TSIDX, 0x03); outb(TSREG, 0x05); /* select font 1 */ - break; - default: - return; - } - splx(s); - - /* set border color for this (virtual) console */ - set_border(scp->border); - return; -} - - -static void set_border(int color) -{ - inb(crtc_addr+6); /* reset flip-flop */ - outb(ATC, 0x11); outb(ATC, color); - inb(crtc_addr+6); /* reset flip-flop */ - outb(ATC, 0x20); /* enable Palette */ -} - -static load_font(int segment, int size, char* font) -{ - int ch, line, s; - u_char val; - - outb(TSIDX, 0x01); val = inb(TSREG); /* blank screen */ - outb(TSIDX, 0x01); outb(TSREG, val | 0x20); - - /* setup vga for loading fonts (graphics plane mode) */ - s = splhigh(); - inb(crtc_addr+6); /* reset flip/flop */ - outb(ATC, 0x30); outb(ATC, 0x01); - outb(TSIDX, 0x02); outb(TSREG, 0x04); - outb(TSIDX, 0x04); outb(TSREG, 0x06); - outb(GDCIDX, 0x04); outb(GDCREG, 0x02); - outb(GDCIDX, 0x05); outb(GDCREG, 0x00); - outb(GDCIDX, 0x06); outb(GDCREG, 0x05); /* addr = a0000, 64kb */ - splx(s); - for (ch=0; ch < 256; ch++) - for (line=0; line < size; line++) - *((char *)atdevbase+(segment*0x4000)+(ch*32)+line) = - font[(ch*size)+line]; - /* setup vga for text mode again */ - s = splhigh(); - inb(crtc_addr+6); /* reset flip/flop */ - outb(ATC, 0x30); outb(ATC, 0x0C); - outb(TSIDX, 0x02); outb(TSREG, 0x03); - outb(TSIDX, 0x04); outb(TSREG, 0x02); - outb(GDCIDX, 0x04); outb(GDCREG, 0x00); - outb(GDCIDX, 0x05); outb(GDCREG, 0x10); - if (crtc_addr == MONO_BASE) { - outb(GDCIDX, 0x06); outb(GDCREG, 0x0A); /* addr = b0000, 32kb */ - } - else { - outb(GDCIDX, 0x06); outb(GDCREG, 0x0E); /* addr = b8000, 32kb */ - } - splx(s); - outb(TSIDX, 0x01); val = inb(TSREG); /* unblank screen */ - outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); -} - - -static void load_palette(void) -{ - int i; - - outb(PIXMASK, 0xFF); /* no pixelmask */ - outb(PALWADR, 0x00); - for (i=0x00; i<0x300; i++) - outb(PALDATA, palette[i]); - inb(crtc_addr+6); /* reset flip/flop */ - outb(ATC, 0x20); /* enable palette */ -} - -static void save_palette(void) -{ - int i; - - outb(PALRADR, 0x00); - for (i=0x00; i<0x300; i++) - palette[i] = inb(PALDATA); - inb(crtc_addr+6); /* reset flip/flop */ -} - - -static change_winsize(struct tty *tp, int x, int y) -{ - if (tp->t_winsize.ws_col != x || tp->t_winsize.ws_row != y) { - tp->t_winsize.ws_col = x; - tp->t_winsize.ws_row = y; - pgsignal(tp->t_pgrp, SIGWINCH, 1); - } -} - -#endif /* NSC */ diff --git a/sys/i386/isa/timerreg.h b/sys/i386/isa/timerreg.h deleted file mode 100644 index 5742f66..0000000 --- a/sys/i386/isa/timerreg.h +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * Copyright (c) 1993 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: timerreg.h,v 1.2 93/02/28 15:08:58 mccanne Exp - * $Id$ - */ - -/* - * - * Register definitions for the Intel 8253 Programmable Interval Timer. - * - * This chip has three independent 16-bit down counters that can be - * read on the fly. There are three mode registers and three countdown - * registers. The countdown registers are addressed directly, via the - * first three I/O ports. The three mode registers are accessed via - * the fourth I/O port, with two bits in the mode byte indicating the - * register. (Why are hardware interfaces always so braindead?). - * - * To write a value into the countdown register, the mode register - * is first programmed with a command indicating the which byte of - * the two byte register is to be modified. The three possibilities - * are load msb (TMR_MR_MSB), load lsb (TMR_MR_LSB), or load lsb then - * msb (TMR_MR_BOTH). - * - * To read the current value ("on the fly") from the countdown register, - * you write a "latch" command into the mode register, then read the stable - * value from the corresponding I/O port. For example, you write - * TMR_MR_LATCH into the corresponding mode register. Presumably, - * after doing this, a write operation to the I/O port would result - * in undefined behavior (but hopefully not fry the chip). - * Reading in this manner has no side effects. - * - * The outputs of the three timers are connected as follows: - * - * timer 0 -> irq 0 - * timer 1 -> dma chan 0 (for dram refresh) - * timer 2 -> speaker (via keyboard controller) - * - * Timer 0 is used to call hardclock. - * Timer 2 is used to generate console beeps. - */ - -/* - * Macros for specifying values to be written into a mode register. - */ -#define TIMER_CNTR0 (IO_TIMER1 + 0) /* timer 0 counter port */ -#define TIMER_CNTR1 (IO_TIMER1 + 1) /* timer 1 counter port */ -#define TIMER_CNTR2 (IO_TIMER1 + 2) /* timer 2 counter port */ -#define TIMER_MODE (IO_TIMER1 + 3) /* timer mode port */ -#define TIMER_SEL0 0x00 /* select counter 0 */ -#define TIMER_SEL1 0x40 /* select counter 1 */ -#define TIMER_SEL2 0x80 /* select counter 2 */ -#define TIMER_INTTC 0x00 /* mode 0, intr on terminal cnt */ -#define TIMER_ONESHOT 0x02 /* mode 1, one shot */ -#define TIMER_RATEGEN 0x04 /* mode 2, rate generator */ -#define TIMER_SQWAVE 0x06 /* mode 3, square wave */ -#define TIMER_SWSTROBE 0x08 /* mode 4, s/w triggered strobe */ -#define TIMER_HWSTROBE 0x0a /* mode 5, h/w triggered strobe */ -#define TIMER_LATCH 0x00 /* latch counter for reading */ -#define TIMER_LSB 0x10 /* r/w counter LSB */ -#define TIMER_MSB 0x20 /* r/w counter MSB */ -#define TIMER_16BIT 0x30 /* r/w counter 16 bits, LSB first */ -#define TIMER_BCD 0x01 /* count in BCD */ - diff --git a/sys/i386/isa/ultra14f.c b/sys/i386/isa/ultra14f.c deleted file mode 100644 index 9566258..0000000 --- a/sys/i386/isa/ultra14f.c +++ /dev/null @@ -1,1209 +0,0 @@ -/* - * Ported for use with the UltraStor 14f by Gary Close (gclose@wvnvms.wvnet.edu) - * Thanks to Julian Elischer for advice and help with this port. - * - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * commenced: Sun Sep 27 18:14:01 PDT 1992 - * slight mod to make work with 34F as well: Wed Jun 2 18:05:48 WST 1993 - * - * $Id: ultra14f.c,v 1.9 1993/10/12 07:15:38 rgrimes Exp $ - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef MACH /* EITHER CMU OR OSF */ -#include -#include -#include - -#ifdef OSF /* OSF ONLY */ -#include -#include -#include -#include - -#else OSF /* CMU ONLY */ -#include -#include -#endif OSF -#endif MACH /* end of MACH specific */ - -#ifdef __386BSD__ /* 386BSD specific */ -#define isa_dev isa_device -#define dev_unit id_unit -#define dev_addr id_iobase - -#include -#include -#include -#include -#endif __386BSD__ - -/* */ - -#ifdef __386BSD__ -#include "ddb.h" -#if NDDB > 0 -int Debugger(); -#else NDDB -#define Debugger() panic("should call debugger here") -#endif NDDB -#endif __386BSD__ - -#ifdef MACH -int Debugger(); -#endif MACH - -typedef struct {unsigned char addr[4]; } physaddr; -typedef struct {unsigned char len[4]; } physlen; - - -#ifdef MACH -extern physaddr kvtophys(); -#define PHYSTOKV(x) phystokv(x) -#define KVTOPHYS(x) kvtophys(x) -#endif MACH - -#ifdef __386BSD__ -#define KVTOPHYS(x) vtophys(x) -#endif __386BSD__ - -extern int hz; -extern int delaycount; /* from clock setup code */ -#define NUM_CONCURRENT 16 /* number of concurrent ops per board */ -#define UHA_NSEG 33 /* number of dma segments supported */ -#define FUDGE(X) (X>>1) /* our loops are slower than spinwait() */ -/* */ -/************************** board definitions *******************************/ -/* - * I/O Port Interface -*/ - #define UHA_LMASK (0x000) /* local doorbell mask reg */ - #define UHA_LINT (0x001) /* local doorbell int/stat reg */ - #define UHA_SMASK (0x002) /* system doorbell mask reg */ - #define UHA_SINT (0x003) /* system doorbell int/stat reg */ - #define UHA_ID0 (0x004) /* product id reg 0 */ - #define UHA_ID1 (0x005) /* product id reg 1 */ - #define UHA_CONF1 (0x006) /* config reg 1 */ - #define UHA_CONF2 (0x007) /* config reg 2 */ - #define UHA_OGM0 (0x008) /* outgoing mail ptr 0 least sig */ - #define UHA_OGM1 (0x009) /* outgoing mail ptr 1 least mid */ - #define UHA_OGM2 (0x00a) /* outgoing mail ptr 2 most mid */ - #define UHA_OGM3 (0x00b) /* outgoing mail ptr 3 most sig */ - #define UHA_ICM0 (0x00c) /* incoming mail ptr 0 */ - #define UHA_ICM1 (0x00d) /* incoming mail ptr 1 */ - #define UHA_ICM2 (0x00e) /* incoming mail ptr 2 */ - #define UHA_ICM3 (0x00f) /* incoming mail ptr 3 */ - - /* -* UHA_LMASK bits (read only) -*/ - -#define UHA_LDIE 0x80 /* local doorbell int enabled */ -#define UHA_SRSTE 0x40 /* soft reset enabled */ -#define UHA_ABORTEN 0x10 /* abort MSCP enabled */ -#define UHA_OGMINTEN 0x01 /* outgoing mail interrupt enabled */ - -/* -* UHA_LINT bits (read) -*/ - -#define UHA_LDIP 0x80 /* local doorbell int pending */ - -/* -* UHA_LINT bits (write) -*/ - -#define UHA_ADRST 0x40 /* adapter soft reset */ -#define UHA_SBRST 0x20 /* scsi bus reset */ -#define UHA_ASRST 0x60 /* adapter and scsi reset */ -#define UHA_ABORT 0x10 /* abort MSCP */ -#define UHA_OGMINT 0x01 /* tell adapter to get mail */ - -/* -* UHA_SMASK bits (read) -*/ - -#define UHA_SINTEN 0x80 /* system doorbell interupt Enabled */ -#define UHA_ABORT_COMPLETE_EN 0x10 /* abort MSCP command complete int Enabled */ -#define UHA_ICM_ENABLED 0x01 /* ICM interrupt enabled - -/* -* UHA_SMASK bits (write) -*/ - -#define UHA_ENSINT 0x80 /* enable system doorbell interrupt */ -#define UHA_EN_ABORT_COMPLETE 0x10 /* enable abort MSCP complete int */ -#define UHA_ENICM 0x01 /* enable ICM interrupt */ - -/* -* UHA_SINT bits (read) -*/ - -#define UHA_SINTP 0x80 /* system doorbell int pending */ -#define UHA_ABORT_SUCC 0x10 /* abort MSCP successful */ -#define UHA_ABORT_FAIL 0x18 /* abort MSCP failed */ - -/* -* UHA_SINT bits (write) -*/ - -#define UHA_ABORT_ACK 0x18 /* acknowledge status and clear */ -#define UHA_ICM_ACK 0x01 /* acknowledge ICM and clear */ - -/* -* UHA_CONF1 bits (read only) -*/ - -#define UHA_DMA_CH5 0x00 /* DMA channel 5 */ -#define UHA_DMA_CH6 0x40 /* 6 */ -#define UHA_DMA_CH7 0x80 /* 7 */ -#define UHA_IRQ15 0x00 /* IRQ 15 */ -#define UHA_IRQ14 0x10 /* 14 */ -#define UHA_IRQ11 0x20 /* 11 */ -#define UHA_IRQ10 0x30 /* 10 */ - -/*********************************** -* ha_status error codes -\***********************************/ - -#define UHA_NO_ERR 0x00 /* No error supposedly */ -#define UHA_SBUS_ABORT_ERR 0x84 /* scsi bus abort error */ -#define UHA_SBUS_TIMEOUT 0x91 /* scsi bus selection timeout */ -#define UHA_SBUS_OVER_UNDER 0x92 /* scsi bus over/underrun */ -#define UHA_BAD_SCSI_CMD 0x96 /* illegal scsi command */ -#define UHA_AUTO_SENSE_ERR 0x9b /* auto request sense err */ -#define UHA_SBUS_RES_ERR 0xa3 /* scsi bus reset error */ -#define UHA_BAD_SG_LIST 0xff /* invalid scatter gath list */ - -/* */ - -struct uha_dma_seg -{ - physaddr addr; - physlen len; -}; -/* */ - -struct mscp -{ - unsigned char opcode:3; - #define U14_HAC 0x01 /*host adapter command*/ - #define U14_TSP 0x02 /*target scsi pass through command*/ - #define U14_SDR 0x04 /*scsi device reset*/ - unsigned char xdir:2; /*xfer direction*/ - #define U14_SDET 0x00 /*determined by scsi command*/ - #define U14_SDIN 0x01 /*scsi data in*/ - #define U14_SDOUT 0x02 /*scsi data out*/ - #define U14_NODATA 0x03 /*no data xfer*/ - unsigned char dcn:1; /*disable disconnect for this command*/ - unsigned char ca:1; /*Cache control*/ - unsigned char sgth:1; /*scatter gather flag*/ - unsigned char target:3; - unsigned char chan:2; /*scsi channel (always 0 for 14f)*/ - unsigned char lun:3; - physaddr data; - physlen datalen; - physaddr link; - unsigned char link_id; - unsigned char sg_num; /*number of scat gath segs */ - /*in s-g list if sg flag is*/ - /*set. starts at 1, 8bytes per*/ - unsigned char senselen; - unsigned char cdblen; - unsigned char cdb[12]; - unsigned char ha_status; - unsigned char targ_status; - physaddr sense; /* if 0 no auto sense */ - /*-----------------end of hardware supported fields----------------*/ - struct mscp *next; /* in free list */ - struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ - int flags; -#define MSCP_FREE 0 -#define MSCP_ACTIVE 1 -#define MSCP_ABORTED 2 - struct uha_dma_seg uha_dma[UHA_NSEG]; - struct scsi_sense_data mscp_sense; -}; - -/* */ - -struct uha_data -{ - int flags; -#define UHA_INIT 0x01; - int baseport; - struct mscp mscps[NUM_CONCURRENT]; - struct mscp *free_mscp; - int our_id; /* our scsi id */ - int vect; - int dma; -} uha_data[NUHA]; - -int uhaprobe(); -int uha_attach(); -int uhaintr(); -int uha_scsi_cmd(); -int uha_timeout(); -int uha_abort(); -struct mscp *cheat; -void uhaminphys(); -long int uha_adapter_info(); - -unsigned long int scratch; - -#ifdef MACH -struct isa_driver uhadriver = { uhaprobe, 0, uha_attach, "uha", 0, 0, 0}; -int (*uhaintrs[])() = {uhaintr, 0}; -#endif MACH - -#ifdef __386BSD__ -struct isa_driver uhadriver = { uhaprobe, uha_attach, "uha"}; -#endif __386BSD__ - -static uha_unit = 0; -#ifdef UHADEBUG -int uha_debug = 0; -#endif /*UHADEBUG*/ -#define UHA_SHOWMSCPS 0x01 -#define UHA_SHOWINTS 0x02 -#define UHA_SHOWCMDS 0x04 -#define UHA_SHOWMISC 0x08 -#define FAIL 1 -#define SUCCESS 0 -#define PAGESIZ 4096 - -struct scsi_switch uha_switch = -{ - uha_scsi_cmd, - uhaminphys, - 0, - 0, - uha_adapter_info, - "uha", - 0,0 -}; - -/* */ -/***********************************************************************\ -* Function to send a command out through a mailbox * -\***********************************************************************/ -uha_send_mbox( int unit - ,struct mscp *mscp) -{ - int port = uha_data[unit].baseport; - int spincount = FUDGE(delaycount) * 1000; /* 1s should be enough */ - int s = splbio(); - - while( ((inb(port + UHA_LINT) & (UHA_LDIP)) - != (0)) - && (spincount--)); - if(spincount == -1) - { - printf("uha%d: uha_send_mbox, board not responding\n",unit); - Debugger(); - } - - outl(port + UHA_OGM0,KVTOPHYS(mscp)); - outb(port + UHA_LINT, (UHA_OGMINT)); - splx(s); -} - -/***********************************************************************\ -* Function to send abort to 14f * -\***********************************************************************/ - -uha_abort( int unit - ,struct mscp *mscp) -{ - int port = uha_data[unit].baseport; - int spincount = FUDGE(delaycount) * 1; - int abortcount = FUDGE(delaycount) * 2000; - int s = splbio(); - - while(((inb(port + UHA_LINT) & (UHA_LDIP)) - != (0)) - && (spincount--)); - if(spincount == -1); - { - printf("uha%d: uha_abort, board not responding\n",unit); - Debugger(); - } - - outl(port + UHA_OGM0,KVTOPHYS(mscp)); - outb(port + UHA_LINT,UHA_ABORT); - - while((abortcount--) && (!(inb(port + UHA_SINT) & UHA_ABORT_FAIL))); - if(abortcount == -1) - { - printf("uha%d: uha_abort, board not responding\n",unit); - Debugger(); - } - if((inb(port + UHA_SINT) & 0x10) != 0) - { - outb(port + UHA_SINT,UHA_ABORT_ACK); - return(1); - } - else - { - outb(port + UHA_SINT,UHA_ABORT_ACK); - return(0); - } -} - -/***********************************************************************\ -* Function to poll for command completion when in poll mode * -\***********************************************************************/ -uha_poll(int unit ,int wait) /* in msec */ -{ - int port = uha_data[unit].baseport; - int spincount = FUDGE(delaycount) * wait; /* in msec */ - int stport = port + UHA_SINT; - int start = spincount; - -retry: - while( (spincount--) && (!(inb(stport) & UHA_SINTP))); - if(spincount == -1) - { - printf("uha%d: uha_poll, board not responding\n",unit); - return(EIO); - } -if ((int)cheat != PHYSTOKV(inl(port + UHA_ICM0))) -{ - printf("uha%d: discarding %x\n",unit,inl(port + UHA_ICM0)); - outb(port + UHA_SINT, UHA_ICM_ACK); - spinwait(50); - goto retry; -}/* don't know this will work */ - uhaintr(unit); - return(0); -} - -/*******************************************************\ -* Check if the device can be found at the port given * -* and if so, set it up ready for further work * -* as an argument, takes the isa_dev structure from * -* autoconf.c * -\*******************************************************/ -uhaprobe(dev) -struct isa_dev *dev; -{ - int unit = uha_unit; - dev->dev_unit = unit; - uha_data[unit].baseport = dev->dev_addr; - if(unit >= NUHA) - { - printf("uha%d: unit number too high\n",unit); - return(0); - } - - /*try and initialize unit at this location*/ - if (uha_init(unit) != 0) - { - return(0); - } - - /* if its there put in it's interrupt and DRQ vectors */ - - dev->id_irq = (1 << uha_data[unit].vect); - dev->id_drq = uha_data[unit].dma; - - - uha_unit ++; -return(1); -} - -/***********************************************\ -* Attach all the sub-devices we can find * -\***********************************************/ -uha_attach(dev) -struct isa_dev *dev; -{ - int unit = dev->dev_unit; - - - /***********************************************\ - * ask the adapter what subunits are present * - \***********************************************/ - scsi_attachdevs( unit, uha_data[unit].our_id, &uha_switch); - -#if defined(OSF) - uha_attached[unit]=1; -#endif /* defined(OSF) */ - return; -} - -/***********************************************\ -* Return some information to the caller about * -* the adapter and it's capabilities * -\***********************************************/ -long int uha_adapter_info(unit) -int unit; -{ - return(2); /* 2 outstanding requests at a time per device */ -} - -/***********************************************\ -* Catch an interrupt from the adaptor * -\***********************************************/ -uhaintr(unit) -{ - struct mscp *mscp; - u_char uhastat; - unsigned long int mboxval; - - int port = uha_data[unit].baseport; - - -#ifdef UHADEBUG - if(scsi_debug & PRINTROUTINES) - printf("uhaintr "); -#endif /*UHADEBUG*/ - -#if defined(OSF) - if (!uha_attached[unit]) - { - return(1); - } -#endif /* defined(OSF) */ - while(inb(port + UHA_SINT) & UHA_SINTP) - { - /***********************************************\ - * First get all the information and then * - * acknowlege the interrupt * - \***********************************************/ - uhastat = inb(port + UHA_SINT); - mboxval = inl(port + UHA_ICM0); - outb(port + UHA_SINT,UHA_ICM_ACK); - -#ifdef UHADEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("status = 0x%x ",uhastat); -#endif /*UHADEBUG*/ - /***********************************************\ - * Process the completed operation * - \***********************************************/ - - mscp = (struct mscp *)(PHYSTOKV(mboxval)); - -#ifdef UHADEBUG - if(uha_debug & UHA_SHOWCMDS ) - { - uha_show_scsi_cmd(mscp->xs); - } - if((uha_debug & UHA_SHOWMSCPS) && mscp) - printf("",mscp); -#endif /*UHADEBUG*/ - untimeout(uha_timeout,mscp); - - uha_done(unit,mscp); - } - return(1); -} - -/***********************************************\ -* We have a mscp which has been processed by the * -* adaptor, now we look to see how the operation * -* went. * -\***********************************************/ - -uha_done(unit,mscp) -int unit; -struct mscp *mscp; -{ - struct scsi_sense_data *s1,*s2; - struct scsi_xfer *xs = mscp->xs; - -#ifdef UHADEBUG - if(scsi_debug & (PRINTROUTINES | TRACEINTERRUPTS)) - printf("uha_done "); -#endif /*UHADEBUG*/ - /***********************************************\ - * Otherwise, put the results of the operation * - * into the xfer and call whoever started it * - \***********************************************/ - if ( (mscp->ha_status == UHA_NO_ERR) || (xs->flags & SCSI_ERR_OK)) - { /* All went correctly OR errors expected */ - xs->resid = 0; - xs->error = 0; - } - else - { - - s1 = &(mscp->mscp_sense); - s2 = &(xs->sense); - - if(mscp->ha_status != UHA_NO_ERR) - { - switch(mscp->ha_status) - { - case UHA_SBUS_TIMEOUT: /* No response */ -#ifdef UHADEBUG - if (uha_debug & UHA_SHOWMISC) - { - printf("timeout reported back\n"); - } -#endif /*UHADEBUG*/ - xs->error = XS_TIMEOUT; - break; - case UHA_SBUS_OVER_UNDER: -#ifdef UHADEBUG - if (uha_debug & UHA_SHOWMISC) - { - printf("scsi bus xfer over/underrun\n"); - } -#endif /*UHADEBUG*/ - xs->error = XS_DRIVER_STUFFUP; - break; - case UHA_BAD_SG_LIST: -#ifdef UHADEBUG - if (uha_debug & UHA_SHOWMISC) - { - printf("bad sg list reported back\n"); - } -#endif /*UHADEBUG*/ - xs->error = XS_DRIVER_STUFFUP; - break; - default: /* Other scsi protocol messes */ - xs->error = XS_DRIVER_STUFFUP; -#ifdef UHADEBUG - if (uha_debug & UHA_SHOWMISC) - { - printf("unexpected ha_status: %x\n", - mscp->ha_status); - } -#endif /*UHADEBUG*/ - } - - } - else - { - - if (mscp->targ_status != 0) -/**************************************************************************\ -* I have no information for any possible value of target status field * -* other than 0 means no error!! So I guess any error is unexpected in that * -* event!! * -\**************************************************************************/ - - { -#ifdef UHADEBUG - if (uha_debug & UHA_SHOWMISC) - { - printf("unexpected targ_status: %x\n", - mscp->targ_status); - } -#endif /*UHADEBUG*/ - xs->error = XS_DRIVER_STUFFUP; - } - } - } -done: xs->flags |= ITSDONE; - uha_free_mscp(unit,mscp, xs->flags); - if(xs->when_done) - (*(xs->when_done))(xs->done_arg,xs->done_arg2); -} - -/***********************************************\ -* A mscp (and hence a mbx-out is put onto the * -* free list. * -\***********************************************/ -uha_free_mscp(unit,mscp, flags) -struct mscp *mscp; -{ - unsigned int opri; - -#ifdef UHADEBUG - if(scsi_debug & PRINTROUTINES) - printf("mscp%d(0x%x)> ",unit,flags); -#endif /*UHADEBUG*/ - if (!(flags & SCSI_NOMASK)) - opri = splbio(); - - mscp->next = uha_data[unit].free_mscp; - uha_data[unit].free_mscp = mscp; - mscp->flags = MSCP_FREE; - /***********************************************\ - * If there were none, wake abybody waiting for * - * one to come free, starting with queued entries* - \***********************************************/ - if (!mscp->next) { - wakeup(&uha_data[unit].free_mscp); - } - if (!(flags & SCSI_NOMASK)) - splx(opri); -} - -/***********************************************\ -* Get a free mscp (and hence mbox-out entry) * -\***********************************************/ -struct mscp * -uha_get_mscp(unit,flags) -{ - unsigned opri; - struct mscp *rc; - -#ifdef UHADEBUG - if(scsi_debug & PRINTROUTINES) - printf("next; - rc->flags = MSCP_ACTIVE; - } - if (!(flags & SCSI_NOMASK)) - splx(opri); - return(rc); -} - - - -/***********************************************\ -* Start the board, ready for normal operation * -\***********************************************/ - -uha_init(unit) -int unit; -{ - unsigned char ad[4]; - volatile unsigned char model; - volatile unsigned char submodel; - unsigned char config_reg1; - unsigned char config_reg2; - unsigned char dma_ch; - unsigned char irq_ch; - unsigned char uha_id; - int port = uha_data[unit].baseport; - int i; - int resetcount = FUDGE(delaycount) * 4000; - - model = inb(port + UHA_ID0); - submodel = inb(port + UHA_ID1); - if ((model != 0x56) & (submodel != 0x40)) { -#ifdef UHADEBUG - printf("uha%d: uha_init, board not responding\n",unit); -#endif /*UHADEBUG*/ - return(ENXIO); - } - - printf("uha%d: reading board settings, ",unit); - - config_reg1 = inb(port + UHA_CONF1); - config_reg2 = inb(port + UHA_CONF2); - dma_ch = (config_reg1 & 0xc0); - irq_ch = (config_reg1 & 0x30); - uha_id = (config_reg2 & 0x07); - - switch(dma_ch) - { - case UHA_DMA_CH5: - uha_data[unit].dma = 5; - printf("dma=5 "); - break; - case UHA_DMA_CH6: - uha_data[unit].dma = 6; - printf("dma=6 "); - break; - case UHA_DMA_CH7: - uha_data[unit].dma = 7; - printf("dma=7 "); - break; - default: - printf("illegal dma jumper setting\n"); - return(EIO); - } - switch(irq_ch) - { - case UHA_IRQ10: - uha_data[unit].vect = 10; - printf("int=10 "); - break; - case UHA_IRQ11: - uha_data[unit].vect = 11; - printf("int=11 "); - break; - case UHA_IRQ14: - uha_data[unit].vect = 14; - printf("int=14 "); - break; - case UHA_IRQ15: - uha_data[unit].vect = 15; - printf("int=15 "); - break; - default: - printf("illegal int jumper setting\n"); - return(EIO); - } - /* who are we on the scsi bus */ - printf("id=%x\n",uha_id); - uha_data[unit].our_id = uha_id; - - - /***********************************************\ - * link up all our MSCPs into a free list * - \***********************************************/ - for (i=0; i < NUM_CONCURRENT; i++) - { - uha_data[unit].mscps[i].next = uha_data[unit].free_mscp; - uha_data[unit].free_mscp = &uha_data[unit].mscps[i]; - uha_data[unit].free_mscp->flags = MSCP_FREE; - } - - /***********************************************\ - * Note that we are going and return (to probe) * - \***********************************************/ - outb(port + UHA_LINT, UHA_ASRST); - while( (resetcount--) && (!(inb(port + UHA_LINT)))); - if(resetcount == -1) - { - printf("uha%d: board timed out during reset\n",unit); - return(ENXIO); - } - - outb(port + UHA_SMASK, 0x81); /* make sure interrupts are enabled */ - uha_data[unit].flags |= UHA_INIT; - return(0); -} - - - -#ifndef min -#define min(x,y) (x < y ? x : y) -#endif min - - -void uhaminphys(bp) -struct buf *bp; -{ -#ifdef MACH -#if !defined(OSF) - bp->b_flags |= B_NPAGES; /* can support scat/gather */ -#endif /* defined(OSF) */ -#endif MACH - if(bp->b_bcount > ((UHA_NSEG-1) * PAGESIZ)) - { - bp->b_bcount = ((UHA_NSEG-1) * PAGESIZ); - } -} - -/***********************************************\ -* start a scsi operation given the command and * -* the data address. Also needs the unit, target * -* and lu * -\***********************************************/ -int uha_scsi_cmd(xs) -struct scsi_xfer *xs; -{ - struct scsi_sense_data *s1,*s2; - struct mscp *mscp; - struct uha_dma_seg *sg; - int seg; /* scatter gather seg being worked on */ - int i = 0; - int rc = 0; - int thiskv; - unsigned long int thisphys,nextphys; - int unit =xs->adapter; - int bytes_this_seg,bytes_this_page,datalen,flags; - struct iovec *iovp; - int s; - unsigned int stat; - int port = uha_data[unit].baseport; - unsigned long int templen; - - -#ifdef UHADEBUG - if(scsi_debug & PRINTROUTINES) - printf("uha_scsi_cmd "); -#endif /*UHADEBUG*/ - /***********************************************\ - * get a mscp (mbox-out) to use. If the transfer * - * is from a buf (possibly from interrupt time) * - * then we can't allow it to sleep * - \***********************************************/ - flags = xs->flags; - if(xs->bp) flags |= (SCSI_NOSLEEP); /* just to be sure */ - if(flags & ITSDONE) - { - printf("uha%d: Already done?",unit); - xs->flags &= ~ITSDONE; - } - if(!(flags & INUSE)) - { - printf("uha%d: Not in use?",unit); - xs->flags |= INUSE; - } - if (!(mscp = uha_get_mscp(unit,flags))) - { - xs->error = XS_DRIVER_STUFFUP; - return(TRY_AGAIN_LATER); - } - -cheat = mscp; -#ifdef UHADEBUG - if(uha_debug & UHA_SHOWMSCPS) - printf("",mscp); - if(scsi_debug & SHOWCOMMANDS) - { - uha_show_scsi_cmd(xs); - } -#endif /*UHADEBUG*/ - mscp->xs = xs; - /***********************************************\ - * Put all the arguments for the xfer in the mscp * - \***********************************************/ - - if (flags & SCSI_RESET) - { - mscp->opcode = 0x04; - mscp->ca = 0x01; - } - else - { - mscp->opcode = 0x02; - mscp->ca = 0x01; - } - - if (flags & SCSI_DATA_IN) - { - mscp->xdir = 0x01; - } - if (flags & SCSI_DATA_OUT) - { - mscp->xdir = 0x02; - } - - if (xs->lu != 0) - { - xs->error = XS_DRIVER_STUFFUP; - uha_free_mscp(unit,mscp,flags); - return(HAD_ERROR); - } - - mscp->dcn = 0x00; - mscp->chan = 0x00; - mscp->target = xs->targ; - mscp->lun = xs->lu; - mscp->link.addr[0] = 0x00; - mscp->link.addr[1] = 0x00; - mscp->link.addr[2] = 0x00; - mscp->link.addr[3] = 0x00; - mscp->link_id = 0x00; - mscp->cdblen = xs->cmdlen; - scratch = KVTOPHYS(&(mscp->mscp_sense)); - mscp->sense.addr[0] = (scratch & 0xff); - mscp->sense.addr[1] = ((scratch >> 8) & 0xff); - mscp->sense.addr[2] = ((scratch >> 16) & 0xff); - mscp->sense.addr[3] = ((scratch >> 24) & 0xff); - mscp->senselen = sizeof(mscp->mscp_sense); - mscp->ha_status = 0x00; - mscp->targ_status = 0x00; - - if(xs->datalen) - { /* should use S/G only if not zero length */ - scratch = KVTOPHYS(mscp->uha_dma); - mscp->data.addr[0] = (scratch & 0xff); - mscp->data.addr[1] = ((scratch >> 8) & 0xff); - mscp->data.addr[2] = ((scratch >> 16) & 0xff); - mscp->data.addr[3] = ((scratch >> 24) & 0xff); - sg = mscp->uha_dma ; - seg = 0; - mscp->sgth = 0x01; - - if(flags & SCSI_DATA_UIO) - { - iovp = ((struct uio *)xs->data)->uio_iov; - datalen = ((struct uio *)xs->data)->uio_iovcnt; - xs->datalen = 0; - while ((datalen) && (seg < UHA_NSEG)) - { - scratch = (unsigned long)iovp->iov_base; - sg->addr.addr[0] = (scratch & 0xff); - sg->addr.addr[1] = ((scratch >> 8) & 0xff); - sg->addr.addr[2] = ((scratch >> 16) & 0xff); - sg->addr.addr[3] = ((scratch >> 24) & 0xff); - xs->datalen += *(unsigned long *)sg->len.len = iovp->iov_len; -#ifdef UHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x@0x%x)" - ,iovp->iov_len - ,iovp->iov_base); -#endif /*UHADEBUG*/ - sg++; - iovp++; - seg++; - datalen--; - } - } - else - { - /***********************************************\ - * Set up the scatter gather block * - \***********************************************/ - -#ifdef UHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("%d @0x%x:- ",xs->datalen,xs->data); -#endif /*UHADEBUG*/ - datalen = xs->datalen; - thiskv = (int)xs->data; - thisphys = KVTOPHYS(thiskv); - templen = 0; - - while ((datalen) && (seg < UHA_NSEG)) - { - bytes_this_seg = 0; - - /* put in the base address */ - sg->addr.addr[0] = (thisphys & 0xff); - sg->addr.addr[1] = ((thisphys >> 8) & 0xff); - sg->addr.addr[2] = ((thisphys >> 16) & 0xff); - sg->addr.addr[3] = ((thisphys >> 24) & 0xff); - -#ifdef UHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("0x%x",thisphys); -#endif /*UHADEBUG*/ - - /* do it at least once */ - nextphys = thisphys; - while ((datalen) && (thisphys == nextphys)) - /*********************************************\ - * This page is contiguous (physically) with * - * the the last, just extend the length * - \*********************************************/ - { - /* how far to the end of the page */ - nextphys = (thisphys & (~(PAGESIZ - 1))) - + PAGESIZ; - bytes_this_page = nextphys - thisphys; - /**** or the data ****/ - bytes_this_page = min(bytes_this_page - ,datalen); - bytes_this_seg += bytes_this_page; - datalen -= bytes_this_page; - - /* get more ready for the next page */ - thiskv = (thiskv & (~(PAGESIZ - 1))) - + PAGESIZ; - if(datalen) - thisphys = KVTOPHYS(thiskv); - } - /********************************************\ - * next page isn't contiguous, finish the seg * - \********************************************/ -#ifdef UHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("(0x%x)",bytes_this_seg); -#endif /*UHADEBUG*/ - sg->len.len[0] = (bytes_this_seg & 0xff); - sg->len.len[1] = ((bytes_this_seg >> 8) & 0xff); - sg->len.len[2] = ((bytes_this_seg >> 16) & 0xff); - sg->len.len[3] = ((bytes_this_seg >> 24) & 0xff); - templen += bytes_this_seg; - sg++; - seg++; - } - } /*end of iov/kv decision */ - mscp->datalen.len[0] = (templen & 0xff); - mscp->datalen.len[1] = ((templen >> 8) & 0xff); - mscp->datalen.len[2] = ((templen >> 16) & 0xff); - mscp->datalen.len[3] = ((templen >> 24) & 0xff); - mscp->sg_num = seg; - -#ifdef UHADEBUG - if(scsi_debug & SHOWSCATGATH) - printf("\n"); -#endif /*UHADEBUG*/ - if (datalen) - { /* there's still data, must have run out of segs! */ - printf("uha%d: uha_scsi_cmd, more than %d DMA segs\n", - unit,UHA_NSEG); - xs->error = XS_DRIVER_STUFFUP; - uha_free_mscp(unit,mscp,flags); - return(HAD_ERROR); - } - - } - else - { /* No data xfer, use non S/G values */ - mscp->data.addr[0] = 0x00; - mscp->data.addr[1] = 0x00; - mscp->data.addr[2] = 0x00; - mscp->data.addr[3] = 0x00; - mscp->datalen.len[0] = 0x00; - mscp->datalen.len[1] = 0x00; - mscp->datalen.len[2] = 0x00; - mscp->datalen.len[3] = 0x00; - mscp->xdir = 0x03; - mscp->sgth = 0x00; - mscp->sg_num = 0x00; - } - - /***********************************************\ - * Put the scsi command in the mscp and start it * - \***********************************************/ - bcopy(xs->cmd, mscp->cdb, xs->cmdlen); - - /***********************************************\ - * Usually return SUCCESSFULLY QUEUED * - \***********************************************/ - if (!(flags & SCSI_NOMASK)) - { - s = splbio(); - uha_send_mbox(unit,mscp); - timeout(uha_timeout,mscp,(xs->timeout * hz) / 1000); - splx(s); -#ifdef UHADEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("cmd_sent "); -#endif /*UHADEBUG*/ - return(SUCCESSFULLY_QUEUED); - } - /***********************************************\ - * If we can't use interrupts, poll on completion* - \***********************************************/ - uha_send_mbox(unit,mscp); -#ifdef UHADEBUG - if(scsi_debug & TRACEINTERRUPTS) - printf("cmd_wait "); -#endif /*UHADEBUG*/ - do - { - if(uha_poll(unit,xs->timeout)) - { - if (!(xs->flags & SCSI_SILENT)) - printf("uha%d: cmd fail\n",unit); - if(!(uha_abort(unit,mscp))) - { - printf("uha%d: abort failed in wait\n",unit); - uha_free_mscp(unit,mscp,flags); - } - xs->error = XS_DRIVER_STUFFUP; - return(HAD_ERROR); - } - } while (!(xs->flags & ITSDONE));/* something (?) else finished */ - if(xs->error) - { - return(HAD_ERROR); - } - return(COMPLETE); -} - - -uha_timeout(struct mscp *mscp) -{ - int unit; - int s = splbio(); - int port = uha_data[unit].baseport; - - unit = mscp->xs->adapter; - printf("uha%d:%d device timed out\n",unit - ,mscp->xs->targ); -#ifdef UHADEBUG - if(uha_debug & UHA_SHOWMSCPS) - uha_print_active_mscp(unit); -#endif /*UHADEBUG*/ - - if((uha_abort(unit,mscp) !=1) || (mscp->flags = MSCP_ABORTED)) - { - printf("AGAIN"); - mscp->xs->retries = 0; /* I MEAN IT ! */ - uha_done(unit,mscp,FAIL); - } - else /* abort the operation that has timed out */ - { - printf("\n"); - timeout(uha_timeout,mscp,2 * hz); - mscp->flags = MSCP_ABORTED; - } - splx(s); -} - -uha_show_scsi_cmd(struct scsi_xfer *xs) -{ - u_char *b = (u_char *)xs->cmd; - int i = 0; - if(!(xs->flags & SCSI_RESET)) - { - printf("uha%d:%d:%d-" - ,xs->adapter - ,xs->targ - ,xs->lu); - while(i < xs->cmdlen ) - { - if(i) printf(","); - printf("%x",b[i++]); - } - printf("-\n"); - } - else - { - printf("uha%d:%d:%d-RESET-\n" - ,xs->adapter - ,xs->targ - ,xs->lu - ); - } -} -uha_print_mscp(mscp) -struct mscp *mscp; -{ - printf("mscp:%x op:%x cmdlen:%d senlen:%d\n" - ,mscp - ,mscp->opcode - ,mscp->cdblen - ,mscp->senselen); - printf(" sg:%d sgnum:%x datlen:%d hstat:%x tstat:%x flags:%x\n" - ,mscp->sgth - ,mscp->sg_num - ,mscp->datalen - ,mscp->ha_status - ,mscp->targ_status - ,mscp->flags); - uha_show_scsi_cmd(mscp->xs); -} - -uha_print_active_mscp(int unit) -{ - struct mscp *mscp = uha_data[unit].mscps; - int i = NUHA; - - while(i--) - { - if(mscp->flags != MSCP_FREE) - uha_print_mscp(mscp); - mscp++; - } -} diff --git a/sys/i386/isa/vector.s b/sys/i386/isa/vector.s deleted file mode 100644 index aa40fd5..0000000 --- a/sys/i386/isa/vector.s +++ /dev/null @@ -1,368 +0,0 @@ -/* - * from: vector.s, 386BSD 0.1 unknown origin - * $Id$ - */ - -#include "i386/isa/icu.h" -#include "i386/isa/isa.h" -#include "vector.h" - -#define ICU_EOI 0x20 /* XXX - define elsewhere */ - -#define IRQ_BIT(irq_num) (1 << ((irq_num) % 8)) -#define IRQ_BYTE(irq_num) ((irq_num) / 8) - -#define ENABLE_ICU1 \ - movb $ICU_EOI,%al ; /* as soon as possible send EOI ... */ \ - FASTER_NOP ; /* ... ASAP ... */ \ - outb %al,$IO_ICU1 /* ... to clear in service bit */ -#ifdef AUTO_EOI_1 -#undef ENABLE_ICU1 /* we now use auto-EOI to reduce i/o */ -#define ENABLE_ICU1 -#endif - -#define ENABLE_ICU1_AND_2 \ - movb $ICU_EOI,%al ; /* as above */ \ - FASTER_NOP ; \ - outb %al,$IO_ICU2 ; /* but do second icu first */ \ - FASTER_NOP ; \ - outb %al,$IO_ICU1 /* then first icu */ -#ifdef AUTO_EOI_2 -#undef ENABLE_ICU1_AND_2 /* data sheet says no auto-EOI on slave ... */ -#define ENABLE_ICU1_AND_2 /* ... but it works */ -#endif - -/* - * Macros for interrupt interrupt entry, call to handler, and exit. - * - * XXX - the interrupt frame is set up to look like a trap frame. This is - * usually a waste of time. The only interrupt handlers that want a frame - * are the clock handler (it wants a clock frame), the npx handler (it's - * easier to do right all in assembler). The interrupt return routine - * needs a trap frame for rare AST's (it could easily convert the frame). - * The direct costs of setting up a trap frame are two pushl's (error - * code and trap number), an addl to get rid of these, and pushing and - * popping the call-saved regs %esi, %edi and %ebp twice, The indirect - * costs are making the driver interface nonuniform so unpending of - * interrupts is more complicated and slower (call_driver(unit) would - * be easier than ensuring an interrupt frame for all handlers. Finally, - * there are some struct copies in the npx handler and maybe in the clock - * handler that could be avoided by working more with pointers to frames - * instead of frames. - * - * XXX - should we do a cld on every system entry to avoid the requirement - * for scattered cld's? - * - * Coding notes for *.s: - * - * If possible, avoid operations that involve an operand size override. - * Word-sized operations might be smaller, but the operand size override - * makes them slower on on 486's and no faster on 386's unless perhaps - * the instruction pipeline is depleted. E.g., - * - * Use movl to seg regs instead of the equivalent but more descriptive - * movw - gas generates an irelevant (slower) operand size override. - * - * Use movl to ordinary regs in preference to movw and especially - * in preference to movz[bw]l. Use unsigned (long) variables with the - * top bits clear instead of unsigned short variables to provide more - * opportunities for movl. - * - * If possible, use byte-sized operations. They are smaller and no slower. - * - * Use (%reg) instead of 0(%reg) - gas generates larger code for the latter. - * - * If the interrupt frame is made more flexible, INTR can push %eax first - * and decide the ipending case with less overhead, e.g., by avoiding - * loading segregs. - */ - -#define FAST_INTR(unit, irq_num, id_num, handler, enable_icus) \ - pushl %eax ; /* save only call-used registers */ \ - pushl %ecx ; \ - pushl %edx ; \ - pushl %ds ; \ - /* pushl %es ; know compiler doesn't do string insns */ \ - movl $KDSEL,%eax ; \ - movl %ax,%ds ; \ - /* movl %ax,%es ; */ \ - SHOW_CLI ; /* although it interferes with "ASAP" */ \ - pushl $unit ; \ - call handler ; /* do the work ASAP */ \ - enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \ - addl $4,%esp ; \ - incl _cnt+V_INTR ; /* book-keeping can wait */ \ - COUNT_EVENT(_intrcnt_actv, id_num) ; \ - SHOW_STI ; \ - /* popl %es ; */ \ - popl %ds ; \ - popl %edx; \ - popl %ecx; \ - popl %eax; \ - iret - -#define INTR(unit, irq_num, id_num, mask, handler, icu, enable_icus, reg, stray) \ - pushl $0 ; /* dummy error code */ \ - pushl $T_ASTFLT ; \ - pushal ; \ - pushl %ds ; /* save our data and extra segments ... */ \ - pushl %es ; \ - movl $KDSEL,%eax ; /* ... and reload with kernel's own ... */ \ - movl %ax,%ds ; /* ... early in case SHOW_A_LOT is on */ \ - movl %ax,%es ; \ - SHOW_CLI ; /* interrupt did an implicit cli */ \ - movb _imen + IRQ_BYTE(irq_num),%al ; \ - orb $IRQ_BIT(irq_num),%al ; \ - movb %al,_imen + IRQ_BYTE(irq_num) ; \ - SHOW_IMEN ; \ - FASTER_NOP ; \ - outb %al,$icu+1 ; \ - enable_icus ; \ - incl _cnt+V_INTR ; /* tally interrupts */ \ - movl _cpl,%eax ; \ - testb $IRQ_BIT(irq_num),%reg ; \ - jne 2f ; \ -1: ; \ - COUNT_EVENT(_intrcnt_actv, id_num) ; \ - movl _cpl,%eax ; \ - pushl %eax ; \ - pushl $unit ; \ - orl mask,%eax ; \ - movl %eax,_cpl ; \ - SHOW_CPL ; \ - SHOW_STI ; \ - sti ; \ - call handler ; \ - movb _imen + IRQ_BYTE(irq_num),%al ; \ - andb $~IRQ_BIT(irq_num),%al ; \ - movb %al,_imen + IRQ_BYTE(irq_num) ; \ - SHOW_IMEN ; \ - FASTER_NOP ; \ - outb %al,$icu+1 ; \ - jmp doreti ; \ -; \ - ALIGN_TEXT ; \ -2: ; \ - COUNT_EVENT(_intrcnt_pend, id_num) ; \ - movl $1b,%eax ; /* register resume address */ \ - /* XXX - someday do it at attach time */ \ - movl %eax,Vresume + (irq_num) * 4 ; \ - orb $IRQ_BIT(irq_num),_ipending + IRQ_BYTE(irq_num) ; \ - SHOW_IPENDING ; \ - popl %es ; \ - popl %ds ; \ - popal ; \ - addl $4+4,%esp ; \ - iret - -/* - * vector.h has defined a macro 'BUILD_VECTORS' containing a big list of info - * about vectors, including a submacro 'BUILD_VECTOR' that operates on the - * info about each vector. We redefine 'BUILD_VECTOR' to expand the info - * in different ways. Here we expand it to a list of interrupt handlers. - * This order is of course unimportant. Elsewhere we expand it to inline - * linear search code for which the order is a little more important and - * concatenating the code with no holes is very important. - * - * XXX - now there is BUILD_FAST_VECTOR as well as BUILD_VECTOR. - * - * The info consists of the following items for each vector: - * - * name (identifier): name of the vector; used to build labels - * unit (expression): unit number to call the device driver with - * irq_num (number): number of the IRQ to handled (0-15) - * id_num (number): uniq numeric id for handler (assigned by config) - * mask (blank-ident): priority mask used - * handler (blank-ident): interrupt handler to call - * icu_num (number): (1 + irq_num / 8) converted for label building - * icu_enables (number): 1 for icu_num == 1, 1_AND_2 for icu_num == 2 - * reg (blank-ident): al for icu_num == 1, ah for icu_num == 2 - * - * 'irq_num' is converted in several ways at config time to get around - * limitations in cpp. The macros have blanks after commas iff they would - * not mess up identifiers and numbers. - */ - -#undef BUILD_FAST_VECTOR -#define BUILD_FAST_VECTOR(name, unit, irq_num, id_num, mask, handler, \ - icu_num, icu_enables, reg) \ - .globl handler ; \ - .text ; \ - .globl _V/**/name ; \ - SUPERALIGN_TEXT ; \ -_V/**/name: ; \ - FAST_INTR(unit, irq_num, id_num, handler, ENABLE_ICU/**/icu_enables) - -#undef BUILD_VECTOR -#define BUILD_VECTOR(name, unit, irq_num, id_num, mask, handler, \ - icu_num, icu_enables, reg) \ - .globl handler ; \ - .text ; \ - .globl _V/**/name ; \ - SUPERALIGN_TEXT ; \ -_V/**/name: ; \ - INTR(unit,irq_num,id_num, mask, handler, IO_ICU/**/icu_num, \ - ENABLE_ICU/**/icu_enables, reg,) - - BUILD_VECTORS - - /* hardware interrupt catcher (IDT 32 - 47) */ - .globl _isa_strayintr - -#define STRAYINTR(irq_num, icu_num, icu_enables, reg) \ -IDTVEC(intr/**/irq_num) ; \ - INTR(irq_num,irq_num,irq_num, _highmask, _isa_strayintr, \ - IO_ICU/**/icu_num, ENABLE_ICU/**/icu_enables, reg,stray) - -/* - * XXX - the mask (1 << 2) == IRQ_SLAVE will be generated for IRQ 2, instead - * of the mask IRQ2 (defined as IRQ9 == (1 << 9)). But IRQ 2 "can't happen". - * In fact, all stray interrupts "can't happen" except for bugs. The - * "stray" IRQ 7 is documented behaviour of the 8259. It happens when there - * is a glitch on any of its interrupt inputs. Does it really interrupt when - * IRQ 7 is masked? - * - * XXX - unpend doesn't work for these, it sends them to the real handler. - * - * XXX - the race bug during initialization may be because I changed the - * order of switching from the stray to the real interrupt handler to before - * enabling interrupts. The old order looked unsafe but maybe it is OK with - * the stray interrupt handler installed. But these handlers only reduce - * the window of vulnerability - it is still open at the end of - * isa_configure(). - * - * XXX - many comments are stale. - */ - - STRAYINTR(0,1,1, al) - STRAYINTR(1,1,1, al) - STRAYINTR(2,1,1, al) - STRAYINTR(3,1,1, al) - STRAYINTR(4,1,1, al) - STRAYINTR(5,1,1, al) - STRAYINTR(6,1,1, al) - STRAYINTR(8,2,1_AND_2, ah) - STRAYINTR(9,2,1_AND_2, ah) - STRAYINTR(10,2,1_AND_2, ah) - STRAYINTR(11,2,1_AND_2, ah) - STRAYINTR(12,2,1_AND_2, ah) - STRAYINTR(13,2,1_AND_2, ah) - STRAYINTR(14,2,1_AND_2, ah) - STRAYINTR(15,2,1_AND_2, ah) -IDTVEC(intrdefault) - STRAYINTR(7,1,1, al) /* XXX */ -#if 0 - INTRSTRAY(255, _highmask, 255) ; call _isa_strayintr ; INTREXIT2 -#endif -/* - * These are the interrupt counters, I moved them here from icu.s so that - * they are with the name table. rgrimes - * - * There are now lots of counters, this has been redone to work with - * Bruce Evans intr-0.1 code, which I modified some more to make it all - * work with vmstat. - */ - .data -Vresume: .space 16 * 4 /* where to resume intr handler after unpend */ - .globl _intrcnt -_intrcnt: /* used by vmstat to calc size of table */ - .globl _intrcnt_bad7 -_intrcnt_bad7: .space 4 /* glitches on irq 7 */ - .globl _intrcnt_bad15 -_intrcnt_bad15: .space 4 /* glitches on irq 15 */ - .globl _intrcnt_stray -_intrcnt_stray: .space 4 /* total count of stray interrupts */ - .globl _intrcnt_actv -_intrcnt_actv: .space NR_REAL_INT_HANDLERS * 4 /* active interrupts */ - .globl _intrcnt_pend -_intrcnt_pend: .space NR_REAL_INT_HANDLERS * 4 /* pending interrupts */ - .globl _eintrcnt -_eintrcnt: /* used by vmstat to calc size of table */ - .globl _intrcnt_spl -_intrcnt_spl: .space 32 * 4 /* XXX 32 should not be hard coded ? */ - .globl _intrcnt_show -_intrcnt_show: .space 8 * 4 /* XXX 16 should not be hard coded ? */ - -/* - * Build the interrupt name table for vmstat - */ - -#undef BUILD_FAST_VECTOR -#define BUILD_FAST_VECTOR BUILD_VECTOR - -#undef BUILD_VECTOR -#define BUILD_VECTOR(name, unit, irq_num, id_num, mask, handler, \ - icu_num, icu_enables, reg) \ - .ascii "name irq" ; \ - .asciz "irq_num" -/* - * XXX - use the STRING and CONCAT macros from to stringize - * and concatenate names above and elsewhere. - */ - - .text - .globl _intrnames, _eintrnames -_intrnames: - BUILD_VECTOR(bad,,7,,,,,,) - BUILD_VECTOR(bad,,15,,,,,,) - BUILD_VECTOR(stray,,,,,,,,) - BUILD_VECTORS - -#undef BUILD_FAST_VECTOR -#define BUILD_FAST_VECTOR BUILD_VECTOR - -#undef BUILD_VECTOR -#define BUILD_VECTOR(name, unit, irq_num, id_num, mask, handler, \ - icu_num, icu_enables, reg) \ - .asciz "name pend" - - BUILD_VECTORS -_eintrnames: - -/* - * now the spl names - */ - .asciz "unpend_v" - .asciz "doreti" - .asciz "p0!ni" - .asciz "!p0!ni" - .asciz "p0ni" - .asciz "netisr_raw" - .asciz "netisr_ip" - .asciz "netisr_imp" - .asciz "netisr_ns" - .asciz "netisr_iso" - .asciz "softclock" /* 10 */ - .asciz "trap" - .asciz "doreti_exit2" - .asciz "splbio" - .asciz "splclock" - .asciz "splhigh" - .asciz "splimp" - .asciz "splnet" - .asciz "splsoftclock" - .asciz "spltty" - .asciz "spl0" /* 20 */ - .asciz "netisr_raw2" - .asciz "netisr_ip2" - .asciz "netisr_imp2" - .asciz "netisr_ns2" - .asciz "netisr_iso2" - .asciz "splx" - .asciz "splx!0" - .asciz "unpend_V" - .asciz "spl29" /* spl29-spl31 are spares */ - .asciz "spl30" - .asciz "spl31" -/* - * now the mask names - */ - .asciz "cli" - .asciz "cpl" - .asciz "imen" - .asciz "ipending" - .asciz "sti" - .asciz "mask5" /* mask5-mask7 are spares */ - .asciz "mask6" - .asciz "mask7" - diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c deleted file mode 100644 index 02b53e4..0000000 --- a/sys/i386/isa/wd.c +++ /dev/null @@ -1,1341 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)wd.c 7.2 (Berkeley) 5/9/91 - * $Id$ - */ - -/* TODO:peel out buffer at low ipl, speed improvement */ - - -#include "wd.h" -#if NWD > 0 - -#include "param.h" -#include "dkbad.h" -#include "systm.h" -#include "conf.h" -#include "file.h" -#include "stat.h" -#include "ioctl.h" -#include "disklabel.h" -#include "buf.h" -#include "uio.h" -#include "malloc.h" -#include "machine/cpu.h" -#include "i386/isa/isa.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/icu.h" -#include "i386/isa/wdreg.h" -#include "syslog.h" -#include "vm/vm.h" - -#define _NWD (NWD - 1) /* One is for the controller XXX 31 Jul 92*/ - -#ifndef WDCTIMEOUT -#define WDCTIMEOUT 10000000 /* arbitrary timeout for drive ready waits */ -#endif - -#define RETRIES 5 /* number of retries before giving up */ -#define MAXTRANSFER 32 /* max size of transfer in page clusters */ - -#define wdnoreloc(dev) (minor(dev) & 0x80) /* ignore partition table */ -#define wddospart(dev) (minor(dev) & 0x40) /* use dos partitions */ -#define wdunit(dev) ((minor(dev) & 0x38) >> 3) -#define wdpart(dev) (minor(dev) & 0x7) -#define makewddev(maj, unit, part) (makedev(maj,((unit<<3)+part))) -#define WDRAW 3 /* 'd' partition isn't a partition! */ - -#define b_cylin b_resid /* cylinder number for doing IO to */ - /* shares an entry in the buf struct */ - -/* - * Drive states. Used to initialize drive. - */ - -#define CLOSED 0 /* disk is closed. */ -#define WANTOPEN 1 /* open requested, not started */ -#define RECAL 2 /* doing restore */ -#define OPEN 3 /* done with open */ - -/* - * The structure of a disk drive. - */ -struct disk { - long dk_bc; /* byte count left */ - short dk_skip; /* blocks already transferred */ - char dk_unit; /* physical unit number */ - char dk_state; /* control state */ - u_char dk_status; /* copy of status reg. */ - u_char dk_error; /* copy of error reg. */ - short dk_port; /* i/o port base */ - - u_long dk_copenpart; /* character units open on this drive */ - u_long dk_bopenpart; /* block units open on this drive */ - u_long dk_openpart; /* all units open on this drive */ - short dk_wlabel; /* label writable? */ - short dk_flags; /* drive characteistics found */ -#define DKFL_DOSPART 0x00001 /* has DOS partition table */ -#define DKFL_QUIET 0x00002 /* report errors back, but don't complain */ -#define DKFL_SINGLE 0x00004 /* sector at a time mode */ -#define DKFL_ERROR 0x00008 /* processing a disk error */ -#define DKFL_BSDLABEL 0x00010 /* has a BSD disk label */ -#define DKFL_BADSECT 0x00020 /* has a bad144 badsector table */ -#define DKFL_WRITEPROT 0x00040 /* manual unit write protect */ - struct wdparams dk_params; /* ESDI/IDE drive/controller parameters */ - struct disklabel dk_dd; /* device configuration data */ - struct dos_partition - dk_dospartitions[NDOSPART]; /* DOS view of disk */ - struct dkbad dk_bad; /* bad sector table */ -}; - -struct disk *wddrives[_NWD]; /* table of units */ -struct buf wdtab; -struct buf wdutab[_NWD]; /* head of queue per drive */ -struct buf rwdbuf[_NWD]; /* buffers for raw IO */ -long wdxfer[_NWD]; /* count of transfers */ -#ifdef WDDEBUG -int wddebug; -#endif - -struct isa_driver wddriver = { - wdprobe, wdattach, "wd", -}; - -static void wdustart(struct disk *); -static void wdstart(); -static int wdcommand(struct disk *, int); -static int wdcontrol(struct buf *); -static int wdsetctlr(dev_t, struct disk *); -static int wdgetctlr(int, struct disk *); - -/* - * Probe for controller. - */ -int -wdprobe(struct isa_device *dvp) -{ - int unit = dvp->id_unit; - struct disk *du; - int wdc; - - if (unit >= _NWD) /* 31 Jul 92*/ - return(0); - - if ((du = wddrives[unit]) == 0) { - du = wddrives[unit] = (struct disk *) - malloc (sizeof(struct disk), M_TEMP, M_NOWAIT); - bzero (du, sizeof(struct disk)); /* 31 Jul 92*/ - du->dk_unit = unit; - } - - wdc = du->dk_port = dvp->id_iobase; - - /* check if we have registers that work */ - outb(wdc+wd_cyl_lo, 0xa5) ; /* wd_cyl_lo is read/write */ - if(inb(wdc+wd_cyl_lo) != 0xa5) - goto nodevice; - - /* reset the device */ - outb(wdc+wd_ctlr, (WDCTL_RST|WDCTL_IDS)); - DELAY(1000); - outb(wdc+wd_ctlr, WDCTL_IDS); - DELAY(1000); - - /* execute a controller only command */ - if (wdcommand(du, WDCC_DIAGNOSE) < 0) - goto nodevice; - - (void) inb(wdc+wd_error); /* XXX! */ - outb(wdc+wd_ctlr, WDCTL_4BIT); - return (IO_WDCSIZE); - -nodevice: - free(du, M_TEMP); - wddrives[unit] = 0; - return (0); -} - -/* - * Attach each drive if possible. - */ -int -wdattach(struct isa_device *dvp) -{ - int unit; -/* int unit = dvp->id_unit;*/ - - for (unit=0; unit< _NWD; unit++) { - struct disk *du; - if ((du = wddrives[unit]) == 0) { - du = wddrives[unit] = (struct disk *) - malloc (sizeof(struct disk), M_TEMP, M_NOWAIT); - bzero (du, sizeof(struct disk)); - du->dk_unit = unit; - du->dk_port = dvp->id_iobase; - } - - /* print out description of drive, suppressing multiple blanks*/ - if(wdgetctlr(unit, du) == 0) { - int i, blank; - char c; - printf("wd%d: unit %d type ", unit, unit); - for (i = blank = 0 ; i < sizeof(du->dk_params.wdp_model); i++) { - char c = du->dk_params.wdp_model[i]; - - if (blank && c == ' ') continue; - if (blank && c != ' ') { - printf(" %c", c); - blank = 0; - continue; - } - if (c == ' ') - blank = 1; - else - printf("%c", c); - } - printf("\n"); - du->dk_unit = unit; - } - } - return(1); -} - -/* Read/write routine for a buffer. Finds the proper unit, range checks - * arguments, and schedules the transfer. Does not wait for the transfer - * to complete. Multi-page transfers are supported. All I/O requests must - * be a multiple of a sector in length. - */ -int -wdstrategy(register struct buf *bp) -{ - register struct buf *dp; - struct disklabel *lp; - register struct partition *p; - struct disk *du; /* Disk unit to do the IO. */ - long maxsz, sz; - int unit = wdunit(bp->b_dev); - int s; - - /* valid unit, controller, and request? */ - if (unit >= _NWD || bp->b_blkno < 0 || (du = wddrives[unit]) == 0) { - - bp->b_error = EINVAL; - bp->b_flags |= B_ERROR; - goto done; - } - - /* "soft" write protect check */ - if ((du->dk_flags & DKFL_WRITEPROT) && (bp->b_flags & B_READ) == 0) { - bp->b_error = EROFS; - bp->b_flags |= B_ERROR; - goto done; - } - - /* have partitions and want to use them? */ - if ((du->dk_flags & DKFL_BSDLABEL) != 0 && wdpart(bp->b_dev) != WDRAW) { - - /* - * do bounds checking, adjust transfer. if error, process. - * if end of partition, just return - */ - if (bounds_check_with_label(bp, &du->dk_dd, du->dk_wlabel) <= 0) - goto done; - /* otherwise, process transfer request */ - } - -q: - /* queue transfer on drive, activate drive and controller if idle */ - dp = &wdutab[unit]; - s = splbio(); - disksort(dp, bp); - if (dp->b_active == 0) - wdustart(du); /* start drive */ - if (wdtab.b_active == 0) - wdstart(s); /* start controller */ - splx(s); - return; - -done: - /* toss transfer, we're done early */ - biodone(bp); -} - -/* - * Routine to queue a command to the controller. The unit's - * request is linked into the active list for the controller. - * If the controller is idle, the transfer is started. - */ -static void -wdustart(register struct disk *du) -{ - register struct buf *bp, *dp = &wdutab[du->dk_unit]; - - /* unit already active? */ - if (dp->b_active) - return; - - /* anything to start? */ - bp = dp->b_actf; - if (bp == NULL) - return; - - /* link onto controller queue */ - dp->b_forw = NULL; - if (wdtab.b_actf == NULL) - wdtab.b_actf = dp; - else - wdtab.b_actl->b_forw = dp; - wdtab.b_actl = dp; - - /* mark the drive unit as busy */ - dp->b_active = 1; -} - -/* - * Controller startup routine. This does the calculation, and starts - * a single-sector read or write operation. Called to start a transfer, - * or from the interrupt routine to continue a multi-sector transfer. - * RESTRICTIONS: - * 1. The transfer length must be an exact multiple of the sector size. - */ - -static void -wdstart() -{ - register struct disk *du; /* disk unit for IO */ - register struct buf *bp; - struct disklabel *lp; - struct buf *dp; - register struct bt_bad *bt_ptr; - long blknum, pagcnt, cylin, head, sector; - long secpertrk, secpercyl, addr, i, timeout; - int unit, s, wdc; - -loop: - /* is there a drive for the controller to do a transfer with? */ - dp = wdtab.b_actf; - if (dp == NULL) - return; - - /* is there a transfer to this drive ? if so, link it on - the controller's queue */ - bp = dp->b_actf; - if (bp == NULL) { - wdtab.b_actf = dp->b_forw; - goto loop; - } - - /* obtain controller and drive information */ - unit = wdunit(bp->b_dev); - du = wddrives[unit]; - - /* if not really a transfer, do control operations specially */ - if (du->dk_state < OPEN) { - (void) wdcontrol(bp); - return; - } - - /* calculate transfer details */ - blknum = bp->b_blkno + du->dk_skip; -/*if(wddebug)printf("bn%d ", blknum);*/ -#ifdef WDDEBUG - if (du->dk_skip == 0) - printf("\nwdstart %d: %s %d@%d; map ", unit, - (bp->b_flags & B_READ) ? "read" : "write", - bp->b_bcount, blknum); - else - printf(" %d)%x", du->dk_skip, inb(wdc+wd_altsts)); -#endif - addr = (int) bp->b_un.b_addr; - if (du->dk_skip == 0) - du->dk_bc = bp->b_bcount; - - lp = &du->dk_dd; - secpertrk = lp->d_nsectors; - secpercyl = lp->d_secpercyl; - if ((du->dk_flags & DKFL_BSDLABEL) != 0 && wdpart(bp->b_dev) != WDRAW) - blknum += lp->d_partitions[wdpart(bp->b_dev)].p_offset; - cylin = blknum / secpercyl; - head = (blknum % secpercyl) / secpertrk; - sector = blknum % secpertrk; - - /* - * See if the current block is in the bad block list. - * (If we have one, and not formatting.) - */ - if ((du->dk_flags & (DKFL_SINGLE|DKFL_BADSECT)) /* 19 Aug 92*/ - == (DKFL_SINGLE|DKFL_BADSECT)) - /* XXX - * BAD144END was done to clean up some old bad code that was - * attempting to compare a u_short to -1. This makes the compilers - * happy and clearly shows what is going on. - * rgrimes 93/06/17 - */ -#define BAD144END (u_short)(-1) - for (bt_ptr = du->dk_bad.bt_bad; bt_ptr->bt_cyl != BAD144END; bt_ptr++) { - if (bt_ptr->bt_cyl > cylin) - /* Sorted list, and we passed our cylinder. quit. */ - break; - if (bt_ptr->bt_cyl == cylin && - bt_ptr->bt_trksec == (head << 8) + sector) { - /* - * Found bad block. Calculate new block addr. - * This starts at the end of the disk (skip the - * last track which is used for the bad block list), - * and works backwards to the front of the disk. - */ -#ifdef WDDEBUG - printf("--- badblock code -> Old = %d; ", - blknum); -#endif - blknum = lp->d_secperunit - lp->d_nsectors - - (bt_ptr - du->dk_bad.bt_bad) - 1; - cylin = blknum / secpercyl; - head = (blknum % secpercyl) / secpertrk; - sector = blknum % secpertrk; -#ifdef WDDEBUG - printf("new = %d\n", blknum); -#endif - break; - } - } -/*if(wddebug)pg("c%d h%d s%d ", cylin, head, sector);*/ - sector += 1; /* sectors begin with 1, not 0 */ - - wdtab.b_active = 1; /* mark controller active */ - wdc = du->dk_port; - -RETRY: - /* if starting a multisector transfer, or doing single transfers */ - if (du->dk_skip == 0 || (du->dk_flags & DKFL_SINGLE)) { - if (wdtab.b_errcnt && (bp->b_flags & B_READ) == 0) - du->dk_bc += DEV_BSIZE; - - /* controller idle? */ - timeout = 0; - while (inb(wdc+wd_status) & WDCS_BUSY) - { - if (++timeout > WDCTIMEOUT) - { - printf("wd.c: Controller busy too long!\n"); - /* reset the device */ - outb(wdc+wd_ctlr, (WDCTL_RST|WDCTL_IDS)); - DELAY(1000); - outb(wdc+wd_ctlr, WDCTL_IDS); - DELAY(1000); - (void) inb(wdc+wd_error); /* XXX! */ - outb(wdc+wd_ctlr, WDCTL_4BIT); - break; - } - } - - /* stuff the task file */ - outb(wdc+wd_precomp, lp->d_precompcyl / 4); -#ifdef B_FORMAT - if (bp->b_flags & B_FORMAT) { - outb(wdc+wd_sector, lp->d_gap3); - outb(wdc+wd_seccnt, lp->d_nsectors); - } else { -#endif - if (du->dk_flags & DKFL_SINGLE) - outb(wdc+wd_seccnt, 1); - else - outb(wdc+wd_seccnt, howmany(du->dk_bc, DEV_BSIZE)); - outb(wdc+wd_sector, sector); - -#ifdef B_FORMAT - } -#endif - - outb(wdc+wd_cyl_lo, cylin); - outb(wdc+wd_cyl_hi, cylin >> 8); - - /* set up the SDH register (select drive) */ - outb(wdc+wd_sdh, WDSD_IBM | (unit<<4) | (head & 0xf)); - - /* wait for drive to become ready */ - timeout = 0; - while ((inb(wdc+wd_status) & WDCS_READY) == 0) - { - if (++timeout > WDCTIMEOUT) - { - printf("wd.c: Drive busy too long!\n"); - /* reset the device */ - outb(wdc+wd_ctlr, (WDCTL_RST|WDCTL_IDS)); - DELAY(1000); - outb(wdc+wd_ctlr, WDCTL_IDS); - DELAY(1000); - (void) inb(wdc+wd_error); /* XXX! */ - outb(wdc+wd_ctlr, WDCTL_4BIT); - goto RETRY; - } - } - - /* initiate command! */ -#ifdef B_FORMAT - if (bp->b_flags & B_FORMAT) - outb(wdc+wd_command, WDCC_FORMAT); - else -#endif - outb(wdc+wd_command, - (bp->b_flags & B_READ)? WDCC_READ : WDCC_WRITE); -#ifdef WDDEBUG - printf("sector %d cylin %d head %d addr %x sts %x\n", - sector, cylin, head, addr, inb(wdc+wd_altsts)); -#endif - } - - /* if this is a read operation, just go away until it's done. */ - if (bp->b_flags & B_READ) return; - - /* ready to send data? */ - timeout = 0; - while ((inb(wdc+wd_status) & WDCS_DRQ) == 0) - { - if (++timeout > WDCTIMEOUT) - { - printf("wd.c: Drive not ready for too long!\n"); - /* reset the device */ - outb(wdc+wd_ctlr, (WDCTL_RST|WDCTL_IDS)); - DELAY(1000); - outb(wdc+wd_ctlr, WDCTL_IDS); - DELAY(1000); - (void) inb(wdc+wd_error); /* XXX! */ - outb(wdc+wd_ctlr, WDCTL_4BIT); - goto RETRY; - } - } - - /* then send it! */ - outsw (wdc+wd_data, addr+du->dk_skip * DEV_BSIZE, - DEV_BSIZE/sizeof(short)); - du->dk_bc -= DEV_BSIZE; -} - -/* Interrupt routine for the controller. Acknowledge the interrupt, check for - * errors on the current operation, mark it done if necessary, and start - * the next request. Also check for a partially done transfer, and - * continue with the next chunk if so. - */ -void -wdintr(struct intrframe wdif) -{ - register struct disk *du; - register struct buf *bp, *dp; - int status, wdc; - char partch ; - - if (!wdtab.b_active) { -#ifdef nyet - printf("wd: extra interrupt\n"); -#endif - return; - } - - dp = wdtab.b_actf; - bp = dp->b_actf; - du = wddrives[wdunit(bp->b_dev)]; - wdc = du->dk_port; - -#ifdef WDDEBUG - printf("I "); -#endif - - while ((status = inb(wdc+wd_status)) & WDCS_BUSY) ; - - /* is it not a transfer, but a control operation? */ - if (du->dk_state < OPEN) { - if (wdcontrol(bp)) - wdstart(); - return; - } - - /* have we an error? */ - if (status & (WDCS_ERR | WDCS_ECCCOR)) { - - du->dk_status = status; - du->dk_error = inb(wdc + wd_error); -#ifdef WDDEBUG - printf("status %x error %x\n", status, du->dk_error); -#endif - if((du->dk_flags & DKFL_SINGLE) == 0) { - du->dk_flags |= DKFL_ERROR; - goto outt; - } -#ifdef B_FORMAT - if (bp->b_flags & B_FORMAT) { - bp->b_error = EIO; /* 17 Sep 92*/ - bp->b_flags |= B_ERROR; - goto done; - } -#endif - - /* error or error correction? */ - if (status & WDCS_ERR) { - if (++wdtab.b_errcnt < RETRIES) { - wdtab.b_active = 0; - } else { - diskerr(bp, "wd", "hard error", LOG_PRINTF, - du->dk_skip, &du->dk_dd); -#ifdef WDDEBUG - printf( "status %b error %b\n", - status, WDCS_BITS, - inb(wdc+wd_error), WDERR_BITS); -#endif - bp->b_error = EIO; /* 17 Sep 92*/ - bp->b_flags |= B_ERROR; /* flag the error */ - } - } else { - diskerr(bp, "wd", "soft ecc", 0, - du->dk_skip, &du->dk_dd); - } - } -outt: - - /* - * If this was a successful read operation, fetch the data. - */ - if (((bp->b_flags & (B_READ | B_ERROR)) == B_READ) && wdtab.b_active) { - int chk, dummy; - - chk = min(DEV_BSIZE / sizeof(short), du->dk_bc / sizeof(short)); - - /* ready to receive data? */ - while ((inb(wdc+wd_status) & WDCS_DRQ) == 0) - ; - - /* suck in data */ - insw (wdc+wd_data, - (int)bp->b_un.b_addr + du->dk_skip * DEV_BSIZE, chk); - du->dk_bc -= chk * sizeof(short); - - /* for obselete fractional sector reads */ - while (chk++ < 256) insw (wdc+wd_data, &dummy, 1); - } - - wdxfer[du->dk_unit]++; - if (wdtab.b_active) { - if ((bp->b_flags & B_ERROR) == 0) { - du->dk_skip++; /* Add to successful sectors. */ - if (wdtab.b_errcnt) - diskerr(bp, "wd", "soft error", 0, - du->dk_skip, &du->dk_dd); - wdtab.b_errcnt = 0; - - /* see if more to transfer */ - if (du->dk_bc > 0 && (du->dk_flags & DKFL_ERROR) == 0) { - wdstart(); - return; /* next chunk is started */ - } else if ((du->dk_flags & (DKFL_SINGLE|DKFL_ERROR)) - == DKFL_ERROR) { - du->dk_skip = 0; - du->dk_flags &= ~DKFL_ERROR; - du->dk_flags |= DKFL_SINGLE; - wdstart(); - return; /* redo xfer sector by sector */ - } - } - -done: - /* done with this transfer, with or without error */ - du->dk_flags &= ~DKFL_SINGLE; - wdtab.b_actf = dp->b_forw; - wdtab.b_errcnt = 0; - du->dk_skip = 0; - dp->b_active = 0; - dp->b_actf = bp->av_forw; - dp->b_errcnt = 0; - bp->b_resid = 0; - biodone(bp); - } - - /* controller idle */ - wdtab.b_active = 0; - - /* anything more on drive queue? */ - if (dp->b_actf) - wdustart(du); - /* anything more for controller to do? */ - if (wdtab.b_actf) - wdstart(); -} - -/* - * Initialize a drive. - */ -int -wdopen(dev_t dev, int flags, int fmt, struct proc *p) -{ - register unsigned int unit; - register struct disk *du; - int part = wdpart(dev), mask = 1 << part; - struct partition *pp; - struct dkbad *db; - int i, error = 0; - char *msg; - - unit = wdunit(dev); - if (unit >= _NWD) return (ENXIO) ; - - du = wddrives[unit]; - if (du == 0) return (ENXIO) ; - - if ((du->dk_flags & DKFL_BSDLABEL) == 0) { - du->dk_flags |= DKFL_WRITEPROT; - wdutab[unit].b_actf = NULL; - - /* - * Use the default sizes until we've read the label, - * or longer if there isn't one there. - */ - bzero(&du->dk_dd, sizeof(du->dk_dd)); -#undef d_type /* fix goddamn segments.h! XXX */ - du->dk_dd.d_type = DTYPE_ST506; - du->dk_dd.d_ncylinders = 1024; - du->dk_dd.d_secsize = DEV_BSIZE; - du->dk_dd.d_ntracks = 8; - du->dk_dd.d_nsectors = 17; - du->dk_dd.d_secpercyl = 17*8; - du->dk_state = WANTOPEN; - du->dk_unit = unit; - - /* read label using "c" partition */ - if (msg = readdisklabel(makewddev(major(dev), wdunit(dev), WDRAW), - wdstrategy, &du->dk_dd, du->dk_dospartitions, - &du->dk_bad, 0)) { - log(LOG_WARNING, "wd%d: cannot find label (%s)\n", - unit, msg); - if (part != WDRAW) - error = EINVAL; /* XXX needs translation */ - goto done; - } else { - - wdsetctlr(dev, du); - du->dk_flags |= DKFL_BSDLABEL; - du->dk_flags &= ~DKFL_WRITEPROT; - if (du->dk_dd.d_flags & D_BADSECT) - du->dk_flags |= DKFL_BADSECT; - } - -done: - if (error) - return(error); - - } - /* - * Warn if a partion is opened - * that overlaps another partition which is open - * unless one is the "raw" partition (whole disk). - */ - if ((du->dk_openpart & mask) == 0 /*&& part != RAWPART*/ && part != WDRAW) { - int start, end; - - pp = &du->dk_dd.d_partitions[part]; - start = pp->p_offset; - end = pp->p_offset + pp->p_size; - for (pp = du->dk_dd.d_partitions; - pp < &du->dk_dd.d_partitions[du->dk_dd.d_npartitions]; - pp++) { - if (pp->p_offset + pp->p_size <= start || - pp->p_offset >= end) - continue; - /*if (pp - du->dk_dd.d_partitions == RAWPART) - continue; */ - if (pp - du->dk_dd.d_partitions == WDRAW) - continue; - if (du->dk_openpart & (1 << (pp - - du->dk_dd.d_partitions))) - log(LOG_WARNING, - "wd%d%c: overlaps open partition (%c)\n", - unit, part + 'a', - pp - du->dk_dd.d_partitions + 'a'); - } - } - if (part >= du->dk_dd.d_npartitions && part != WDRAW) - return (ENXIO); - - /* insure only one open at a time */ - du->dk_openpart |= mask; - switch (fmt) { - case S_IFCHR: - du->dk_copenpart |= mask; - break; - case S_IFBLK: - du->dk_bopenpart |= mask; - break; - } - return (0); -} - -/* - * Implement operations other than read/write. - * Called from wdstart or wdintr during opens and formats. - * Uses finite-state-machine to track progress of operation in progress. - * Returns 0 if operation still in progress, 1 if completed. - */ -static int -wdcontrol(register struct buf *bp) -{ - register struct disk *du; - register unit; - unsigned char stat; - int s, cnt; - extern int bootdev; - int cyl, trk, sec, i, wdc; - struct wdparams foo; - - du = wddrives[wdunit(bp->b_dev)]; - unit = du->dk_unit; - wdc = du->dk_port; - - switch (du->dk_state) { - - tryagainrecal: - case WANTOPEN: /* set SDH, step rate, do restore */ -#ifdef WDDEBUG - printf("wd%d: recal ", unit); -#endif - s = splbio(); /* not called from intr level ... */ - wdgetctlr(unit, du); - - outb(wdc+wd_sdh, WDSD_IBM | (unit << 4)); - wdtab.b_active = 1; - - /* wait for drive and controller to become ready */ - for (i = WDCTIMEOUT; (inb(wdc+wd_status) & (WDCS_READY|WDCS_BUSY)) - != WDCS_READY && i-- != 0; ) - ; - outb(wdc+wd_command, WDCC_RESTORE | WD_STEP); - du->dk_state++; - splx(s); - return(0); - - case RECAL: - if ((stat = inb(wdc+wd_status)) & WDCS_ERR) { - printf("wd%d: recal", du->dk_unit); - printf(": status %b error %b\n", stat, WDCS_BITS, - inb(wdc+wd_error), WDERR_BITS); - if (++wdtab.b_errcnt < RETRIES) { - du->dk_state = WANTOPEN; - goto tryagainrecal; - } - bp->b_error = ENXIO; /* XXX needs translation */ - goto badopen; - } - - /* some controllers require this ... */ - wdsetctlr(bp->b_dev, du); - - wdtab.b_errcnt = 0; - du->dk_state = OPEN; - /* - * The rest of the initialization can be done - * by normal means. - */ - return(1); - - default: - panic("wdcontrol"); - } - /* NOTREACHED */ - -badopen: - printf(": status %b error %b\n", stat, WDCS_BITS, - inb(wdc + wd_error), WDERR_BITS); - bp->b_flags |= B_ERROR; - return(1); -} - -/* - * send a command and wait uninterruptibly until controller is finished. - * return -1 if controller busy for too long, otherwise - * return status. intended for brief controller commands at critical points. - * assumes interrupts are blocked. - */ -static int -wdcommand(struct disk *du, int cmd) { - int timeout = WDCTIMEOUT, stat, wdc; - - /* controller ready for command? */ - wdc = du->dk_port; - while (((stat = inb(wdc + wd_status)) & WDCS_BUSY) && timeout > 0) - timeout--; - if (timeout <= 0) - return(-1); - - /* send command, await results */ - outb(wdc+wd_command, cmd); - while (((stat = inb(wdc+wd_status)) & WDCS_BUSY) && timeout > 0) - timeout--; - if (timeout <= 0) - return(-1); - if (cmd != WDCC_READP) - return (stat); - - /* is controller ready to return data? */ - while (((stat = inb(wdc+wd_status)) & (WDCS_ERR|WDCS_DRQ)) == 0 && - timeout > 0) - timeout--; - if (timeout <= 0) - return(-1); - - return (stat); -} - -/* - * issue IDC to drive to tell it just what geometry it is to be. - */ -static int -wdsetctlr(dev_t dev, struct disk *du) { - int stat, x, wdc; - -/*printf("C%dH%dS%d ", du->dk_dd.d_ncylinders, du->dk_dd.d_ntracks, - du->dk_dd.d_nsectors);*/ - - x = splbio(); - wdc = du->dk_port; - outb(wdc+wd_cyl_lo, du->dk_dd.d_ncylinders+1); - outb(wdc+wd_cyl_hi, (du->dk_dd.d_ncylinders+1)>>8); - outb(wdc+wd_sdh, WDSD_IBM | (wdunit(dev) << 4) + du->dk_dd.d_ntracks-1); - outb(wdc+wd_seccnt, du->dk_dd.d_nsectors); - stat = wdcommand(du, WDCC_IDC); - - if (stat < 0) { - splx(x); - return(stat); - } - if (stat & WDCS_ERR) - printf("wdsetctlr: status %b error %b\n", - stat, WDCS_BITS, inb(wdc+wd_error), WDERR_BITS); - splx(x); - return(stat); -} - -/* - * issue READP to drive to ask it what it is. - */ -static int -wdgetctlr(int u, struct disk *du) { - int stat, x, i, wdc; - char tb[DEV_BSIZE]; - struct wdparams *wp; - - x = splbio(); /* not called from intr level ... */ - wdc = du->dk_port; - outb(wdc+wd_sdh, WDSD_IBM | (u << 4)); - stat = wdcommand(du, WDCC_READP); - - if (stat < 0) { - splx(x); - return(stat); - } - /* - * If WDCC_READP fails then we might have an old ST506 type drive - * so we try a seek to 0; if that passes then the - * drive is there but it's OLD AND KRUSTY - */ - if (stat & WDCS_ERR) { - stat = wdcommand(du, WDCC_RESTORE | WD_STEP); - if (stat & WDCS_ERR) { - stat = inb(wdc+wd_error); - splx(x); - return(stat); - } - - strncpy(du->dk_dd.d_typename, "ST506", - sizeof du->dk_dd.d_typename); - strncpy(du->dk_params.wdp_model, "Unknown Type", - sizeof du->dk_params.wdp_model); - du->dk_dd.d_type = DTYPE_ST506; - splx(x); - return(0); - } - - /* obtain parameters */ - wp = &du->dk_params; - insw(wdc+wd_data, tb, sizeof(tb)/sizeof(short)); - bcopy(tb, wp, sizeof(struct wdparams)); - - /* shuffle string byte order */ - for (i=0; i < sizeof(wp->wdp_model) ;i+=2) { - u_short *p; - p = (u_short *) (wp->wdp_model + i); - *p = ntohs(*p); - } -/*printf("gc %x cyl %d trk %d sec %d type %d sz %d model %s\n", wp->wdp_config, -wp->wdp_fixedcyl+wp->wdp_removcyl, wp->wdp_heads, wp->wdp_sectors, -wp->wdp_cntype, wp->wdp_cnsbsz, wp->wdp_model);*/ - - /* update disklabel given drive information */ - du->dk_dd.d_ncylinders = wp->wdp_fixedcyl + wp->wdp_removcyl /*+- 1*/; - du->dk_dd.d_ntracks = wp->wdp_heads; - du->dk_dd.d_nsectors = wp->wdp_sectors; - du->dk_dd.d_secpercyl = du->dk_dd.d_ntracks * du->dk_dd.d_nsectors; - du->dk_dd.d_partitions[1].p_size = du->dk_dd.d_secpercyl * - wp->wdp_sectors; - du->dk_dd.d_partitions[1].p_offset = 0; - /* dubious ... */ - bcopy("ESDI/IDE", du->dk_dd.d_typename, 9); - bcopy(wp->wdp_model+20, du->dk_dd.d_packname, 14-1); - /* better ... */ - du->dk_dd.d_type = DTYPE_ESDI; - du->dk_dd.d_subtype |= DSTYPE_GEOMETRY; - - /* XXX sometimes possibly needed */ - (void) inb(wdc+wd_status); - return (0); -} - - -/* ARGSUSED */ -int -wdclose(dev_t dev, int flags, int fmt) -{ - register struct disk *du; - int part = wdpart(dev), mask = 1 << part; - - du = wddrives[wdunit(dev)]; - - /* insure only one open at a time */ - du->dk_openpart &= ~mask; - switch (fmt) { - case S_IFCHR: - du->dk_copenpart &= ~mask; - break; - case S_IFBLK: - du->dk_bopenpart &= ~mask; - break; - } - return(0); -} - -int -wdioctl(dev_t dev, int cmd, caddr_t addr, int flag) -{ - int unit = wdunit(dev); - register struct disk *du; - int error = 0; - struct uio auio; - struct iovec aiov; - - du = wddrives[unit]; - - switch (cmd) { - - case DIOCSBAD: - if ((flag & FWRITE) == 0) - error = EBADF; - else - du->dk_bad = *(struct dkbad *)addr; - break; - - case DIOCGDINFO: - *(struct disklabel *)addr = du->dk_dd; - break; - - case DIOCGPART: - ((struct partinfo *)addr)->disklab = &du->dk_dd; - ((struct partinfo *)addr)->part = - &du->dk_dd.d_partitions[wdpart(dev)]; - break; - - case DIOCSDINFO: - if ((flag & FWRITE) == 0) - error = EBADF; - else - error = setdisklabel(&du->dk_dd, - (struct disklabel *)addr, - /*(du->dk_flags & DKFL_BSDLABEL) ? du->dk_openpart : */0, - du->dk_dospartitions); - if (error == 0) { - du->dk_flags |= DKFL_BSDLABEL; - wdsetctlr(dev, du); - } - break; - - case DIOCWLABEL: - du->dk_flags &= ~DKFL_WRITEPROT; - if ((flag & FWRITE) == 0) - error = EBADF; - else - du->dk_wlabel = *(int *)addr; - break; - - case DIOCWDINFO: - du->dk_flags &= ~DKFL_WRITEPROT; - if ((flag & FWRITE) == 0) - error = EBADF; - else if ((error = setdisklabel(&du->dk_dd, (struct disklabel *)addr, - /*(du->dk_flags & DKFL_BSDLABEL) ? du->dk_openpart :*/ 0, - du->dk_dospartitions)) == 0) { - int wlab; - - du->dk_flags |= DKFL_BSDLABEL; - wdsetctlr(dev, du); - - /* simulate opening partition 0 so write succeeds */ - du->dk_openpart |= (1 << 0); /* XXX */ - wlab = du->dk_wlabel; - du->dk_wlabel = 1; - error = writedisklabel(dev, wdstrategy, - &du->dk_dd, du->dk_dospartitions); - du->dk_openpart = du->dk_copenpart | du->dk_bopenpart; - du->dk_wlabel = wlab; - } - break; - -#ifdef notyet - case DIOCGDINFOP: - *(struct disklabel **)addr = &(du->dk_dd); - break; - - case DIOCWFORMAT: - if ((flag & FWRITE) == 0) - error = EBADF; - else { - register struct format_op *fop; - - fop = (struct format_op *)addr; - aiov.iov_base = fop->df_buf; - aiov.iov_len = fop->df_count; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_resid = fop->df_count; - auio.uio_segflg = 0; - auio.uio_offset = - fop->df_startblk * du->dk_dd.d_secsize; - error = physio(wdformat, &rwdbuf[unit], dev, B_WRITE, - minphys, &auio); - fop->df_count -= auio.uio_resid; - fop->df_reg[0] = du->dk_status; - fop->df_reg[1] = du->dk_error; - } - break; -#endif - - default: - error = ENOTTY; - break; - } - return (error); -} - -#ifdef B_FORMAT -int -wdformat(struct buf *bp) -{ - - bp->b_flags |= B_FORMAT; - return (wdstrategy(bp)); -} -#endif - -int -wdsize(dev_t dev) -{ - int unit = wdunit(dev), part = wdpart(dev), val = 0; - struct disk *du; - - if (unit >= _NWD) /* 31 Jul 92*/ - return(-1); - - du = wddrives[unit]; - if (du == 0 || du->dk_state == 0) - val = wdopen (makewddev(major(dev), unit, WDRAW), FREAD, S_IFBLK, 0); - if (du == 0 || val != 0 || du->dk_flags & DKFL_WRITEPROT) - return (-1); - - return((int)du->dk_dd.d_partitions[part].p_size); -} - -extern char *vmmap; /* poor name! */ - -int -wddump(dev_t dev) /* dump core after a system crash */ -{ - register struct disk *du; /* disk unit to do the IO */ - register struct bt_bad *bt_ptr; - long num; /* number of sectors to write */ - int unit, part, wdc; - long blkoff, blknum, blkcnt; - long cylin, head, sector, stat; - long secpertrk, secpercyl, nblocks, i; - char *addr; - extern int Maxmem; - static wddoingadump = 0 ; - extern caddr_t CADDR1; - - addr = (char *) 0; /* starting address */ - - /* toss any characters present prior to dump */ - while (sgetc(1)) - ; - - /* size of memory to dump */ - num = Maxmem; - unit = wdunit(dev); /* eventually support floppies? */ - part = wdpart(dev); /* file system */ - /* check for acceptable drive number */ - if (unit >= _NWD) return(ENXIO); /* 31 Jul 92*/ - - du = wddrives[unit]; - if (du == 0) return(ENXIO); - /* was it ever initialized ? */ - if (du->dk_state < OPEN) return (ENXIO) ; - if (du->dk_flags & DKFL_WRITEPROT) return(ENXIO); - wdc = du->dk_port; - - /* Convert to disk sectors */ - num = (u_long) num * NBPG / du->dk_dd.d_secsize; - - /* check if controller active */ - /*if (wdtab.b_active) return(EFAULT); */ - if (wddoingadump) return(EFAULT); - - secpertrk = du->dk_dd.d_nsectors; - secpercyl = du->dk_dd.d_secpercyl; - nblocks = du->dk_dd.d_partitions[part].p_size; - blkoff = du->dk_dd.d_partitions[part].p_offset; - -/*pg("xunit %x, nblocks %d, dumplo %d num %d\n", part,nblocks,dumplo,num);*/ - /* check transfer bounds against partition size */ - if ((dumplo < 0) || ((dumplo + num) > nblocks)) - return(EINVAL); - - /*wdtab.b_active = 1; /* mark controller active for if we - panic during the dump */ - wddoingadump = 1 ; i = 100000 ; - while ((inb(wdc+wd_status) & WDCS_BUSY) && (i-- > 0)) ; - outb(wdc+wd_sdh, WDSD_IBM | (unit << 4)); - outb(wdc+wd_command, WDCC_RESTORE | WD_STEP); - while (inb(wdc+wd_status) & WDCS_BUSY) ; - - /* some compaq controllers require this ... */ - wdsetctlr(dev, du); - - blknum = dumplo + blkoff; - while (num > 0) { -#ifdef notdef - if (blkcnt > MAXTRANSFER) blkcnt = MAXTRANSFER; - if ((blknum + blkcnt - 1) / secpercyl != blknum / secpercyl) - blkcnt = secpercyl - (blknum % secpercyl); - /* keep transfer within current cylinder */ -#endif - pmap_enter(kernel_pmap, CADDR1, trunc_page(addr), VM_PROT_READ, TRUE); - - /* compute disk address */ - cylin = blknum / secpercyl; - head = (blknum % secpercyl) / secpertrk; - sector = blknum % secpertrk; - -#ifdef notyet - /* - * See if the current block is in the bad block list. - * (If we have one.) - */ - for (bt_ptr = du->dk_bad.bt_bad; - bt_ptr->bt_cyl != -1; bt_ptr++) { - if (bt_ptr->bt_cyl > cylin) - /* Sorted list, and we passed our cylinder. - quit. */ - break; - if (bt_ptr->bt_cyl == cylin && - bt_ptr->bt_trksec == (head << 8) + sector) { - /* - * Found bad block. Calculate new block addr. - * This starts at the end of the disk (skip the - * last track which is used for the bad block list), - * and works backwards to the front of the disk. - */ - blknum = (du->dk_dd.d_secperunit) - - du->dk_dd.d_nsectors - - (bt_ptr - du->dk_bad.bt_bad) - 1; - cylin = blknum / secpercyl; - head = (blknum % secpercyl) / secpertrk; - sector = blknum % secpertrk; - break; - } - -#endif - sector++; /* origin 1 */ - - /* select drive. */ - outb(wdc+wd_sdh, WDSD_IBM | (unit<<4) | (head & 0xf)); - while ((inb(wdc+wd_status) & WDCS_READY) == 0) ; - - /* transfer some blocks */ - outb(wdc+wd_sector, sector); - outb(wdc+wd_seccnt,1); - outb(wdc+wd_cyl_lo, cylin); - outb(wdc+wd_cyl_hi, cylin >> 8); -#ifdef notdef - /* lets just talk about this first...*/ - pg ("sdh 0%o sector %d cyl %d addr 0x%x", - inb(wdc+wd_sdh), inb(wdc+wd_sector), - inb(wdc+wd_cyl_hi)*256+inb(wdc+wd_cyl_lo), addr) ; -#endif - outb(wdc+wd_command, WDCC_WRITE); - - /* Ready to send data? */ - while ((inb(wdc+wd_status) & WDCS_DRQ) == 0) ; - if (inb(wdc+wd_status) & WDCS_ERR) return(EIO) ; - - outsw (wdc+wd_data, CADDR1+((int)addr&(NBPG-1)), 256); - - if (inb(wdc+wd_status) & WDCS_ERR) return(EIO) ; - /* Check data request (should be done). */ - if (inb(wdc+wd_status) & WDCS_DRQ) return(EIO) ; - - /* wait for completion */ - for ( i = WDCTIMEOUT ; inb(wdc+wd_status) & WDCS_BUSY ; i--) { - if (i < 0) return (EIO) ; - } - /* error check the xfer */ - if (inb(wdc+wd_status) & WDCS_ERR) return(EIO) ; - - if ((unsigned)addr % (1024*1024) == 0) printf("%d ", num/2048) ; - /* update block count */ - num--; - blknum++ ; - (int) addr += 512; - - /* operator aborting dump? */ - if (sgetc(1)) - return(EINTR); - } - return(0); -} -#endif diff --git a/sys/i386/isa/wdreg.h b/sys/i386/isa/wdreg.h deleted file mode 100644 index 5feabf5..0000000 --- a/sys/i386/isa/wdreg.h +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)wdreg.h 7.1 (Berkeley) 5/9/91 - * $Id$ - */ - -/* - * Disk Controller register definitions. - */ -#define wd_data 0x0 /* data register (R/W - 16 bits) */ -#define wd_error 0x1 /* error register (R) */ -#define wd_precomp wd_error /* write precompensation (W) */ -#define wd_seccnt 0x2 /* sector count (R/W) */ -#define wd_sector 0x3 /* first sector number (R/W) */ -#define wd_cyl_lo 0x4 /* cylinder address, low byte (R/W) */ -#define wd_cyl_hi 0x5 /* cylinder address, high byte (R/W)*/ -#define wd_sdh 0x6 /* sector size/drive/head (R/W)*/ -#define wd_command 0x7 /* command register (W) */ -#define wd_status wd_command /* immediate status (R) */ - -#define wd_altsts 0x206 /*alternate fixed disk status(via 1015) (R)*/ -#define wd_ctlr 0x206 /*fixed disk controller control(via 1015) (W)*/ -#define WDCTL_4BIT 0x8 /* use four head bits (wd1003) */ -#define WDCTL_RST 0x4 /* reset the controller */ -#define WDCTL_IDS 0x2 /* disable controller interrupts */ -#define wd_digin 0x207 /* disk controller input(via 1015) (R)*/ - -/* - * Status Bits. - */ -#define WDCS_BUSY 0x80 /* Controller busy bit. */ -#define WDCS_READY 0x40 /* Selected drive is ready */ -#define WDCS_WRTFLT 0x20 /* Write fault */ -#define WDCS_SEEKCMPLT 0x10 /* Seek complete */ -#define WDCS_DRQ 0x08 /* Data request bit. */ -#define WDCS_ECCCOR 0x04 /* ECC correction made in data */ -#define WDCS_INDEX 0x02 /* Index pulse from selected drive */ -#define WDCS_ERR 0x01 /* Error detect bit. */ - -#define WDCS_BITS "\020\010busy\006rdy\006wrtflt\005seekdone\004drq\003ecc_cor\002index\001err" - -#define WDERR_BITS "\020\010badblk\007uncorr\006id_crc\005no_id\003abort\002tr000\001no_dam" - -/* - * Commands for Disk Controller. - */ -#define WDCC_RESTORE 0x10 /* disk restore code -- resets cntlr */ - -#define WDCC_READ 0x20 /* disk read code */ -#define WDCC_WRITE 0x30 /* disk write code */ -#define WDCC__LONG 0x02 /* modifier -- access ecc bytes */ -#define WDCC__NORETRY 0x01 /* modifier -- no retrys */ - -#define WDCC_FORMAT 0x50 /* disk format code */ -#define WDCC_DIAGNOSE 0x90 /* controller diagnostic */ -#define WDCC_IDC 0x91 /* initialize drive command */ - -#define WDCC_EXTDCMD 0xE0 /* send extended command */ -#define WDCC_READP 0xEC /* read parameters from controller */ -#define WDCC_CACHEC 0xEF /* cache control */ - -#define WD_STEP 0 /* winchester- default 35us step */ - -#define WDSD_IBM 0xa0 /* forced to 512 byte sector, ecc */ - - -#ifdef KERNEL -/* - * read parameters command returns this: - */ -struct wdparams { - /* drive info */ - short wdp_config; /* general configuration */ - short wdp_fixedcyl; /* number of non-removable cylinders */ - short wdp_removcyl; /* number of removable cylinders */ - short wdp_heads; /* number of heads */ - short wdp_unfbytespertrk; /* number of unformatted bytes/track */ - short wdp_unfbytes; /* number of unformatted bytes/sector */ - short wdp_sectors; /* number of sectors */ - short wdp_minisg; /* minimum bytes in inter-sector gap*/ - short wdp_minplo; /* minimum bytes in postamble */ - short wdp_vendstat; /* number of words of vendor status */ - /* controller info */ - char wdp_cnsn[20]; /* controller serial number */ - short wdp_cntype; /* controller type */ -#define WDTYPE_SINGLEPORTSECTOR 1 /* single port, single sector buffer */ -#define WDTYPE_DUALPORTMULTI 2 /* dual port, multiple sector buffer */ -#define WDTYPE_DUALPORTMULTICACHE 3 /* above plus track cache */ - short wdp_cnsbsz; /* sector buffer size, in sectors */ - short wdp_necc; /* ecc bytes appended */ - char wdp_rev[8]; /* firmware revision */ - char wdp_model[40]; /* model name */ - short wdp_nsecperint; /* sectors per interrupt */ - short wdp_usedmovsd; /* can use double word read/write? */ -}; - -/* - * wd driver entry points - */ -int wdprobe(struct isa_device *); -int wdattach(struct isa_device *); -int wdstrategy(struct buf *); -void wdintr(struct intrframe); -int wdopen(dev_t, int, int, struct proc *); -int wdclose(dev_t dev, int flags, int fmt); -int wdioctl(dev_t, int, caddr_t, int); -/* int wdformat(struct buf *bp); */ -int wdsize(dev_t); -int wddump(dev_t); - -#endif KERNEL diff --git a/sys/i386/isa/wt.c b/sys/i386/isa/wt.c deleted file mode 100644 index 7ae351f..0000000 --- a/sys/i386/isa/wt.c +++ /dev/null @@ -1,821 +0,0 @@ -/* - * Streamer tape driver for 386bsd and FreeBSD. - * Supports Archive QIC-02 and Wangtek QIC-02/QIC-36 boards. - * - * Copyright (C) 1993 by: - * Sergey Ryzhkov - * Serge Vakulenko - * - * Placed in the public domain with NO WARRANTIES, not even the implied - * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Authors grant any other persons or organisations permission to use - * or modify this software as long as this message is kept with the software, - * all derivative works or modified versions. - * - * This driver is derived from the old 386bsd Wangtek streamer tape driver, - * made by Robert Baron at CMU, based on Intel sources. - * Authors thank Robert Baron, CMU and Intel and retain here - * the original CMU copyright notice. - * - * from: Version 1.1, Fri Sep 24 02:14:31 MSD 1993 - * $Id$ - */ - -/* - * Copyright (c) 1989 Carnegie-Mellon University. - * All rights reserved. - * - * Authors: Robert Baron - * - * 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 "AS IS" - * 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. - */ - -#include "wt.h" -#if NWT > 0 - -#include "sys/param.h" -#include "sys/buf.h" -#include "sys/fcntl.h" -#include "sys/malloc.h" -#include "sys/ioctl.h" -#include "sys/mtio.h" -#include "vm/vm_param.h" -#include "i386/include/pio.h" -#include "i386/isa/isa_device.h" -#include "i386/isa/wtreg.h" - -#define WTPRI (PZERO+10) /* sleep priority */ -#define BLKSIZE 512 /* streamer tape block size */ - -/* - * Wangtek controller ports - */ -#define WT_CTLPORT(base) ((base)+0) /* control, write only */ -#define WT_STATPORT(base) ((base)+0) /* status, read only */ -#define WT_CMDPORT(base) ((base)+1) /* command, write only */ -#define WT_DATAPORT(base) ((base)+1) /* data, read only */ -#define WT_NPORT 2 /* 2 i/o ports */ - -/* status port bits */ -#define WT_BUSY 0x01 /* not ready bit define */ -#define WT_NOEXCEP 0x02 /* no exception bit define */ -#define WT_RESETMASK 0x07 /* to check after reset */ -#define WT_RESETVAL 0x05 /* state after reset */ - -/* control port bits */ -#define WT_ONLINE 0x01 /* device selected */ -#define WT_RESET 0x02 /* reset command */ -#define WT_REQUEST 0x04 /* request command */ -#define WT_IEN(chan) ((chan)>2 ? 0x10 : 0x8) /* enable intr */ - -/* - * Archive controller ports - */ -#define AV_DATAPORT(base) ((base)+0) /* data, read only */ -#define AV_CMDPORT(base) ((base)+0) /* command, write only */ -#define AV_STATPORT(base) ((base)+1) /* status, read only */ -#define AV_CTLPORT(base) ((base)+1) /* control, write only */ -#define AV_SDMAPORT(base) ((base)+2) /* start dma */ -#define AV_RDMAPORT(base) ((base)+3) /* reset dma */ -#define AV_NPORT 4 /* 4 i/o ports */ - -/* status port bits */ -#define AV_BUSY 0x40 /* not ready bit define */ -#define AV_NOEXCEP 0x20 /* no exception bit define */ -#define AV_RESETMASK 0xf8 /* to check after reset */ -#define AV_RESETVAL 0x50 /* state after reset */ - -/* control port bits */ -#define AV_RESET 0x80 /* reset command */ -#define AV_REQUEST 0x40 /* request command */ -#define AV_IEN 0x20 /* enable interrupts */ - -#define DMA_STATUSREG 0x8 -#define DMA_DONE(chan) (1 << (chan)) - -typedef struct { - unsigned short err; /* code for error encountered */ - unsigned short ercnt; /* number of error blocks */ - unsigned short urcnt; /* number of underruns */ -} wtstatus_t; - -typedef struct { - unsigned unit; /* unit number */ - unsigned port; /* base i/o port */ - unsigned chan; /* dma channel number, 1..3 */ - unsigned flags; /* state of tape drive */ - unsigned dens; /* tape density */ - void *buf; /* internal i/o buffer */ - - void *dmavaddr; /* virtual address of dma i/o buffer */ - unsigned dmatotal; /* size of i/o buffer */ - unsigned dmaflags; /* i/o direction, B_READ or B_WRITE */ - unsigned dmacount; /* resulting length of dma i/o */ - - wtstatus_t error; /* status of controller */ - - unsigned short DATAPORT, CMDPORT, STATPORT, CTLPORT, SDMAPORT, RDMAPORT; - unsigned char BUSY, NOEXCEP, RESETMASK, RESETVAL; - unsigned char ONLINE, RESET, REQUEST, IEN; -} wtinfo_t; - -wtinfo_t wttab[NWT]; /* tape info by unit number */ - -extern int hz; /* number of ticks per second */ - -static int wtwait (wtinfo_t *t, int catch, char *msg); -static int wtcmd (wtinfo_t *t, int cmd); -static int wtstart (wtinfo_t *t, unsigned mode, void *vaddr, unsigned len); -static void wtdma (wtinfo_t *t); -static void wtimer (wtinfo_t *t); -static void wtclock (wtinfo_t *t); -static int wtreset (wtinfo_t *t); -static int wtsense (wtinfo_t *t, int ignor); -static int wtstatus (wtinfo_t *t); -static void wtrewind (wtinfo_t *t); -static int wtreadfm (wtinfo_t *t); -static int wtwritefm (wtinfo_t *t); -static int wtpoll (wtinfo_t *t); - -extern void DELAY (int usec); -extern void bcopy (void *from, void *to, unsigned len); -extern void isa_dmastart (int flags, void *addr, unsigned len, unsigned chan); -extern void isa_dmadone (int flags, void *addr, unsigned len, int chan); -extern void printf (char *str, ...); -extern int splbio (void); -extern int splx (int level); -extern void timeout (void (*func) (), void *arg, int timo); -extern int tsleep (void *chan, int priority, char *msg, int timo); -extern void wakeup (void *chan); - -/* - * Probe for the presence of the device. - */ -int wtprobe (struct isa_device *id) -{ - wtinfo_t *t = wttab + id->id_unit; - - t->unit = id->id_unit; - t->chan = id->id_drq; - t->port = 0; /* Mark it as not configured. */ - if (t->chan<1 || t->chan>3) { - printf ("wt%d: Bad drq=%d, should be 1..3\n", t->unit, t->chan); - return (0); - } - t->port = id->id_iobase; - - /* Try Wangtek. */ - t->CTLPORT = WT_CTLPORT (t->port); t->STATPORT = WT_STATPORT (t->port); - t->CMDPORT = WT_CMDPORT (t->port); t->DATAPORT = WT_DATAPORT (t->port); - t->SDMAPORT = 0; t->RDMAPORT = 0; - t->BUSY = WT_BUSY; t->NOEXCEP = WT_NOEXCEP; - t->RESETMASK = WT_RESETMASK; t->RESETVAL = WT_RESETVAL; - t->ONLINE = WT_ONLINE; t->RESET = WT_RESET; - t->REQUEST = WT_REQUEST; t->IEN = WT_IEN (t->chan); - if (wtreset (t)) - return (WT_NPORT); - - /* Try Archive. */ - t->CTLPORT = AV_CTLPORT (t->port); t->STATPORT = AV_STATPORT (t->port); - t->CMDPORT = AV_CMDPORT (t->port); t->DATAPORT = AV_DATAPORT (t->port); - t->SDMAPORT = AV_SDMAPORT (t->port); t->RDMAPORT = AV_RDMAPORT (t->port); - t->BUSY = AV_BUSY; t->NOEXCEP = AV_NOEXCEP; - t->RESETMASK = AV_RESETMASK; t->RESETVAL = AV_RESETVAL; - t->ONLINE = 0; t->RESET = AV_RESET; - t->REQUEST = AV_REQUEST; t->IEN = AV_IEN; - if (wtreset (t)) - return (AV_NPORT); - - /* Tape controller not found. */ - t->port = 0; - return (0); -} - -/* - * Device is found, configure it. - */ -int wtattach (struct isa_device *id) -{ - wtinfo_t *t = wttab + id->id_unit; - - if (t->RDMAPORT) { - printf ("wt%d: type \n", t->unit); - outb (t->RDMAPORT, 0); /* reset dma */ - } else - printf ("wt%d: type \n", t->unit); - t->flags = TPSTART; /* tape is rewound */ - t->dens = -1; /* unknown density */ - t->buf = malloc (BLKSIZE, M_TEMP, M_NOWAIT); - return (1); -} - -struct isa_driver wtdriver = { wtprobe, wtattach, "wt", }; - -int wtdump (int dev) -{ - /* Not implemented */ - return (EINVAL); -} - -int wtsize (int dev) -{ - /* Not implemented */ - return (-1); -} - -/* - * Open routine, called on every device open. - */ -int wtopen (int dev, int flag) -{ - int u = minor (dev) & T_UNIT; - wtinfo_t *t = wttab + u; - int error; - - if (u >= NWT || !t->port) - return (ENXIO); - - /* Check that device is not in use */ - if (t->flags & TPINUSE) - return (EBUSY); - - /* If the tape is in rewound state, check the status and set density. */ - if (t->flags & TPSTART) { - /* If rewind is going on, wait */ - error = wtwait (t, PCATCH, "wtrew"); - if (error) - return (error); - - if (! wtsense (t, (flag & FWRITE) ? 0 : TP_WRP)) { - /* Bad status. Reset the controller. */ - if (! wtreset (t)) - return (ENXIO); - if (! wtsense (t, (flag & FWRITE) ? 0 : TP_WRP)) - return (ENXIO); - } - - /* Set up tape density. */ - if (t->dens != (minor (dev) & T_DENSEL)) { - int d; - - switch (minor (dev) & T_DENSEL) { - default: - case T_800BPI: d = QIC_FMT150; break; /* minor 000 */ - case T_1600BPI: d = QIC_FMT120; break; /* minor 010 */ - case T_6250BPI: d = QIC_FMT24; break; /* minor 020 */ - case T_BADBPI: d = QIC_FMT11; break; /* minor 030 */ - } - if (! wtcmd (t, d)) - return (ENXIO); - - /* Check the status of the controller. */ - if (! wtsense (t, (flag & FWRITE) ? 0 : TP_WRP)) - return (ENXIO); - - t->dens = minor (dev) & T_DENSEL; - } - t->flags &= ~TPSTART; - } else if (t->dens != (minor (dev) & T_DENSEL)) - return (ENXIO); - - t->flags = TPINUSE; - if (flag & FREAD) - t->flags |= TPREAD; - if (flag & FWRITE) - t->flags |= TPWRITE; - return (0); -} - -/* - * Close routine, called on last device close. - */ -int wtclose (int dev) -{ - int u = minor (dev) & T_UNIT; - wtinfo_t *t = wttab + u; - - if (u >= NWT || !t->port) - return (ENXIO); - - /* If rewind is pending, do nothing */ - if (t->flags & TPREW) - goto done; - - /* If seek forward is pending and no rewind on close, do nothing */ - if ((t->flags & TPRMARK) && (minor (dev) & T_NOREWIND)) - goto done; - - /* If file mark read is going on, wait */ - wtwait (t, 0, "wtrfm"); - - if (t->flags & TPWANY) - /* Tape was written. Write file mark. */ - wtwritefm (t); - - if (! (minor (dev) & T_NOREWIND)) { - /* Rewind tape to beginning of tape. */ - /* Don't wait until rewind, though. */ - wtrewind (t); - goto done; - } - if ((t->flags & TPRANY) && ! (t->flags & (TPVOL | TPWANY))) - /* Space forward to after next file mark if no writing done. */ - /* Don't wait for completion. */ - wtreadfm (t); -done: - t->flags &= TPREW | TPRMARK | TPSTART | TPTIMER; - return (0); -} - -/* - * Ioctl routine. Compatible with BSD ioctls. - * Direct QIC-02 commands ERASE and RETENSION added. - * There are three possible ioctls: - * ioctl (int fd, MTIOCGET, struct mtget *buf) -- get status - * ioctl (int fd, MTIOCTOP, struct mtop *buf) -- do BSD-like op - * ioctl (int fd, WTQICMD, int qicop) -- do QIC op - */ -int wtioctl (int dev, int cmd, void *arg, int mode) -{ - int u = minor (dev) & T_UNIT; - wtinfo_t *t = wttab + u; - int error, count, op; - - if (u >= NWT || !t->port) - return (ENXIO); - - switch (cmd) { - default: - return (EINVAL); - case WTQICMD: /* direct QIC command */ - op = (int) *(void**)arg; - switch (op) { - default: - return (EINVAL); - case QIC_ERASE: /* erase the whole tape */ - if (! (t->flags & TPWRITE) || (t->flags & TPWP)) - return (EACCES); - if (error = wtwait (t, PCATCH, "wterase")) - return (error); - break; - case QIC_RETENS: /* retension the tape */ - if (error = wtwait (t, PCATCH, "wtretens")) - return (error); - break; - } - /* Both ERASE and RETENS operations work like REWIND. */ - /* Simulate the rewind operation here. */ - t->flags &= ~(TPRO | TPWO | TPVOL); - if (! wtcmd (t, op)) - return (EIO); - t->flags |= TPSTART | TPREW; - if (op == QIC_ERASE) - t->flags |= TPWANY; - wtclock (t); - return (0); - case MTIOCIEOT: /* ignore EOT errors */ - case MTIOCEEOT: /* enable EOT errors */ - return (0); - case MTIOCGET: - ((struct mtget*)arg)->mt_type = t->RDMAPORT ? MT_ISVIPER1 : 0x11; - ((struct mtget*)arg)->mt_dsreg = t->flags; /* status */ - ((struct mtget*)arg)->mt_erreg = t->error.err; /* errors */ - ((struct mtget*)arg)->mt_resid = 0; - ((struct mtget*)arg)->mt_fileno = 0; /* file */ - ((struct mtget*)arg)->mt_blkno = 0; /* block */ - return (0); - case MTIOCTOP: - break; - } - switch ((short) ((struct mtop*)arg)->mt_op) { - default: - case MTFSR: /* forward space record */ - case MTBSR: /* backward space record */ - case MTBSF: /* backward space file */ - break; - case MTNOP: /* no operation, sets status only */ - case MTCACHE: /* enable controller cache */ - case MTNOCACHE: /* disable controller cache */ - return (0); - case MTREW: /* rewind */ - case MTOFFL: /* rewind and put the drive offline */ - if (t->flags & TPREW) /* rewind is running */ - return (0); - if (error = wtwait (t, PCATCH, "wtorew")) - return (error); - wtrewind (t); - return (0); - case MTFSF: /* forward space file */ - for (count=((struct mtop*)arg)->mt_count; count>0; --count) { - if (error = wtwait (t, PCATCH, "wtorfm")) - return (error); - if (error = wtreadfm (t)) - return (error); - } - return (0); - case MTWEOF: /* write an end-of-file record */ - if (! (t->flags & TPWRITE) || (t->flags & TPWP)) - return (EACCES); - if (error = wtwait (t, PCATCH, "wtowfm")) - return (error); - if (error = wtwritefm (t)) - return (error); - return (0); - } - return (EINVAL); -} - -/* - * Strategy routine. - */ -void wtstrategy (struct buf *bp) -{ - int u = minor (bp->b_dev) & T_UNIT; - wtinfo_t *t = wttab + u; - int s; - - bp->b_resid = bp->b_bcount; - if (u >= NWT || !t->port) - goto errxit; - - /* at file marks and end of tape, we just return '0 bytes available' */ - if (t->flags & TPVOL) - goto xit; - - if (bp->b_flags & B_READ) { - /* Check read access and no previous write to this tape. */ - if (! (t->flags & TPREAD) || (t->flags & TPWANY)) - goto errxit; - - /* For now, we assume that all data will be copied out */ - /* If read command outstanding, just skip down */ - if (! (t->flags & TPRO)) { - if (! wtsense (t, TP_WRP)) /* clear status */ - goto errxit; - if (! wtcmd (t, QIC_RDDATA)) { /* sed read mode */ - wtsense (t, TP_WRP); - goto errxit; - } - t->flags |= TPRO | TPRANY; - } - } else { - /* Check write access and write protection. */ - /* No previous read from this tape allowed. */ - if (! (t->flags & TPWRITE) || (t->flags & (TPWP | TPRANY))) - goto errxit; - - /* If write command outstanding, just skip down */ - if (! (t->flags & TPWO)) { - if (! wtsense (t, 0)) /* clear status */ - goto errxit; - if (! wtcmd (t, QIC_WRTDATA)) { /* set write mode */ - wtsense (t, 0); - goto errxit; - } - t->flags |= TPWO | TPWANY; - } - } - - if (! bp->b_bcount) - goto xit; - - t->flags &= ~TPEXCEP; - s = splbio (); - if (wtstart (t, bp->b_flags, bp->b_un.b_addr, bp->b_bcount)) { - wtwait (t, 0, (bp->b_flags & B_READ) ? "wtread" : "wtwrite"); - bp->b_resid -= t->dmacount; - } - splx (s); - - if (t->flags & TPEXCEP) { -errxit: bp->b_flags |= B_ERROR; - bp->b_error = EIO; - } -xit: biodone (bp); - return; -} - -/* - * Interrupt routine. - */ -void wtintr (int u) -{ - wtinfo_t *t = wttab + u; - unsigned char s; - - if (u >= NWT || !t->port) - return; - - s = inb (t->STATPORT); /* get status */ - if ((s & (t->BUSY | t->NOEXCEP)) == (t->BUSY | t->NOEXCEP)) - return; /* device is busy */ - outb (t->CTLPORT, t->ONLINE); /* stop controller */ - - /* - * Check if rewind finished. - */ - if (t->flags & TPREW) { - t->flags &= ~TPREW; /* Rewind finished. */ - wtsense (t, TP_WRP); - wakeup (t); - return; - } - - /* - * Check if writing/reading of file mark finished. - */ - if (t->flags & (TPRMARK | TPWMARK)) { - if (! (s & t->NOEXCEP)) /* Operation failed. */ - wtsense (t, (t->flags & TPRMARK) ? TP_WRP : 0); - t->flags &= ~(TPRMARK | TPWMARK); /* Operation finished. */ - wakeup (t); - return; - } - - /* - * Do we started any i/o? If no, just return. - */ - if (! (t->flags & TPACTIVE)) - return; - t->flags &= ~TPACTIVE; - - if (inb (DMA_STATUSREG) & DMA_DONE (t->chan)) /* if dma finished */ - t->dmacount += BLKSIZE; /* increment counter */ - - /* - * Clean up dma. - */ - if ((t->dmaflags & B_READ) && (t->dmatotal - t->dmacount) < BLKSIZE) { - /* If the address crosses 64-k boundary, or reading short block, - * copy the internal buffer to the user memory. */ - isa_dmadone (t->dmaflags, t->buf, BLKSIZE, t->chan); - bcopy (t->buf, t->dmavaddr, t->dmatotal - t->dmacount); - } else - isa_dmadone (t->dmaflags, t->dmavaddr, BLKSIZE, t->chan); - - /* - * On exception, check for end of file and end of volume. - */ - if (! (s & t->NOEXCEP)) { - wtsense (t, (t->dmaflags & B_READ) ? TP_WRP : 0); - if (t->error.err & (TP_EOM | TP_FIL)) - t->flags |= TPVOL; /* end of file */ - else - t->flags |= TPEXCEP; /* i/o error */ - wakeup (t); - return; - } - - if (t->dmacount < t->dmatotal) { /* continue i/o */ - t->dmavaddr += BLKSIZE; - wtdma (t); - return; - } - if (t->dmacount > t->dmatotal) /* short last block */ - t->dmacount = t->dmatotal; - wakeup (t); /* wake up user level */ -} - -/* start the rewind operation */ -static void wtrewind (wtinfo_t *t) -{ - t->flags &= ~(TPRO | TPWO | TPVOL); - if (! wtcmd (t, QIC_REWIND)) - return; - t->flags |= TPSTART | TPREW; - wtclock (t); -} - -/* start the `read marker' operation */ -static int wtreadfm (wtinfo_t *t) -{ - t->flags &= ~(TPRO | TPWO | TPVOL); - if (! wtcmd (t, QIC_READFM)) { - wtsense (t, TP_WRP); - return (EIO); - } - t->flags |= TPRMARK | TPRANY; - wtclock (t); - /* Don't wait for completion here. */ - return (0); -} - -/* write marker to the tape */ -static int wtwritefm (wtinfo_t *t) -{ - tsleep (wtwritefm, WTPRI, "wtwfm", hz); /* timeout: 1 second */ - t->flags &= ~(TPRO | TPWO); - if (! wtcmd (t, QIC_WRITEFM)) { - wtsense (t, 0); - return (EIO); - } - t->flags |= TPWMARK | TPWANY; - wtclock (t); - return (wtwait (t, 0, "wtwfm")); -} - -/* wait for controller ready or exception */ -static int wtpoll (wtinfo_t *t) -{ - int s, NOTREADY = t->BUSY | t->NOEXCEP; - - /* Poll status port, waiting for ready or exception. */ - do s = inb (t->STATPORT); - while ((s & NOTREADY) == NOTREADY); - return (s); -} - -/* execute QIC command */ -static int wtcmd (wtinfo_t *t, int cmd) -{ - if (! (wtpoll (t) & t->NOEXCEP)) /* wait for ready */ - return (0); /* error */ - - outb (t->CMDPORT, cmd); /* output the command */ - - outb (t->CTLPORT, t->REQUEST | t->ONLINE); /* set request */ - while (inb (t->STATPORT) & t->BUSY) /* wait for ready */ - continue; - outb (t->CTLPORT, t->IEN | t->ONLINE); /* reset request */ - while (! (inb (t->STATPORT) & t->BUSY)) /* wait for not ready */ - continue; - - return (1); -} - -/* wait for the end of i/o, seeking marker or rewind operation */ -static int wtwait (wtinfo_t *t, int catch, char *msg) -{ - int error; - - while (t->flags & (TPACTIVE | TPREW | TPRMARK | TPWMARK)) - if (error = tsleep (t, WTPRI | catch, msg, 0)) - return (error); - return (0); -} - -/* initialize dma for the i/o operation */ -static void wtdma (wtinfo_t *t) -{ - t->flags |= TPACTIVE; - wtclock (t); - - if (t->SDMAPORT) - outb (t->SDMAPORT, 0); /* set dma */ - - if ((t->dmaflags & B_READ) && (t->dmatotal - t->dmacount) < BLKSIZE) - /* Reading short block. Do it through the internal buffer. */ - isa_dmastart (t->dmaflags, t->buf, BLKSIZE, t->chan); - else - isa_dmastart (t->dmaflags, t->dmavaddr, BLKSIZE, t->chan); - - outb (t->CTLPORT, t->IEN | t->ONLINE); -} - -/* start i/o operation */ -static int wtstart (wtinfo_t *t, unsigned flags, void *vaddr, unsigned len) -{ - if (! (wtpoll (t) & t->NOEXCEP)) { /* wait for ready or error */ - t->flags |= TPEXCEP; /* error */ - return (0); - } - t->flags &= ~TPEXCEP; /* clear exception flag */ - t->dmavaddr = vaddr; - t->dmatotal = len; - t->dmacount = 0; - t->dmaflags = flags; - wtdma (t); - return (1); -} - -/* start timer */ -static void wtclock (wtinfo_t *t) -{ - if (! (t->flags & TPTIMER)) { - t->flags |= TPTIMER; - timeout (wtimer, t, hz); - } -} - -/* - * Simulate an interrupt periodically while i/o is going. - * This is necessary in case interrupts get eaten due to - * multiple devices on a single IRQ line. - */ -static void wtimer (wtinfo_t *t) -{ - int s; - - t->flags &= ~TPTIMER; - if (! (t->flags & (TPACTIVE | TPREW | TPRMARK | TPWMARK))) - return; - - /* If i/o going, simulate interrupt. */ - s = splbio (); - wtintr (t->unit); - splx (s); - - /* Restart timer if i/o pending. */ - if (t->flags & (TPACTIVE | TPREW | TPRMARK | TPWMARK)) - wtclock (t); -} - -/* reset the controller */ -static int wtreset (wtinfo_t *t) -{ - outb (t->CTLPORT, t->RESET); /* send reset */ - DELAY (25); - outb (t->CTLPORT, 0); /* turn off reset */ - if ((inb (t->STATPORT) & t->RESETMASK) != t->RESETVAL) - return (0); - return (1); -} - -/* get controller status information */ -/* return 0 if user i/o request should receive an i/o error code */ -static int wtsense (wtinfo_t *t, int ignor) -{ - char *msg = 0; - int err; - - t->flags &= ~(TPRO | TPWO); - if (! wtstatus (t)) - return (0); - if (! (t->error.err & TP_ST0)) - t->error.err &= ~TP_ST0MASK; - if (! (t->error.err & TP_ST1)) - t->error.err &= ~TP_ST1MASK; - t->error.err &= ~ignor; /* ignore certain errors */ - err = t->error.err & (TP_FIL | TP_BNL | TP_UDA | TP_EOM | TP_WRP | - TP_USL | TP_CNI | TP_MBD | TP_NDT | TP_ILL); - if (! err) - return (1); - - /* lifted from tdriver.c from Wangtek */ - if (err & TP_USL) msg = "Drive not online"; - else if (err & TP_CNI) msg = "No cartridge"; - else if ((err & TP_WRP) && !(t->flags & TPWP)) { - msg = "Tape is write protected"; - t->flags |= TPWP; - } - else if (err & TP_FIL) msg = 0 /*"Filemark detected"*/; - else if (err & TP_EOM) msg = 0 /*"End of tape"*/; - else if (err & TP_BNL) msg = "Block not located"; - else if (err & TP_UDA) msg = "Unrecoverable data error"; - else if (err & TP_NDT) msg = "No data detected"; - else if (err & TP_ILL) msg = "Illegal command"; - if (msg) - printf ("wt%d: %s\n", t->unit, msg); - return (0); -} - -/* get controller status information */ -static int wtstatus (wtinfo_t *t) -{ - char *p; - - wtpoll (t); /* wait for ready or exception */ - outb (t->CMDPORT, QIC_RDSTAT); /* send `read status' command */ - - outb (t->CTLPORT, t->REQUEST | t->ONLINE); /* set request */ - while (inb (t->STATPORT) & t->BUSY) /* wait for ready */ - continue; - outb (t->CTLPORT, t->ONLINE); /* reset request */ - while (! (inb (t->STATPORT) & t->BUSY)) /* wait for not ready */ - continue; - - p = (char*) &t->error; - while (p < (char*)&t->error + 6) { - if (! (wtpoll (t) & t->NOEXCEP)) /* wait for ready */ - return (0); /* error */ - - *p++ = inb (t->DATAPORT); /* read status byte */ - - outb (t->CTLPORT, t->REQUEST); /* set request */ - while (! (inb (t->STATPORT) & t->BUSY)) /* wait for not ready */ - continue; - /* DELAY (50); */ /* wait 50 usec */ - outb (t->CTLPORT, 0); /* unset request */ - } - return (1); -} -#endif /* NWT */ diff --git a/sys/i386/isa/wtreg.h b/sys/i386/isa/wtreg.h deleted file mode 100644 index d7658f3..0000000 --- a/sys/i386/isa/wtreg.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Streamer tape driver for 386bsd and FreeBSD. - * Supports Archive QIC-02 and Wangtek QIC-02/QIC-36 boards. - * - * Copyright (C) 1993 by: - * Sergey Ryzhkov - * Serge Vakulenko - * - * Placed in the public domain with NO WARRANTIES, not even the implied - * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Authors grant any other persons or organisations permission to use - * or modify this software as long as this message is kept with the software, - * all derivative works or modified versions. - * - * This driver is derived from the old 386bsd Wangtek streamer tape driver, - * made by Robert Baron at CMU, based on Intel sources. - * Authors thank Robert Baron, CMU and Intel and retain here - * the original CMU copyright notice. - * - * from: Version 1.1, Fri Sep 24 02:14:42 MSD 1993 - * $Id$ - */ - -/* - * Copyright (c) 1989 Carnegie-Mellon University. - * All rights reserved. - * - * Authors: Robert Baron - * - * 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 "AS IS" - * 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. - */ - -/* ioctl for direct QIC commands */ -#define WTQICMD _IO('W', 0) - -/* QIC-02 commands allowed for WTQICMD */ -#define QIC_ERASE 0x22 -#define QIC_RETENS 0x24 - -/* internal QIC-02 commands */ -#define QIC_RDDATA 0x80 /* read data */ -#define QIC_READFM 0xa0 /* read file mark */ -#define QIC_WRTDATA 0x40 /* write data */ -#define QIC_WRITEFM 0x60 /* write file mark */ -#define QIC_RDSTAT 0xc0 /* read status command */ -#define QIC_REWIND 0x21 /* rewind command (position+bot) */ -#define QIC_FMT11 0x26 /* set format QIC-11 */ -#define QIC_FMT24 0x27 /* set format QIC-24 */ -#define QIC_FMT120 0x28 /* set format QIC-120 */ -#define QIC_FMT150 0x29 /* set format QIC-150 */ - -/* tape driver flags */ -#define TPINUSE 0x0001 /* tape is already open */ -#define TPREAD 0x0002 /* tape is only open for reading */ -#define TPWRITE 0x0004 /* tape is only open for writing */ -#define TPSTART 0x0008 /* tape must be rewound and reset */ -#define TPRMARK 0x0010 /* read file mark command outstanding */ -#define TPWMARK 0x0020 /* write file mark command outstanding */ -#define TPREW 0x0040 /* rewind command outstanding */ -#define TPEXCEP 0x0080 /* i/o exception flag */ -#define TPVOL 0x0100 /* read file mark or hit end of tape */ -#define TPWO 0x0200 /* write command outstanding */ -#define TPRO 0x0400 /* read command outstanding */ -#define TPWANY 0x0800 /* write command requested */ -#define TPRANY 0x1000 /* read command requested */ -#define TPWP 0x2000 /* write protect error seen */ -#define TPTIMER 0x4000 /* timer() is active */ -#define TPACTIVE 0x8000 /* dma i/o active */ - -/* controller error register bits */ -#define TP_FIL 0x0001 /* File mark detected */ -#define TP_BNL 0x0002 /* Block not located */ -#define TP_UDA 0x0004 /* Unrecoverable data error */ -#define TP_EOM 0x0008 /* End of media */ -#define TP_WRP 0x0010 /* Write protected cartridge */ -#define TP_USL 0x0020 /* Unselected drive */ -#define TP_CNI 0x0040 /* Cartridge not in place */ -#define TP_ST0 0x0080 /* Status byte 0 bits */ -#define TP_ST0MASK 0x00ff /* Status byte 0 mask */ -#define TP_POR 0x0100 /* Power on/reset occurred */ -#define TP_RES1 0x0200 /* Reserved for end of media */ -#define TP_RES2 0x0400 /* Reserved for bus parity */ -#define TP_BOM 0x0800 /* Beginning of media */ -#define TP_MBD 0x1000 /* Marginal block detected */ -#define TP_NDT 0x2000 /* No data detected */ -#define TP_ILL 0x4000 /* Illegal command - should not happen! */ -#define TP_ST1 0x8000 /* Status byte 1 bits */ -#define TP_ST1MASK 0xff00 /* Status byte 1 mask */ - -/* formats for printing flags and error values */ -#define WTDS_BITS "\20\1inuse\2read\3write\4start\5rmark\6wmark\7rew\10excep\11vol\12wo\13ro\14wany\15rany\16wp\17timer\20active" -#define WTER_BITS "\20\1eof\2bnl\3uda\4eom\5wrp\6usl\7cni\11por\12res1\13res2\14bom\15mbd\16ndt\17ill" -- cgit v1.1