xref: /freebsd/usr.bin/top/machine.h (revision 8caf462ef6a0a2362a98fd88b65cd75b6f398d1d)
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 
138d0d2676SEitan Adler #include <sys/time.h>
148d0d2676SEitan Adler #include <sys/types.h>
158d0d2676SEitan Adler 
16eae589f1SEitan Adler #define NUM_AVERAGES    3
17eae589f1SEitan Adler 
18eae589f1SEitan Adler /* Log base 2 of 1024 is 10 (2^10 == 1024) */
19eae589f1SEitan Adler #define LOG1024		10
203be6ef06SEitan Adler 
213be6ef06SEitan Adler /*
223be6ef06SEitan Adler  * the statics struct is filled in by machine_init
233be6ef06SEitan Adler  */
243be6ef06SEitan Adler struct statics
253be6ef06SEitan Adler {
269f8096e3SEitan Adler     const char * const *procstate_names;
279f8096e3SEitan Adler     const char * const *cpustate_names;
289f8096e3SEitan Adler     const char * const *memory_names;
299f8096e3SEitan Adler     const char * const *arc_names;
309f8096e3SEitan Adler     const char * const *carc_names;
319f8096e3SEitan Adler     const char * const *swap_names;
329f8096e3SEitan Adler     const char * const *order_names;
333be6ef06SEitan Adler     int ncpus;
343be6ef06SEitan Adler };
353be6ef06SEitan Adler 
363be6ef06SEitan Adler /*
373be6ef06SEitan Adler  * the system_info struct is filled in by a machine dependent routine.
383be6ef06SEitan Adler  */
393be6ef06SEitan Adler 
403be6ef06SEitan Adler struct system_info
413be6ef06SEitan Adler {
423be6ef06SEitan Adler     int    last_pid;
433be6ef06SEitan Adler     double load_avg[NUM_AVERAGES];
443be6ef06SEitan Adler     int    p_total;
455ef89dbfSEitan Adler     int    p_pactive;     /* number of procs considered "active" */
463be6ef06SEitan Adler     int    *procstates;
473be6ef06SEitan Adler     int    *cpustates;
483be6ef06SEitan Adler     int    *memory;
493be6ef06SEitan Adler     int    *arc;
503be6ef06SEitan Adler     int    *carc;
513be6ef06SEitan Adler     int    *swap;
523be6ef06SEitan Adler     struct timeval boottime;
533be6ef06SEitan Adler     int    ncpus;
543be6ef06SEitan Adler };
553be6ef06SEitan Adler 
563be6ef06SEitan Adler /*
57fc36f5a7SEitan Adler  * the process_select struct tells get_process_info what processes
58fc36f5a7SEitan Adler  * and information we are interested in seeing
593be6ef06SEitan Adler  */
603be6ef06SEitan Adler 
613be6ef06SEitan Adler struct process_select
623be6ef06SEitan Adler {
63fc36f5a7SEitan Adler     bool idle;		/* show idle processes */
64fc36f5a7SEitan Adler     bool self;		/* show self */
65fc36f5a7SEitan Adler     bool system;		/* show system processes */
66fc36f5a7SEitan Adler     bool thread;		/* show threads */
67fc36f5a7SEitan Adler     bool thread_id;		/* show thread ids */
683be6ef06SEitan Adler #define TOP_MAX_UIDS 8
693be6ef06SEitan Adler     int uid[TOP_MAX_UIDS];	/* only these uids (unless uid[0] == -1) */
70fc36f5a7SEitan Adler     bool wcpu;		/* show weighted cpu */
713be6ef06SEitan Adler     int jid;		/* only this jid (unless jid == -1) */
72fc36f5a7SEitan Adler     bool jail;		/* show jail ID */
73fc36f5a7SEitan Adler     bool swap;		/* show swap usage */
74fc36f5a7SEitan Adler     bool kidle;		/* show per-CPU idle threads */
75fc36f5a7SEitan Adler     int pid;		/* only this pid (unless pid == -1) */
76fc36f5a7SEitan Adler     const char *command;	/* only this command (unless == NULL) */
773be6ef06SEitan Adler };
783be6ef06SEitan Adler 
793be6ef06SEitan Adler /* routines defined by the machine dependent module */
803be6ef06SEitan Adler 
81*8caf462eSEitan Adler struct handle;
82*8caf462eSEitan Adler 
8351c834c4SEitan Adler char	*format_header(const char *uname_field);
84*8caf462eSEitan Adler char	*format_next_process(struct handle* handle, char *(*get_userid)(int),
853be6ef06SEitan Adler 	    int flags);
863be6ef06SEitan Adler void	 toggle_pcpustats(void);
873be6ef06SEitan Adler void	 get_system_info(struct system_info *si);
884b9ca404SEitan Adler int	 machine_init(struct statics *statics);
893be6ef06SEitan Adler 
903be6ef06SEitan Adler /* non-int routines typically used by the machine dependent module */
911b7645c6SEitan Adler extern struct process_select ps;
923be6ef06SEitan Adler 
931b7645c6SEitan Adler void *
941d6a4ba3SEitan Adler get_process_info(struct system_info *si, struct process_select *sel,
951d6a4ba3SEitan Adler     int (*compare)(const void *, const void *));
961d6a4ba3SEitan Adler 
973be6ef06SEitan Adler #endif /* MACHINE_H */
98