From 2be7f58cffb25072ff7306ab84b84c2556ea3a0f Mon Sep 17 00:00:00 2001
From: Antonio Huete Jimenez <tuxillo@quantumachine.net>
Date: Mon, 15 Feb 2010 15:33:14 -0800
Subject: [PATCH] usr.sbin - Add to x86_64 some programs that were only available for i386.

---
 sys/platform/pc64/include/cdk.h      |  501 ++++++++++++++++++++++++++++++++++
 sys/platform/pc64/include/comstats.h |  124 +++++++++
 sys/platform/pc64/include/gsc.h      |   54 ++++
 usr.sbin/Makefile                    |   15 +-
 usr.sbin/apm/Makefile                |    2 +
 usr.sbin/apmd/Makefile               |    2 +-
 usr.sbin/apmd/apmd.c                 |    3 +-
 usr.sbin/apmd/apmd.h                 |   22 ++
 usr.sbin/battd/Makefile              |    2 +
 usr.sbin/kgmon/Makefile              |    2 +-
 usr.sbin/kgmon/kgmon.c               |   10 +-
 usr.sbin/kgzip/Makefile              |    1 +
 usr.sbin/lptcontrol/Makefile         |    1 +
 usr.sbin/rndcontrol/Makefile         |    1 +
 usr.sbin/sgsc/Makefile               |    2 +-
 usr.sbin/sgsc/sgsc.c                 |    2 +-
 usr.sbin/sicontrol/Makefile          |    1 +
 usr.sbin/stallion/stlload/Makefile   |    1 +
 usr.sbin/stallion/stlload/stlload.c  |    2 +-
 usr.sbin/stallion/stlstats/Makefile  |    1 +
 usr.sbin/stallion/stlstty/Makefile   |    1 +
 usr.sbin/stallion/stlstty/stlstty.c  |    5 +
 22 files changed, 736 insertions(+), 19 deletions(-)
 create mode 100644 sys/platform/pc64/include/cdk.h
 create mode 100644 sys/platform/pc64/include/comstats.h
 create mode 100644 sys/platform/pc64/include/gsc.h

