[79edc36] | 1 | /*
|
---|
[dec16a2] | 2 | * Copyright (c) 2010 Stanislav Kozina
|
---|
| 3 | * Copyright (c) 2010 Martin Decky
|
---|
[79edc36] | 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | /** @addtogroup top
|
---|
| 31 | * @{
|
---|
| 32 | */
|
---|
| 33 |
|
---|
| 34 | #ifndef TOP_TOP_H_
|
---|
| 35 | #define TOP_TOP_H_
|
---|
| 36 |
|
---|
[dd6c71c] | 37 | #include <task.h>
|
---|
[dec16a2] | 38 | #include <stats.h>
|
---|
| 39 | #include <time.h>
|
---|
[dd6c71c] | 40 |
|
---|
[be06914] | 41 | #define FRACTION_TO_FLOAT(float, a, b) \
|
---|
[b3b7e14a] | 42 | do { \
|
---|
[be06914] | 43 | if ((b) != 0) { \
|
---|
| 44 | (float).upper = (a); \
|
---|
| 45 | (float).lower = (b); \
|
---|
| 46 | } else { \
|
---|
| 47 | (float).upper = 0; \
|
---|
| 48 | (float).lower = 1; \
|
---|
| 49 | } \
|
---|
[b3b7e14a] | 50 | } while (0)
|
---|
[e43cdac] | 51 |
|
---|
[b3b7e14a] | 52 | typedef enum {
|
---|
[f682f5a] | 53 | SCREEN_TABLE,
|
---|
[b8d6783] | 54 | SCREEN_SORT,
|
---|
[f682f5a] | 55 | SCREEN_HELP,
|
---|
| 56 | } screen_mode_t;
|
---|
[dec16a2] | 57 |
|
---|
[f682f5a] | 58 | extern screen_mode_t screen_mode;
|
---|
[bdfd3c97] | 59 |
|
---|
[e43cdac] | 60 | typedef struct {
|
---|
| 61 | uint64_t upper;
|
---|
| 62 | uint64_t lower;
|
---|
[dec16a2] | 63 | } fixed_float;
|
---|
[e43cdac] | 64 |
|
---|
[ee35ba0b] | 65 | typedef struct {
|
---|
[dec16a2] | 66 | fixed_float idle;
|
---|
| 67 | fixed_float busy;
|
---|
| 68 | } perc_cpu_t;
|
---|
[ee35ba0b] | 69 |
|
---|
| 70 | typedef struct {
|
---|
[be06914] | 71 | fixed_float virtmem;
|
---|
[a0ce870] | 72 | fixed_float resmem;
|
---|
[dec16a2] | 73 | fixed_float ucycles;
|
---|
| 74 | fixed_float kcycles;
|
---|
| 75 | } perc_task_t;
|
---|
[ee35ba0b] | 76 |
|
---|
[be06914] | 77 | typedef struct {
|
---|
| 78 | fixed_float cycles;
|
---|
| 79 | fixed_float count;
|
---|
| 80 | } perc_exc_t;
|
---|
| 81 |
|
---|
[f682f5a] | 82 | typedef enum {
|
---|
| 83 | FIELD_EMPTY, FIELD_UINT, FIELD_UINT_SUFFIX_BIN, FIELD_UINT_SUFFIX_DEC,
|
---|
| 84 | FIELD_PERCENT, FIELD_STRING
|
---|
| 85 | } field_type_t;
|
---|
| 86 |
|
---|
| 87 | typedef struct {
|
---|
| 88 | field_type_t type;
|
---|
| 89 | union {
|
---|
| 90 | fixed_float fixed;
|
---|
| 91 | uint64_t uint;
|
---|
| 92 | const char *string;
|
---|
| 93 | };
|
---|
| 94 | } field_t;
|
---|
| 95 |
|
---|
| 96 | typedef struct {
|
---|
| 97 | const char *name;
|
---|
| 98 | char key;
|
---|
| 99 | int width;
|
---|
| 100 | } column_t;
|
---|
| 101 |
|
---|
| 102 | typedef struct {
|
---|
| 103 | const char *name;
|
---|
| 104 | size_t num_columns;
|
---|
| 105 | const column_t *columns;
|
---|
| 106 | size_t num_fields;
|
---|
| 107 | field_t *fields;
|
---|
| 108 | } table_t;
|
---|
| 109 |
|
---|
[79edc36] | 110 | typedef struct {
|
---|
[dec16a2] | 111 | time_t hours;
|
---|
| 112 | time_t minutes;
|
---|
| 113 | time_t seconds;
|
---|
| 114 |
|
---|
| 115 | sysarg_t udays;
|
---|
| 116 | sysarg_t uhours;
|
---|
| 117 | sysarg_t uminutes;
|
---|
| 118 | sysarg_t useconds;
|
---|
| 119 |
|
---|
| 120 | size_t load_count;
|
---|
| 121 | load_t *load;
|
---|
| 122 |
|
---|
| 123 | size_t cpus_count;
|
---|
| 124 | stats_cpu_t *cpus;
|
---|
| 125 | perc_cpu_t *cpus_perc;
|
---|
| 126 |
|
---|
| 127 | size_t tasks_count;
|
---|
| 128 | stats_task_t *tasks;
|
---|
| 129 | perc_task_t *tasks_perc;
|
---|
| 130 |
|
---|
| 131 | size_t threads_count;
|
---|
| 132 | stats_thread_t *threads;
|
---|
| 133 |
|
---|
[8eec3c8] | 134 | size_t exceptions_count;
|
---|
| 135 | stats_exc_t *exceptions;
|
---|
[be06914] | 136 | perc_exc_t *exceptions_perc;
|
---|
[8eec3c8] | 137 |
|
---|
[dec16a2] | 138 | stats_physmem_t *physmem;
|
---|
[172aad6] | 139 |
|
---|
| 140 | uint64_t *ucycles_diff;
|
---|
| 141 | uint64_t *kcycles_diff;
|
---|
| 142 | uint64_t *ecycles_diff;
|
---|
| 143 | uint64_t *ecount_diff;
|
---|
[f682f5a] | 144 |
|
---|
| 145 | table_t table;
|
---|
[79edc36] | 146 | } data_t;
|
---|
| 147 |
|
---|
| 148 | #endif
|
---|
| 149 |
|
---|
| 150 | /**
|
---|
| 151 | * @}
|
---|
| 152 | */
|
---|