#ifndef _KACRASH_H_
#define _KACRASH_H_

#define KAC_MAXARGS 64
#define KAC_MAXCALLS 10

/* THE SIZE OF THIS STRUCTURE IS WIRED INTO MINIKERNEL locore.s */

struct _crashinfo {
  int type;
#define CI_NULL      0 /* nothing here yet */
#define CI_EXIT      1 /* user called exit() */
#define CI_ARITHTRAP 2 /* arithmetic trap/fault */
#define CI_ILLINST   3 /* illegal/reserved instruction */
#define CI_TRACE     4 /* trace trap */
#define CI_MEMFAULT  5 /* memory fault */
  int pc; /* isn't compatibility wonderful! */
  int psl;
  union {
    int subtype; /* CI_ARITHTRAP, CI_ILLINST, or exit code for CI_EXIT */
/* CI_ARITHTRAP: arithmetic traps */
#define CI_AT_IOVERF    1 /* integer overflow */
#define CI_AT_IDIVZ     2 /* integer divide-by-zero */
#define CI_AT_FOVERF    3 /* floating overflow */
#define CI_AT_FDIVZ     4 /* floating divide-by-zero */
#define CI_AT_FUNDERF   5 /* floating underflow */
#define CI_AT_DOVERF    6 /* decimal overflow */
#define CI_AT_SUBRANGE  7 /* subscript range */
/* CI_ARITHTRAP: arithmetic faults */
#define CI_AF_FOVERF    8 /* floating overflow */
#define CI_AF_FDIVZ     9 /* floating divide-by-zero */
#define CI_AF_FUNDERF  10 /* floating underflow */
/* CI_ILLINST: illegal instructions */
#define CI_II_RADRMOD  0 /* reserved addressing mode */
#define CI_II_PRIVINST 1 /* privileged instruction */
#define CI_II_RESOPRND 2 /* reserved operand */
#define CI_II_BPT      3 /* breakpoint instruction */
    /* nothing extra for CI_TRACE */
    struct {		/* CI_MEMFAULT */
      int bits; /* bits describing the fault: */
#define CI_MF_TYPE   1 /* type of violation: */
#define CI_MF_LENGTH 1 /*   length           */
#define CI_MF_PROT   0 /*   protection       */
#define CI_MF_WHAT   2 /* what faulted:      */
#define CI_MF_PTE    2 /*   pte              */
#define CI_MF_PAGE   0 /*   page             */
#define CI_MF_ACCESS 4 /* attempted access:  */
#define CI_MF_WRITE  4 /*   for write        */
#define CI_MF_READ   0 /*   for read         */
#define CI_MF_WHERE  8 /* what sort of memory: */
#define CI_MF_QBUS   8 /*   Q-bus space        */
#define CI_MF_MEM    0 /*   normal virtual     */
      int vaddr; /* some address in the faulting page */
      } memfault;
    } u;
  unsigned long int registers[16];
  struct _crashframe {
    int pc;
    unsigned char nargs;
    unsigned char flags;
#define CI_CF_VALID   0x01
#define CI_CF_ARGLOST 0x02
    unsigned char argindex;
    } callstack[KAC_MAXCALLS];
  int callargs[KAC_MAXARGS];
  } ;

typedef struct _crashinfo CRASHINFO;
typedef struct _crashframe CRASHFRAME;

#endif
