Subject: Free Code
To: None <port-i386@NetBSD.ORG>
From: None <rvb@IGW.TRUST.CS.CMU.EDU>
List: port-i386
Date: 06/08/1995 18:40:13
Sorry, in advance, for the length of this mail.  Feel free
to ignore the material after the "===============" line if
you are not interested in the details.

I am making several drivers and features as well as bug fixes
available to the NetBSD i386 community.  I hope people will look at
them and take what is useful.  Hopefully, the changes will make
their way into the NetBSD-current system.  All of the changes build
in the 5/14/95 NetBSD-current.  The goal of my work is to make
NetBSD work well with PC laptops.

Included in the code is:
	a D-Link DE-600 pocket ether driver from Mach 2.5/CODA
	 (note Mach 2.5 was a project at CMU and CODA is an
	  ongoing activity at CMU involved in file systems and
	  laptop research.)
	a PCMCIA WaveLan driver from CODA -- not the Klemets Driver
	an intel pcmcia lan driver using the 82595 chip from CODA

	changes to pccons.c to exchange the capslock and control
	changes to pccons.c to let arrow keys and F1,F2,F3 emulate
	 a mouse.
	a frame buffer device (minor on /dev/mem) for X

	some bug fixes to prevent hardware resets, reallow break points.
	handle suspend/resume for the disk.

	and more ...

A synopsis is provided at the end of this message and in the README
file.  All the code is in the project/coda/netbsd directory available
at ftp.cs.cmu.edu  (It can be put in incoming if there is a demand.)
The code changes were made against the 5/14/95 NetBSD-current that
Chris Dimetriou kindly released.  (I can update it to a more recent
-current if there are problems.)  In the netbsd/ directory are:
	Index			the obvious
	Announcement-1		This notice
	README-1		annotated changes
	0514-1.tgz		kernel changes and new code
	0514-1.patch.gz		kernel patch file for the changes only
	man-1.tgz		manual pages only
	new-1.tgz		new code only
	src-1.tgz		some interesting user programs and docs.
	

Finally, I must apologize for one "feature".  To simplify my porting
effort, I just "slipped" the mach 2.5 pcmcia support into NetBSD for
my pcmcia drivers to use.  I would have not taken this approach if
there were a pcmcia driver part of the NetBSD distribution -- there
should be.  Perhaps this pcmcia driver might provide helpful insights
to whichever pcmcia subsystem is finally chosen for NetBSD.  The
pcmcia drivers I have supplied for NetBSD have a rather simple
interface to the pcmcia module and it should be pretty easy to drop
them into any pcmcia subsystem.

I invite discussion about this code either in this group or in
private mail.
					Robert V. Baron
					rvb@cmu.edu

=======================================================================
=======================================================================

Below is an annotated list of which netbsd kernel files have been
changed and why.  The list is organized by topics: COMPILATION,
PCMCIA SUPPORT, OTHER DEVICES, DEBUGGING AIDS/BUG FIXES, LAPTOP
support and MACH_COMPAT.  In all *.[chs] files that I changed, I
made the changes under a #ifdef new conditional; to make changes
easy to find.
				Robert V. Baron
				rvb@cmu.edu

------------------------COMPILATION---------------------------
------------------------COMPILATION---------------------------
DIFF -R SYS/ARCH/I386/CONF/GENERIC SYS.ORIG/ARCH/I386/CONF/GENERIC
ADDED
 1.	pwl0	NCR PCMCIA Wavelan driver
 2.	pix0	Intel PCMCIA EtherXpress driver (82595)
 3.	dl0	D-Link parallel port ether driver
and
 4.	options		COMPAT_MACH
			MACH is essentially 4.3 compat + getting the
			calls above 150 right.  I confess this is
			not totally complete yet.

DIFF -R SYS/ARCH/I386/CONF/FILES.I386 SYS.ORIG/ARCH/I386/CONF/FILES.I386
ADDED
 1.	file	arch/i386/i386/db_magic.s	ddb
		This defines inb and friends so they can be called from
		the debugger.  And it defines a simple interface to
		the hardware debug registers DR0 .. DR3

 2.	device	pcm at root ...
		the pcmcia support is handled as a "root" device and
		config was changed so it is scanned first.

 3.	include "../../../dev/pcmcia/files.pcmcia"
	#file	arch/i386/pcmcia/pcmcia_machdep.c	pcm
		pcmcia gets its own directory under /dev

 4.	include "../../../compat/mach/files.mach"
	#file	arch/i386/i386/mach_machdep.c	compat_mach
			As mentioned above mach compatability

