source: mainline/kernel/generic/include/sysinfo/sysinfo.h@ e5a4250

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since e5a4250 was 196c253, checked in by Martin Decky <martin@…>, 14 years ago

add support for private/instance data also for the other sysinfo generated content

  • Property mode set to 100644
File size: 5.5 KB
RevLine 
[6326f5e6]1/*
[df4ed85]2 * Copyright (c) 2006 Jakub Vana
[196c253]3 * Copyright (c) 2012 Martin Decky
[6326f5e6]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
[c8bf88d]30/** @addtogroup generic
[b45c443]31 * @{
32 */
33/** @file
34 */
35
[06e1e95]36#ifndef KERN_SYSINFO_H_
37#define KERN_SYSINFO_H_
38
[d99c1d2]39#include <typedefs.h>
[19f857a]40#include <str.h>
[9a426d1f]41#include <abi/sysinfo.h>
[2666daa]42
[80bfb601]43/** Framebuffer info exported flags */
[a71c158]44extern bool fb_exported;
45
[80bfb601]46/** Subtree type
47 *
48 */
[d9fae235]49typedef enum {
[80bfb601]50 SYSINFO_SUBTREE_NONE = 0, /**< No subtree (leaf item) */
51 SYSINFO_SUBTREE_TABLE = 1, /**< Fixed subtree */
52 SYSINFO_SUBTREE_FUNCTION = 2 /**< Generated subtree */
[d9fae235]53} sysinfo_subtree_type_t;
54
55struct sysinfo_item;
56
[196c253]57/** Generated numeric value function */
58typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *, void *);
59
60/** Sysinfo generated numberic value data
61 *
62 */
63typedef struct {
64 sysinfo_fn_val_t fn; /**< Generated value function */
65 void *data; /**< Private data */
66} sysinfo_gen_val_data_t;
[80bfb601]67
68/** Generated binary data function */
[196c253]69typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool,
70 void *);
71
72/** Sysinfo generated binary data data
73 *
74 */
75typedef struct {
76 sysinfo_fn_data_t fn; /**< Generated binary data function */
77 void *data; /**< Private data */
78} sysinfo_gen_data_data_t;
[d9fae235]79
[80bfb601]80/** Sysinfo item binary data
81 *
82 */
[d9fae235]83typedef struct {
[80bfb601]84 void *data; /**< Data */
85 size_t size; /**< Size (bytes) */
[d9fae235]86} sysinfo_data_t;
87
[80bfb601]88/** Sysinfo item value (union)
89 *
90 */
[d9fae235]91typedef union {
[196c253]92 sysarg_t val; /**< Constant numberic value */
93 sysinfo_data_t data; /**< Constant binary data */
94 sysinfo_gen_val_data_t gen_val; /**< Generated numeric value function */
95 sysinfo_gen_data_data_t gen_data; /**< Generated binary data function */
[42d3be3]96} sysinfo_item_val_t;
[2666daa]97
[80bfb601]98/** Sysinfo return holder
99 *
100 * This structure is generated from the constant
101 * items or by the generating functions. Note that
102 * the validity of the data is limited by the scope
103 * of single sysinfo invocation guarded by sysinfo_lock.
104 *
105 */
[9dae191e]106typedef struct {
[80bfb601]107 sysinfo_item_val_type_t tag; /**< Return value type */
[9dae191e]108 union {
[96b02eb9]109 sysarg_t val; /**< Numberic value */
[80bfb601]110 sysinfo_data_t data; /**< Binary data */
[9dae191e]111 };
112} sysinfo_return_t;
113
[80bfb601]114/** Generated subtree function */
[5869ce0]115typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool, void *);
116
117/** Sysinfo generated subtree data
118 *
119 */
120typedef struct {
121 sysinfo_fn_subtree_t fn; /**< Generated subtree function */
122 void *data; /**< Private data */
[196c253]123} sysinfo_gen_subtree_data_t;
[9dae191e]124
[80bfb601]125/** Sysinfo subtree (union)
126 *
127 */
[d9fae235]128typedef union {
[196c253]129 struct sysinfo_item *table; /**< Fixed subtree (list of subitems) */
130 sysinfo_gen_subtree_data_t generator; /**< Generated subtree */
[d9fae235]131} sysinfo_subtree_t;
132
[80bfb601]133/** Sysinfo item
134 *
135 */
[42d3be3]136typedef struct sysinfo_item {
[80bfb601]137 char *name; /**< Item name */
[d9fae235]138
[80bfb601]139 sysinfo_item_val_type_t val_type; /**< Item value type */
140 sysinfo_item_val_t val; /**< Item value */
[d9fae235]141
[80bfb601]142 sysinfo_subtree_type_t subtree_type; /**< Subtree type */
143 sysinfo_subtree_t subtree; /**< Subtree */
[d9fae235]144
[80bfb601]145 struct sysinfo_item *next; /**< Sibling item */
[42d3be3]146} sysinfo_item_t;
[2666daa]147
[96b02eb9]148extern void sysinfo_set_item_val(const char *, sysinfo_item_t **, sysarg_t);
[d9fae235]149extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *,
150 size_t);
[196c253]151extern void sysinfo_set_item_gen_val(const char *, sysinfo_item_t **,
152 sysinfo_fn_val_t, void *);
153extern void sysinfo_set_item_gen_data(const char *, sysinfo_item_t **,
154 sysinfo_fn_data_t, void *);
[d9fae235]155extern void sysinfo_set_item_undefined(const char *, sysinfo_item_t **);
156
[9dae191e]157extern void sysinfo_set_subtree_fn(const char *, sysinfo_item_t **,
[5869ce0]158 sysinfo_fn_subtree_t, void *);
[9dae191e]159
160extern void sysinfo_init(void);
161extern void sysinfo_dump(sysinfo_item_t *);
[d9fae235]162
[0030eef]163extern sysarg_t sys_sysinfo_get_keys_size(void *, size_t, void *);
164extern sysarg_t sys_sysinfo_get_keys(void *, size_t, void *, size_t, size_t *);
[9a426d1f]165extern sysarg_t sys_sysinfo_get_val_type(void *, size_t);
[96b02eb9]166extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *);
167extern sysarg_t sys_sysinfo_get_data_size(void *, size_t, void *);
[311bc25]168extern sysarg_t sys_sysinfo_get_data(void *, size_t, void *, size_t, size_t *);
[35a96cf]169
[06e1e95]170#endif
171
[42d3be3]172/** @}
[b45c443]173 */
Note: See TracBrowser for help on using the repository browser.