1 /* 2 * $FreeBSD$ 3 */ 4 5 /* 6 * This file defines the interface between top and the machine-dependent 7 * module. It is NOT machine dependent and should not need to be changed 8 * for any specific machine. 9 */ 10 #ifndef MACHINE_H 11 #define MACHINE_H 12 13 #include <sys/time.h> 14 #include <sys/types.h> 15 16 #define NUM_AVERAGES 3 17 18 /* Log base 2 of 1024 is 10 (2^10 == 1024) */ 19 #define LOG1024 10 20 21 /* 22 * the statics struct is filled in by machine_init 23 */ 24 struct statics 25 { 26 const char * const *procstate_names; 27 const char * const *cpustate_names; 28 const char * const *memory_names; 29 const char * const *arc_names; 30 const char * const *carc_names; 31 const char * const *swap_names; 32 const char * const *order_names; 33 int ncpus; 34 }; 35 36 /* 37 * the system_info struct is filled in by a machine dependent routine. 38 */ 39 40 struct system_info 41 { 42 int last_pid; 43 double load_avg[NUM_AVERAGES]; 44 int p_total; 45 int p_pactive; /* number of procs considered "active" */ 46 int *procstates; 47 int *cpustates; 48 int *memory; 49 int *arc; 50 int *carc; 51 int *swap; 52 struct timeval boottime; 53 int ncpus; 54 }; 55 56 /* cpu_states is an array of percentages * 10. For example, 57 the (integer) value 105 is 10.5% (or .105). 58 */ 59 60 /* 61 * the process_select struct tells get_process_info what processes 62 * and information we are interested in seeing 63 */ 64 65 struct process_select 66 { 67 bool idle; /* show idle processes */ 68 bool self; /* show self */ 69 bool system; /* show system processes */ 70 bool thread; /* show threads */ 71 bool thread_id; /* show thread ids */ 72 #define TOP_MAX_UIDS 8 73 int uid[TOP_MAX_UIDS]; /* only these uids (unless uid[0] == -1) */ 74 bool wcpu; /* show weighted cpu */ 75 int jid; /* only this jid (unless jid == -1) */ 76 bool jail; /* show jail ID */ 77 bool swap; /* show swap usage */ 78 bool kidle; /* show per-CPU idle threads */ 79 int pid; /* only this pid (unless pid == -1) */ 80 const char *command; /* only this command (unless == NULL) */ 81 }; 82 83 /* routines defined by the machine dependent module */ 84 85 const char *format_header(const char *uname_field); 86 char *format_next_process(void* handle, char *(*get_userid)(int), 87 int flags); 88 void toggle_pcpustats(void); 89 void get_system_info(struct system_info *si); 90 int machine_init(struct statics *statics); 91 int proc_owner(int pid); 92 93 /* non-int routines typically used by the machine dependent module */ 94 extern struct process_select ps; 95 96 void * 97 get_process_info(struct system_info *si, struct process_select *sel, 98 int (*compare)(const void *, const void *)); 99 100 #endif /* MACHINE_H */ 101