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 13*8d0d2676SEitan Adler #include <sys/time.h> 14*8d0d2676SEitan Adler #include <sys/types.h> 15*8d0d2676SEitan 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 /* cpu_states is an array of percentages * 10. For example, 573be6ef06SEitan Adler the (integer) value 105 is 10.5% (or .105). 583be6ef06SEitan Adler */ 593be6ef06SEitan Adler 603be6ef06SEitan Adler /* 613be6ef06SEitan Adler * the process_select struct tells get_process_info what processes we 623be6ef06SEitan Adler * are interested in seeing 633be6ef06SEitan Adler */ 643be6ef06SEitan Adler 653be6ef06SEitan Adler struct process_select 663be6ef06SEitan Adler { 673be6ef06SEitan Adler int idle; /* show idle processes */ 683be6ef06SEitan Adler int self; /* show self */ 693be6ef06SEitan Adler int system; /* show system processes */ 703be6ef06SEitan Adler int thread; /* show threads */ 713be6ef06SEitan Adler #define TOP_MAX_UIDS 8 723be6ef06SEitan Adler int uid[TOP_MAX_UIDS]; /* only these uids (unless uid[0] == -1) */ 733be6ef06SEitan Adler int wcpu; /* show weighted cpu */ 743be6ef06SEitan Adler int jid; /* only this jid (unless jid == -1) */ 753be6ef06SEitan Adler int jail; /* show jail ID */ 763be6ef06SEitan Adler int swap; /* show swap usage */ 773be6ef06SEitan Adler int kidle; /* show per-CPU idle threads */ 7851b29cb7SRoman Bogorodskiy pid_t pid; /* only this pid (unless pid == -1) */ 793be6ef06SEitan Adler char *command; /* only this command (unless == NULL) */ 803be6ef06SEitan Adler }; 813be6ef06SEitan Adler 823be6ef06SEitan Adler /* routines defined by the machine dependent module */ 833be6ef06SEitan Adler 849f8096e3SEitan Adler const char *format_header(const char *uname_field); 85eae589f1SEitan Adler char *format_next_process(void* 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 int proc_owner(int pid); 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