| 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 | (float).upper = (a); \
|
|---|
| 43 | (float).lower = (b); \
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | #define OP_TASKS 1
|
|---|
| 47 | #define OP_IPC 2
|
|---|
| 48 |
|
|---|
| 49 | extern int operation_type;
|
|---|
| 50 |
|
|---|
| 51 | typedef struct {
|
|---|
| 52 | uint64_t upper;
|
|---|
| 53 | uint64_t lower;
|
|---|
| 54 | } fixed_float;
|
|---|
| 55 |
|
|---|
| 56 | typedef struct {
|
|---|
| 57 | fixed_float idle;
|
|---|
| 58 | fixed_float busy;
|
|---|
| 59 | } perc_cpu_t;
|
|---|
| 60 |
|
|---|
| 61 | typedef struct {
|
|---|
| 62 | fixed_float ucycles;
|
|---|
| 63 | fixed_float kcycles;
|
|---|
| 64 | fixed_float virtmem;
|
|---|
| 65 | } perc_task_t;
|
|---|
| 66 |
|
|---|
| 67 | typedef struct {
|
|---|
| 68 | time_t hours;
|
|---|
| 69 | time_t minutes;
|
|---|
| 70 | time_t seconds;
|
|---|
| 71 |
|
|---|
| 72 | sysarg_t udays;
|
|---|
| 73 | sysarg_t uhours;
|
|---|
| 74 | sysarg_t uminutes;
|
|---|
| 75 | sysarg_t useconds;
|
|---|
| 76 |
|
|---|
| 77 | size_t load_count;
|
|---|
| 78 | load_t *load;
|
|---|
| 79 |
|
|---|
| 80 | size_t cpus_count;
|
|---|
| 81 | stats_cpu_t *cpus;
|
|---|
| 82 | perc_cpu_t *cpus_perc;
|
|---|
| 83 |
|
|---|
| 84 | size_t tasks_count;
|
|---|
| 85 | stats_task_t *tasks;
|
|---|
| 86 | perc_task_t *tasks_perc;
|
|---|
| 87 |
|
|---|
| 88 | size_t threads_count;
|
|---|
| 89 | stats_thread_t *threads;
|
|---|
| 90 |
|
|---|
| 91 | stats_physmem_t *physmem;
|
|---|
| 92 | } data_t;
|
|---|
| 93 |
|
|---|
| 94 | #endif
|
|---|
| 95 |
|
|---|
| 96 | /**
|
|---|
| 97 | * @}
|
|---|
| 98 | */
|
|---|