xref: /freebsd/usr.bin/top/machine.h (revision 9f8096e3394d73d186b5f8d23a191e8c993b74a9)
13be6ef06SEitan Adler /*
23be6ef06SEitan Adler  * $FreeBSD$
33be6ef06SEitan Adler  */
43be6ef06SEitan Adler 
53be6ef06SEitan Adler /*
63be6ef06SEitan Adler  *  This file defines the interface between top and the machine-dependent
73be6ef06SEitan Adler  *  module.  It is NOT machine dependent and should not need to be changed
83be6ef06SEitan Adler  *  for any specific machine.
93be6ef06SEitan Adler  */
103be6ef06SEitan Adler #ifndef MACHINE_H
113be6ef06SEitan Adler #define MACHINE_H
123be6ef06SEitan Adler 
133be6ef06SEitan Adler #include "top.h"
143be6ef06SEitan Adler 
153be6ef06SEitan Adler /*
163be6ef06SEitan Adler  * the statics struct is filled in by machine_init
173be6ef06SEitan Adler  */
183be6ef06SEitan Adler struct statics
193be6ef06SEitan Adler {
20*9f8096e3SEitan Adler     const char * const *procstate_names;
21*9f8096e3SEitan Adler     const char * const *cpustate_names;
22*9f8096e3SEitan Adler     const char * const *memory_names;
23*9f8096e3SEitan Adler     const char * const *arc_names;
24*9f8096e3SEitan Adler     const char * const *carc_names;
25*9f8096e3SEitan Adler     const char * const *swap_names;
26*9f8096e3SEitan Adler     const char * const *order_names;
273be6ef06SEitan Adler     int ncpus;
283be6ef06SEitan Adler };
293be6ef06SEitan Adler 
303be6ef06SEitan Adler /*
313be6ef06SEitan Adler  * the system_info struct is filled in by a machine dependent routine.
323be6ef06SEitan Adler  */
333be6ef06SEitan Adler 
343be6ef06SEitan Adler struct system_info
353be6ef06SEitan Adler {
363be6ef06SEitan Adler     int    last_pid;
373be6ef06SEitan Adler     double load_avg[NUM_AVERAGES];
383be6ef06SEitan Adler     int    p_total;
395ef89dbfSEitan Adler     int    p_pactive;     /* number of procs considered "active" */
403be6ef06SEitan Adler     int    *procstates;
413be6ef06SEitan Adler     int    *cpustates;
423be6ef06SEitan Adler     int    *memory;
433be6ef06SEitan Adler     int    *arc;
443be6ef06SEitan Adler     int    *carc;
453be6ef06SEitan Adler     int    *swap;
463be6ef06SEitan Adler     struct timeval boottime;
473be6ef06SEitan Adler     int    ncpus;
483be6ef06SEitan Adler };
493be6ef06SEitan Adler 
503be6ef06SEitan Adler /* cpu_states is an array of percentages * 10.  For example,
513be6ef06SEitan Adler    the (integer) value 105 is 10.5% (or .105).
523be6ef06SEitan Adler  */
533be6ef06SEitan Adler 
543be6ef06SEitan Adler /*
553be6ef06SEitan Adler  * the process_select struct tells get_process_info what processes we
563be6ef06SEitan Adler  * are interested in seeing
573be6ef06SEitan Adler  */
583be6ef06SEitan Adler 
593be6ef06SEitan Adler struct process_select
603be6ef06SEitan Adler {
613be6ef06SEitan Adler     int idle;		/* show idle processes */
623be6ef06SEitan Adler     int self;		/* show self */
633be6ef06SEitan Adler     int system;		/* show system processes */
643be6ef06SEitan Adler     int thread;		/* show threads */
653be6ef06SEitan Adler #define TOP_MAX_UIDS 8
663be6ef06SEitan Adler     int uid[TOP_MAX_UIDS];	/* only these uids (unless uid[0] == -1) */
673be6ef06SEitan Adler     int wcpu;		/* show weighted cpu */
683be6ef06SEitan Adler     int jid;		/* only this jid (unless jid == -1) */
693be6ef06SEitan Adler     int jail;		/* show jail ID */
703be6ef06SEitan Adler     int swap;		/* show swap usage */
713be6ef06SEitan Adler     int kidle;		/* show per-CPU idle threads */
7251b29cb7SRoman Bogorodskiy     pid_t pid;		/* only this pid (unless pid == -1) */
733be6ef06SEitan Adler     char *command;	/* only this command (unless == NULL) */
743be6ef06SEitan Adler };
753be6ef06SEitan Adler 
763be6ef06SEitan Adler /* routines defined by the machine dependent module */
773be6ef06SEitan Adler 
78*9f8096e3SEitan Adler const char	*format_header(const char *uname_field);
7901a55f00SEitan Adler char	*format_next_process(caddr_t handle, char *(*get_userid)(int),
803be6ef06SEitan Adler 	    int flags);
813be6ef06SEitan Adler void	 toggle_pcpustats(void);
823be6ef06SEitan Adler void	 get_system_info(struct system_info *si);
834b9ca404SEitan Adler int	 machine_init(struct statics *statics);
843be6ef06SEitan Adler int	 proc_owner(int pid);
853be6ef06SEitan Adler 
863be6ef06SEitan Adler /* non-int routines typically used by the machine dependent module */
871b7645c6SEitan Adler extern struct process_select ps;
883be6ef06SEitan Adler 
891b7645c6SEitan Adler void *
901d6a4ba3SEitan Adler get_process_info(struct system_info *si, struct process_select *sel,
911d6a4ba3SEitan Adler     int (*compare)(const void *, const void *));
921d6a4ba3SEitan Adler 
933be6ef06SEitan Adler #endif /* MACHINE_H */
94