#
#include "mkconf.h"
struct tab table[]{
	"console",
	-1,	0,	060,	CHAR+INTR+KL+DISCP,	010,
	"\tklin; br5\n\tklou; br5\n",
	".globl\t_klrint\nklin:\tjsr\tr0,call; _klrint\n",
	".globl\t_klxint\nklou:\tjsr\tr0,call; _klxint\n",
	"",
	"\t&klopen,   &klclose,   &klread,   &klwrite,   &klsgtty,",
	"\t&nulldev,       &klmctl,",
	"",

	"mem",
	-1,	0,	0300,	CHAR,	0,
	"",
	"",
	"",
	"",
	"\t&nulldev,  &nulldev,   &mmread,   &mmwrite,   &nodev,",
	"",
	"",

	"pc",
	0,	0,	070,	CHAR+INTR,	010,
	"\tpcin; br4\n\tpcou; br4\n",
	".globl\t_pcrint\npcin:\tjsr\tr0,call; _pcrint\n",
	".globl\t_pcpint\npcou:\tjsr\tr0,call; _pcpint\n",
	"",
	"\t&pcopen,   &pcclose,   &pcread,   &pcwrite,   &nodev,",
	"",
	"",

	"clock",
	-2,	0,	0100,	INTR,	04,
	"\tkwlp; br6\n",
	".globl\t_clock\n",
	"kwlp:\tjsr\tr0,call; _clock\n",
	"",
	"",
	"",
	"",

/*
 * 110 unused
 * 114 memory parity
 * 120 XY plotter
 * 124 DR11-B
 */
	"da",
	0,	0,	0124,	BLOCK+CHAR+INTR,	04,
	"\tdaio; br4\n",
	"",
	".globl\t_daint\ndaio:\tjsr\tr0,call; _daint\n",
	"\t&daopen,\t&daclose,\t&dastrategy, \t&datab,",
	"\t&daopen,   &daclose,   &daread,    &dawrite,   &dasgtty,",
	"",
	"",
/*
 * 130 AD01
 * 134 AFC11
 * 140 AA11
 * 144 AA11
 * 150-174 unused
 */

	"lp",
	0,	0,	0200,	CHAR+INTR,	04,
	"\tlpou; br4\n",
	"",
	".globl\t_lpint\nlpou:\tjsr\tr0,call; _lpint\n",
	"",
	"\t&lpopen,   &lpclose,   &nodev,    &lpwrite,   &nodev,",
	"",
	"",

	"rf",
	0,	0,	0204,	BLOCK+CHAR+INTR,	04,
	"\trfio; br5\n",
	".globl\t_rfintr\n",
	"rfio:\tjsr\tr0,call; _rfintr\n",
	"\t&rfopen,\t&nulldev,\t&rfstrategy, \t&rftab,",
	"\t&rfopen,   &nulldev,   &rfread,   &rfwrite,   &nodev,",
	"",
	"\t&rfetab,",

	"hs",
	0,	0,	0204,	BLOCK+CHAR+INTR,	04,
	"\thsio; br5\n",
	".globl\t_hsintr\n",
	"hsio:\tjsr\tr0,call; _hsintr\n",
	"\t&hsopen,\t&nulldev,\t&hsstrategy, \t&hstab,",
	"\t&hsopen,   &nulldev,   &hsread,   &hswrite,   &nodev,",
	"",
	"\t&hsetab,",

/*
 * 210 RC
 */

	"tc",
	0,	0,	0214,	BLOCK+INTR,	04,
	"\ttcio; br6\n",
	".globl\t_tcintr\n",
	"tcio:\tjsr\tr0,call; _tcintr\n",
	"\t&tcopen,\t&tcclose,\t&tcstrategy, \t&tctab,",
	"",
	"",
	"\t&tcetab,",

	"rk",
	0,	0,	0220,	BLOCK+CHAR+INTR,	04,
	"\trkio; br5\n",
	".globl\t_rkintr\n",
	"rkio:\tjsr\tr0,call; _rkintr\n",
	"\t&rkopen,\t&nulldev,\t&rkstrategy, \t&rktab,",
	"\t&rkopen,   &nulldev,   &rkread,   &rkwrite,   &nodev,",
	"",
	"\t&rketab,",

