**	sysmon.i
**
**	$Filename: sysmon.i $
**	$Revision: 0.7 $
**	$Date: 1996/04/13 14:31:55 $
**
*******************************************************************************
**	definition of sysmon.library base and internal structures (version 0.7)
*******************************************************************************
**
**	Copyright (c) 1995 by Etienne Vogt.
**

	IFND	SYSMON_I
SYSMON_I	SET	1

	IFND	EXEC_TYPES_I
	INCLUDE	"exec/types.i"
	ENDC	; EXEC_TYPES_I

	IFND	EXEC_LIBRARIES_I
	INCLUDE	"exec/libraries.i"
	ENDC	; EXEC_LIBRARIES_I

	IFND	DEVICES_TIMER_I
	INCLUDE	"devices/timer.i"
	ENDC	; DEVICES_TIMER_I

	IFND	DOS_DATETIME_I
	INCLUDE	"dos/datetime.i"
	ENDC	; DOS_DATETIME_I

* library data structure
* All field in the SysmonBase structure are PRIVATE !!!
* Don't access these directly as they will change in future versions.
* You have been warned !!!

HASHSIZE	EQU	32
HASHMASK	EQU	$f8

 STRUCTURE SysmonBase,LIB_SIZE			; Standard lib node
	UBYTE	sb_Flags			; Some flags here
	UBYTE	sb_pad				; We are now longword aligned
	APTR	sb_ExecBase			; Pointer to exec
	APTR	sb_UtilityBase			; Pointer to utility
	BPTR	sb_SegList			; SegList BCPL pointer
	APTR	sb_CurrTaskInfo			; Current TaskInfo Structure
	APTR	sb_Switch			; Original Switch() entry point
	APTR	sb_Dispatch			; Original Dispatch() entry point
	APTR	sb_AddTask			; Original AddTask() entry point
	APTR	sb_RemTask			; Original RemTask() entry point
	APTR	sb_TaskExit			; Original ExecBase->TaskExitCode
	STRUCT	sb_TimeReq,IOTV_SIZE		; Time Request
	STRUCT	sb_TempTime,EV_SIZE		; Temporary EClock Time
	STRUCT	sb_TaskFrozen,LH_SIZE		; Frozen task list
	UWORD	sb_Reserved0			; For longword alignment
	STRUCT	sb_TaskInfoHash,4*HASHSIZE	; TaskInfo hash table
	APTR	sb_FindTask			; Original FindTask() entry point
	APTR	sb_ServerEntry			; Server process entry point
	APTR	sb_ServerName			; Server process name
	APTR	sb_SyslogFile			; SysLog file name
	APTR	sb_SyslogWindow			; Syslog Window Name
	UBYTE	sb_FilePri			; File logging priority
	UBYTE	sb_WindowPri			; Window logging priority
	UBYTE	sb_ConsolePri			; Console logging priority
	UBYTE	sb_NumLogBuffers		; Number of allocated Buffers
	APTR	sb_Buffers			; Pointer to allocated buffers
	APTR	sb_DOSBase			; Pointer to dos
	APTR	sb_DateTime			; struct DateTime used by syslog
	ULONG	sb_StampPeriod			; Period for syslog file stamp
	BPTR	sb_LogWindowHandle		; LogWindow file handle
	APTR	sb_IntuitionBase		; Pointer to intuition
	ULONG	sb_LastGuru			; Guru Meditation code after crash
	APTR	sb_SyslogPort			; Pointer to Syslog MsgPort
 LABEL   SysmonBase_SIZEOF

* The TaskInfo structure contains the CPU usage information in EClock ticks.
* The link pointers are private and should not be used. Use the smNextTaskInfo()
* function to traverse the list.
* This structure may be extended later with new fields.

 STRUCTURE TaskInfo,0
	APTR	ti_Link				; private pointer to next TaskInfo
	APTR	ti_Pred				; private pointer to previous TaskInfo
	APTR	ti_Task				; pointer to Task Control Block
	ULONG	ti_DispCount			; Task Dispatch counter
	STRUCT	ti_StartTime,EV_SIZE		; Starting EClock Time
	STRUCT	ti_LaunchTime,EV_SIZE		; Last Launch Time
	STRUCT	ti_CPUTime,EV_SIZE		; Cumulated CPU Time
 LABEL	TaskInfo_SIZEOF
	