diff --git a/sys/platform/pc64/include/cdk.h b/sys/platform/pc64/include/cdk.h
new file mode 100644
index 0000000..31d4824
--- /dev/null
+++ b/sys/platform/pc64/include/cdk.h
@@ -0,0 +1,501 @@
+/*****************************************************************************/
+
+/*
+ * cdk.h  -- CDK interface definitions.
+ *
+ * Copyright (c) 1994-1998 Greg Ungerer (gerg@stallion.oz.au).
+ * 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 Greg Ungerer.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * 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.
+ *
+ * $FreeBSD: src/sys/i386/include/cdk.h,v 1.5.2.1 2001/08/30 12:29:57 murray Exp $
+ * $DragonFly: src/sys/platform/pc32/include/cdk.h,v 1.3 2003/06/28 04:16:03 dillon Exp $
+ */
+
+#ifndef	_CDK_H_
+#define	_CDK_H_
+
+#include <sys/ioccom.h>
+
+#pragma	pack(2)
+
+/*
+ *	The following set of definitions is used to communicate with the
+ *	shared memory interface of the Stallion intelligent multiport serial
+ *	boards. The definitions in this file are taken directly from the
+ *	document titled "Generic Stackable Interface, Downloader and
+ *	Communications Development Kit".
+ */
+
+/*
+ *	Define the set of importrant shared memory addresses. These are
+ *	required to intialize the board and get things started. All of these
+ *	addresses are relative to the start of the shared memory.
+ */
+#define	CDK_SIGADDR	0x200
+#define	CDK_FEATADDR	0x280
+#define	CDK_CDKADDR	0x300
+#define	CDK_RDYADDR	0x262
+
+#define	CDK_ALIVEMARKER	13
+
+/*
+ *	On hardware power up the ROMs located on the EasyConnection 8/64 will
+ *	fill out the following signature information into shared memory. This
+ *	way the host system can quickly determine that the board is present
+ *	and is operational.
+ */
+typedef struct cdkecpsig {
+	unsigned long	magic;
+	unsigned short	romver;
+	unsigned short	cputype;
+	unsigned char	panelid[8];
+} cdkecpsig_t;
+
+#define	ECP_MAGIC	0x21504345
+
+/*
+ *	On hardware power up the ROMs located on the ONboard, Stallion and
+ *	Brumbys will fill out the following signature information into shared
+ *	memory. This way the host system can quickly determine that the board
+ *	is present and is operational.
+ */
+typedef struct cdkonbsig {
+	unsigned short	magic0;
+	unsigned short	magic1;
+	unsigned short	magic2;
+	unsigned short	magic3;
+	unsigned short	romver;
+	unsigned short	memoff;
+	unsigned short	memseg;
+	unsigned short	amask0;
+	unsigned short	pic;
+	unsigned short	status;
+	unsigned short	btype;
+	unsigned short	clkticks;
+	unsigned short	clkspeed;
+	unsigned short	amask1;
+	unsigned short	amask2;
+} cdkonbsig_t;
+
+#define	ONB_MAGIC0	0xf2a7
+#define	ONB_MAGIC1	0xa149
+#define	ONB_MAGIC2	0x6352
+#define	ONB_MAGIC3	0xf121
+
+/*
+ *	Define the feature area structure. The feature area is the set of
+ *	startup parameters used by the slave image when it starts executing.
+ *	They allow for the specification of buffer sizes, debug trace, etc.
+ */
+typedef struct cdkfeature {
+	unsigned long	debug;
+	unsigned long	banner;
+	unsigned long	etype;
+	unsigned long	nrdevs;
+	unsigned long	brdspec;
+	unsigned long	txrqsize;
+	unsigned long	rxrqsize;
+	unsigned long	flags;
+} cdkfeature_t;
+
+#define	ETYP_DDK	0
+#define	ETYP_CDK	1
+
+/*
+ *	Define the CDK header structure. This is the info that the slave
+ *	environment sets up after it has been downloaded and started. It
+ *	essentially provides a memory map for the shared memory interface.
+ */
+typedef struct cdkhdr {
+	unsigned short	command;
+	unsigned short	status;
+	unsigned short	port;
+	unsigned short	mode;
+	unsigned long	cmd_buf[14];
+	unsigned short	alive_cnt;
+	unsigned short	intrpt_mode;
+	unsigned char	intrpt_id[8];
+	unsigned char	ver_release;
+	unsigned char	ver_modification;
+	unsigned char	ver_fix;
+	unsigned char	deadman_restart;
+	unsigned short	deadman;
+	unsigned short	nrdevs;
+	unsigned long	memp;
+	unsigned long	hostp;
+	unsigned long	slavep;
+	unsigned char	hostreq;
+	unsigned char	slavereq;
+	unsigned char	cmd_reserved[30];
+} cdkhdr_t;
+
+#define	MODE_DDK	0
+#define	MODE_CDK	1
+
+#define	IMD_INTR	0x0
+#define	IMD_PPINTR	0x1
+#define	IMD_POLL	0xff
+
+/*
+ *	Define the memory mapping structure. This structure is pointed to by
+ *	the memp field in the stlcdkhdr struct. As many as these structures
+ *	as required are layed out in shared memory to define how the rest of
+ *	shared memory is divided up. There will be one for each port.
+ */
+typedef struct cdkmem {
+	unsigned short	dtype;
+	unsigned long	offset;
+} cdkmem_t;
+
+#define	TYP_UNDEFINED	0x0
+#define	TYP_ASYNCTRL	0x1
+#define	TYP_ASYNC	0x20
+#define	TYP_PARALLEL	0x40
+#define	TYP_SYNCX21	0x60
+
+/*****************************************************************************/
+
+/*
+ *	Following is a set of defines and structures used to actually deal
+ *	with the serial ports on the board. Firstly is the set of commands
+ *	that can be applied to ports.
+ */
+#define	ASYCMD		(((unsigned long) 'a') << 8)
+
+#define	A_NULL		(ASYCMD | 0)
+#define	A_FLUSH		(ASYCMD | 1)
+#define	A_BREAK		(ASYCMD | 2)
+#define	A_GETPORT	(ASYCMD | 3)
+#define	A_SETPORT	(ASYCMD | 4)
+#define	A_SETPORTF	(ASYCMD | 5)
+#define	A_SETPORTFTX	(ASYCMD | 6)
+#define	A_SETPORTFRX	(ASYCMD | 7)
+#define	A_GETSIGNALS	(ASYCMD | 8)
+#define	A_SETSIGNALS	(ASYCMD | 9)
+#define	A_SETSIGNALSF	(ASYCMD | 10)
+#define	A_SETSIGNALSFTX	(ASYCMD | 11)
+#define	A_SETSIGNALSFRX	(ASYCMD | 12)
+#define	A_GETNOTIFY	(ASYCMD | 13)
+#define	A_SETNOTIFY	(ASYCMD | 14)
+#define	A_NOTIFY	(ASYCMD | 15)
+#define	A_PORTCTRL	(ASYCMD | 16)
+#define	A_GETSTATS	(ASYCMD | 17)
+#define	A_RQSTATE	(ASYCMD | 18)
+#define	A_FLOWSTATE	(ASYCMD | 19)
+#define	A_CLEARSTATS	(ASYCMD | 20)
+
+/*
+ *	Define those arguments used for simple commands.
+ */
+#define	FLUSHRX		0x1
+#define	FLUSHTX		0x2
+
+#define	BREAKON		-1
+#define	BREAKOFF	-2
+
+/*
+ *	Define the port setting structure, and all those defines that go along
+ *	with it. Basically this structure defines the charcateristics of this
+ *	port: baud rate, chars, parity, input/output char cooking etc.
+ */
+typedef struct asyport {
+	unsigned long	baudout;
+	unsigned long	baudin;
+	unsigned long	iflag;
+	unsigned long	oflag;
+	unsigned long	lflag;
+	unsigned long	pflag;
+	unsigned long	flow;
+	unsigned long	spare1;
+	unsigned short	vtime;
+	unsigned short	vmin;
+	unsigned short	txlo;
+	unsigned short	txhi;
+	unsigned short	rxlo;
+	unsigned short	rxhi;
+	unsigned short	rxhog;
+	unsigned short	spare2;
+	unsigned char	csize;
+	unsigned char	stopbs;
+	unsigned char	parity;
+	unsigned char	stopin;
+	unsigned char	startin;
+	unsigned char	stopout;
+	unsigned char	startout;
+	unsigned char	parmark;
+	unsigned char	brkmark;
+	unsigned char	cc[11];
+} asyport_t;
+
+#define	PT_STOP1	0x0
+#define	PT_STOP15	0x1
+#define	PT_STOP2	0x2
+
+#define	PT_NOPARITY	0x0
+#define	PT_ODDPARITY	0x1
+#define	PT_EVENPARITY	0x2
+#define	PT_MARKPARITY	0x3
+#define	PT_SPACEPARITY	0x4
+
+#define	F_NONE		0x0
+#define	F_IXON		0x1
+#define	F_IXOFF		0x2
+#define	F_IXANY		0x4
+#define	F_IOXANY	0x8
+#define	F_RTSFLOW	0x10
+#define	F_CTSFLOW	0x20
+#define	F_DTRFLOW	0x40
+#define	F_DCDFLOW	0x80
+#define	F_DSROFLOW	0x100
+#define	F_DSRIFLOW	0x200
+
+#define	FI_NORX		0x1
+#define	FI_RAW		0x2
+#define	FI_ISTRIP	0x4
+#define	FI_UCLC		0x8
+#define	FI_INLCR	0x10
+#define	FI_ICRNL	0x20
+#define	FI_IGNCR	0x40
+#define	FI_IGNBREAK	0x80
+#define	FI_DSCRDBREAK	0x100
+#define	FI_1MARKBREAK	0x200
+#define	FI_2MARKBREAK	0x400
+#define	FI_XCHNGBREAK	0x800
+#define	FI_IGNRXERRS	0x1000
+#define	FI_DSCDRXERRS	0x2000
+#define	FI_1MARKRXERRS	0x4000
+#define	FI_2MARKRXERRS	0x8000
+#define	FI_XCHNGRXERRS	0x10000
+#define	FI_DSCRDNULL	0x20000
+
+#define	FO_OLCUC	0x1
+#define	FO_ONLCR	0x2
+#define	FO_OOCRNL	0x4
+#define	FO_ONOCR	0x8
+#define	FO_ONLRET	0x10
+#define	FO_ONL		0x20
+#define	FO_OBS		0x40
+#define	FO_OVT		0x80
+#define	FO_OFF		0x100
+#define	FO_OTAB1	0x200
+#define	FO_OTAB2	0x400
+#define	FO_OTAB3	0x800
+#define	FO_OCR1		0x1000
+#define	FO_OCR2		0x2000
+#define	FO_OCR3		0x4000
+#define	FO_OFILL	0x8000
+#define	FO_ODELL	0x10000
+
+#define	P_RTSLOCK	0x1
+#define	P_CTSLOCK	0x2
+#define	P_MAPRTS	0x4
+#define	P_MAPCTS	0x8
+#define	P_LOOPBACK	0x10
+#define	P_DTRFOLLOW	0x20
+#define	P_FAKEDCD	0x40
+
+#define	P_RXIMIN	0x10000
+#define	P_RXITIME	0x20000
+#define	P_RXTHOLD	0x40000
+
+/*
+ *	Define a structure to communicate serial port signal and data state
+ *	information.
+ */
+typedef struct asysigs {
+	unsigned long	data;
+	unsigned long	signal;
+	unsigned long	sigvalue;
+} asysigs_t;
+
+#define	DT_TXBUSY	0x1
+#define	DT_TXEMPTY	0x2
+#define	DT_TXLOW	0x4
+#define	DT_TXHIGH	0x8
+#define	DT_TXFULL	0x10
+#define	DT_TXHOG	0x20
+#define	DT_TXFLOWED	0x40
+#define	DT_TXBREAK	0x80
+
+#define	DT_RXBUSY	0x100
+#define	DT_RXEMPTY	0x200
+#define	DT_RXLOW	0x400
+#define	DT_RXHIGH	0x800
+#define	DT_RXFULL	0x1000
+#define	DT_RXHOG	0x2000
+#define	DT_RXFLOWED	0x4000
+#define	DT_RXBREAK	0x8000
+
+#define	SG_DTR		0x1
+#define	SG_DCD		0x2
+#define	SG_RTS		0x4
+#define	SG_CTS		0x8
+#define	SG_DSR		0x10
+#define	SG_RI		0x20
+
+/*
+ *	Define the notification setting structure. This is used to tell the
+ *	port what events we want to be informed about. Fields here use the
+ *	same defines as for the asysigs structure above.
+ */
+typedef struct asynotify {
+	unsigned long	ctrl;
+	unsigned long	data;
+	unsigned long	signal;
+	unsigned long	sigvalue;
+} asynotify_t;
+
+/*
+ *	Define the port control structure. It is used to do fine grain
+ *	control operations on the port.
+ */
+typedef struct {
+	unsigned long	rxctrl;
+	unsigned long	txctrl;
+	char		rximdch;
+	char		tximdch;
+	char		spare1;
+	char		spare2;
+} asyctrl_t;
+
+#define	CT_ENABLE	0x1
+#define	CT_DISABLE	0x2
+#define	CT_STOP		0x4
+#define	CT_START	0x8
+#define	CT_STARTFLOW	0x10
+#define	CT_STOPFLOW	0x20
+#define	CT_SENDCHR	0x40
+
+/*
+ *	Define the stats structure kept for each port. This is a useful set
+ *	of data collected for each port on the slave. The A_GETSTATS command
+ *	is used to retrive this data from the slave.
+ */
+typedef struct asystats {
+	unsigned long	opens;
+	unsigned long	txchars;
+	unsigned long	rxchars;
+	unsigned long	txringq;
+	unsigned long	rxringq;
+	unsigned long	txmsgs;
+	unsigned long	rxmsgs;
+	unsigned long	txflushes;
+	unsigned long	rxflushes;
+	unsigned long	overruns;
+	unsigned long	framing;
+	unsigned long	parity;
+	unsigned long	ringover;
+	unsigned long	lost;
+	unsigned long	rxstart;
+	unsigned long	rxstop;
+	unsigned long	txstart;
+	unsigned long	txstop;
+	unsigned long	dcdcnt;
+	unsigned long	dtrcnt;
+	unsigned long	ctscnt;
+	unsigned long	rtscnt;
+	unsigned long	dsrcnt;
+	unsigned long	ricnt;
+	unsigned long	txbreaks;
+	unsigned long	rxbreaks;
+	unsigned long	signals;
+	unsigned long	state;
+	unsigned long	hwid;
+} asystats_t;
+
+/*****************************************************************************/
+
+/*
+ *	All command and control communication with a device on the slave is
+ *	via a control block in shared memory. Each device has its own control
+ *	block, defined by the following structure. The control block allows
+ *	the host to open, close and control the device on the slave.
+ */
+typedef struct cdkctrl {
+	unsigned char	open;
+	unsigned char	close;
+	unsigned long	openarg;
+	unsigned long	closearg;
+	unsigned long	cmd;
+	unsigned long	status;
+	unsigned long	args[32];
+} cdkctrl_t;
+
+/*
+ *	Each device on the slave passes data to and from the host via a ring
+ *	queue in shared memory. Define a ring queue structure to hold the
+ *	vital information about each ring queue. Two ring queues will be
+ *	allocated for each port, one for reveice data and one for transmit
+ *	data.
+ */
+typedef struct cdkasyrq {
+	unsigned long	offset;
+	unsigned short	size;
+	unsigned short	head;
+	unsigned short	tail;
+} cdkasyrq_t;
+
+/*
+ *	Each asynchronous port is defined in shared memory by the following
+ *	structure. It contains a control block to command a device, and also
+ *	the neccessary data channel information as well.
+ */
+typedef struct cdkasy {
+	cdkctrl_t	ctrl;
+	unsigned short	notify;
+	asynotify_t	changed;
+	unsigned short	receive;
+	cdkasyrq_t	rxq;
+	unsigned short	transmit;
+	cdkasyrq_t	txq;
+} cdkasy_t;
+
+#pragma	pack()
+
+/*****************************************************************************/
+
+/*
+ *	Define the set of ioctls used by the driver to do special things
+ *	to the board. These include interrupting it, and initializeing
+ *	the driver after board startup and shutdown.
+ */
+#define	STL_BINTR	_IO('s', 20)
+#define	STL_BSTART	_IO('s', 21)
+#define	STL_BSTOP	_IO('s', 22)
+#define	STL_BRESET	_IO('s', 23)
+
+/*
+ *	Define a set of ioctl extensions, used to get at special stuff.
+ */
+#define	STL_GETPFLAG	_IOR('s', 80, unsigned long)
+#define	STL_SETPFLAG	_IOW('s', 81, unsigned long)
+
+/*****************************************************************************/
+
+#endif
diff --git a/sys/platform/pc64/include/comstats.h b/sys/platform/pc64/include/comstats.h
new file mode 100644
index 0000000..c2be5bc
--- /dev/null
+++ b/sys/platform/pc64/include/comstats.h
@@ -0,0 +1,124 @@
+/*****************************************************************************/
+
+/*
+ * comstats.h  -- Serial Port Stats.
+ *
+ * Copyright (c) 1994-1996 Greg Ungerer (gerg@stallion.oz.au).
+ * 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 Greg Ungerer.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * 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.
+ *
+ * $FreeBSD: src/sys/i386/include/comstats.h,v 1.5 1999/08/28 00:44:09 peter Exp $
+ * $DragonFly: src/sys/platform/pc32/include/comstats.h,v 1.4 2008/05/18 03:02:53 pavalos Exp $
+ */
+
+#ifndef	_COMSTATS_H_
+#define	_COMSTATS_H_
+
+#include <sys/ioccom.h>
+
+/*
+ *	Serial port stats structure. The structure itself is UART
+ *	independent, but some fields may be UART/driver specific (for
+ *	example state).
+ */
+
+typedef struct {
+	unsigned long	brd;
+	unsigned long	panel;
+	unsigned long	port;
+	unsigned long	hwid;
+	unsigned long	type;
+	unsigned long	txtotal;
+	unsigned long	rxtotal;
+	unsigned long	txbuffered;
+	unsigned long	rxbuffered;
+	unsigned long	rxoverrun;
+	unsigned long	rxparity;
+	unsigned long	rxframing;
+	unsigned long	rxlost;
+	unsigned long	txbreaks;
+	unsigned long	rxbreaks;
+	unsigned long	txxon;
+	unsigned long	txxoff;
+	unsigned long	rxxon;
+	unsigned long	rxxoff;
+	unsigned long	txctson;
+	unsigned long	txctsoff;
+	unsigned long	rxrtson;
+	unsigned long	rxrtsoff;
+	unsigned long	modem;
+	unsigned long	state;
+	unsigned long	flags;
+	unsigned long	ttystate;
+	unsigned long	cflags;
+	unsigned long	iflags;
+	unsigned long	oflags;
+	unsigned long	lflags;
+	unsigned long	signals;
+} comstats_t;
+
+
+/*
+ *	Board stats structure. Returns useful info about the board.
+ */
+
+#define	COM_MAXPANELS	8
+
+typedef struct {
+	unsigned long	panel;
+	unsigned long	type;
+	unsigned long	hwid;
+	unsigned long	nrports;
+} companel_t;
+
+typedef struct {
+	unsigned long	brd;
+	unsigned long	type;
+	unsigned long	hwid;
+	unsigned long	state;
+	unsigned long	ioaddr;
+	unsigned long	ioaddr2;
+	unsigned long	memaddr;
+	unsigned long	irq;
+	unsigned long	nrpanels;
+	unsigned long	nrports;
+	companel_t	panels[COM_MAXPANELS];
+} combrd_t;
+
+
+/*
+ *	Define the ioctl operations for stats stuff.
+ */
+#define	COM_GETPORTSTATS	_IOWR('c', 30, comstats_t)
+#define	COM_CLRPORTSTATS	_IOWR('c', 31, comstats_t)
+#define	COM_GETBRDSTATS		_IOWR('c', 32, combrd_t)
+
+/*****************************************************************************/
+
+#endif
diff --git a/sys/platform/pc64/include/gsc.h b/sys/platform/pc64/include/gsc.h
new file mode 100644
index 0000000..f00bbfa
--- /dev/null
+++ b/sys/platform/pc64/include/gsc.h
@@ -0,0 +1,54 @@
+/* gsc.h - programming interface to the scanner device driver `gsc'
+ *
+ *
+ * Copyright (c) 1995 Gunther Schadow.  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 Gunther Schadow.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/i386/include/gsc.h,v 1.2.10.1 2000/08/03 01:01:19 peter Exp $
+ * $DragonFly: src/sys/platform/pc32/include/gsc.h,v 1.2 2003/06/17 04:28:35 dillon Exp $
+ */
+
+#ifndef	_MACHINE_GSC_H_
+#define	_MACHINE_GSC_H_
+
+#include <sys/ioccom.h>
+
+#define GSC_GRES	_IOR('S', 1, int)	/* get resolution / dpi */
+#define GSC_SRES	_IOW('S', 2, int)	/* set resolution / dpi */
+#define GSC_GWIDTH	_IOR('S', 3, int)	/* get width / pixels */
+#define	GSC_SWIDTH	_IOW('S', 4, int)	/* set width / pixels */
+#define GSC_GHEIGHT	_IOR('S', 5, int)	/* get height / pixels */
+#define GSC_SHEIGHT	_IOW('S', 6, int)	/* set height / pixels */
+
+#define GSC_GBLEN	_IOR('S', 7, int)	/* get buffer length / lines */
+#define GSC_SBLEN	_IOW('S', 8, int)	/* set buffer length / lines */
+#define GSC_GBTIME	_IOR('S', 9, int)	/* get buffer timeout / s */
+#define GSC_SBTIME	_IOW('S', 10, int)	/* set buffer timeout / s */
+
+#define GSC_SRESSW	_IO('S', 11)	        /* set resolution by switch */
+
+#endif /* !_MACHINE_GSC_H_ */
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index 54b0189..ad548bf 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -174,23 +174,24 @@ SUBDIR+=editmap \
 .endif
 
 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