	"tm",
	0,	0,	0224,	BLOCK+CHAR+INTR,	04,
	"\ttmio; br5\n",
	".globl\t_tmintr\n",
	"tmio:\tjsr\tr0,call; _tmintr\n",
	"\t&tmopen,\t&tmclose,\t&tmstrategy, \t&tmtab,",
	"\t&tmopen,   &tmclose,   &tmread,   &tmwrite,   &nodev,",
	"",
	"\t&tmetab,",

	"ht",
	0,	0,	0224,	BLOCK+CHAR+INTR,	04,
	"\thtio; br5\n",
	".globl\t_htintr\n",
	"htio:\tjsr\tr0,call; _htintr\n",
	"\t&htopen,\t&htclose,\t&htstrategy, \t&httab,",
	"\t&htopen,   &htclose,   &htread,   &htwrite,   &nodev,",
	"",
	"\t&htetab,",

	"cr",
	0,	0,	0230,	CHAR+INTR,	04,
	"\tcrin; br6\n",
	"",
	".globl\t_crint\ncrin:\tjsr\tr0,call; _crint\n",
	"",
	"\t&cropen,   &crclose,   &crread,   &nodev,     &nodev,",
	"",
	"",

/*
 * 234 UDC11
 */

	"rp",
	0,	0,	0254,	BLOCK+CHAR+INTR,	04,
	"\trpio; br5\n",
	".globl\t_rpintr\n",
	"rpio:\tjsr\tr0,call; _rpintr\n",
	"\t&rpopen,\t&nulldev,\t&rpstrategy, \t&rptab,",
	"\t&rpopen,  &nulldev,   &rpread,   &rpwrite,   &nodev,",
	"",
	"\t&rpetab,",

	"hp",
	0,	0,	0254,	BLOCK+CHAR+INTR,	04,
	"\thpio; br5\n",
	".globl\t_hpintr\n",
	"hpio:\tjsr\tr0,call; _hpintr\n",
	"\t&hpopen,\t&nulldev,\t&hpstrategy, \t&hptab,",
	"\t&hpopen,   &nulldev,   &hpread,   &hpwrite,   &nodev,",
	"",
	"\t&hpetab,",

/*
 * 260 TA11
 * 264-274 unused
 */

/*
 * DM11-A
 */

	"dn",
	0,	0,	0304,	CHAR+INTR,	04,
	"\tdnou; br5+%d.\n",
	"",
	".globl\t_dnint\ndnou:\tjsr\tr0,call; _dnint\n",
	"",
	"\t&dnopen,   &dnclose,   &nodev,    &dnwrite,   &nodev,",
	"",
	"",

	"dhdm",
	0,	0,	0300,	INTR,	04,
	"\tdmin; br5+%d.\n",
	"",
	".globl\t_dmint\ndmin:\tjsr\tr0,call; _dmint\n",
	"",
	"",
	"",
	"",


	"dc",
	0,	0,	0300,	CHAR+INTR+DISCP,	010,
	"\tdcin; br5+%d.\n\tdcou; br5+%d.\n",
	".globl\t_dcrint\ndcin:\tjsr\tr0,call; _dcrint\n",
	".globl\t_dcxint\ndcou:\tjsr\tr0,call; _dcxint\n",
	"",
	"\t&dcopen,   &dcclose,   &dcread,   &dcwrite,   &dcsgtty,",
	"\t&dcparam,       &dcmctl,",
	"",

	"mpdc",
	0,	0,	0300,	CHAR+INTR,	010,
	"\tmpin; br5+%d.\n\tmpou; br5+%d.\n",
	".globl\t_mprintr\nmpin:\tjsr\tr0,call; _mprintr\n",
	".globl\t_mpxintr\nmpou:\tjsr\tr0,call; _mpxintr\n",
	"",
	"\t&mpopen,   &mpclose,   &mpread,   &mpwrite,   &mpsgtty,",
	"",
	"",

	"vt",
	0,	0,	0300,	CHAR+INTR,	04,
	"\tvtin; br5+%d.\n",
	".globl\t_vtint\nvtin:\tjsr\tr0,call; _vtint\n",
	"",
	"",
	"\t&vtopen,   &vtclose,   &vtread,   &vtwrite,   &nodev,",
	"",
	"",