-----------------------PCMCIA SUPPORT-------------------------
-----------------------PCMCIA SUPPORT-------------------------
IN SYS/DEV/PCMCIA/
	files.pcmcia	- lists files needed below
	pcm.c		- pcmcia support for intel 
	pcmreg.h	-  82365 look alikes
	if_i82595.c	- pcmcia ether using intel 82595
	if_i82595reg.h
	if_i82593.c	- ncr wavelan == 82593
	if_wavelan.c	  + ncr specific chip.
	if_i82593reg.h
	if_wavelan.h
	if_cntrs.h
NB. this wavelan support is NOT Anders Klemets code.  It is totally
free.

DIFF -R SYS/ARCH/I386/I386/AUTOCONF.C SYS.ORIG/ARCH/I386/I386/AUTOCONF.C
 1. Do a 
  	config_rootfound("pcm", NULL);
    to scan the pcmcia devices first.  This is truly necessary to turn
    off the device and undo the window mappings before the normal bus
    scans are done.

DIFF -R SYS/ARCH/I386/I386/CONF.C SYS.ORIG/ARCH/I386/I386/CONF.C
 1. ADDED a pcm device at major 18 -- it was unused.

DIFF -R SYS/SYS/CONF.H SYS.ORIG/SYS/CONF.H
 1. For pcm device

DIFF -R SYS/DEV/ISA/ISA.C SYS.ORIG/DEV/ISA/ISA.C
 1. For pcmcia modems, code to probe a single device.
    and all the code really does is calls routines in
    kern/subr_autoconf.c -- which is mostly what the rest
    of the code here does.

DIFF -R SYS/KERN/SUBR_AUTOCONF.C SYS.ORIG/KERN/SUBR_AUTOCONF.C
 1. For pcmcia support, add a config_scan_one command which
    tries to probe a single known device.  and config_detach
    which removes a single device.

DIFF -R SYS/DEV/ISA/COM.C SYS.ORIG/DEV/ISA/COM.C
 1. Pretty major hit here.  If the device does not exists, but is
    being opened, try to reprobe the parent/cfdata again and see
    if it comes alive.  This is for pcmcia modems.
 2. If the pcmcia modem disappears, have any new operation (read/write/
    ioctl/close) fail
 3. Support for recognizing a few modem brands in the kernel
 4. Don't print garbage ifdef COMCONSOLE during probe.

DIFF -R SYS/DEV/ISA/COMREG.H SYS.ORIG/DEV/ISA/COMREG.H
 1. need ifndefs around CONADDR and CONUNIT

-----------------------OTHER DEVICES--------------------------
-----------------------OTHER DEVICES--------------------------

DIFF -R SYS/DEV/ISA/FILES.ISA SYS.ORIG/DEV/ISA/FILES.ISA
 1. Files for d-link de600 pocket ethernet adaptor

IN SYS/DEV/ISA/IF_DL6C.C
IN SYS/DEV/ISA/IF_DL6CREG.H
IN ARCH/386/ISA/IF_DL6S.S
 1. Dlink support.


-------------------DEBUGGING AIDS/BUG FIXES-------------------
-------------------DEBUGGING AIDS/BUG FIXES-------------------

IN SYS/ARCH/I386/I386/DB_MAGIC.S
 1. Define in{b,w,l}/out{b,w,l} for kernel debugging
 2. Define dr0 .. dr3 to get at debug registers

DIFF -R SYS/ARCH/I386/I386/LOCORE.S SYS.ORIG/ARCH/I386/I386/LOCORE.S
 1. Under the GPROF conditional emit a call to mcount for bcopy, bzero,
    copyin, and copyout, so they can be profiled.  During a kernel build
    these 4 routines account for 14% of the time in the kernel.

DIFF -R SYS/ARCH/I386/I386/MACHDEP.C SYS.ORIG/ARCH/I386/I386/MACHDEP.C
 1. Define pm_dir for the kernel map so that the system does not double
    fault during early kernel errors.
 2. Under ibm_tp7xx don't use physical page that abuts 0xa0000; the firmware
    uses it.
 3. Detect Mach a.out's.

DIFF -R SYS/ARCH/I386/I386/TRAP.C SYS.ORIG/ARCH/I386/I386/TRAP.C
 1. Avoid double fault when trap()ing early in kernel 