-SUBDIR+= btxld
-.endif
-
-.if ${MACHINE_ARCH} == "i386"
 SUBDIR+=apm \
 	apmd \
 	battd \
+	btxld \
 	kgmon \
 	kgzip \
 	lptcontrol \
 	mptable \
 	rndcontrol \
-	sgsc \
 	sicontrol \
+	sgsc \
 	spkrtest \
-	stallion \
-	wlconfig
+	stallion
+.endif
+
+.if ${MACHINE_ARCH} == "i386"
+SUBDIR+=wlconfig
+
 .if !defined(NO_I4B)
 SUBDIR+=i4b
 .endif
diff --git a/usr.sbin/apm/Makefile b/usr.sbin/apm/Makefile
index 08e029c..de7d2f2 100644
--- a/usr.sbin/apm/Makefile
+++ b/usr.sbin/apm/Makefile
@@ -6,4 +6,6 @@ LINKS=	${BINDIR}/apm ${BINDIR}/zzz
 MAN=	apm.8
 MLINKS=	apm.8 apmconf.8 apm.8 zzz.8
 
+WARNS ?= 6
+
 .include <bsd.prog.mk>
diff --git a/usr.sbin/apmd/Makefile b/usr.sbin/apmd/Makefile
index 3534ce7..7af60d3 100644
--- a/usr.sbin/apmd/Makefile
+++ b/usr.sbin/apmd/Makefile
@@ -3,7 +3,7 @@
 
 PROG=	apmd
 SRCS=	apmd.c apmdlex.l apmdparse.y y.tab.h
