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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a53ed3a was b7fd2a0, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

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