xref: /freebsd/usr.bin/top/machine.h (revision a00d703f)
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 nbatteries;
34     int ncpus;
35 };
36 
37 /*
38  * the system_info struct is filled in by a machine dependent routine.
39  */
40 
41 struct system_info
42 {
43     int    last_pid;
44     double load_avg[NUM_AVERAGES];
45     int    p_total;
46     int    p_pactive;     /* number of procs considered "active" */
47     int    *procstates;
48     int    *cpustates;
49     int    *memory;
50     int    *arc;
51     int    *carc;
52     int    *swap;
53     struct timeval boottime;
54     int    battery;
55     int    ncpus;
56 };
57 
58 /*
59  * the process_select struct tells get_process_info what processes
60  * and information we are interested in seeing
61  */
62 
63 struct process_select
64 {
65     bool idle;		/* show idle processes */
66     bool self;		/* show self */
67     bool system;		/* show system processes */
68     bool thread;		/* show threads */
69     bool thread_id;		/* show thread ids */
70 #define TOP_MAX_UIDS 8
71     int uid[TOP_MAX_UIDS];	/* only these uids (unless uid[0] == -1) */
72     bool wcpu;		/* show weighted cpu */
73     int jid;		/* only this jid (unless jid == -1) */
74     bool jail;		/* show jail ID */
75     bool swap;		/* show swap usage */
76     bool kidle;		/* show per-CPU idle threads */
77     int pid;		/* only this pid (unless pid == -1) */
78     char *command;	/* only this command (unless == NULL) */
79 };
80 
81 /* routines defined by the machine dependent module */
82 
83 struct handle;
84 
85 char	*format_header(const char *uname_field);
86 char	*format_next_process(struct handle* 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 
92 /* non-int routines typically used by the machine dependent module */
93 extern struct process_select ps;
94 
95 void *
96 get_process_info(struct system_info *si, struct process_select *sel,
97     int (*compare)(const void *, const void *));
98 
99 #endif /* MACHINE_H */
100