00001 /* 00002 * Copyright (C) 2006 Jakub Vana 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 00009 * - Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * - Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * - The name of the author may not be used to endorse or promote products 00015 * derived from this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00019 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00020 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00022 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00024 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00026 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00035 #include <arch/types.h> 00036 00037 typedef union sysinfo_item_val 00038 { 00039 __native val; 00040 void *fn; 00041 }sysinfo_item_val_t; 00042 00043 typedef struct sysinfo_item 00044 { 00045 char *name; 00046 union 00047 { 00048 __native val; 00049 void *fn; 00050 }val; 00051 00052 union 00053 { 00054 struct sysinfo_item *table; 00055 void *fn; 00056 }subinfo; 00057 00058 struct sysinfo_item *next; 00059 int val_type; 00060 int subinfo_type; 00061 }sysinfo_item_t; 00062 00063 #define SYSINFO_VAL_VAL 0 00064 #define SYSINFO_VAL_FUNCTION 1 00065 #define SYSINFO_VAL_UNDEFINED '?' 00066 00067 #define SYSINFO_SUBINFO_NONE 0 00068 #define SYSINFO_SUBINFO_TABLE 1 00069 #define SYSINFO_SUBINFO_FUNCTION 2 00070 00071 00072 typedef __native (*sysinfo_val_fn_t)(sysinfo_item_t *root); 00073 typedef __native (*sysinfo_subinfo_fn_t)(const char *subname); 00074 00075 typedef struct sysinfo_rettype 00076 { 00077 __native val; 00078 __native valid; 00079 }sysinfo_rettype_t; 00080 00081 void sysinfo_set_item_val(const char *name,sysinfo_item_t **root,__native val); 00082 void sysinfo_dump(sysinfo_item_t **root,int depth); 00083 void sysinfo_set_item_function(const char *name,sysinfo_item_t **root,sysinfo_val_fn_t fn); 00084 void sysinfo_set_item_undefined(const char *name,sysinfo_item_t **root); 00085 00086 sysinfo_rettype_t sysinfo_get_val(const char *name,sysinfo_item_t **root); 00087 00088 __native sys_sysinfo_valid(__native ptr,__native len); 00089 __native sys_sysinfo_value(__native ptr,__native len); 00090 00091 00092