1 /* 2 * Copyright (c) 1984 through 2008, William LeFebvre 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * * Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following disclaimer 13 * in the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * * Neither the name of William LeFebvre nor the names of other 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 /* 34 * This file defines the interface between top and the machine-dependent 35 * module. It is NOT machine dependent and should not need to be changed 36 * for any specific machine. 37 */ 38 39 #ifndef _MACHINE_H_ 40 #define _MACHINE_H_ 41 42 #include "top.h" 43 44 /* 45 * The statics struct is filled in by machine_init. Fields marked as 46 * "optional" are not filled in by every module. 47 */ 48 struct statics 49 { 50 const char **procstate_names; 51 const char **cpustate_names; 52 const char **memory_names; 53 const char **swap_names; /* optional */ 54 const char **order_names; /* optional */ 55 const char **top_color_names; /* optional */ 56 const char **kernel_names; /* optional */ 57 time_t boottime; /* optional */ 58 int modemax; /* optional */ 59 int ncpu; /* optional */ 60 struct { 61 unsigned int fullcmds : 1; 62 unsigned int idle : 1; 63 unsigned int warmup : 1; 64 unsigned int threads : 1; 65 } flags; 66 }; 67 68 /* 69 * the system_info struct is filled in by a machine dependent routine. 70 */ 71 72 #ifdef p_active /* uw7 define macro p_active */ 73 #define P_ACTIVE p_pactive 74 #else 75 #define P_ACTIVE p_active 76 #endif 77 78 struct system_info 79 { 80 pid_t last_pid; 81 double load_avg[NUM_AVERAGES]; 82 int p_total; 83 int P_ACTIVE; /* number of procs considered "active" */ 84 int *procstates; 85 int *cpustates; 86 int *kernel; 87 long *memory; 88 long *swap; 89 }; 90 91 /* cpu_states is an array of percentages * 10. For example, 92 the (integer) value 105 is 10.5% (or .105). 93 */ 94 95 /* 96 * the process_select struct tells get_process_info what processes we 97 * are interested in seeing 98 */ 99 100 struct process_select 101 { 102 int idle; /* show idle processes */ 103 int system; /* show system processes */ 104 int fullcmd; /* show full command */ 105 int usernames; /* show usernames */ 106 int uid; /* only this uid (unless uid == -1) */ 107 char *command; /* only this command (unless == NULL) */ 108 int mode; /* select display mode (0 is default) */ 109 int threads; /* show threads separately */ 110 pid_t pid; /* show only this pid (unless pid == -1) */ 111 }; 112 113 /* routines defined by the machine dependent module */ 114 int machine_init(struct statics *); 115 void get_system_info(struct system_info *); 116 caddr_t get_process_info(struct system_info *, struct process_select *, int); 117 char *format_header(char *); 118 char *format_next_process(caddr_t, char *(*)(int)); 119 int proc_owner(int); 120 #ifdef HAVE_FORMAT_PROCESS_HEADER 121 122 #endif /* _MACHINE_H_ */ 123 char *format_process_header(struct process_select *sel, caddr_t handle, int count); 124 #endif 125