| 1 | /*
|
|---|
| 2 | * Copyright (c) 2010 Stanislav Kozina
|
|---|
| 3 | * Copyright (c) 2010 Martin Decky
|
|---|
| 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 |
|
|---|
| 37 | #include <task.h>
|
|---|
| 38 | #include <stats.h>
|
|---|
| 39 | #include <time.h>
|
|---|
| 40 |
|
|---|
| 41 | #define FRACTION_TO_FLOAT(float, a, b) \
|
|---|
| 42 | do { \
|
|---|
| 43 | if ((b) != 0) { \
|
|---|
| 44 | (float).upper = (a); \
|
|---|
| 45 | (float).lower = (b); \
|
|---|
| 46 | } else { \
|
|---|
| 47 | (float).upper = 0; \
|
|---|
| 48 | (float).lower = 1; \
|
|---|
| 49 | } \
|
|---|
| 50 | } while (0)
|
|---|
| 51 |
|
|---|
| 52 | typedef enum {
|
|---|
| 53 | SCREEN_TABLE,
|
|---|
| 54 | SCREEN_HELP,
|
|---|
| 55 | } screen_mode_t;
|
|---|
| 56 |
|
|---|
| 57 | typedef enum {
|
|---|
| 58 | SORT_TASK_CYCLES
|
|---|
| 59 | } sort_mode_t;
|
|---|
| 60 |
|
|---|
| 61 | extern screen_mode_t screen_mode;
|
|---|
| 62 | extern sort_mode_t sort_mode;
|
|---|
| 63 |
|
|---|
| 64 | typedef struct {
|
|---|
| 65 | uint64_t upper;
|
|---|
| 66 | uint64_t lower;
|
|---|
| 67 | } fixed_float;
|
|---|
| 68 |
|
|---|
| 69 | typedef struct {
|
|---|
| 70 | fixed_float idle;
|
|---|
| 71 | fixed_float busy;
|
|---|
| 72 | } perc_cpu_t;
|
|---|
| 73 |
|
|---|
| 74 | typedef struct {
|
|---|
| 75 | fixed_float virtmem;
|
|---|
| 76 | fixed_float resmem;
|
|---|
| 77 | fixed_float ucycles;
|
|---|
| 78 | fixed_float kcycles;
|
|---|
| 79 | } perc_task_t;
|
|---|
| 80 |
|
|---|
| 81 | typedef struct {
|
|---|
| 82 | fixed_float cycles;
|
|---|
| 83 | fixed_float count;
|
|---|
| 84 | } perc_exc_t;
|
|---|
| 85 |
|
|---|
| 86 | typedef enum {
|
|---|
| 87 | FIELD_EMPTY, FIELD_UINT, FIELD_UINT_SUFFIX_BIN, FIELD_UINT_SUFFIX_DEC,
|
|---|
| 88 | FIELD_PERCENT, FIELD_STRING
|
|---|
| 89 | } field_type_t;
|
|---|
| 90 |
|
|---|
| 91 | typedef struct {
|
|---|
| 92 | field_type_t type;
|
|---|
| 93 | union {
|
|---|
| 94 | fixed_float fixed;
|
|---|
| 95 | uint64_t uint;
|
|---|
| 96 | const char *string;
|
|---|
| 97 | };
|
|---|
| 98 | } field_t;
|
|---|
| 99 |
|
|---|
| 100 | typedef struct {
|
|---|
| 101 | const char *name;
|
|---|
| 102 | char key;
|
|---|
| 103 | int width;
|
|---|
| 104 | } column_t;
|
|---|
| 105 |
|
|---|
| 106 | typedef struct {
|
|---|
| 107 | const char *name;
|
|---|
| 108 | size_t num_columns;
|
|---|
| 109 | const column_t *columns;
|
|---|
| 110 | size_t num_fields;
|
|---|
| 111 | field_t *fields;
|
|---|
| 112 | } table_t;
|
|---|
| 113 |
|
|---|
| 114 | typedef struct {
|
|---|
| 115 | time_t hours;
|
|---|
| 116 | time_t minutes;
|
|---|
| 117 | time_t seconds;
|
|---|
| 118 |
|
|---|
| 119 | sysarg_t udays;
|
|---|
| 120 | sysarg_t uhours;
|
|---|
| 121 | sysarg_t uminutes;
|
|---|
| 122 | sysarg_t useconds;
|
|---|
| 123 |
|
|---|
| 124 | size_t load_count;
|
|---|
| 125 | load_t *load;
|
|---|
| 126 |
|
|---|
| 127 | size_t cpus_count;
|
|---|
| 128 | stats_cpu_t *cpus;
|
|---|
| 129 | perc_cpu_t *cpus_perc;
|
|---|
| 130 |
|
|---|
| 131 | size_t tasks_count;
|
|---|
| 132 | stats_task_t *tasks;
|
|---|
| 133 | perc_task_t *tasks_perc;
|
|---|
| 134 | size_t *tasks_map;
|
|---|
| 135 |
|
|---|
| 136 | size_t threads_count;
|
|---|
| 137 | stats_thread_t *threads;
|
|---|
| 138 |
|
|---|
| 139 | size_t exceptions_count;
|
|---|
| 140 | stats_exc_t *exceptions;
|
|---|
| 141 | perc_exc_t *exceptions_perc;
|
|---|
| 142 |
|
|---|
| 143 | stats_physmem_t *physmem;
|
|---|
| 144 |
|
|---|
| 145 | uint64_t *ucycles_diff;
|
|---|
| 146 | uint64_t *kcycles_diff;
|
|---|
| 147 | uint64_t *ecycles_diff;
|
|---|
| 148 | uint64_t *ecount_diff;
|
|---|
| 149 |
|
|---|
| 150 | table_t table;
|
|---|
| 151 | } data_t;
|
|---|
| 152 |
|
|---|
| 153 | #endif
|
|---|
| 154 |
|
|---|
| 155 | /**
|
|---|
| 156 | * @}
|
|---|
| 157 | */
|
|---|