source: mainline/kernel/generic/include/sysinfo/sysinfo.h@ 0030eef

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

add kernel support for listing sysinfo keys from uspace

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*
2 * Copyright (c) 2006 Jakub Vana
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 */
34
35#ifndef KERN_SYSINFO_H_
36#define KERN_SYSINFO_H_
37
38#include <typedefs.h>
39#include <str.h>
40#include <abi/sysinfo.h>
41
42/** Framebuffer info exported flags */
43extern bool fb_exported;
44
45/** Subtree type
46 *
47 */
48typedef enum {
49 SYSINFO_SUBTREE_NONE = 0, /**< No subtree (leaf item) */
50 SYSINFO_SUBTREE_TABLE = 1, /**< Fixed subtree */
51 SYSINFO_SUBTREE_FUNCTION = 2 /**< Generated subtree */
52} sysinfo_subtree_type_t;
53
54struct sysinfo_item;
55
56/** Gerated numeric value function */
57typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *);
58
59/** Generated binary data function */
60typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool);
61
62/** Sysinfo item binary data
63 *
64 */
65typedef struct {
66 void *data; /**< Data */
67 size_t size; /**< Size (bytes) */
68} sysinfo_data_t;
69
70/** Sysinfo item value (union)
71 *
72 */
73typedef union {
74 sysarg_t val; /**< Constant numberic value */
75 sysinfo_data_t data; /**< Constant binary data */
76 sysinfo_fn_val_t fn_val; /**< Generated numeric value function */
77 sysinfo_fn_data_t fn_data; /**< Generated binary data function */
78} sysinfo_item_val_t;
79
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 */
88typedef struct {
89 sysinfo_item_val_type_t tag; /**< Return value type */
90 union {
91 sysarg_t val; /**< Numberic value */
92 sysinfo_data_t data; /**< Binary data */
93 };
94} sysinfo_return_t;
95
96/** Generated subtree function */
97typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool, void *);
98
99/** Sysinfo generated subtree data
100 *
101 */
102typedef struct {
103 sysinfo_fn_subtree_t fn; /**< Generated subtree function */
104 void *data; /**< Private data */
105} sysinfo_fn_subtree_data_t;
106
107/** Sysinfo subtree (union)
108 *
109 */
110typedef union {
111 struct sysinfo_item *table; /**< Fixed subtree (list of subitems) */
112 sysinfo_fn_subtree_data_t generator; /**< Generated subtree */
113} sysinfo_subtree_t;
114
115/** Sysinfo item
116 *
117 */
118typedef struct sysinfo_item {
119 char *name; /**< Item name */
120
121 sysinfo_item_val_type_t val_type; /**< Item value type */
122 sysinfo_item_val_t val; /**< Item value */
123
124 sysinfo_subtree_type_t subtree_type; /**< Subtree type */
125 sysinfo_subtree_t subtree; /**< Subtree */
126
127 struct sysinfo_item *next; /**< Sibling item */
128} sysinfo_item_t;
129
130extern void sysinfo_set_item_val(const char *, sysinfo_item_t **, sysarg_t);
131extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *,
132 size_t);
133extern void sysinfo_set_item_fn_val(const char *, sysinfo_item_t **,
134 sysinfo_fn_val_t);
135extern void sysinfo_set_item_fn_data(const char *, sysinfo_item_t **,
136 sysinfo_fn_data_t);
137extern void sysinfo_set_item_undefined(const char *, sysinfo_item_t **);
138
139extern void sysinfo_set_subtree_fn(const char *, sysinfo_item_t **,
140 sysinfo_fn_subtree_t, void *);
141
142extern void sysinfo_init(void);
143extern void sysinfo_dump(sysinfo_item_t *);
144
145extern sysarg_t sys_sysinfo_get_keys_size(void *, size_t, void *);
146extern sysarg_t sys_sysinfo_get_keys(void *, size_t, void *, size_t, size_t *);
147extern sysarg_t sys_sysinfo_get_val_type(void *, size_t);
148extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *);
149extern sysarg_t sys_sysinfo_get_data_size(void *, size_t, void *);
150extern sysarg_t sys_sysinfo_get_data(void *, size_t, void *, size_t, size_t *);
151
152#endif
153
154/** @}
155 */
Note: See TracBrowser for help on using the repository browser.