DIFF -R SYS/DEV/ISA/WD.C SYS.ORIG/DEV/ISA/WD.C
 1. Flush the check to see if the error reg is readable.
 2. Wdcwait incorrectly returns 1 iff there is an error since
    lots of code checks for < 0 (or != 0).  suspend/resume creates
    a error return of 4.
 3. Add inittodr(0) to above code to resync clock.
DIFF -R SYS/KERN/VFS_BIO.C SYS.ORIG/KERN/VFS_BIO.C
 1. Don't B_AGE on brlse, its an old BSD tradition but has
    always been wrong.

DIFF -R SYS/CONF/FILES SYS.ORIG/CONF/FILES
 1. File net/if_prpkt.c		ether
    some debugging printout routines for ether packets

IN SYS/NET/IF_PRPKT.C
 1. Utility routines for printing ether packets.


-----------------------LAPTOP SUPPORT-------------------------
-----------------------LAPTOP SUPPORT-------------------------

DIFF -R SYS/ARCH/I386/I386/MEM.C SYS.ORIG/ARCH/I386/I386/MEM.C
 1. Add minor 13 for /dev/fb -- frame buffer.  You can 
	mknod /dev/xf86 c 2 13 and ignore the aperture driver.

DIFF -R SYS/ARCH/I386/INCLUDE/PCCONS.H SYS.ORIG/ARCH/I386/INCLUDE/PCCONS.H
 1. #define CONSOLE_FLIP_CAPS_CTL		_IO('t', 64)
    inverts the meaning of the caps lock and the control key.
 2. #define CONSOLE_RESET_CAPS_CTL		_IO('t', 65)
    makes the caps lock and control keys behave as expected
 3. #define CONSOLE_MOUSE			_IOW('t',66,u_int)
    makes the arrow keys and F1, F2, F3 keys function as an auxiliary
    mouse for laptops.

DIFF -R SYS/ARCH/I386/ISA/PCCONS.C SYS.ORIG/ARCH/I386/ISA/PCCONS.C
 1. As above
 2. As above
 3. As above
 4. If there exists a COMCONSOLE, enter the debugger on F12 if X is up

DIFF -R SYS/ARCH/I386/ISA/PMS.C SYS.ORIG/ARCH/I386/ISA/PMS.C
 1. Hang around a bit after mouse close and try to grab characters
    that turn up -- necessary for some hardware.
 2. Break pmsintr into a accumulate and a post phase.  pmspost is also
    called by the console mouse support (above).

------------------------MACH COMPAT---------------------------
------------------------MACH COMPAT---------------------------

IN SYS/COMPAT/MACH/
	files.mach	- files below to be included
	mach_exec.c	- exec rules
	mach_misc.c	- glue code
	makesyscalls.sh
	syscalls.conf
	syscalls.master	- how is mach different

DIFF -R SYS/KERN/EXEC_SUBR.C SYS.ORIG/KERN/EXEC_SUBR.C
 1. Add a vmcmd_bzero for mach binaries.

DIFF -R SYS/SYS/EXEC.H SYS.ORIG/SYS/EXEC.H
 1. Export vmcmd_bzero

----------------------USER PROGRAMS---------------------------
----------------------USER PROGRAMS---------------------------

 pccons	- "advice" to pc style console
	pccons reset	- make caps lock and control function as
			  advertised
	pccons flip	- flip caps lock and control keys
	pccons mouse	- turn on mouse emulation in the keyboard
	pccons cat	- turn off mouse emulation

 ixcntrs - Print "ether device" statistics with no arg.
 dlcntrs    with arg, print continuous read out of statistics
 wlcntrs    on packets transfered.

 roam	- Set wavelan network id (nwid)

 pcic	- Print 82365/pcmcia interface registers 

 pcmcia	- "advice" to pcmcia subsystem.
	pcmcia {-0,-1} -vers1
		Rescan for the version string for pcmcia slot -0, -1
	pcmcia {-0,-1} -print
		Print the card information structure (CIS) info
		for pcmcia slot -0, -1
	pcmcia {-0,-1} com{0,1,2,3}
		Using CIS set kernel to recognize modem as com0,
		com1, etc.  This will happen when the device is
		next opened.
	pcmcia {-0,-1} -cfr # -index #
		This allows you to register a configuration register
		address and corresponding index to use with it.
		This is useful if the mfr screws up the CIS and it
		can not be reliably parsed.