	"vtlp",
	0,	0,	0300,	CHAR+INTR,	04,
	"\tvtlpin; br5+%d.\n",
	".globl\t_vtlpint\nvtlpin:\tjsr\tr0,call; _vtlpint\n",
	"",
	"",
	"\t&vtlpopen,   &vtlpclose,   &vtlpread,   &nodev,   &nodev,",
	"",
	"",

	"cm",
	0,	0,	0300,	CHAR+INTR,	010,
	"\tcmin; br5+%d.\n\tcmin; br5+%d.\n",
	".globl\t_cmintr\ncmin:\tjsr\tr0,call; _cmintr\n",
	"",
	"",
	"\t&cmopen,   &cmclose,   &cmread,   &cmwrite,   &nodev,",
	"",
	"",

	"toy",
	0,	0,	0320,	CHAR+INTR,	010,
	"\ttyin; br5+%d.\n\ttyou; br5+%d.\n",
	".globl\t_tyaintr\ntyin:\tjsr\tr0,call; _tyaintr\n",
	".globl\t_tybintr\ntyou:\tjsr\tr0,call; _tybintr\n",
	"",
	"\t&tyopen,   &nulldev,   &tyread,   &tywrite,   &tysgtty,",
	"",
	"",

	"dqs",
	0,	0,	0300,	CHAR+INTR,	010,
	"\tdqsin; br5+%d.\n\tdqsou; br5+%d.\n",
	".globl\t_dqsint\ndqsin:\tjsr\tr0,call; _dqsint\n",
	".globl\t_dqsint\ndqsou:\tjsr\tr0,call; _dqsint\n",
	"",
	"\t&dqsopen,   &dqsclose,   &dqsread,   &dqswrite,   &nodev,",
	"",
	"",

	"kl",
	0,	0,	0310,	INTR+KL,	010,
	"\tklin; br5+%d.\n\tklou; br5+%d.\n",
	"",
	"",
	"",
	"",
	"",
	"",

	"dp",
	0,	0,	0310,	CHAR+INTR,	010,
	"\tdpin; br6+%d.\n\tdpou; br6+%d.\n",
	".globl\t_dprint\ndpin:\tjsr\tr0,call; _dprint\n",
	".globl\t_dpxint\ndpou:\tjsr\tr0,call; _dpxint\n",
	"",
	"\t&dpopen,   &dpclose,   &dpread,   &dpwrite,   &nodev,",
	"",
	"",

/*
 * DR11-A+
 * DR11-C+
 * PA611+
 * PA611+
 * DT11+
 * DX11+
*/

	"dl",
	0,	0,	0300,	INTR+KL+DISCP,	010,
	"\tklin; br4+%d.\n\tklou; br4+%d.\n",
	"",
	"",
	"",
	"",
	"\t&nulldev,       &dlmctl,",
	"",


	"dh",
	0,	0,	0300,	CHAR+INTR+EVEN+DISCP,	010,
	"\tdhin; br5+%d.\n\tdhou; br5+%d.\n",
	".globl\t_dhrint\ndhin:\tjsr\tr0,call; _dhrint\n",
	".globl\t_dhxint\ndhou:\tjsr\tr0,call; _dhxint\n",
	"",
	"\t&dhopen,   &dhclose,   &dhread,   &dhwrite,   &dhsgtty,",
	"\t&dhparam,       &dhmctl,",
	"",

	"dj",
	0,	0,	0300,	CHAR+INTR,	010,
	"\tdjin; br5+%d.\n\tdjou; br5+%d.\n",
	".globl\t_djrint\ndjin:\tjsr\tr0,call; _djrint\n",
	".globl\t_djxint\ndjou:\tjsr\tr0,call; _djxint\n",
	"",
	"\t&djopen,   &djclose,   &djread,   &djwrite,   &djsgtty,",
	"",
	"",

	"dv",
	0,	0,	0300,	CHAR+INTR+EVEN,	010,
	"\tdvin; br5+%d.\n\tdvou; br5+%d.\n",
	".globl\t_dvrint\ndvin:\tjsr\tr0,call; _dvrint\n",
	".globl\t_dvxint\ndvou:\tjsr\tr0,call; _dvxint\n",
	"",
	"\t&dvopen,   &dvclose,   &dvread,   &dvwrite,   &dvsgtty,",
	"",
	"",

