xref: /freebsd/usr.bin/top/machine.h (revision 42b38843)
13be6ef06SEitan Adler /*
23be6ef06SEitan Adler  */
33be6ef06SEitan Adler 
43be6ef06SEitan Adler /*
53be6ef06SEitan Adler  *  This file defines the interface between top and the machine-dependent
63be6ef06SEitan Adler  *  module.  It is NOT machine dependent and should not need to be changed
73be6ef06SEitan Adler  *  for any specific machine.
83be6ef06SEitan Adler  */
93be6ef06SEitan Adler #ifndef MACHINE_H
103be6ef06SEitan Adler #define MACHINE_H
113be6ef06SEitan Adler 
128d0d2676SEitan Adler #include <sys/time.h>
138d0d2676SEitan Adler #include <sys/types.h>
148d0d2676SEitan Adler 
15eae589f1SEitan Adler #define NUM_AVERAGES    3
16eae589f1SEitan Adler 
17eae589f1SEitan Adler /* Log base 2 of 1024 is 10 (2^10 == 1024) */
18eae589f1SEitan Adler #define LOG1024		10
193be6ef06SEitan Adler 
203be6ef06SEitan Adler /*
213be6ef06SEitan Adler  * the statics struct is filled in by machine_init
223be6ef06SEitan Adler  */
233be6ef06SEitan Adler struct statics
243be6ef06SEitan Adler {
259f8096e3SEitan Adler     const char * const *procstate_names;
269f8096e3SEitan Adler     const char * const *cpustate_names;
279f8096e3SEitan Adler     const char * const *memory_names;
289f8096e3SEitan Adler     const char * const *arc_names;
299f8096e3SEitan Adler     const char * const *carc_names;
309f8096e3SEitan Adler     const char * const *swap_names;
319f8096e3SEitan Adler     const char * const *order_names;
32fc8ae86aSPhilip Paeps     int nbatteries;
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;
53fc8ae86aSPhilip Paeps     int    battery;
543be6ef06SEitan Adler     int    ncpus;
553be6ef06SEitan Adler };
563be6ef06SEitan Adler 
573be6ef06SEitan Adler /*
58fc36f5a7SEitan Adler  * the process_select struct tells get_process_info what processes
59fc36f5a7SEitan Adler  * and information we are interested in seeing
603be6ef06SEitan Adler  */
613be6ef06SEitan Adler 
623be6ef06SEitan Adler struct process_select
633be6ef06SEitan Adler {
64fc36f5a7SEitan Adler     bool idle;		/* show idle processes */
65fc36f5a7SEitan Adler     bool self;		/* show self */
66fc36f5a7SEitan Adler     bool system;		/* show system processes */
67fc36f5a7SEitan Adler     bool thread;		/* show threads */
68fc36f5a7SEitan Adler     bool thread_id;		/* show thread ids */
693be6ef06SEitan Adler #define TOP_MAX_UIDS 8
703be6ef06SEitan Adler     int uid[TOP_MAX_UIDS];	/* only these uids (unless uid[0] == -1) */
71fc36f5a7SEitan Adler     bool wcpu;		/* show weighted cpu */
723be6ef06SEitan Adler     int jid;		/* only this jid (unless jid == -1) */
73fc36f5a7SEitan Adler     bool jail;		/* show jail ID */
74fc36f5a7SEitan Adler     bool swap;		/* show swap usage */
75fc36f5a7SEitan Adler     bool kidle;		/* show per-CPU idle threads */
76fc36f5a7SEitan Adler     int pid;		/* only this pid (unless pid == -1) */
77a00d703fSJohn Grafton     char *command;	/* only this command (unless == NULL) */
783be6ef06SEitan Adler };
793be6ef06SEitan Adler 
803be6ef06SEitan Adler /* routines defined by the machine dependent module */
813be6ef06SEitan Adler 
828caf462eSEitan Adler struct handle;
838caf462eSEitan Adler 
8451c834c4SEitan Adler char	*format_header(const char *uname_field);
858caf462eSEitan Adler char	*format_next_process(struct handle* handle, char *(*get_userid)(int),
863be6ef06SEitan Adler 	    int flags);
873be6ef06SEitan Adler void	 toggle_pcpustats(void);
883be6ef06SEitan Adler void	 get_system_info(struct system_info *si);
894b9ca404SEitan Adler int	 machine_init(struct statics *statics);
903be6ef06SEitan Adler 
913be6ef06SEitan Adler /* non-int routines typically used by the machine dependent module */
921b7645c6SEitan Adler extern struct process_select ps;
933be6ef06SEitan Adler 
941b7645c6SEitan Adler void *
951d6a4ba3SEitan Adler get_process_info(struct system_info *si, struct process_select *sel,
961d6a4ba3SEitan Adler     int (*compare)(const void *, const void *));
971d6a4ba3SEitan Adler 
983be6ef06SEitan Adler #endif /* MACHINE_H */
99