[62550dce] | 1 | /*
|
---|
[9dae191e] | 2 | * Copyright (c) 2010 Martin Decky
|
---|
[62550dce] | 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
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup generic
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
[80bfb601] | 33 | * Data structures passed between kernel sysinfo and user space.
|
---|
[62550dce] | 34 | */
|
---|
| 35 |
|
---|
[c0699467] | 36 | #ifndef ABI_SYSINFO_H_
|
---|
| 37 | #define ABI_SYSINFO_H_
|
---|
[9dae191e] | 38 |
|
---|
[9a426d1f] | 39 | #include <abi/proc/task.h>
|
---|
| 40 | #include <abi/proc/thread.h>
|
---|
| 41 |
|
---|
[80bfb601] | 42 | /** Number of load components */
|
---|
[da1bafb] | 43 | #define LOAD_STEPS 3
|
---|
[80bfb601] | 44 |
|
---|
[8eec3c8] | 45 | /** Maximum name sizes */
|
---|
[9dae191e] | 46 | #define TASK_NAME_BUFLEN 20
|
---|
[8eec3c8] | 47 | #define EXC_NAME_BUFLEN 20
|
---|
[62550dce] | 48 |
|
---|
[9a426d1f] | 49 | /** Item value type
|
---|
| 50 | *
|
---|
| 51 | */
|
---|
[e1b6742] | 52 | typedef enum {
|
---|
[9a426d1f] | 53 | SYSINFO_VAL_UNDEFINED = 0, /**< Undefined value */
|
---|
| 54 | SYSINFO_VAL_VAL = 1, /**< Constant numeric value */
|
---|
| 55 | SYSINFO_VAL_DATA = 2, /**< Constant binary data */
|
---|
| 56 | SYSINFO_VAL_FUNCTION_VAL = 3, /**< Generated numeric value */
|
---|
| 57 | SYSINFO_VAL_FUNCTION_DATA = 4 /**< Generated binary data */
|
---|
| 58 | } sysinfo_item_val_type_t;
|
---|
[e1b6742] | 59 |
|
---|
[80bfb601] | 60 | /** Statistics about a single CPU
|
---|
| 61 | *
|
---|
| 62 | */
|
---|
[62550dce] | 63 | typedef struct {
|
---|
[04357767] | 64 | unsigned int id; /**< CPU ID as stored by kernel */
|
---|
[bd01a4e] | 65 | bool active; /**< CPU is activate */
|
---|
[80bfb601] | 66 | uint16_t frequency_mhz; /**< Frequency in MHz */
|
---|
[d0c82c5] | 67 | uint64_t idle_cycles; /**< Number of idle cycles */
|
---|
| 68 | uint64_t busy_cycles; /**< Number of busy cycles */
|
---|
[9dae191e] | 69 | } stats_cpu_t;
|
---|
| 70 |
|
---|
[80bfb601] | 71 | /** Physical memory statistics
|
---|
| 72 | *
|
---|
| 73 | */
|
---|
[9dae191e] | 74 | typedef struct {
|
---|
[80bfb601] | 75 | uint64_t total; /**< Total physical memory (bytes) */
|
---|
| 76 | uint64_t unavail; /**< Unavailable (reserved, firmware) bytes */
|
---|
| 77 | uint64_t used; /**< Allocated physical memory (bytes) */
|
---|
| 78 | uint64_t free; /**< Free physical memory (bytes) */
|
---|
[9dae191e] | 79 | } stats_physmem_t;
|
---|
| 80 |
|
---|
[80bfb601] | 81 | /** IPC statistics
|
---|
| 82 | *
|
---|
| 83 | * Associated with a task.
|
---|
| 84 | *
|
---|
| 85 | */
|
---|
[9dae191e] | 86 | typedef struct {
|
---|
[80bfb601] | 87 | uint64_t call_sent; /**< IPC calls sent */
|
---|
[be06914] | 88 | uint64_t call_received; /**< IPC calls received */
|
---|
[80bfb601] | 89 | uint64_t answer_sent; /**< IPC answers sent */
|
---|
[be06914] | 90 | uint64_t answer_received; /**< IPC answers received */
|
---|
| 91 | uint64_t irq_notif_received; /**< IPC IRQ notifications */
|
---|
[80bfb601] | 92 | uint64_t forwarded; /**< IPC messages forwarded */
|
---|
[9dae191e] | 93 | } stats_ipc_t;
|
---|
| 94 |
|
---|
[80bfb601] | 95 | /** Statistics about a single task
|
---|
| 96 | *
|
---|
| 97 | */
|
---|
[9dae191e] | 98 | typedef struct {
|
---|
[dec16a2] | 99 | task_id_t task_id; /**< Task ID */
|
---|
[80bfb601] | 100 | char name[TASK_NAME_BUFLEN]; /**< Task name (in kernel) */
|
---|
| 101 | size_t virtmem; /**< Size of VAS (bytes) */
|
---|
[a0ce870] | 102 | size_t resmem; /**< Size of resident (used) memory (bytes) */
|
---|
[80bfb601] | 103 | size_t threads; /**< Number of threads */
|
---|
| 104 | uint64_t ucycles; /**< Number of CPU cycles in user space */
|
---|
| 105 | uint64_t kcycles; /**< Number of CPU cycles in kernel */
|
---|
| 106 | stats_ipc_t ipc_info; /**< IPC statistics */
|
---|
[9dae191e] | 107 | } stats_task_t;
|
---|
| 108 |
|
---|
[e1b6742] | 109 | /** Statistics about a single thread
|
---|
| 110 | *
|
---|
| 111 | */
|
---|
| 112 | typedef struct {
|
---|
[dec16a2] | 113 | thread_id_t thread_id; /**< Thread ID */
|
---|
| 114 | task_id_t task_id; /**< Associated task ID */
|
---|
| 115 | state_t state; /**< Thread state */
|
---|
| 116 | int priority; /**< Thread priority */
|
---|
| 117 | uint64_t ucycles; /**< Number of CPU cycles in user space */
|
---|
| 118 | uint64_t kcycles; /**< Number of CPU cycles in kernel */
|
---|
| 119 | bool on_cpu; /**< Associated with a CPU */
|
---|
| 120 | unsigned int cpu; /**< Associated CPU ID (if on_cpu is true) */
|
---|
[e1b6742] | 121 | } stats_thread_t;
|
---|
| 122 |
|
---|
[8eec3c8] | 123 | /** Statistics about a single exception
|
---|
| 124 | *
|
---|
| 125 | */
|
---|
| 126 | typedef struct {
|
---|
| 127 | unsigned int id; /**< Exception ID */
|
---|
| 128 | char desc[EXC_NAME_BUFLEN]; /**< Description */
|
---|
[b3b7e14a] | 129 | bool hot; /**< Active or inactive exception */
|
---|
[8eec3c8] | 130 | uint64_t cycles; /**< Number of CPU cycles in the handler */
|
---|
| 131 | uint64_t count; /**< Number of handled exceptions */
|
---|
| 132 | } stats_exc_t;
|
---|
| 133 |
|
---|
[80bfb601] | 134 | /** Load fixed-point value */
|
---|
[9dae191e] | 135 | typedef uint32_t load_t;
|
---|
[62550dce] | 136 |
|
---|
| 137 | #endif
|
---|
| 138 |
|
---|
| 139 | /** @}
|
---|
| 140 | */
|
---|