-WARNS?=	2
+WARNS?=	3
 
 DPADD=	${LIBL} ${LIBUTIL}
 LDADD=	-ll -lutil
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index e1ca991..7f9edce 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -51,7 +51,6 @@
 
 #include "apmd.h"
 
-extern int	yyparse(void);
 
 int		debug_level = 0;
 int		verbose = 0;
@@ -540,7 +539,7 @@ check_battery(void)
 		if (p -> direction == AC_POWER_STATE &&
 			!(p -> done) &&
 			((p -> type == BATTERY_PERCENT && 
-				p -> level == pw_info.ai_batt_life) ||
+				p -> level == (int)pw_info.ai_batt_life) ||
 			(p -> type == BATTERY_MINUTES &&
 				p -> level == (pw_info.ai_batt_time / 60)))) {
 			p -> done++;
diff --git a/usr.sbin/apmd/apmd.h b/usr.sbin/apmd/apmd.h
index 5e09fb8..d3fd119 100644
--- a/usr.sbin/apmd/apmd.h
+++ b/usr.sbin/apmd/apmd.h
@@ -107,5 +107,27 @@ extern int register_apm_event_handlers(
 	struct event_cmd *cmdlist);
 extern void free_event_cmd_list(struct event_cmd *p);
 
+extern int	yyparse(void);
+
 void	yyerror(const char *);
 int	yylex(void);
+
+struct event_cmd *event_cmd_default_clone(void *);
+int event_cmd_exec_act(void *);
+void event_cmd_exec_dump(void *, FILE *);
+struct event_cmd *event_cmd_exec_clone(void *);
+void event_cmd_exec_free(void *);
+int event_cmd_reject_act(void *);
+struct event_cmd *clone_event_cmd_list(struct event_cmd *);
+int exec_run_cmd(struct event_cmd *);
+int exec_event_cmd(struct event_config *);
+void read_config(void);
+void dump_config(void);
+void destroy_config(void);
+void restart(void);
+void enque_signal(int);
+void wait_child(void);
+int proc_signal(int);
+void proc_apmevent(int);
+void check_battery(void);
+void event_loop(void);
diff --git a/usr.sbin/battd/Makefile b/usr.sbin/battd/Makefile
index d0a2e68..4a90819 100644
--- a/usr.sbin/battd/Makefile
+++ b/usr.sbin/battd/Makefile
@@ -4,6 +4,8 @@
 PROG=	battd	
 MAN=	battd.8
 
+WARNS ?= 6
+
 LDADD+=	-lutil
 DPADD+=	${LIBUTIL}
 
diff --git a/usr.sbin/kgmon/Makefile b/usr.sbin/kgmon/Makefile
index 8ca9fa5..5d50f3b 100644
--- a/usr.sbin/kgmon/Makefile
+++ b/usr.sbin/kgmon/Makefile
@@ -6,7 +6,7 @@ PROG=	kgmon
 MAN=	kgmon.8
 DPADD=	${LIBKVM}
 LDADD=	-lkvm
-WARNS?=	1
+WARNS?=	2
 
 #
 # This program may safely be run setuid-root to allow non-root
diff --git a/usr.sbin/kgmon/kgmon.c b/usr.sbin/kgmon/kgmon.c
index 299852f..4431ae4 100644
--- a/usr.sbin/kgmon/kgmon.c
+++ b/usr.sbin/kgmon/kgmon.c
@@ -347,7 +347,7 @@ dumpstate(struct kvmvars *kvp)
 			i = 0;
 	}
 	if (i != kvp->gpm.kcountsize)