	"dz",
	0,	0,	0300,	CHAR+INTR+EVEN,	010,
	"\tdzin; br5+%d.\n\tdzou; br5+%d.\n",
	".globl\t_dzrint\ndzin:\tjsr\tr0,call; _dzrint\n",
	".globl\t_dzxint\ndzou:\tjsr\tr0,call; _dzxint\n",
	"",
	"\t&dzopen,   &dzclose,   &dzread,   &dzwrite,   &dzsgtty,",
	"",
	"",
	"dmc",
	0,	0,	0300,	CHAR+INTR+EVEN,	010,
	"\tdmcin; br5+%d.\n\tdmcou; br5+%d.\n",
	".globl\t_dmcrint\ndmcin:\tjsr\tr0,call; _dmcrint\n",
	".globl\t_dmcxint\ndmcou:\tjsr\tr0,call; _dmcxint\n",
	"",
	"\t&dmcopen,   &dmcclose,   &dmcread,   &dmcwrite,   &dmcsgtty,",
	"",
	"",
/*
 * GT40
 * LPS+
 * VT20
 */
	"null",
	0,	0,	0,	CHAR+BLOCK,	0,
	"",
	"",
	"",
	"\t&nodev,\t\t&nodev,\t\t&nodev,\t\t0,",
	"\t&nodev,    &nodev,     &nodev,    &nodev,     &nodev,",
	"\t&nodev,         &nodev,",
	"",

	"parity",
	0,	0,	0114,	INTR,	04,
	"\ttrap; br7+10.\t\t/ 11/70 parity\n",
	"",
	"",
	"",
	"",
	"",
	"",
/*
 *	Spider
 */
	"tiu",
	0,	0,	0174,	INTR+CHAR,	04,
	"\ttiuio; br6\n",
	".globl\t_tiuintr\ntiuio:\tjsr\tr0,call; _tiuintr",
	"",
	"",
	"\t&tiuopen,  &tiuclose,  &tiuread,  &tiuwrite,  &snstat,",
	"",
	"",
/*
 * Time of day clock
 */
	"tdck",
	0,	0,	0,	CHAR,	0,
	"",
	"",
	"",
	"",
	"\t&nulldev,   &nulldev,   &nulldev,   &nulldev,   &tdsgtty,",
	"",
	"",
/*
 *	Indirect teletype driver
 */
	"sys",
	0,	0,	0,	CHAR,	0,
	"",
	"",
	"",
	"",
	"\t&syopen,   &nulldev,   &syread,   &sywrite,   &sysgtty,",
	"",
	"",

	"du",
	0,	0,	0300,	CHAR+INTR,	010,
	"\tduin; br5+%d.\n\tduou; br5+%d.\n",
	".globl\t_durint\nduin:\tjsr\tr0,call; _durint\n",
	".globl\t_duxint\nduou:\tjsr\tr0,call; _duxint\n",
	"",
	"\t&duopen,   &duclose,   &duread,   &duwrite,   &nodev,",
	"",
	"",

	0
};

char	*stra40[]
{
	"/copyright 1974 Bell Telephone Laboratories Inc.",
	"/low core",
	"",
	"br4 = 200",
	"br5 = 240",
	"br6 = 300",
	"br7 = 340",
	"",
	". = 0^.",
	"\tbr\t1f",
	"\t4",
	"",
	"/ trap vectors",
	"\ttrap; br7+0.\t\t/ bus error",
	"\ttrap; br7+1.\t\t/ illeagle instruction",
	"\ttrap; br7+2.\t\t/ bpt-trace trap",
	"\ttrap; br7+3.\t\t/ iot trap",
	"\ttrap; br7+4.\t\t/ power fail",
	"\ttrap; br7+5.\t\t/ emulator trap",
	"\ttrap; br7+6.\t\t/ system entry",
	"",
	". = 40^.",
	".globl\tstart, dump",
	"1:\tjmp\tstart",
	"\tjmp\tdump",
	"",
	0,
};

