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