| 1 | /*
|
|---|
| 2 | * Copyright (c) 2010 Martin Decky
|
|---|
| 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
|
|---|
| 33 | * Data structures passed between kernel sysinfo and user space.
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | #ifndef ABI_SYSINFO_H_
|
|---|
| 37 | #define ABI_SYSINFO_H_
|
|---|
| 38 |
|
|---|
| 39 | /** Number of load components */
|
|---|
| 40 | #define LOAD_STEPS 3
|
|---|
| 41 |
|
|---|
| 42 | /** Maximum name sizes */
|
|---|
| 43 | #define TASK_NAME_BUFLEN 20
|
|---|
| 44 | #define EXC_NAME_BUFLEN 20
|
|---|
| 45 |
|
|---|
| 46 | /** Thread states */
|
|---|
| 47 | typedef enum {
|
|---|
| 48 | /** It is an error, if thread is found in this state. */
|
|---|
| 49 | Invalid,
|
|---|
| 50 | /** State of a thread that is currently executing on some CPU. */
|
|---|
| 51 | Running,
|
|---|
| 52 | /** Thread in this state is waiting for an event. */
|
|---|
| 53 | Sleeping,
|
|---|
| 54 | /** State of threads in a run queue. */
|
|---|
| 55 | Ready,
|
|---|
| 56 | /** Threads are in this state before they are first readied. */
|
|---|
| 57 | Entering,
|
|---|
| 58 | /** After a thread calls thread_exit(), it is put into Exiting state. */
|
|---|
| 59 | Exiting,
|
|---|
| 60 | /** Threads that were not detached but exited are Lingering. */
|
|---|
| 61 | Lingering
|
|---|
| 62 | } state_t;
|
|---|
| 63 |
|
|---|
| 64 | /** Statistics about a single CPU
|
|---|
| 65 | *
|
|---|
| 66 | */
|
|---|
| 67 | typedef struct {
|
|---|
| 68 | unsigned int id; /**< CPU ID as stored by kernel */
|
|---|
| 69 | bool active; /**< CPU is activate */
|
|---|
| 70 | uint16_t frequency_mhz; /**< Frequency in MHz */
|
|---|
| 71 | uint64_t idle_cycles; /**< Number of idle cycles */
|
|---|
| 72 | uint64_t busy_cycles; /**< Number of busy cycles */
|
|---|
| 73 | } stats_cpu_t;
|
|---|
| 74 |
|
|---|
| 75 | /** Physical memory statistics
|
|---|
| 76 | *
|
|---|
| 77 | */
|
|---|
| 78 | typedef struct {
|
|---|
| 79 | uint64_t total; /**< Total physical memory (bytes) */
|
|---|
| 80 | uint64_t unavail; /**< Unavailable (reserved, firmware) bytes */
|
|---|
| 81 | uint64_t used; /**< Allocated physical memory (bytes) */
|
|---|
| 82 | uint64_t free; /**< Free physical memory (bytes) */
|
|---|
| 83 | } stats_physmem_t;
|
|---|
| 84 |
|
|---|
| 85 | /** IPC statistics
|
|---|
| 86 | *
|
|---|
| 87 | * Associated with a task.
|
|---|
| 88 | *
|
|---|
| 89 | */
|
|---|
| 90 | typedef struct {
|
|---|
| 91 | uint64_t call_sent; /**< IPC calls sent */
|
|---|
| 92 | uint64_t call_received; /**< IPC calls received */
|
|---|
| 93 | uint64_t answer_sent; /**< IPC answers sent */
|
|---|
| 94 | uint64_t answer_received; /**< IPC answers received */
|
|---|
| 95 | uint64_t irq_notif_received; /**< IPC IRQ notifications */
|
|---|
| 96 | uint64_t forwarded; /**< IPC messages forwarded */
|
|---|
| 97 | } stats_ipc_t;
|
|---|
| 98 |
|
|---|
| 99 | /** Statistics about a single task
|
|---|
| 100 | *
|
|---|
| 101 | */
|
|---|
| 102 | typedef struct {
|
|---|
| 103 | task_id_t task_id; /**< Task ID */
|
|---|
| 104 | char name[TASK_NAME_BUFLEN]; /**< Task name (in kernel) */
|
|---|
| 105 | size_t virtmem; /**< Size of VAS (bytes) */
|
|---|
| 106 | size_t resmem; /**< Size of resident (used) memory (bytes) */
|
|---|
| 107 | size_t threads; /**< Number of threads */
|
|---|
| 108 | uint64_t ucycles; /**< Number of CPU cycles in user space */
|
|---|
| 109 | uint64_t kcycles; /**< Number of CPU cycles in kernel */
|
|---|
| 110 | stats_ipc_t ipc_info; /**< IPC statistics */
|
|---|
| 111 | } stats_task_t;
|
|---|
| 112 |
|
|---|
| 113 | /** Statistics about a single thread
|
|---|
| 114 | *
|
|---|
| 115 | */
|
|---|
| 116 | typedef struct {
|
|---|
| 117 | thread_id_t thread_id; /**< Thread ID */
|
|---|
| 118 | task_id_t task_id; /**< Associated task ID */
|
|---|
| 119 | state_t state; /**< Thread state */
|
|---|
| 120 | int priority; /**< Thread priority */
|
|---|
| 121 | uint64_t ucycles; /**< Number of CPU cycles in user space */
|
|---|
| 122 | uint64_t kcycles; /**< Number of CPU cycles in kernel */
|
|---|
| 123 | bool on_cpu; /**< Associated with a CPU */
|
|---|
| 124 | unsigned int cpu; /**< Associated CPU ID (if on_cpu is true) */
|
|---|
| 125 | } stats_thread_t;
|
|---|
| 126 |
|
|---|
| 127 | /** Statistics about a single exception
|
|---|
| 128 | *
|
|---|
| 129 | */
|
|---|
| 130 | typedef struct {
|
|---|
| 131 | unsigned int id; /**< Exception ID */
|
|---|
| 132 | char desc[EXC_NAME_BUFLEN]; /**< Description */
|
|---|
| 133 | bool hot; /**< Active or inactive exception */
|
|---|
| 134 | uint64_t cycles; /**< Number of CPU cycles in the handler */
|
|---|
| 135 | uint64_t count; /**< Number of handled exceptions */
|
|---|
| 136 | } stats_exc_t;
|
|---|
| 137 |
|
|---|
| 138 | /** Load fixed-point value */
|
|---|
| 139 | typedef uint32_t load_t;
|
|---|
| 140 |
|
|---|
| 141 | #endif
|
|---|
| 142 |
|
|---|
| 143 | /** @}
|
|---|
| 144 | */
|
|---|