/*	Convergent Technologies - System V - May 1983	*/
/*	"@(#)erec.h	1.4"	*/

#ifndef erec_h
#define erec_h

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

/*
 * Every error record has a header as follows.
 */

struct errhdr {
	short	e_type;		/* record type */
	short	e_len;		/* bytes in record (with header) */
	time_t	e_time;		/* time of day */
};

/*
 * Error record types
 */

#define E_GOTS	010		/* Start for UNIX/TS */
#define E_GORT	011		/* Start for UNIX/RT */
#define E_STOP	012		/* Stop */
#define E_TCHG	013		/* Time change */
#define E_CCHG	014		/* Configuration change */
#define E_BLK	020		/* Block device error */
#define E_STRAY	030		/* Stray interrupt */
#define E_PRTY	031		/* Memory parity */
#define E_BUSFLT 032		/* Bus fault */
#define E_CONS	040		/* Console string */
#define E_CONR	041		/* Console record */
#define E_CONO	042		/* Console string overflow */

/*
 * Error logging startup record. One of these is
 * sent to the logging daemon when logging is
 * first activated.
 */


struct estart {
	short	e_cpu;		/* cpu type */
	struct utsname e_name;	/* system names */
	short	e_mmr3;		/* boot reason from cdt */
	long	e_syssize;	/* system memory size */
	int	e_fhole;	/* 64k chunks of memory omitted */
	short	e_bconf;	/* block device configuration */
	char	e_panic;	/* if rebooted from panic, what was it */
};

/*
 * Error logging termination record that is sent to the daemon
 * when it stops error logging.
 */

#define eend errhdr

/*
 * A time change record is sent to the daemon whenever
 * the system's time of day is changed.
 */

struct etimchg {
	time_t	e_ntime;	/* new time */
};

/*
 * A configuration change message is sent to
 * the error logging daemon whenever a block device driver
 * is attached or detached (MERT only).
 */

struct econfchg {
	char	e_trudev;	/* "true" major device number */
	char	e_cflag;	/* driver attached or detached */
};

#define E_ATCH	1
#define E_DTCH	0


/*
 * Template for the error record that is logged by block devices.
 */

struct eblock {
	dev_t	e_dev;		/* "true" major + minor dev number */
	physadr	e_regloc;	/* controller address */
	short	e_bacty;	/* other block I/O activity */
	struct iostat e_stats;	/* unit I/O statistics */
	short	e_bflags;	/* read/write, error, etc */
	short	e_trkoff;	/* logical dev start trk */
	daddr_t	e_bnum;		/* logical block number */
	ushort e_bytes;		/* number of bytes to transfer */
	paddr_t	e_memadd;	/* buffer memory address */
	ushort e_rtry;		/* number of retries */
	short	e_nreg;		/* number of device registers */
	short	e_trks;		/* # of heads */
	short	e_secs;		/* # of physical sectors per track */
#ifdef vax
	struct	mba_regs e_mba;	/* mass bus adaptor registers */
#endif
};

/*
 * Flags (selected subset of flags in buffer header)
 */

#define E_WRITE	0
#define E_READ	1
#define E_NOIO	02
#define E_PHYS	04
#define E_MAP	010
#define E_ERROR	020

/*
 * Template for the stray interrupt record that is logged
 * every time an unexpected interrupt occurs.
 */

struct estray {
	physadr	e_saddr;	/* stray loc or device addr */
	short	e_sbacty;	/* active block devices */
};

/*
 * Memory parity error record that is logged whenever one
 * of those things occurs.
 */

struct eparity {
	ushort	e_gsr;		/* general status register */
	ushort	e_pte;		/* pte for vad in bsr */
	uint	e_bsr;		/* bsr */
};
struct ememory {
	int	e_sbier;
	int	e_memcad;
};

/* bus fault error record: NOTE this is almost always accompianed by
 * a panic ==> we are assuming errdead pulls the info out of a crash dump
 */
struct ebusflt {
	short	e_type;		/* kind of fault */
	ushort	e_gsr;
	uint	e_bsr;		/* combined bsr0 & nsr1 */
	ushort	e_pte;		/* page frame of fault */
	ushort	e_pid;		/* pid */
	uint	e_pc;		/* PC at time */
	uint	e_rps;		/* RPS at time */
	uint	e_regs[16];	/* all the registers */
};
#endif