char	*stra[]
{
	"/ Copyright 1974 Bell Telephone Laboratories Inc",
	"/ low core",
	"",
	".data",
	"br4 = 200",
	"br5 = 240",
	"br6 = 300",
	"br7 = 340",
	"",
	". = 0^.",
	"\tbr\t1f",
	"\t4",
	"",
	"/ trap vectors",
	"\ttrap; br7+0.\t\t/ bus error",
	"\ttrap; br7+1.\t\t/ illegal instruction",
	"\ttrap; br7+2.\t\t/ bpt-trace trap",
	"\ttrap; br7+3.\t\t/ iot trap",
	"\ttrap; br7+4.\t\t/ power fail",
	"\ttrap; br7+5.\t\t/ emulator trap",
	"\ttrap; br7+6.\t\t/ system entry",
	"",
	". = 40^.",
	".globl\tstart, dump",
	"1:\tjmp\tstart",
	"\tjmp\tdump",
	"",
	0,
};

char	*strb[]
{
	"",
	". = 240^.",
	"\ttrap; br7+7.\t\t/ programmed interrupt",
	"\ttrap; br7+8.\t\t/ floating point",
	"\ttrap; br7+9.\t\t/ segmentation violation",
	0
};

char	*strc[]
{
	"",
	"/ floating vectors",
	0,
};

char	*strd[]
{
	"",
	"//////////////////////////////////////////////////////",
	"/\t\tinterface code to C",
	"//////////////////////////////////////////////////////",
	"",
	".globl\tcall, trap",
	0
};

char	*stre[]
{
	"#",
	"#include \"../head/param.h\"",
	"",
	"/*",
	" *\tCopyright 1974 Bell Telephone Laboratories Inc",
	" */",
	"",
	"/*",
	" *\tFrozen Configuration Table - New devices may be",
	" *\tadded to the end of the tables only!",
	" *\tblock order - rk,rp,rf,tm,tc,hp,ht,hs,0",
	" *\tcharacter order - kl,pc,lp,dc,dh,dp,dj,dn,mem,rk,rf,rp,tm,",
	" *\t\t\thp,ht,hs,sys,0",
	" */",
	"int\t(*bdevsw[])()",
	"{",
	0,
};

char	*strf[]
{
	"\t0",
	"};",
	"",
	"int\t(*cdevsw[])()",
	"{",
	0,
};

char	*strg[]
{
	"\t0",
	"};",
	"",
	"int\t(*ctlsw[])()",
	"{",
	0,
};

char	*strh[]
{
	"\t0",
	"};",
	"",
	"int\t(*linesw[])() {",
"&ttopen,  &ttclose, &ttread,  &ttwrite, &ttyinput,&ttxmtd,  &ttmt,    &ttstty,",
	"\t0",
	"};",
	0,
};

char	*stri[]{
	"int sysparam[]{",
	"\tNPROC,",
	"\tNTEXT,",
	"\tNINODE,",
	"\tNFILE,",
	"\tNBUF,",
	"\tNMOUNT,",
	"\tNCLIST,",
	"\t0",
	"};",
	0
};

struct ord border[NBDEVSW]{
	"rk", 0, 0,
	"rp", 0, 0,
	"rf", 0, 0,
	"tm", 0, 0,
	"tc", 0, 0,
	"hp", 0, 0,
	"ht", 0, 0,
	"hs", 0, 0,
	0
};
struct	ord	corder[NCDEVSW]{
	"console", 0, 0,
	"pc", 0, 0,
	"lp", 0, 0,
	"dc", 0, 0,
	"dh", 0, 0,
	"dp", 0, 0,
	"dj", 0, 0,
	"dn", 0, 0,
	"mem", 0, 0,
	"rk", 0, 0,
	"rf", 0, 0,
	"rp", 0, 0,
	"tm", 0, 0,
	"hp", 0, 0,
	"ht", 0, 0,
	"hs", 0, 0,
	"sys", 0, 0,
	0
};
struct	ord	dorder[]{
	"console", 0, 0,
	"dl", 0, 0,
	"dc", 0, 0,
	"dh", 0, 0,
	0
};
struct	ord	std[]{"null",0,0};
int	rootswap	-2;
int	memflg		-2;

int	rootdev	ROOTDEV;
int	swapdev	SWAPDEV;
int	swplo	4000;
int	nswap	872;
struct ord *bextra &border[NBFROZ];
struct ord *cextra &corder[NCFROZ];
