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