;       SCCSID = @(#)debequ.inc 6.2 91/06/01
;***    DEBEQU.INC
;
;       This file contains the debugger's general/global equates.
;
;       SCCSID = @(#)debequ.inc 6.2 91/06/01
;

FALSE                   equ     0
TRUE                    equ     -1

CTRLC                   equ     3
CTRLQ                   equ     17
CTRLS                   equ     19
BEL                     equ     7
BS                      equ     8
TABCHR                  equ     9
CR                      equ     13
LF                      equ     10
ESCCHR                  equ     27
DEL                     equ     127

KDP_BREAK               equ     1fh     ; Packet Break character
KDP_START               equ     1dh     ; Packet Start character
KDP_END                 equ     1eh     ; Packet End character

BUFLEN                  equ     80      ; Length of "list" buffer
;136682 CMDLINELEN              equ     80      ; Maximum length of command line buffer
CMDLINELEN              equ     160     ; Maximum length of command line buffer
OPBUFLEN                equ     200     ; Length of unassemble line buffer

PROMPT                  equ     ">"     ; real mode prompt
PPROMPT                 equ     "#"     ; protected mode prompt
VPROMPT                 equ     "-"     ; v86 mode prompt

FWORDPTR                equ     fword ptr

; Start of change DGE
TSBUFF_LEN              equ     4096    ; Length of time stamp buffer
TSBUFF_ENTRY_SIZE       equ     8       ; Number of bytes in each time stamp
TSBUFF_BUFF_SIZE        equ     TSBUFF_LEN*TSBUFF_ENTRY_SIZE
; End of change DGE

; Machine instructions

LONG_JMP_OP             equ     0eah
PUSHF_OP                equ     9ch
INT3_OP                 equ     0cch
LOADALL_OP1             equ     0fh
LOADALL_OP2             equ     05h
OPER_OVERRIDE           equ     66h
ADDR_OVERRIDE           equ     67h

; Expression type codes

EXPR_TYPE_SEGSEL        equ     0001b   ; segment or selector class
EXPR_TYPE_LINPHY        equ     0010b   ; linear or physical class
EXPR_TYPE_DEF           equ     0100b   ; default address type

EXPR_TYPE_DATA          equ     0000b   ; data type
EXPR_TYPE_SEG           equ     0001b   ; address type segment:offset
EXPR_TYPE_SEL           equ     1001b   ; address type selector:offset
EXPR_TYPE_LIN           equ     0010b   ; address type linear
EXPR_TYPE_PHY           equ     1010b   ; address type physical

; Expression size codes

EXPR_SIZE_BYTE          equ     01h     ; byte size (1 byte)
EXPR_SIZE_WORD          equ     02h     ; word size (2 bytes)
EXPR_SIZE_DWORD         equ     04h     ; dword size (4 bytes)

; Word size versions

EXPR_TYPE_DATA_W        equ     EXPR_TYPE_DATA
EXPR_TYPE_SEG_W         equ     EXPR_TYPE_SEG
EXPR_TYPE_SEL_W         equ     EXPR_TYPE_SEL
EXPR_TYPE_LIN_W         equ     EXPR_TYPE_LIN
EXPR_TYPE_PHY_W         equ     EXPR_TYPE_PHY

EXPR_SIZE_BYTE_W        equ     EXPR_SIZE_BYTE SHL 8
EXPR_SIZE_WORD_W        equ     EXPR_SIZE_WORD SHL 8
EXPR_SIZE_DWORD_W       equ     EXPR_SIZE_DWORD SHL 8

; fmtaddr() flags

FMT_ADDR_32ENV          equ     0001            ; format as 32 bit offset
FMT_ADDR_SEG            equ     0002            ; format segment/selector

STACK_FENCE_VALUE       equ     05c4eh

; Flag bit definitions

F_AC                    equ     00040000H
F_VM                    equ     00020000H
F_RF                    equ     00010000H
F_NT                    equ     00004000H

F_OVERFLOW              equ     0000100000000000B
F_DIRECTION             equ     0000010000000000B
F_INTERRUPT             equ     0000001000000000B
F_TRACE                 equ     0000000100000000B
F_SIGN                  equ     0000000010000000B
F_ZERO                  equ     0000000001000000B
F_AUX                   equ     0000000000010000B
F_PARITY                equ     0000000000000100B
F_CARRY                 equ     0000000000000001B

; Some codes for TrapNumber

KDP_PAGEIN_EVENT        equ     106
KDP_TASK_END_EVENT      equ     105
KDP_TASK_CREATE_EVENT   equ     104
KDP_UNLINK_EVENT        equ     103
KDP_LINK_EVENT          equ     102
KDP_ASYNC_TRAP          equ     101
KDP_NOEVENT             equ     -1

SINGLE_STEP_TRAP        equ     1
NMI_TRAP                equ     2
BREAK_POINT_TRAP        equ     3
INVALID_OPCODE_TRAP     equ     6

; Maximum path length used by debugger.  The kernel may use longer paths,
; but we use this to keep everything in a byte.

DBG_MAX_PATH_LEN        equ     255

; Cache Size Definition (cache used to speed up memory operations)

MEMCACHESIZE            equ     512

; CVK Cache Size Definition  - DHE

CVK_MEMCACHE_SIZE       equ     MEMCACHESIZE

; Misc. error code and trap number definations

NO_ERROR                equ     0               ; no error code
NO_TRAPNUM              equ     0ffffh          ; no trap number

; Codes to indicate what command was executed to continue debugger

TRACECMD                equ     0
PTRACECMD               equ     1
GOCMD                   equ     2

; Debugger call out routine codes

DEB_CALLOUT_INIT_COM            equ     0
DEB_CALLOUT_OUTPUT_CHAR         equ     1
DEB_CALLOUT_SCAN_CHAR           equ     2
DEB_CALLOUT_ENABLE_NMI          equ     3
DEB_CALLOUT_ENABLE_A20          equ     4
DEB_CALLOUT_RESTORE_A20         equ     5
DEB_CALLOUT_EXTCMD              equ     6
DEB_CALLOUT_DEBENTRY            equ     7
DEB_CALLOUT_DEBEXIT             equ     8
DEB_CALLOUT_DEBINIT             equ     9
DEB_CALLOUT_DEBEND              equ     10
DEB_CALLOUT_GETCURRTASK         equ     11
DEB_CALLOUT_GETDESCINFO         equ     12
DEB_CALLOUT_BREAK               equ     13
DEB_CALLOUT_BEEP                equ     14
DEB_CALLOUT_DRALLOC             equ     15
DEB_CALLOUT_DRFREE              equ     16
DEB_CALLOUT_GETPDE              equ     17
DEB_CALLOUT_GETFRAME            equ     18

DEB_CALLOUT_MAX                 equ     18

; Memory get/put error codes

DEBERR_INVALID_SELECTOR         equ     1
DEBERR_SELECTOR_NOT_PRESENT     equ     2
DEBERR_OFFSET_PAST_LIMIT        equ     3
DEBERR_INVALID_TASK_NUMBER      equ     4
DEBERR_INVALID_ADDR_TYPE        equ     5
DEBERR_PAGE_TABLE_NOT_PRESENT   equ     6
DEBERR_PAGE_NOT_PRESENT         equ     7
DEBERR_INVALID_ADDRESS          equ     8
DEBERR_CODE_MAX                 equ     8

IFNDEF INCL_MI

; Word and double word structures

w_s             struc
lobyte          db      ?
hibyte          db      ?
w_s             ends

LowByte         equ     lobyte
HighByte        equ     hibyte

dw_s            struc
loword          dw      ?
hiword          dw      ?
dw_s            ends

LowWord         equ     loword
HighWord        equ     hiword

FarPtr32        struc
Offst32         dd      ?
Segmt32         dw      ?
Pad32           dw      ?
FarPtr32        ends

ENDIF ; INCL_MI

FarPtr16        struc
Offst16         dw      ?
Segmt16         dw      ?
FarPtr16        ends

; Expression value structures, both ExprS and AddrS are unions
; of each other. ExprS is used by the Expr routine. AddrS is used
; by the routines that take addresses as parameters.

ExprS   struc
        ExprData        dd      0
        ExprSeg         dw      0
        ExprType        db      0
        ExprSize        db      0
        ExprTask        dw      0
ExprS   ends

ExprTypeSize    equ     word ptr ExprType

AddrS   struc
        AddrOff         dd      0
        AddrSeg         dw      0
        AddrType        db      0
        AddrSize        db      0
        AddrTask        dw      0
AddrS   ends

AddrTypeSize    equ     word ptr AddrType

;
; Size of bad tracepoint table
;
MAX_BAD_TRACE   equ     3

BAD_TRACE_SIZE equ size AddrS * MAX_BAD_TRACE * 2

;
; Size/# elements in TS stack trace table
;
MAX_TRACE_CALLS         equ     100
TRACE_CALLS_SIZE        equ     size AddrS * MAX_TRACE_CALLS

;
; User register save structure
;


RegSA_frame     struc
        AXsav           dw      0
                        dw      0
        BXsav           dw      0
                        dw      0
        CXsav           dw      0
                        dw      0
        DXsav           dw      0
                        dw      0
        SPsav           dw      0
                        dw      0
        BPsav           dw      0
                        dw      0
        SIsav           dw      0
                        dw      0
        DIsav           dw      0
                        dw      0
        ESsav           dw      0
        SSsav           dw      0
        DSsav           dw      0
        FSsav           dw      0
        GSsav           dw      0
        CSIPsav         db      size AddrS dup(0)
        Fsav            dw      0
                        dw      0
        MSWsav          dw      0               ; MSW -> CR0 low
                        dw      0               ; High of CR0
        ?GDTsav         dq      0
        ?IDTsav         dq      0
        LDTsav          dw      0
        TRsav           dw      0
        CR2sav          dd      0
        CR3sav          dd      0
        CR4sav          dd      0               ; 148688
        DR0sav          dd      0
        DR1sav          dd      0
        DR2sav          dd      0
        DR3sav          dd      0
        DR6sav          dd      0
        DR7sav          dd      0
        DR7sav2         dd      0
        TR6sav          dd      0
        TR7sav          dd      0
RegSA_frame     ends

GDTsav  equ     (FWORDPTR ?GDTsav)
IDTsav  equ     (FWORDPTR ?IDTsav)

CSsav   equ     (CSIPsav.AddrSeg)
IPsav   equ     (CSIPsav.AddrOff.LowWord)
EIPsav  equ     (dword ptr CSIPsav.AddrOff)
CR0sav  equ     (dword ptr MSWsav)
EAXsav  equ     (dword ptr AXsav)
EBXsav  equ     (dword ptr BXsav)
ECXsav  equ     (dword ptr CXsav)
EDXsav  equ     (dword ptr DXsav)
ESPsav  equ     (dword ptr SPsav)
EBPsav  equ     (dword ptr BPsav)
ESIsav  equ     (dword ptr SIsav)
EDIsav  equ     (dword ptr DIsav)
EFsav   equ     (dword ptr Fsav)

;
; Sticky break point structure
;

StickyBP_struc  struc
        BrkFlag         db      0                 ; Break flags
        BrkDRFlag       db      0                 ; Debug register flags
        BrkAddr         db      size AddrS dup(0) ; Breakpoint address
        BrkCntr         dw      0                 ; Repetition down counter
        BrkReps         dw      0                 ; Repetition count
        BrkInst         db      0                 ; Save instruction
        BrkCmd          db      CMDLINELEN dup(0) ; Breakpoint command buffer
StickyBP_struc  ends

STICKY_BP_MAX   equ     10                      ; Number of sticky break points
STICKY_BP_LEN   equ     size StickyBP_struc * STICKY_BP_MAX

BP_SET          equ     01h                     ; Set if bp is set
BP_ENABLED      equ     02h                     ; Set if bp is enabled
BP_INMEM        equ     04h                     ; Set if set in user memory
BP_TMP          equ     08h                     ; Set if tmp on sticky bp
BP_BADADDR      equ     10h                     ; Set if bad address
; Start of change DGE
BP_TIMESTAMP    equ     20h                     ; Set if time stamp bp
; End of change DGE

DRFlag          record  DR_ALLOC:1, DR_SET:1, DR_NUM:2, DR_LEN:2, DR_TYPE:2

DR_LEN_1        equ     00000000b               ; one-byte length
DR_LEN_2        equ     00000001b               ; word length
DR_LEN_4        equ     00000011b               ; dword length

DR_TYPE_EXECUTE equ     00000000b               ; break on instr execute only
DR_TYPE_WRITE   equ     00000001b               ; break on data writes only
DR_TYPE_IO      equ     00000010b               ; break on i/o read/writes      ; 148688
DR_TYPE_RW      equ     00000011b               ; break on read/writes only

;
; Temporary break point structure
;

BPtbl_struc     struc
        BpFlag  db      0                       ; if set flag = BP_SET if set
        BpAddr  db      size AddrS dup(0)       ; breakpoint address
        BpInst  db      0                       ; saved instruction
BPtbl_struc     ends

BPMAX           equ     10                      ; maximum number of breakpoints
BPLEN           equ     size BPtbl_struc * BPMAX; length of breakpoint table

;
; Tasking code definitions
;

TASK_CHANGE_TASKNUM     equ     1       ; used as fn# to call Debug_Task
TASK_DISABLE_BPS        equ     -1      ; means "disable BPs" to ChangeBPTaskNum

;
; Trap table defination
;

TrapTblS        struc
        TrapTblMsg      dw      0       ; address of message to print, 0 if none
        TrapTblEntry    dw      0       ; address of 16 bit debug entry routine
        TrapTblEntry32  dw      0       ; address of 32 bit debug entry routine
        TrapTblFlag     dw      0       ; trap table flags
        TrapTblPMsave   dq      0       ; protected mode IDT gate save area
        TrapTblRMsave   dd      0       ; real mode IDT vector save area
TrapTblS        ends

; TrapTblFlag, Set/RestIdtEntry definitions

TRAP_ERRCD              equ     0001h   ; error code on stack
TRAP_PM_USED            equ     0002h   ; prot mode int vector used
TRAP_RM_USED            equ     0004h   ; real mode int vector used
TRAP_PM_HARD            equ     0008h   ; PM trap is always caught
TRAP_32_USED            equ     0010h   ; 32 bit int vector used
TRAP_BEEP               equ     0020h   ; beep and loop if trap hit
TRAP_V86_USED           equ     0040h   ; V86 trap is always caught
TRAP_FATAL              equ     0080h   ; process fatal traps are caught
TRAP_FATAL_DISABLE      equ     0100h   ; trap_fatal temporary disabled
TRAP_PM_TEMP            equ     0200h   ; debugger temporarily grabs it
TRAP_RM_TEMP            equ     0400h   ; debugger temporarily grabs it
TRAP_PM_FORCE           equ     0800h   ; override the already set check
TRAP_RM_FORCE           equ     1000h   ; override the already set check

NUMBER_TRAPS            equ     15      ; number of interrupts trap in table
NUMBER_RM_TRAPS         equ     7       ; number of real interrupts


; CmdTable_s structure for ExecSubr

CmdTable_s struc
        cmd_char        db      ?       ; command character
        cmd_proc        dw      ?       ; procedure address
CmdTable_s ends

; JWE start
; Registered pagein table

PageinS struc
        pagein_module   dw      ?       ; MTE handle of module containing page
        pagein_filler   dw      ?
        pagein_page     dd      ?       ; Address of page
PageinS ends
PAGEINMAX       equ     256
PAGEINLEN       equ     size PageinS * PAGEINMAX
; JWE end

