Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/sysinfo/sysinfo.h

    re1b6742 rd99c1d2  
    3939#include <str.h>
    4040
    41 /** Framebuffer info exported flags */
    4241extern bool fb_exported;
    4342
    44 /** Item value type
    45  *
    46  */
    47 typedef enum {
    48         SYSINFO_VAL_UNDEFINED = 0,     /**< Undefined value */
    49         SYSINFO_VAL_VAL = 1,           /**< Constant numeric value */
    50         SYSINFO_VAL_DATA = 2,          /**< Constant binary data */
    51         SYSINFO_VAL_FUNCTION_VAL = 3,  /**< Generated numeric value */
    52         SYSINFO_VAL_FUNCTION_DATA = 4  /**< Generated binary data */
    53 } sysinfo_item_val_type_t;
    54 
    55 /** Subtree type
    56  *
    57  */
    58 typedef enum {
    59         SYSINFO_SUBTREE_NONE = 0,     /**< No subtree (leaf item) */
    60         SYSINFO_SUBTREE_TABLE = 1,    /**< Fixed subtree */
    61         SYSINFO_SUBTREE_FUNCTION = 2  /**< Generated subtree */
    62 } sysinfo_subtree_type_t;
    63 
    64 struct sysinfo_item;
    65 
    66 /** Gerated numeric value function */
    67 typedef unative_t (*sysinfo_fn_val_t)(struct sysinfo_item *);
    68 
    69 /** Generated binary data function */
    70 typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *, bool);
    71 
    72 /** Sysinfo item binary data
    73  *
    74  */
    75 typedef struct {
    76         void *data;   /**< Data */
    77         size_t size;  /**< Size (bytes) */
    78 } sysinfo_data_t;
    79 
    80 /** Sysinfo item value (union)
    81  *
    82  */
    83 typedef union {
    84         unative_t val;              /**< Constant numberic value */
    85         sysinfo_fn_val_t fn_val;    /**< Generated numeric value function */
    86         sysinfo_fn_data_t fn_data;  /**< Generated binary data function */
    87         sysinfo_data_t data;        /**< Constant binary data */
     43typedef union sysinfo_item_val {
     44        unative_t val;
     45        void *fn;
    8846} sysinfo_item_val_t;
    8947
    90 /** Sysinfo return holder
    91  *
    92  * This structure is generated from the constant
    93  * items or by the generating functions. Note that
    94  * the validity of the data is limited by the scope
    95  * of single sysinfo invocation guarded by sysinfo_lock.
    96  *
    97  */
    98 typedef struct {
    99         sysinfo_item_val_type_t tag;  /**< Return value type */
     48typedef struct sysinfo_item {
     49        char *name;
    10050        union {
    101                 unative_t val;            /**< Numberic value */
    102                 sysinfo_data_t data;      /**< Binary data */
    103         };
    104 } sysinfo_return_t;
     51                unative_t val;
     52                void *fn;
     53        } val;
    10554
    106 /** Generated subtree function */
    107 typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *, bool);
     55        union {
     56                struct sysinfo_item *table;
     57                void *fn;
     58        } subinfo;
    10859
    109 /** Sysinfo subtree (union)
    110  *
    111  */
    112 typedef union {
    113         struct sysinfo_item *table;     /**< Fixed subtree (list of subitems) */
    114         sysinfo_fn_subtree_t get_data;  /**< Generated subtree function */
    115 } sysinfo_subtree_t;
    116 
    117 /** Sysinfo item
    118  *
    119  */
    120 typedef struct sysinfo_item {
    121         char *name;                           /**< Item name */
    122        
    123         sysinfo_item_val_type_t val_type;     /**< Item value type */
    124         sysinfo_item_val_t val;               /**< Item value */
    125        
    126         sysinfo_subtree_type_t subtree_type;  /**< Subtree type */
    127         sysinfo_subtree_t subtree;            /**< Subtree */
    128        
    129         struct sysinfo_item *next;            /**< Sibling item */
     60        struct sysinfo_item *next;
     61        int val_type;
     62        int subinfo_type;
    13063} sysinfo_item_t;
    13164
    132 extern void sysinfo_set_item_val(const char *, sysinfo_item_t **, unative_t);
    133 extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *,
    134     size_t);
    135 extern void sysinfo_set_item_fn_val(const char *, sysinfo_item_t **,
    136     sysinfo_fn_val_t);
    137 extern void sysinfo_set_item_fn_data(const char *, sysinfo_item_t **,
    138     sysinfo_fn_data_t);
    139 extern void sysinfo_set_item_undefined(const char *, sysinfo_item_t **);
     65#define SYSINFO_VAL_VAL        0
     66#define SYSINFO_VAL_FUNCTION   1
     67#define SYSINFO_VAL_UNDEFINED  U_SPECIAL
    14068
    141 extern void sysinfo_set_subtree_fn(const char *, sysinfo_item_t **,
    142     sysinfo_fn_subtree_t);
     69#define SYSINFO_SUBINFO_NONE      0
     70#define SYSINFO_SUBINFO_TABLE     1
     71#define SYSINFO_SUBINFO_FUNCTION  2
    14372
    144 extern void sysinfo_init(void);
    145 extern void sysinfo_dump(sysinfo_item_t *);
     73typedef unative_t (*sysinfo_val_fn_t)(sysinfo_item_t *root);
     74typedef unative_t (*sysinfo_subinfo_fn_t)(const char *subname);
    14675
    147 extern unative_t sys_sysinfo_get_tag(void *, size_t);
    148 extern unative_t sys_sysinfo_get_value(void *, size_t, void *);
    149 extern unative_t sys_sysinfo_get_data_size(void *, size_t, void *);
    150 extern unative_t sys_sysinfo_get_data(void *, size_t, void *, size_t);
     76typedef struct sysinfo_rettype {
     77        unative_t val;
     78        unative_t valid;
     79} sysinfo_rettype_t;
     80
     81void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, unative_t val);
     82void sysinfo_dump(sysinfo_item_t **root, int depth);
     83void sysinfo_set_item_function(const char *name, sysinfo_item_t **root, sysinfo_val_fn_t fn);
     84void sysinfo_set_item_undefined(const char *name, sysinfo_item_t **root);
     85
     86sysinfo_rettype_t sysinfo_get_val(const char *name, sysinfo_item_t **root);
     87
     88unative_t sys_sysinfo_valid(unative_t ptr, unative_t len);
     89unative_t sys_sysinfo_value(unative_t ptr, unative_t len);
    15190
    15291#endif
Note: See TracChangeset for help on using the changeset viewer.