* This is the private structure used by smVSysLog() to communicate with the
* Sysmon.server process.

SM_MAXLOGCHARS	EQU	256			; Max bytes in SysLog message

 STRUCTURE SysLogMsg,MN_SIZE			; Message structure
	ULONG	slm_Priority			; SysLog priority and flags
	STRUCT	slm_Text,SM_MAXLOGCHARS		; Syslog Message body
 LABEL	SysLogMsg_SIZEOF

SYSMONNAME	MACRO
	DC.B	'sysmon.library',0
	ENDM

SERVERNAME	MACRO
	DC.B	'Sysmon.server',0
	ENDM

* sb_Flags bits

	BITDEF	SBF,FPU,0			; System has a FPU
	BITDEF	SBF,IDLELED,1			; Dim power LED when CPU is idle

* Alert definitions
* These are the Guru codes that sysmon.library can spit out in a panic
* condition.

AN_Sysmon	EQU	$40000000	; SubSystem ID
AN_smNoTaskInfo	EQU	$C0000001	; No TaskInfo at Dispatch() time
AN_smNoTIMem	EQU	$40010002	; No mem for TaskInfo at startup
AN_smSysLogBuf	EQU	$40010003	; No memory for syslog buffers
AN_BadSysLogMsg	EQU	$40000004	; Bad SysLogMsg received by server
AO_Sysmon	EQU	$00008040	; Alert object

* New Task States Definitions
* TS_STOP is not a real state. It is used by ShowSys to identify tasks that
* are stuck in a Wait(0) call, such as crashed tasks that have been suspended.

TS_FROZENW	EQU	$80		; Frozen task that was in WAIT state
TS_STOP		EQU	TS_FROZENW	; Stopped task (Wait(0L))
TS_FROZEN	EQU	$81		; Frozen task

* SysLog priorities and flags
* The priorities are similar to that used on UNIX systems. This means that
* the values use the UNIX ordering that is reversed from the Amiga one.
* The flags are Amiga and sysmon specifics.

LOG_EMERG	EQU	0		; Panic condition (Guru time)
LOG_ALERT	EQU	1		; Very serious problem
LOG_CRIT	EQU	2		; Critical error
LOG_ERR		EQU	3		; General error condition
LOG_WARN	EQU	4		; Warning condition
LOG_NOTICE	EQU	5		; Noticeable event
LOG_INFO	EQU	6		; General informational event
LOG_DEBUG	EQU	7		; Debugging information
LOG_PRI		EQU	$7		; Mask for priority field

LOG_INUSE	EQU	$80000000	; Message is in use (private !)
LOG_NOHEAD	EQU	$40000000	; Don't prepend header
LOG_NOWIN	EQU	$20000000	; Don't output to window
LOG_NOFILE	EQU	$10000000	; Don't output to file

LOGB_INUSE	EQU	31		; Bit numbers for flags
LOGB_NOHEAD	EQU	30
LOGB_NOWIN	EQU	29
LOGB_NOFILE	EQU	28

* Flags definitions for smHalt()

	BITDEF	HALT,REBOOT,0		; Reboot immediately
	BITDEF	HALT,REKICK,1		; Reload kickstart on MMU-Kicked systems.

* Function LVOs	*

	INCLUDE "exec/funcdef.i"

	FUNCDEF	smGetTaskInfo
	FUNCDEF	smFreeze
	FUNCDEF	smUnFreeze
	FUNCDEF	smSleep
	FUNCDEF	smVKPrintf
	FUNCDEF	smVSPrintf
	FUNCDEF	smVSysLog
	FUNCDEF	smFindTaskInfo
	FUNCDEF	smNextTaskInfo
	FUNCDEF	smHalt

   ENDC  ;SYSMON_I

