/*static char *SCCSID = "@(#)dynxport.h	6.1 90/11/17";*/
/***	SCCSID = @(#)dynxport.h 13.7 90/01/27
 *
 *	Definitions for 32 bit exported structures for DosDynamicTrace.
 *
 *
 *	IBM/Microsoft Confidential
 *
 *	Copyright (c) IBM Corporation 1987, 1989
 *	Copyright (c) Microsoft Corporation 1987, 1989
 *
 *	All Rights Reserved
 */

/* ASM

;***	DYNTrapReset - Reset Tracepoint after a single-step
;
;	DYNTrapReset is invoked just after each protect-mode
;	exception to insure that the tracepoint remains in memory.
;
;	The TF bit must be restored in the eflags image on the
;	stack frame if we took a fault while performing the
;	single-step.  This prevents spurious single-steps
;	when we take a page fault while performing a DynTrc single-step.
;
;	Beware:	 Be sure to have _pbDynResetPoint restored to
;	point at dynNullResetPoint BEFORE restoring the INT3.
;	This way, if the page under _pbDynResetPoint is not present
;	(that would be a bug, by the way) we will avoid taking
;	many nested page faults - eventually causing a stack
;	overrun.  Instead, we would just get a normal Panic...
;
;	ENTRY	(DS) = Flat
;		reg = scratch register
;		eflags = address of the eflags image in the iret frame.
;
;	EXIT	Dynamic Trace tracpoint reset (if any)
;		EFlags NOT MODIFIED!
;		(reg) = value of _pbDynResetPoint before Reset.  If (reg)
;		is not equal to (OFFSET FLAT:dynNullResetPoint), then
;		the DynamicTrace single step just occurred (or failed)
;
;	USES	EAX

DYNTrapReset	macro	reg,peflgas
	local	dtrx

	.errb	<reg>
	.errb	<peflags>
if	RAS
	mov	reg,OFFSET FLAT:_DYNNullResetPoint
	xchg	reg,ds:[_pbDYNResetPoint]	;; get/disarm reset point

;;	RING 3 PREEMPTION ENABLED NOW

	mov	BYTE PTR [reg],MI_INT3		;; set the tracepoint again
	cmp	reg,OFFSET FLAT:_DYNNullResetPoint	;; was tracepoint set?
	je	short dtrx			;; no - don't touch TF bit.

;;	The following code is not particularly time-critical.  However,
;;	peflags may optionally use ESP in the address, so we cannot
;;	afford to push or pop here, lest we mess up the addressing.
;;	We use DWORD PTR peflgas as a scratch save area, so that we can
;;	maintain the state of [_pbDYNResetPoint] before the reset.

	xchg	reg,DWORD PTR [peflgas]			;; get eflags
	and	reg,NOT F_TRACE				;; turn off TF bit
	and	DWORD PTR [_DYNSavedUserFlags],F_TRACE	;; mask TF bit
	or	reg,DWORD PTR [_DYNSavedUserFlags]	;; restore TF bit
	xchg	reg,DWORD PTR [peflgas]			;; restore eflags

;;	(reg) = Value of _pbDynResetPoint before DYNTrapReset.

dtrx:
endif	; RAS
endm	; end DYNTrapReset

*/

//	External interfaces
//	Loader API

// XLATOFF
extern	ulong_t DYNDynamicTrace (ulong_t lCmd, char *preqUser, char *presUser);
extern	ulong_t DYNDetach	(VMHOB hmte);
extern	ulong_t DYNAttachCheck	(VMHOB hmte);
extern	ulong_t DYNAttach	();
extern	ulong_t DYNAttachError	();
extern	ulong_t DYNReAttachRange(VMHOB hmte,		// mte owning range
				ulong_t lAddrMin,	// inclusive bound
				ulong_t lAddrMax);	// inclusive bound

//	Memory Manager

extern	ulong_t DYNPurgeRange	(VMHOB hmte,		// mte owning range
				ulong_t lAddrMin,	// inclusive bound
				ulong_t cb,		// size to purge
				char	*pAlias);	// Alias to lAddrMin

//	fDYNActive is nonzero only if Dynamic Trace is "active".  Other
//	components should avoid calling the (swappable) DynTrc functions
//	if fDYNActive is zero.  fDYNActive is read-only.

extern	void	*fDYNActive;

// XLATON

