
/*
 *	sysmon.h
 *
 *	QNX 4
 *
 *	(C) Copyright 1991 by Robert Krten, all rights reserved.
 *
 *	This module contains the system monitor manifest constants, etc.
 *
 *	1991 09 20	R. Krten		created
 *	1992 04 18	R. Krten		added "SMstatus"
 *	1996 08 17	R. Krten		added "SMinterrupts"
*/

/*
 *	Common includes
*/

#ifndef SYSMON_H
#define SYSMON_H

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>

#include <sys/dev.h>
#include <sys/qnxterm.h>
#include <sys/kernel.h>
#include <sys/psinfo.h>
#include <sys/osinfo.h>
#include <sys/times.h>
#include <sys/debug.h>
#include <sys/seginfo.h>

#define	UInt			unsigned int
#define	UChar			unsigned char

#include "proto.h"

/*
 *	Structures
*/

/* RGH */
#define NumberOfPriorities  31
#define PrioTotalsT             struct prioTotalsT
#define PrioTotalsS             (sizeof (PrioTotalsT))
PrioTotalsT
{
  int    cpuprio_totals[NumberOfPriorities];
  float  memprio_totals[NumberOfPriorities];
};

#define	StatusT			struct statusT
#define	StatusS			(sizeof (StatusT))
StatusT
{
	pid_t	pid;		/* process ID */
	char	prio;		/* priority */
	long	codeK;		/* total code memory */
	long	dataK;		/* total data memory */
	char	name [17];	/* process name */
	int		state;		/* process state */
	clock_t	delta;		/* delta CPU */
	clock_t	total;		/* total CPU */
	char	pass;		/* which pass this was last used in */
	StatusT	*next;		/* ptr to next pid of same hash key */
};

#define	TopcpuT			struct topcpuT
#define	TopcpuS			(sizeof (TopcpuT))
TopcpuT
{
	pid_t	pid;		/* process ID */
	char	prio;		/* priority (for histogram mode) */
	char	name [17];	/* process name */
	clock_t	delta;		/* delta CPU */
	clock_t	total;		/* total CPU */
	char	pass;		/* which pass this was last used in */
	TopcpuT	*next;		/* ptr to next pid of same hash key */
	int     percentage;     /* RGH calculated percentage of cpu */
};

#define	TopmemT			struct TopmemT
#define	TopmemS			(sizeof (TopmemT))
TopmemT
{
	pid_t	pid;		/* process ID */
	char	prio;		/* priority */
	char	name [17];	/* process name */
	long	dataK;		/* data memory, kilobytes */
	long	codeK;		/* code memory, kilobytes */
	char	pass;		/* which pass this was last used in */
	TopmemT	*next;		/* ptr to next pid of same hash key */
	float   percentage;     /* RGH calculated percentage of mem */
};

#define	RegisterT		struct RegisterT
#define	RegisterS		(sizeof (RegisterT))
RegisterT
{
	pid_t	pid;		/* process ID */
	char	name [17];	/* process name */
	struct _reg_struct regs;	/* register storage */
	char	pass;		/* which pass this was last used in */
	char	valid;		/* valid info in "regs" ? */
	RegisterT *next;	/* ptr to next pid of same hash key */
};

/*
 *	System monitor types
*/

#define	SMtopcpu		1
#define	SMstates		2
#define	SMtopcode		3
#define	SMtopdata		4
#define	SMtopmem		5
#define	SMphysmem		6
#define	SMregister		7
#define	SMstatus		8
#define	SMinterrupts	9
#define	SMfaults		10
#define	SMkcalls		11

/*
 *	Maximums
*/

#define	MaxProcesses	64
#define	MaxIRQNameLen	4

/*
 *	Debugging
*/

#define	D	{FILE *fp;fp=fopen ("debug.out","a");fprintf(fp,"%s %d\n",__FILE__, __LINE__);fclose(fp);}

#endif
