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