xref: /freebsd/usr.bin/top/machine.h (revision fc8ae86a)
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;
33fc8ae86aSPhilip Paeps     int nbatteries;
343be6ef06SEitan Adler     int ncpus;
353be6ef06SEitan Adler };
363be6ef06SEitan Adler 
373be6ef06SEitan Adler /*
383be6ef06SEitan Adler  * the system_info struct is filled in by a machine dependent routine.
393be6ef06SEitan Adler  */
403be6ef06SEitan Adler 
413be6ef06SEitan Adler struct system_info
423be6ef06SEitan Adler {
433be6ef06SEitan Adler     int    last_pid;
443be6ef06SEitan Adler     double load_avg[NUM_AVERAGES];
453be6ef06SEitan Adler     int    p_total;
465ef89dbfSEitan Adler     int    p_pactive;     /* number of procs considered "active" */
473be6ef06SEitan Adler     int    *procstates;
483be6ef06SEitan Adler     int    *cpustates;
493be6ef06SEitan Adler     int    *memory;
503be6ef06SEitan Adler     int    *arc;
513be6ef06SEitan Adler     int    *carc;
523be6ef06SEitan Adler     int    *swap;
533be6ef06SEitan Adler     struct timeval boottime;
54fc8ae86aSPhilip Paeps     int    battery;
553be6ef06SEitan Adler     int    ncpus;
563be6ef06SEitan Adler };
573be6ef06SEitan Adler 
583be6ef06SEitan Adler /*
59fc36f5a7SEitan Adler  * the process_select struct tells get_process_info what processes
60fc36f5a7SEitan Adler  * and information we are interested in seeing
613be6ef06SEitan Adler  */
623be6ef06SEitan Adler 
633be6ef06SEitan Adler struct process_select
643be6ef06SEitan Adler {
65fc36f5a7SEitan Adler     bool idle;		/* show idle processes */
66fc36f5a7SEitan Adler     bool self;		/* show self */
67fc36f5a7SEitan Adler     bool system;		/* show system processes */
68fc36f5a7SEitan Adler     bool thread;		/* show threads */
69fc36f5a7SEitan Adler     bool thread_id;		/* show thread ids */
703be6ef06SEitan Adler #define TOP_MAX_UIDS 8
713be6ef06SEitan Adler     int uid[TOP_MAX_UIDS];	/* only these uids (unless uid[0] == -1) */
72fc36f5a7SEitan Adler     bool wcpu;		/* show weighted cpu */
733be6ef06SEitan Adler     int jid;		/* only this jid (unless jid == -1) */
74fc36f5a7SEitan Adler     bool jail;		/* show jail ID */
75fc36f5a7SEitan Adler     bool swap;		/* show swap usage */
76fc36f5a7SEitan Adler     bool kidle;		/* show per-CPU idle threads */
77fc36f5a7SEitan Adler     int pid;		/* only this pid (unless pid == -1) */
78fc36f5a7SEitan Adler     const char *command;	/* only this command (unless == NULL) */
793be6ef06SEitan Adler };
803be6ef06SEitan Adler 
813be6ef06SEitan Adler /* routines defined by the machine dependent module */
823be6ef06SEitan Adler 
838caf462eSEitan Adler struct handle;
848caf462eSEitan Adler 
8551c834c4SEitan Adler char	*format_header(const char *uname_field);
868caf462eSEitan Adler char	*format_next_process(struct handle* handle, char *(*get_userid)(int),
873be6ef06SEitan Adler 	    int flags);
883be6ef06SEitan Adler void	 toggle_pcpustats(void);
893be6ef06SEitan Adler void	 get_system_info(struct system_info *si);
904b9ca404SEitan Adler int	 machine_init(struct statics *statics);
913be6ef06SEitan Adler 
923be6ef06SEitan Adler /* non-int routines typically used by the machine dependent module */
931b7645c6SEitan Adler extern struct process_select ps;
943be6ef06SEitan Adler 
951b7645c6SEitan Adler void *
961d6a4ba3SEitan Adler get_process_info(struct system_info *si, struct process_select *sel,
971d6a4ba3SEitan Adler     int (*compare)(const void *, const void *));
981d6a4ba3SEitan Adler 
993be6ef06SEitan Adler #endif /* MACHINE_H */
100