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

/* System definition */

#include	<types.h>
#include	<sys.h>
#include	<gw/dev.vax/async.h>
#include	<gw/dev.vax/dhv.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	15		/* 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(), EGP();
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, 0,		/* status */
	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 */
/*	EGP, 0,			/* exterior gateway protocol */
	RIP, 0,	    		/* routing information protocol */

	tcp_Init, 0,		/* TCP */
	SUPDUP, 0,		/* SUPDUP server */
/*	KEEP_ALIVE, 1,		/* DEQNA keep alive */
/*	TIMING, 0,		/* print timing info */
	restart_init, 0, /* Sets up restart parameter block */
	0, 0
};


/*
 * Device definitions
 */

ext void viiii(), viioi(), viiin(), viiot(), vii_up();
ext void dmaii(), dmaoi(), dmain(), dmaot(), dma_up();
ext void qna_in_up(), qna_out_up(), qna_out(), qna_in(), qna_int();
ext void dlii(), dloi(), dlup(), dlin(), dlot();
ext void dhii(), dhoi(), dhup(), dhin(), dhot();
ext void con_rup(), con_tup(), con_out(), con_rint(), con_tint();
ext void sd_tup(), sd_write();

dct viidct[2] = {
    DCTMAC(viiii, vii_up, viiin, VAX_CSR(0775200), VAX_INT(0260), &viidct[1]),
    DCTMAC(viioi, vii_up, viiot, VAX_CSR(0775210), VAX_INT(0264), &viidct[0]),
};

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

/*
dct dldct[2] = {
    DCTMAC(dlii, dlup, dlin, VAX_CSR(0777560), VAX_INT(0460), &dldct[1]),
    DCTMAC(dloi, dlup, dlot, VAX_CSR(0777560), VAX_INT(0464), &dldct[0]),
};
*/

struct async_conf modem_9600 = {
    PARITY_OFF,
    CHAR_LEN_8,
    STOP1,
    MODEM,
    BAUD_9600,
    BAUD_9600,
    FC_NONE
};

struct async_conf modem_2400 = {
    PARITY_OFF,
    CHAR_LEN_8,
    STOP1,
    MODEM,
    BAUD_2400,
    BAUD_2400,
    FC_NONE
};

struct async_conf CTS_9600 = {
    PARITY_OFF,
    CHAR_LEN_8,
    STOP1,
    MODEM,
    BAUD_9600,
    BAUD_9600,
    FC_NONE
};

extern dct dhodct[];
dct dhidct[8] = {
    DCTMAC2(dhii, dhup, dhin, VAX_CSR(0760440), VAX_INT(0300), &dhodct[0], NULL),
    DCTMAC2(dhii, dhup, dhin, VAX_CSR(0760440), NO_IVEC, &dhodct[1], &modem_2400),
    DCTMAC2(dhii, dhup, dhin, VAX_CSR(0760440), NO_IVEC, &dhodct[2], &modem_9600),
    DCTMAC2(dhii, dhup, dhin, VAX_CSR(0760440), NO_IVEC, &dhodct[3], NULL),
    DCTMAC2(dhii, dhup, dhin, VAX_CSR(0760440), NO_IVEC, &dhodct[4], NULL),
    DCTMAC2(dhii, dhup, dhin, VAX_CSR(0760440), NO_IVEC, &dhodct[5], NULL),
    DCTMAC2(dhii, dhup, dhin, VAX_CSR(0760440), NO_IVEC, &dhodct[6], NULL),
    DCTMAC2(dhii, dhup, dhin, VAX_CSR(0760440), NO_IVEC, &dhodct[7], NULL),
};

dct dhodct[8] = {
    DCTMAC(dhoi, NULL, dhot, VAX_CSR(0760440), VAX_INT(0304), &dhidct[0]),
    DCTMAC(dhoi, NULL, dhot, VAX_CSR(0760440), NO_IVEC, &dhidct[1]),
    DCTMAC(dhoi, NULL, dhot, VAX_CSR(0760440), NO_IVEC, &dhidct[2]),
    DCTMAC(dhoi, NULL, dhot, VAX_CSR(0760440), NO_IVEC, &dhidct[3]),
    DCTMAC(dhoi, NULL, dhot, VAX_CSR(0760440), NO_IVEC, &dhidct[4]),
    DCTMAC(dhoi, NULL, dhot, VAX_CSR(0760440), NO_IVEC, &dhidct[5]),
    DCTMAC(dhoi, NULL, dhot, VAX_CSR(0760440), NO_IVEC, &dhidct[6]),
    DCTMAC(dhoi, NULL, dhot, VAX_CSR(0760440), NO_IVEC, &dhidct[7]),
};

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, NO_IVEC, &sddct[0]),
};

dct *DCTVT[] =	{
    &viidct[0], &viidct[1],
    &qnadct[0], &qnadct[1],
    &dhidct[0], &dhidct[1], &dhidct[2], &dhidct[3],
    &dhidct[4], &dhidct[5], &dhidct[6], &dhidct[7],
    &dhodct[0], &dhodct[1], &dhodct[2], &dhodct[3],
    &dhodct[4], &dhodct[5], &dhodct[6], &dhodct[7],
    &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;
