/* Copyright 1984 by the Massachusetts Institute of Technology */

/*
 *------------------------------------------------------------------
 *
 * $Source: /afs/net.mit.edu/project/cgw/conf/sewage/RCS/systbl-c.c,v $
 * $Revision: 1.3 $
 * $Date: 90/11/02 18:15:59 $
 * $State: Exp $
 * $Author: jon $
 * $Locker:  $
 *
 * $Log:	systbl-c.c,v $
 * Revision 1.3  90/11/02  18:15:59  jon
 * add nip
 * 
 * Revision 1.2  90/02/06  18:28:40  jon
 * add second ether
 * 
 * Revision 1.1  88/06/23  16:55:06  jon
 * Initial revision
 * 
 * 
 *------------------------------------------------------------------
 */

#ifndef lint
static char *rcsid_systbl_c_c = "$Header: /afs/net.mit.edu/project/cgw/conf/sewage/RCS/systbl-c.c,v 1.3 90/11/02 18:15:59 jon Exp $";
#endif	lint

/* System definition */

#include	<types.h>
#include	<sys.h>


#define	NULL	0

/* definitions of packet sizes */
#define	MX_PKT	3000		/* Size of largest packet */
#define	MX_SH	4		/* software header (MPW) */
#define	MX_HH	14		/* hardware header (10 Mb EtherNet) */
#define	MX_ST	0		/* software trailer */
#define	MX_HT	6		/* hardware trailer (chaos) */

/*
 * System initialization routines
 */

ext void	log_init(), opcon_register();
ext word	log_cmd;
ext void	time_init(), io_init(), bus_int();
ext void	initgw();
ext void	INNET(), CHNET(), ARP(), RIP(), NIP();
ext void	TIMING();
ext void	OPCON(), STAT();
ext void	restart_init();
ext void	tcp_Init(), SUPDUP();
ext void	KEEP_ALIVE();

struct inittbl	INITTBL[] = {
			/* system initialization */
	log_init, 0,		/* logging */
	time_init, 0,		/* timers */
	io_init, 0,		/* devices */
	OPCON, 0,		/* command interpreter */
	STAT, 60*60,		/* log status every 60 minutes */
	opcon_register, (word)(&log_cmd), /* init logging commands */

	initgw, 0,	/* gateway initialization */
		
			/* protocol initialization */
	INNET, 0,		/* internet */
	CHNET, 0,		/* chaos net */
	ARP, 0,			/* address resolution protocol */
	RIP, 0,	    		/* Routed */
	NIP, 0,                 /* JIS's Network Information Protocol */
	tcp_Init, 0,		/* TCP */
	SUPDUP, 0,		/* SUPDUP server */
	restart_init, 0, /* Sets up restart parameter block */
	0, 0
};


/*
 * Device definitions
 */

ext void viiii(), viioi(), viiin(), viiot(), vii_up();
ext void qna_in_up(), qna_out_up(), qna_out(), qna_in(), qna_int();
ext void con_rup(), con_tup(), con_out(), con_rint(), con_tint();
ext void sd_tup(), sd_write();

dct viidct[4] = {
    DCTMAC(viiii, vii_up, viiin, 0x20001a80, 0x2b0, &viidct[1]),
    DCTMAC(viioi, vii_up, viiot, 0x20001a88, 0x2b4, &viidct[0]),
    DCTMAC(viiii, vii_up, viiin, 0x20001a90, 0x2b8, &viidct[3]),
    DCTMAC(viioi, vii_up, viiot, 0x20001a98, 0x2bc, &viidct[2]),
};

dct qnadct[4] = {
    DCTMAC(qna_int, qna_in_up, qna_in, 0x20001920, 0x3f0, &qnadct[1]),
    DCTMAC(qna_int, qna_out_up, qna_out, 0x20001920, 0x3f4, &qnadct[0]),
    DCTMAC(qna_int, qna_in_up, qna_in, 0x20001930, 0x3f8, &qnadct[3]),
    DCTMAC(qna_int, qna_out_up, qna_out, 0x20001930, 0x3fc, &qnadct[2]),
};

dct condct[2] = {
    DCTMAC(con_rint, con_rup, NULL, 0, 0xf8, &condct[1]),
    DCTMAC(con_tint, con_tup, con_out, 0, 0xfc, &condct[0]),
};

dct sddct[1] = {
    DCTMAC(NULL, sd_tup, sd_write, 0, 0, &sddct[0]),
};

dct *DCTVT[] =	{	&viidct[0],
			&viidct[1],
			&viidct[2],
			&viidct[3],
			&qnadct[0],
			&qnadct[1],
			&qnadct[2],
			&qnadct[3],
			&condct[0],
			&condct[1],
			&sddct[0],
			NULL
		};

dct *log_dev = &condct[1];

/*
 * Global Variables defined per configuration
 *
 *	These should really be set from the net structure at runtime.
 */

word	pktsiz = MX_PKT + MX_SH + MX_HH + MX_ST + MX_HT;
word	hdrsiz = MX_SH + MX_HH;
word	tlrsiz = MX_ST + MX_HT;
word	bufsiz = sizeof(iorb) + MX_PKT + MX_SH + MX_HH + MX_ST + MX_HT;
word	pktoff = sizeof(iorb) + MX_SH + MX_HH;