-		errx(6, "read ticks: read %u, got %d: %s",
+		errx(6, "read ticks: read %lu, got %ld: %s",
 		    kvp->gpm.kcountsize, i,
 		    kflag ? kvm_geterr(kvp->kd) : strerror(errno));
 	if ((fwrite(tickbuf, kvp->gpm.kcountsize, 1, fp)) != 1)
@@ -369,7 +369,7 @@ dumpstate(struct kvmvars *kvp)
 			i = 0;
 	}
 	if (i != kvp->gpm.fromssize)
-		errx(9, "read froms: read %u, got %d: %s",
+		errx(9, "read froms: read %lu, got %ld: %s",
 		    kvp->gpm.fromssize, i,
 		    kflag ? kvm_geterr(kvp->kd) : strerror(errno));
 	if ((tos = (struct tostruct *)malloc(kvp->gpm.tossize)) == NULL)
@@ -384,11 +384,11 @@ dumpstate(struct kvmvars *kvp)
 			i = 0;
 	}
 	if (i != kvp->gpm.tossize)
-		errx(11, "read tos: read %u, got %d: %s",
+		errx(11, "read tos: read %lu, got %ld: %s",
 		    kvp->gpm.tossize, i,
 		    kflag ? kvm_geterr(kvp->kd) : strerror(errno));
 	if (debug)
-		warnx("lowpc 0x%x, textsize 0x%x",
+		warnx("lowpc 0x%tx, textsize 0x%lx",
 			      kvp->gpm.lowpc, kvp->gpm.textsize);
 	endfrom = kvp->gpm.fromssize / sizeof(*froms);
 	for (fromindex = 0; fromindex < endfrom; ++fromindex) {
@@ -399,7 +399,7 @@ dumpstate(struct kvmvars *kvp)
 		for (toindex = froms[fromindex]; toindex != 0;
 		   toindex = tos[toindex].link) {
 			if (debug)
-			    warnx("[mcleanup] frompc 0x%x selfpc 0x%x count %d",
+			    warnx("[mcleanup] frompc 0x%lx selfpc 0x%lx count %ld",
 			    frompc, tos[toindex].selfpc,
 			    tos[toindex].count);
 			rawarc.raw_frompc = frompc;
diff --git a/usr.sbin/kgzip/Makefile b/usr.sbin/kgzip/Makefile
index 0e58855..d3ddbde 100644
--- a/usr.sbin/kgzip/Makefile
+++ b/usr.sbin/kgzip/Makefile
@@ -4,5 +4,6 @@
 PROG=	kgzip
 SRCS=	kgzip.c aouthdr.c elfhdr.c kgzcmp.c kgzld.c xio.c
 MAN=	kgzip.8
+WARNS ?= 6
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/lptcontrol/Makefile b/usr.sbin/lptcontrol/Makefile
index 2c42934..2b83f18 100644
--- a/usr.sbin/lptcontrol/Makefile
+++ b/usr.sbin/lptcontrol/Makefile
@@ -3,5 +3,6 @@
 
 PROG=		lptcontrol
 MAN=		lptcontrol.8
+WARNS ?=	6
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/rndcontrol/Makefile b/usr.sbin/rndcontrol/Makefile
index b90727f..f4f9754 100644
--- a/usr.sbin/rndcontrol/Makefile
+++ b/usr.sbin/rndcontrol/Makefile
@@ -4,5 +4,6 @@
 PROG=		rndcontrol
 MAN=		random.4 rndcontrol.8
 MLINKS+=	random.4 urandom.4
+WARNS ?=	6
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/sgsc/Makefile b/usr.sbin/sgsc/Makefile
index ff9acac..80cfe28 100644
--- a/usr.sbin/sgsc/Makefile
+++ b/usr.sbin/sgsc/Makefile
@@ -2,6 +2,6 @@
 # $DragonFly: src/usr.sbin/sgsc/Makefile,v 1.2 2003/06/17 04:30:03 dillon Exp $
 
 PROG=	sgsc
-WARNS?=	3
+WARNS?=	6
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/sgsc/sgsc.c b/usr.sbin/sgsc/sgsc.c
index b536788..fce1aee 100644
--- a/usr.sbin/sgsc/sgsc.c
+++ b/usr.sbin/sgsc/sgsc.c
@@ -63,7 +63,7 @@ main(int argc, char **argv)
   char c;
   int fd;
 
-  char *file = DEFAULT_FILE;
+  const char *file = DEFAULT_FILE;
 
   int show_dpi     = 0;
   int show_width   = 0;
diff --git a/usr.sbin/sicontrol/Makefile b/usr.sbin/sicontrol/Makefile
index b5ed780..4adfbd6 100644
--- a/usr.sbin/sicontrol/Makefile
+++ b/usr.sbin/sicontrol/Makefile
@@ -4,5 +4,6 @@
 PROG=	sicontrol
 MAN=	sicontrol.8
 CFLAGS+= -I${.CURDIR}/../../sys
+WARNS ?= 6
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/stallion/stlload/Makefile b/usr.sbin/stallion/stlload/Makefile
index 8aad525..0b7f37a 100644
--- a/usr.sbin/stallion/stlload/Makefile
+++ b/usr.sbin/stallion/stlload/Makefile
@@ -4,6 +4,7 @@
 PROG=	stlload
 MAN=	stlload.8
 MANSUBDIR=/i386
+WARNS ?= 2
 
 CFLAGS+=-DBOOTDIR=\"${BOOTDIR}\"
 
diff --git a/usr.sbin/stallion/stlload/stlload.c b/usr.sbin/stallion/stlload/stlload.c
index 98db957..2ff4910 100644
--- a/usr.sbin/stallion/stlload/stlload.c
+++ b/usr.sbin/stallion/stlload/stlload.c
@@ -375,7 +375,7 @@ download(void)
 
 	strttime = time(NULL);
 	if (verbose)
-		printf("Waiting for slave alive marker, time=%x timeout=%d\n",
+		printf("Waiting for slave alive marker, time=%lx timeout=%d\n",
 			strttime, TIMEOUT);
 	while (time(NULL) < (strttime + TIMEOUT)) {
 		if (lseek(memfd, CDK_RDYADDR, SEEK_SET) != CDK_RDYADDR) {
diff --git a/usr.sbin/stallion/stlstats/Makefile b/usr.sbin/stallion/stlstats/Makefile
index 7a0b1ff..b4488e4 100644
--- a/usr.sbin/stallion/stlstats/Makefile
+++ b/usr.sbin/stallion/stlstats/Makefile
@@ -4,6 +4,7 @@
 PROG=	stlstats
 MAN=	stlstats.8
 MANSUBDIR=/i386
+WARNS ?= 2
 
 DPADD=	${LIBNCURSES} ${LIBMYTINFO}
 LDADD=	-lncurses -lmytinfo
diff --git a/usr.sbin/stallion/stlstty/Makefile b/usr.sbin/stallion/stlstty/Makefile
index 8cefc13..96c0ade 100644
--- a/usr.sbin/stallion/stlstty/Makefile
+++ b/usr.sbin/stallion/stlstty/Makefile
@@ -4,6 +4,7 @@
 PROG=	stlstty
 MAN=	stlstty.8
 MANSUBDIR=/i386
+WARNS ?= 3
 
 DPADD=	${LIBNCURSES} ${LIBMYTINFO}
 LDADD=	-lncurses -lmytinfo
diff --git a/usr.sbin/stallion/stlstty/stlstty.c b/usr.sbin/stallion/stlstty/stlstty.c
index 9eb9335..b9a4de0 100644
--- a/usr.sbin/stallion/stlstty/stlstty.c
+++ b/usr.sbin/stallion/stlstty/stlstty.c
@@ -44,6 +44,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <string.h>
 #include <sys/ioctl.h>
 
 #include <machine/cdk.h>
@@ -101,6 +102,10 @@ struct stloption longops[] = {
 	{ 0, 0 }
 };
 
+/* Function prototypes */
+void getpflags(void);
+void setpflags(unsigned long , unsigned long );
+
 /*****************************************************************************/
 
 /*
-- 
1.6.4

