/*static char *SCCSID = "@(#)harderr.h	6.1 90/11/17";*/
/*      SCCSID = @(#)harderr.h	13.5 90/04/19 */


//
// Input to hard error routine is type in ax, data in the remainder of the
// registers.
//
// Type codes:
//

#define	HEPacket		0	// device error
#define	HESwapdisk		1	// disk change request
#define	HEShare			2	// file sharing violation
#define	HEFCB			3	// FCB problems
#define	HELock			4	// file locking violation
#define	HEBadFS			5	// bad FAT
#define	HENet			6	// network hard error
#define	HEDrvLocked		7	// disk drive locked
#define	HEMessage		8	// send message to hard error daemon
#define	HEFSHMessage		9	// send message to hard error daemon

//  the following value is for the IFS helper FSH_CRITERROR, which passes
//  a message template and the text to substitute into it

#define	HEMessage_Template	-1	// message template, not message #
#define	HEMaxMsgLen		256	// maximum template size
#define	HEMaxSubs		9	// maximum number of substitutions
#define	HEMaxSubsLen		512	// maximum total length of subs

//	Response packet for system service daemon

struct	HE_Packet {
	ushort_t HE_SG;			// screen group of offending process
	ushort_t HE_ProcID;		// process id of offending process
	ushort_t HE_Error;		// true error code of offense
	ushort_t HE_Allowed;		// bit mask of allowed actions
	ushort_t HE_Def;		// bit mask of default action
	ushort_t HE_MsgLen;		// length of message template
	uchar_t  HE_Msg[HEMaxMsgLen];	// message template
	ushort_t HE_cAsciz;		// number of asciiz strings returned
	ushort_t HE_cbBuf;		// number of bytes in following buffer
	uchar_t  HE_buf[HEMaxSubsLen];	// buffer for text strings
};

// return codes from HardError and int 24 hard error handler

#define	HDERR_IGNORE		0
#define	HDERR_RETRY		1
#define	HDERR_ABORT		2
#define	HDERR_FAIL		3
#define HDERR_ACK		4
#define	HDERR_NORESP		0xFF

//	Terminate signal argument

#define	HE_SIGTERM_ARG		1

//	DosError/TaskArea:AutoFail flags

#define	DOSERR_HARDERR_FLAG	0x01
#define	DOSERR_EXCEPTION_FLAG	0x02
#define	DOSERR_INHERIT		0x04
#define DOSERR_EXTENDEDERR      0x80

/*	MVDM HardErr Support
 *
 *	The following structure is used to support VDM harderrs.
 *	When the system get a hard error while doing work for the
 *	VDM we fill in this packet with data.  We then fail
 *	the hard error.  VHE_DEVICE_HEADER_SIZE is the size of
 *	a device driver header without the four new OS/2 seg/sel
 *	fields.  It is hard coded here because the DOS device
 *	driver header used in the V86 kernel doesn't include
 *	the four new words.
 */

#define	VHE_FLAG_POPUP		0x1	// do both int 24 and prot mode popup
#define	VHE_FLAG_ACTIVE		0x2	// int 24 pending

#define VHE_DEVICE_HEADER_SIZE	0x12	// sizeof(struct SYSDEV)

typedef struct vhe_s {
	uchar_t vhe_fbMisc;
	uchar_t vhe_fbInt24;
	uchar_t vhe_fbAllowed;
	uchar_t vhe_bResp;
	uchar_t vhe_bDriveNum;
	ushort_t vhe_usPacketErr;
	ushort_t vhe_usFailErr;
	uchar_t vhe_abDeviceHeader[VHE_DEVICE_HEADER_SIZE];
} VHE;

typedef VHE *PVHE;

/*	Int 24 flags
 *
 *	When the int 24 is called for the 3xBox ah has the following
 *	meaning:
 *
 *		7   6	5   4	3   2	1   0
 *		|   |	|   |	|   |	|   |
 *		|   |	|   |	|   |	|  Read or Write
 *		|   |	|   |	|   |	|    0 = read 1 = write
 *		|   |	|   |	|  Location
 *		|   |	|   |	|   00 MS-Dos Area
 *		|   |	|   |	|   01 FAT
 *		|   |	|   |	|   10 Directory
 *		|   |	|   |	|   11 Data Area
 *		|   |  Allowed action
 *		|   |  0 = not allowed 1 = allowed
 *		|   |	|   |	Fail
 *		|   |	|   Retry
 *		|   |	Ignore
 *		|   Not defined
 *		0 Error occured on a disk drive (AL has drive number)
 *		1 FAT is bad or error on character device
 *
 */

#define	HE_CHARDEV		0x80
#define	HE_ALLOWBITS		0x38
#define	HE_ALLOW_FAIL		0x08
#define	HE_ALLOW_RETRY		0x10
#define	HE_ALLOW_IGNORE 	0x20
#define	HE_LOC_DOS		0x00
#define	HE_LOC_FAT		0x02
#define	HE_LOC_DIR		0x04
#define	HE_LOC_DATA		0x06
#define	HE_WRITE_ERR		0x01
#define	HE_READ_ERR		0x00
