| [6326f5e6] | 1 | /*
|
|---|
| [df4ed85] | 2 | * Copyright (c) 2006 Jakub Vana
|
|---|
| [6326f5e6] | 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 |
|
|---|
| [c8bf88d] | 29 | /** @addtogroup generic
|
|---|
| [b45c443] | 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 | /** @file
|
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| [06e1e95] | 35 | #ifndef KERN_SYSINFO_H_
|
|---|
| 36 | #define KERN_SYSINFO_H_
|
|---|
| 37 |
|
|---|
| [d99c1d2] | 38 | #include <typedefs.h>
|
|---|
| [19f857a] | 39 | #include <str.h>
|
|---|
| [9a426d1f] | 40 | #include <abi/sysinfo.h>
|
|---|
| [2666daa] | 41 |
|
|---|
| [80bfb601] | 42 | /** Framebuffer info exported flags */
|
|---|
| [a71c158] | 43 | extern bool fb_exported;
|
|---|
| 44 |
|
|---|
| [80bfb601] | 45 | /** Subtree type
|
|---|
| 46 | *
|
|---|
| 47 | */
|
|---|
| [d9fae235] | 48 | typedef enum {
|
|---|
| [80bfb601] | 49 | SYSINFO_SUBTREE_NONE = 0, /**< No subtree (leaf item) */
|
|---|
| 50 | SYSINFO_SUBTREE_TABLE = 1, /**< Fixed subtree */
|
|---|
| 51 | SYSINFO_SUBTREE_FUNCTION = 2 /**< Generated subtree */
|
|---|
| [d9fae235] | 52 | } sysinfo_subtree_type_t;
|
|---|
| 53 |
|
|---|
| 54 | struct sysinfo_item;
|
|---|
| 55 |
|
|---|
| [80bfb601] | 56 | /** Gerated numeric value function */
|
|---|
| [96b02eb9] | 57 | typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *);
|
|---|
| [80bfb601] | 58 |
|
|---|
| 59 | /** Generated binary data function */
|
|---|
| [70e2b2d] | 60 | typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool);
|
|---|
| [d9fae235] | 61 |
|
|---|
| [80bfb601] | 62 | /** Sysinfo item binary data
|
|---|
| 63 | *
|
|---|
| 64 | */
|
|---|
| [d9fae235] | 65 | typedef struct {
|
|---|
| [80bfb601] | 66 | void *data; /**< Data */
|
|---|
| 67 | size_t size; /**< Size (bytes) */
|
|---|
| [d9fae235] | 68 | } sysinfo_data_t;
|
|---|
| 69 |
|
|---|
| [80bfb601] | 70 | /** Sysinfo item value (union)
|
|---|
| 71 | *
|
|---|
| 72 | */
|
|---|
| [d9fae235] | 73 | typedef union {
|
|---|
| [96b02eb9] | 74 | sysarg_t val; /**< Constant numberic value */
|
|---|
| [80bfb601] | 75 | sysinfo_fn_val_t fn_val; /**< Generated numeric value function */
|
|---|
| 76 | sysinfo_fn_data_t fn_data; /**< Generated binary data function */
|
|---|
| 77 | sysinfo_data_t data; /**< Constant binary data */
|
|---|
| [42d3be3] | 78 | } sysinfo_item_val_t;
|
|---|
| [2666daa] | 79 |
|
|---|
| [80bfb601] | 80 | /** Sysinfo return holder
|
|---|
| 81 | *
|
|---|
| 82 | * This structure is generated from the constant
|
|---|
| 83 | * items or by the generating functions. Note that
|
|---|
| 84 | * the validity of the data is limited by the scope
|
|---|
| 85 | * of single sysinfo invocation guarded by sysinfo_lock.
|
|---|
| 86 | *
|
|---|
| 87 | */
|
|---|
| [9dae191e] | 88 | typedef struct {
|
|---|
| [80bfb601] | 89 | sysinfo_item_val_type_t tag; /**< Return value type */
|
|---|
| [9dae191e] | 90 | union {
|
|---|
| [96b02eb9] | 91 | sysarg_t val; /**< Numberic value */
|
|---|
| [80bfb601] | 92 | sysinfo_data_t data; /**< Binary data */
|
|---|
| [9dae191e] | 93 | };
|
|---|
| 94 | } sysinfo_return_t;
|
|---|
| 95 |
|
|---|
| [80bfb601] | 96 | /** Generated subtree function */
|
|---|
| [e1b6742] | 97 | typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool);
|
|---|
| [9dae191e] | 98 |
|
|---|
| [80bfb601] | 99 | /** Sysinfo subtree (union)
|
|---|
| 100 | *
|
|---|
| 101 | */
|
|---|
| [d9fae235] | 102 | typedef union {
|
|---|
| [80bfb601] | 103 | struct sysinfo_item *table; /**< Fixed subtree (list of subitems) */
|
|---|
| 104 | sysinfo_fn_subtree_t get_data; /**< Generated subtree function */
|
|---|
| [d9fae235] | 105 | } sysinfo_subtree_t;
|
|---|
| 106 |
|
|---|
| [80bfb601] | 107 | /** Sysinfo item
|
|---|
| 108 | *
|
|---|
| 109 | */
|
|---|
| [42d3be3] | 110 | typedef struct sysinfo_item {
|
|---|
| [80bfb601] | 111 | char *name; /**< Item name */
|
|---|
| [d9fae235] | 112 |
|
|---|
| [80bfb601] | 113 | sysinfo_item_val_type_t val_type; /**< Item value type */
|
|---|
| 114 | sysinfo_item_val_t val; /**< Item value */
|
|---|
| [d9fae235] | 115 |
|
|---|
| [80bfb601] | 116 | sysinfo_subtree_type_t subtree_type; /**< Subtree type */
|
|---|
| 117 | sysinfo_subtree_t subtree; /**< Subtree */
|
|---|
| [d9fae235] | 118 |
|
|---|
| [80bfb601] | 119 | struct sysinfo_item *next; /**< Sibling item */
|
|---|
| [42d3be3] | 120 | } sysinfo_item_t;
|
|---|
| [2666daa] | 121 |
|
|---|
| [96b02eb9] | 122 | extern void sysinfo_set_item_val(const char *, sysinfo_item_t **, sysarg_t);
|
|---|
| [d9fae235] | 123 | extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *,
|
|---|
| 124 | size_t);
|
|---|
| [9dae191e] | 125 | extern void sysinfo_set_item_fn_val(const char *, sysinfo_item_t **,
|
|---|
| [d9fae235] | 126 | sysinfo_fn_val_t);
|
|---|
| [9dae191e] | 127 | extern void sysinfo_set_item_fn_data(const char *, sysinfo_item_t **,
|
|---|
| [d9fae235] | 128 | sysinfo_fn_data_t);
|
|---|
| 129 | extern void sysinfo_set_item_undefined(const char *, sysinfo_item_t **);
|
|---|
| 130 |
|
|---|
| [9dae191e] | 131 | extern void sysinfo_set_subtree_fn(const char *, sysinfo_item_t **,
|
|---|
| 132 | sysinfo_fn_subtree_t);
|
|---|
| 133 |
|
|---|
| 134 | extern void sysinfo_init(void);
|
|---|
| 135 | extern void sysinfo_dump(sysinfo_item_t *);
|
|---|
| [d9fae235] | 136 |
|
|---|
| [9a426d1f] | 137 | extern sysarg_t sys_sysinfo_get_val_type(void *, size_t);
|
|---|
| [96b02eb9] | 138 | extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *);
|
|---|
| 139 | extern sysarg_t sys_sysinfo_get_data_size(void *, size_t, void *);
|
|---|
| [311bc25] | 140 | extern sysarg_t sys_sysinfo_get_data(void *, size_t, void *, size_t, size_t *);
|
|---|
| [35a96cf] | 141 |
|
|---|
| [06e1e95] | 142 | #endif
|
|---|
| 143 |
|
|---|
| [42d3be3] | 144 | /** @}
|
|---|
| [b45c443] | 145 | */
|
|---|