Changeset d9fae235 in mainline
- Timestamp:
- 2010-04-17T01:28:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9d6bfa5
- Parents:
- 9256ad29
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/syscall/syscall.h
r9256ad29 rd9fae235 82 82 SYS_PREEMPT_CONTROL, 83 83 84 SYS_SYSINFO_VALID, 85 SYS_SYSINFO_VALUE, 84 SYS_SYSINFO_GET_TAG, 85 SYS_SYSINFO_GET_VALUE, 86 SYS_SYSINFO_GET_DATA_SIZE, 87 SYS_SYSINFO_GET_DATA, 86 88 87 89 SYS_DEBUG_ENABLE_CONSOLE, -
kernel/generic/include/sysinfo/sysinfo.h
r9256ad29 rd9fae235 41 41 extern bool fb_exported; 42 42 43 typedef union sysinfo_item_val { 43 typedef enum { 44 SYSINFO_VAL_UNDEFINED = 0, 45 SYSINFO_VAL_VAL = 1, 46 SYSINFO_VAL_DATA = 2, 47 SYSINFO_VAL_FUNCTION_VAL = 3, 48 SYSINFO_VAL_FUNCTION_DATA = 4 49 } sysinfo_item_val_type_t; 50 51 typedef enum { 52 SYSINFO_SUBTREE_NONE = 0, 53 SYSINFO_SUBTREE_TABLE = 1, 54 SYSINFO_SUBTREE_FUNCTION = 2 55 } sysinfo_subtree_type_t; 56 57 struct sysinfo_item; 58 59 typedef unative_t (*sysinfo_fn_val_t)(struct sysinfo_item *); 60 typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *); 61 typedef struct sysinfo_item *(*sysinfo_fn_subtree_t)(const char *); 62 63 typedef struct { 64 void *data; 65 size_t size; 66 } sysinfo_data_t; 67 68 typedef union { 44 69 unative_t val; 45 void *fn; 70 sysinfo_fn_val_t fn_val; 71 sysinfo_fn_data_t fn_data; 72 sysinfo_data_t data; 46 73 } sysinfo_item_val_t; 74 75 typedef union { 76 struct sysinfo_item *table; 77 sysinfo_fn_subtree_t find_item; 78 } sysinfo_subtree_t; 47 79 48 80 typedef struct sysinfo_item { 49 81 char *name; 82 83 sysinfo_item_val_type_t val_type; 84 sysinfo_item_val_t val; 85 86 sysinfo_subtree_type_t subtree_type; 87 sysinfo_subtree_t subtree; 88 89 struct sysinfo_item *next; 90 } sysinfo_item_t; 91 92 typedef struct { 93 sysinfo_item_val_type_t tag; 50 94 union { 51 95 unative_t val; 52 void *fn; 53 } val; 96 sysinfo_data_t data; 97 }; 98 } sysinfo_return_t; 54 99 55 union { 56 struct sysinfo_item *table; 57 void *fn; 58 } subinfo; 100 extern void sysinfo_init(void); 59 101 60 struct sysinfo_item *next; 61 int val_type; 62 int subinfo_type; 63 } sysinfo_item_t; 102 extern void sysinfo_set_item_val(const char *, sysinfo_item_t **, unative_t); 103 extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *, 104 size_t); 105 extern void sysinfo_set_item_val_fn(const char *, sysinfo_item_t **, 106 sysinfo_fn_val_t); 107 extern void sysinfo_set_item_data_fn(const char *, sysinfo_item_t **, 108 sysinfo_fn_data_t); 109 extern void sysinfo_set_item_undefined(const char *, sysinfo_item_t **); 64 110 65 #define SYSINFO_VAL_VAL 0 66 #define SYSINFO_VAL_FUNCTION 1 67 #define SYSINFO_VAL_UNDEFINED U_SPECIAL 111 extern sysinfo_return_t sysinfo_get_item(const char *, sysinfo_item_t **); 112 extern void sysinfo_dump(sysinfo_item_t **, unsigned int); 68 113 69 #define SYSINFO_SUBINFO_NONE 0 70 #define SYSINFO_SUBINFO_TABLE 1 71 #define SYSINFO_SUBINFO_FUNCTION 2 72 73 typedef unative_t (*sysinfo_val_fn_t)(sysinfo_item_t *root); 74 typedef unative_t (*sysinfo_subinfo_fn_t)(const char *subname); 75 76 typedef struct sysinfo_rettype { 77 unative_t val; 78 unative_t valid; 79 } sysinfo_rettype_t; 80 81 void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, unative_t val); 82 void sysinfo_dump(sysinfo_item_t **root, int depth); 83 void sysinfo_set_item_function(const char *name, sysinfo_item_t **root, sysinfo_val_fn_t fn); 84 void sysinfo_set_item_undefined(const char *name, sysinfo_item_t **root); 85 86 sysinfo_rettype_t sysinfo_get_val(const char *name, sysinfo_item_t **root); 87 88 unative_t sys_sysinfo_valid(unative_t ptr, unative_t len); 89 unative_t sys_sysinfo_value(unative_t ptr, unative_t len); 114 unative_t sys_sysinfo_get_tag(void *, size_t); 115 unative_t sys_sysinfo_get_value(void *, size_t, void *); 116 unative_t sys_sysinfo_get_data_size(void *, size_t, void *); 117 unative_t sys_sysinfo_get_data(void *, size_t, void *, size_t); 90 118 91 119 #endif -
kernel/generic/src/main/main.c
r9256ad29 rd9fae235 84 84 #include <main/main.h> 85 85 #include <ipc/event.h> 86 #include <sysinfo/sysinfo.h> 86 87 87 88 /** Global configuration structure. */ … … 209 210 /* Initialize at least 1 memory segment big enough for slab to work. */ 210 211 LOG_EXEC(slab_cache_init()); 212 LOG_EXEC(sysinfo_init()); 211 213 LOG_EXEC(btree_init()); 212 214 LOG_EXEC(as_init()); -
kernel/generic/src/syscall/syscall.c
r9256ad29 rd9fae235 153 153 154 154 /* Sysinfo syscalls */ 155 (syshandler_t) sys_sysinfo_valid, 156 (syshandler_t) sys_sysinfo_value, 155 (syshandler_t) sys_sysinfo_get_tag, 156 (syshandler_t) sys_sysinfo_get_value, 157 (syshandler_t) sys_sysinfo_get_data_size, 158 (syshandler_t) sys_sysinfo_get_data, 157 159 158 160 /* Debug calls */ -
kernel/generic/src/sysinfo/sysinfo.c
r9256ad29 rd9fae235 37 37 #include <print.h> 38 38 #include <syscall/copy.h> 39 #include <errno.h> 40 41 #define SYSINFO_MAX_PATH 2048 39 42 40 43 bool fb_exported = false; 41 sysinfo_item_t *_root = NULL; 42 43 static sysinfo_item_t *sysinfo_find_item(const char *name, sysinfo_item_t *subtree) 44 { 45 if (subtree == NULL) 46 return NULL; 47 48 while (subtree != NULL) { 49 int i = 0; 50 char *a = (char *) name; 51 char *b = subtree->name; 52 53 while ((a[i] == b[i]) && (b[i])) 44 45 static sysinfo_item_t *global_root = NULL; 46 static slab_cache_t *sysinfo_item_slab; 47 48 static int sysinfo_item_constructor(void *obj, int kmflag) 49 { 50 sysinfo_item_t *item = (sysinfo_item_t *) obj; 51 52 item->name = NULL; 53 item->val_type = SYSINFO_VAL_UNDEFINED; 54 item->subtree_type = SYSINFO_SUBTREE_NONE; 55 item->next = NULL; 56 57 return 0; 58 } 59 60 static int sysinfo_item_destructor(void *obj) 61 { 62 sysinfo_item_t *item = (sysinfo_item_t *) obj; 63 64 if (item->name != NULL) 65 free(item->name); 66 67 return 0; 68 } 69 70 void sysinfo_init(void) 71 { 72 sysinfo_item_slab = slab_cache_create("sysinfo_item_slab", 73 sizeof(sysinfo_item_t), 0, sysinfo_item_constructor, 74 sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED); 75 } 76 77 static sysinfo_item_t *sysinfo_find_item(const char *name, 78 sysinfo_item_t *subtree) 79 { 80 sysinfo_item_t *cur = subtree; 81 82 while (cur != NULL) { 83 size_t i = 0; 84 85 /* Compare name with path */ 86 while ((cur->name[i] != 0) && (name[i] == cur->name[i])) 54 87 i++; 55 88 56 if ((!a[i]) && (!b[i])) /* Last name in path matches */ 57 return subtree; 58 59 if ((a[i] == '.') && (!b[i])) { /* Middle name in path matches */ 60 if (subtree->subinfo_type == SYSINFO_SUBINFO_TABLE) 61 return sysinfo_find_item(a + i + 1, subtree->subinfo.table); 89 /* Check for perfect name and path match */ 90 if ((name[i] == 0) && (cur->name[i] == 0)) 91 return cur; 92 93 /* Partial match up to the delimiter */ 94 if ((name[i] == '.') && (cur->name[i] == 0)) { 95 /* Look into the subtree */ 96 switch (cur->subtree_type) { 97 case SYSINFO_SUBTREE_TABLE: 98 /* Recursively find in subtree */ 99 return sysinfo_find_item(name + i + 1, cur->subtree.table); 100 case SYSINFO_SUBTREE_FUNCTION: 101 /* Get generated item */ 102 return cur->subtree.find_item(name + i + 1); 103 default: 104 /* Not found */ 105 return NULL; 106 } 107 } 108 109 cur = cur->next; 110 } 111 112 return NULL; 113 } 114 115 static sysinfo_item_t *sysinfo_create_path(const char *name, 116 sysinfo_item_t **psubtree) 117 { 118 if (*psubtree == NULL) { 119 /* No parent */ 120 121 size_t i = 0; 122 123 /* Find the first delimiter in name */ 124 while ((name[i] != 0) && (name[i] != '.')) 125 i++; 126 127 *psubtree = 128 (sysinfo_item_t *) slab_alloc(sysinfo_item_slab, 0); 129 ASSERT(*psubtree); 130 131 /* Fill in item name up to the delimiter */ 132 (*psubtree)->name = str_ndup(name, i); 133 ASSERT((*psubtree)->name); 134 135 /* Create subtree items */ 136 if (name[i] == '.') { 137 (*psubtree)->subtree_type = SYSINFO_SUBTREE_TABLE; 138 return sysinfo_create_path(name + i + 1, 139 &((*psubtree)->subtree.table)); 140 } 141 142 /* No subtree needs to be created */ 143 return *psubtree; 144 } 145 146 sysinfo_item_t *cur = *psubtree; 147 148 while (cur != NULL) { 149 size_t i = 0; 150 151 /* Compare name with path */ 152 while ((cur->name[i] != 0) && (name[i] == cur->name[i])) 153 i++; 154 155 /* Check for perfect name and path match 156 * -> item is already present. 157 */ 158 if ((name[i] == 0) && (cur->name[i] == 0)) 159 return cur; 160 161 /* Partial match up to the delimiter */ 162 if ((name[i] == '.') && (cur->name[i] == 0)) { 163 switch (cur->subtree_type) { 164 case SYSINFO_SUBTREE_NONE: 165 /* No subtree yet, create one */ 166 cur->subtree_type = SYSINFO_SUBTREE_TABLE; 167 return sysinfo_create_path(name + i + 1, 168 &(cur->subtree.table)); 169 case SYSINFO_SUBTREE_TABLE: 170 /* Subtree already created, add new sibling */ 171 return sysinfo_create_path(name + i + 1, 172 &(cur->subtree.table)); 173 default: 174 /* Subtree items handled by a function, this 175 * cannot be overriden. 176 */ 177 return NULL; 178 } 179 } 180 181 /* No match and no more siblings to check 182 * -> create a new sibling item. 183 */ 184 if (cur->next == NULL) { 185 /* Find the first delimiter in name */ 186 i = 0; 187 while ((name[i] != 0) && (name[i] != '.')) 188 i++; 62 189 63 //if (subtree->subinfo_type == SYSINFO_SUBINFO_FUNCTION) /* Subinfo managed by subsystem */ 64 // return NULL; 190 sysinfo_item_t *item = 191 (sysinfo_item_t *) slab_alloc(sysinfo_item_slab, 0); 192 ASSERT(item); 65 193 66 return NULL; /* No subinfo */ 67 } 68 /* No matches try next */ 69 subtree = subtree->next; 70 } 71 return NULL; 72 } 73 74 static sysinfo_item_t *sysinfo_create_path(const char *name, sysinfo_item_t **psubtree) 75 { 76 sysinfo_item_t *subtree; 77 subtree = *psubtree; 78 79 if (subtree == NULL) { 80 sysinfo_item_t *item = malloc(sizeof(sysinfo_item_t), 0); 81 int i = 0, j; 194 cur->next = item; 82 195 83 ASSERT(item); 84 *psubtree = item; 85 item->next = NULL; 86 item->val_type = SYSINFO_VAL_UNDEFINED; 87 item->subinfo.table = NULL; 88 89 while (name[i] && (name[i] != '.')) 90 i++; 196 /* Fill in item name up to the delimiter */ 197 item->name = str_ndup(name, i); 198 ASSERT(item->name); 91 199 92 item->name = malloc(i, 0); 93 ASSERT(item->name); 94 95 for (j = 0; j < i; j++) 96 item->name[j] = name[j]; 97 item->name[j] = 0; 98 99 if (name[i]) { /* =='.' */ 100 item->subinfo_type = SYSINFO_SUBINFO_TABLE; 101 return sysinfo_create_path(name + i + 1, &(item->subinfo.table)); 102 } 103 item->subinfo_type = SYSINFO_SUBINFO_NONE; 104 return item; 105 } 106 107 while (subtree != NULL) { 108 int i = 0, j; 109 char *a = (char *) name; 110 char *b = subtree->name; 111 112 while ((a[i] == b[i]) && (b[i])) 113 i++; 114 115 if ((!a[i]) && (!b[i])) /* Last name in path matches */ 116 return subtree; 117 118 if ((a[i] == '.') && (!b[i])) { /* Middle name in path matches */ 119 if (subtree->subinfo_type == SYSINFO_SUBINFO_TABLE) 120 return sysinfo_create_path(a + i + 1, &(subtree->subinfo.table)); 121 122 if (subtree->subinfo_type == SYSINFO_SUBINFO_NONE) { 123 subtree->subinfo_type = SYSINFO_SUBINFO_TABLE; 124 return sysinfo_create_path(a + i + 1,&(subtree->subinfo.table)); 200 /* Create subtree items */ 201 if (name[i] == '.') { 202 item->subtree_type = SYSINFO_SUBTREE_TABLE; 203 return sysinfo_create_path(name + i + 1, 204 &(item->subtree.table)); 125 205 } 126 206 127 //if (subtree->subinfo_type == SYSINFO_SUBINFO_FUNCTION) /* Subinfo managed by subsystem */ 128 // return NULL; 129 130 return NULL; 131 } 132 /* No matches try next or create new*/ 133 if (subtree->next == NULL) { 134 sysinfo_item_t *item = malloc(sizeof(sysinfo_item_t), 0); 135 136 ASSERT(item); 137 subtree->next = item; 138 item->next = NULL; 139 item->val_type = SYSINFO_VAL_UNDEFINED; 140 item->subinfo.table = NULL; 141 142 i = 0; 143 while (name[i] && (name[i] != '.')) 144 i++; 145 146 item->name = malloc(i, 0); 147 ASSERT(item->name); 148 149 for (j = 0; j < i; j++) 150 item->name[j] = name[j]; 151 152 item->name[j] = 0; 153 154 if(name[i]) { /* =='.' */ 155 item->subinfo_type = SYSINFO_SUBINFO_TABLE; 156 return sysinfo_create_path(name + i + 1, &(item->subinfo.table)); 157 } 158 item->subinfo_type = SYSINFO_SUBINFO_NONE; 207 /* No subtree needs to be created */ 159 208 return item; 160 } else 161 subtree = subtree->next; 162 } 163 164 panic("Not reached."); 209 } 210 211 /* Get next sibling */ 212 cur = cur->next; 213 } 214 215 /* Unreachable */ 216 ASSERT(false); 165 217 return NULL; 166 218 } 167 219 168 void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, unative_t val) 169 { 170 if (root == NULL) 171 root = &_root; 172 173 /* If already created create only returns pointer 174 If not, create it */ 220 void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, 221 unative_t val) 222 { 223 if (root == NULL) 224 root = &global_root; 225 175 226 sysinfo_item_t *item = sysinfo_create_path(name, root); 176 177 if (item != NULL) { /* If in subsystem, unable to create or return so unable to set */ 178 item->val.val = val; 227 if (item != NULL) { 179 228 item->val_type = SYSINFO_VAL_VAL; 180 }181 }182 183 void sysinfo_set_item_function(const char *name, sysinfo_item_t **root, sysinfo_val_fn_t fn) 184 { 185 if (root == NULL)186 root = &_root; 187 188 /* If already created create only returns pointer189 If not, create it */229 item->val.val = val; 230 } 231 } 232 233 void sysinfo_set_item_data(const char *name, sysinfo_item_t **root, 234 void *data, size_t size) 235 { 236 if (root == NULL) 237 root = &global_root; 238 190 239 sysinfo_item_t *item = sysinfo_create_path(name, root); 191 192 if (item != NULL) { /* If in subsystem, unable to create or return so unable to set */ 193 item->val.fn = fn; 194 item->val_type = SYSINFO_VAL_FUNCTION; 195 } 196 } 197 240 if (item != NULL) { 241 item->val_type = SYSINFO_VAL_DATA; 242 item->val.data.data = data; 243 item->val.data.size = size; 244 } 245 } 246 247 void sysinfo_set_item_val_fn(const char *name, sysinfo_item_t **root, 248 sysinfo_fn_val_t fn) 249 { 250 if (root == NULL) 251 root = &global_root; 252 253 sysinfo_item_t *item = sysinfo_create_path(name, root); 254 if (item != NULL) { 255 item->val_type = SYSINFO_VAL_FUNCTION_VAL; 256 item->val.fn_val = fn; 257 } 258 } 259 260 void sysinfo_set_item_data_fn(const char *name, sysinfo_item_t **root, 261 sysinfo_fn_data_t fn) 262 { 263 if (root == NULL) 264 root = &global_root; 265 266 sysinfo_item_t *item = sysinfo_create_path(name, root); 267 if (item != NULL) { 268 item->val_type = SYSINFO_VAL_FUNCTION_DATA; 269 item->val.fn_data = fn; 270 } 271 } 198 272 199 273 void sysinfo_set_item_undefined(const char *name, sysinfo_item_t **root) 200 274 { 201 275 if (root == NULL) 202 root = &_root; 203 204 /* If already created create only returns pointer 205 If not, create it */ 276 root = &global_root; 277 206 278 sysinfo_item_t *item = sysinfo_create_path(name, root); 207 208 279 if (item != NULL) 209 280 item->val_type = SYSINFO_VAL_UNDEFINED; 210 281 } 211 282 212 213 void sysinfo_dump(sysinfo_item_t **proot, int depth) 214 { 215 sysinfo_item_t *root; 283 static void sysinfo_indent(unsigned int depth) 284 { 285 unsigned int i; 286 for (i = 0; i < depth; i++) 287 printf(" "); 288 } 289 290 void sysinfo_dump(sysinfo_item_t **proot, unsigned int depth) 291 { 216 292 if (proot == NULL) 217 proot = &_root; 218 219 root = *proot; 220 221 while (root != NULL) { 222 int i; 223 unative_t val = 0; 224 const char *vtype = NULL; 225 226 227 for (i = 0; i < depth; i++) 228 printf(" "); 229 230 switch (root->val_type) { 293 proot = &global_root; 294 295 sysinfo_item_t *cur = *proot; 296 297 while (cur != NULL) { 298 sysinfo_indent(depth); 299 300 unative_t val; 301 size_t size; 302 303 switch (cur->val_type) { 231 304 case SYSINFO_VAL_UNDEFINED: 232 val = 0; 233 vtype = "UND"; 305 printf("+ %s\n", cur->name); 234 306 break; 235 307 case SYSINFO_VAL_VAL: 236 val = root->val.val; 237 vtype = "VAL"; 238 break; 239 case SYSINFO_VAL_FUNCTION: 240 val = ((sysinfo_val_fn_t) (root->val.fn)) (root); 241 vtype = "FUN"; 242 break; 243 } 244 245 printf("%s %s val:%" PRIun "(%" PRIxn ") sub:%s\n", root->name, vtype, val, 246 val, (root->subinfo_type == SYSINFO_SUBINFO_NONE) ? 247 "NON" : ((root->subinfo_type == SYSINFO_SUBINFO_TABLE) ? 248 "TAB" : "FUN")); 249 250 if (root->subinfo_type == SYSINFO_SUBINFO_TABLE) 251 sysinfo_dump(&(root -> subinfo.table), depth + 1); 252 253 root = root->next; 254 } 255 } 256 257 sysinfo_rettype_t sysinfo_get_val(const char *name, sysinfo_item_t **root) 258 { 259 // TODO: Implement Subsystem subinfo (by function implemented subinfo) 260 261 sysinfo_rettype_t ret = {0, false}; 262 263 if (root == NULL) 264 root = &_root; 308 printf("+ %s -> %" PRIun" (%#" PRIxn ")\n", cur->name, 309 cur->val.val, cur->val.val); 310 break; 311 case SYSINFO_VAL_DATA: 312 printf("+ %s (%" PRIs" bytes)\n", cur->name, 313 cur->val.data.size); 314 break; 315 case SYSINFO_VAL_FUNCTION_VAL: 316 val = cur->val.fn_val(cur); 317 printf("+ %s -> %" PRIun" (%#" PRIxn ") [generated]\n", 318 cur->name, val, val); 319 break; 320 case SYSINFO_VAL_FUNCTION_DATA: 321 cur->val.fn_data(cur, &size); 322 printf("+ %s (%" PRIs" bytes) [generated]\n", cur->name, 323 size); 324 break; 325 default: 326 printf("+ %s [unknown]\n", cur->name); 327 } 328 329 switch (cur->subtree_type) { 330 case SYSINFO_SUBTREE_NONE: 331 break; 332 case SYSINFO_SUBTREE_TABLE: 333 sysinfo_dump(&(cur->subtree.table), depth + 1); 334 break; 335 case SYSINFO_SUBTREE_FUNCTION: 336 sysinfo_indent(depth + 1); 337 printf(" [generated subtree]\n"); 338 break; 339 default: 340 sysinfo_indent(depth + 1); 341 printf(" [unknown subtree]\n"); 342 } 343 344 cur = cur->next; 345 } 346 } 347 348 sysinfo_return_t sysinfo_get_item(const char *name, sysinfo_item_t **root) 349 { 350 if (root == NULL) 351 root = &global_root; 265 352 266 353 sysinfo_item_t *item = sysinfo_find_item(name, *root); 354 sysinfo_return_t ret; 267 355 268 356 if (item != NULL) { 269 if (item->val_type == SYSINFO_VAL_UNDEFINED)270 return ret;271 else272 ret.valid = true;273 274 if (item->val_type == SYSINFO_VAL_VAL)357 switch (item->val_type) { 358 case SYSINFO_VAL_UNDEFINED: 359 ret.tag = SYSINFO_VAL_UNDEFINED; 360 break; 361 case SYSINFO_VAL_VAL: 362 ret.tag = SYSINFO_VAL_VAL; 275 363 ret.val = item->val.val; 276 else 277 ret.val = ((sysinfo_val_fn_t) (item->val.fn)) (item); 278 } 364 break; 365 case SYSINFO_VAL_DATA: 366 ret.tag = SYSINFO_VAL_DATA; 367 ret.data = item->val.data; 368 break; 369 case SYSINFO_VAL_FUNCTION_VAL: 370 ret.tag = SYSINFO_VAL_VAL; 371 ret.val = item->val.fn_val(item); 372 break; 373 case SYSINFO_VAL_FUNCTION_DATA: 374 ret.tag = SYSINFO_VAL_DATA; 375 ret.data.data = item->val.fn_data(item, &ret.data.size); 376 break; 377 } 378 } else 379 ret.tag = SYSINFO_VAL_UNDEFINED; 380 279 381 return ret; 280 382 } 281 383 282 #define SYSINFO_MAX_LEN 1024 283 284 unative_t sys_sysinfo_valid(unative_t ptr, unative_t len) 285 { 286 char *str; 287 sysinfo_rettype_t ret = {0, 0}; 288 289 if (len > SYSINFO_MAX_LEN) 290 return ret.valid; 291 str = malloc(len + 1, 0); 292 293 ASSERT(str); 294 if (!((copy_from_uspace(str, (void *) ptr, len + 1)) || (str[len]))) 295 ret = sysinfo_get_val(str, NULL); 296 297 free(str); 298 return ret.valid; 299 } 300 301 unative_t sys_sysinfo_value(unative_t ptr, unative_t len) 302 { 303 char *str; 304 sysinfo_rettype_t ret = {0, 0}; 305 306 if (len > SYSINFO_MAX_LEN) 307 return ret.val; 308 str = malloc(len + 1, 0); 309 310 ASSERT(str); 311 if (!((copy_from_uspace(str, (void *) ptr, len + 1)) || (str[len]))) 312 ret = sysinfo_get_val(str, NULL); 313 314 free(str); 315 return ret.val; 384 static sysinfo_return_t sysinfo_get_item_uspace(void *ptr, size_t size) 385 { 386 sysinfo_return_t ret; 387 ret.tag = SYSINFO_VAL_UNDEFINED; 388 389 if (size > SYSINFO_MAX_PATH) 390 return ret; 391 392 char *path = (char *) malloc(size + 1, 0); 393 ASSERT(path); 394 395 if ((copy_from_uspace(path, ptr, size + 1) == 0) 396 && (path[size] == 0)) { 397 ret = sysinfo_get_item(path, NULL); 398 free(path); 399 } 400 401 return ret; 402 } 403 404 unative_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size) 405 { 406 return (unative_t) sysinfo_get_item_uspace(path_ptr, path_size).tag; 407 } 408 409 unative_t sys_sysinfo_get_value(void *path_ptr, size_t path_size, 410 void *value_ptr) 411 { 412 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size); 413 414 if (ret.tag != SYSINFO_VAL_VAL) 415 return (unative_t) EINVAL; 416 417 return (unative_t) copy_to_uspace(value_ptr, &ret.val, 418 sizeof(ret.val)); 419 } 420 421 unative_t sys_sysinfo_get_data_size(void *path_ptr, size_t path_size, 422 void *size_ptr) 423 { 424 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size); 425 426 if (ret.tag != SYSINFO_VAL_DATA) 427 return (unative_t) EINVAL; 428 429 return (unative_t) copy_to_uspace(size_ptr, &ret.data.size, 430 sizeof(ret.data.size)); 431 } 432 433 unative_t sys_sysinfo_get_data(void *path_ptr, size_t path_size, 434 void *buffer_ptr, size_t buffer_size) 435 { 436 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size); 437 438 if (ret.tag != SYSINFO_VAL_DATA) 439 return (unative_t) EINVAL; 440 441 if (ret.data.size != buffer_size) 442 return ENOMEM; 443 444 return (unative_t) copy_to_uspace(buffer_ptr, ret.data.data, 445 ret.data.size); 316 446 } 317 447 -
uspace/app/bdsh/exec.c
r9256ad29 rd9fae235 121 121 free(found); 122 122 123 tid = task_spawn(tmp, (const char **) argv );123 tid = task_spawn(tmp, (const char **) argv, &retval); 124 124 free(tmp); 125 125 126 126 if (tid == 0) { 127 cli_error(CL_EEXEC, "%s: Cannot spawn `%s'", progname, cmd); 127 cli_error(CL_EEXEC, "%s: Cannot spawn `%s' (%s)", progname, cmd, 128 str_error(retval)); 128 129 return 1; 129 130 } -
uspace/app/getterm/getterm.c
r9256ad29 rd9fae235 40 40 #include <stdio.h> 41 41 #include <task.h> 42 #include <str_error.h> 42 43 #include "version.h" 44 45 #define APP_NAME "getterm" 43 46 44 47 static void usage(void) 45 48 { 46 printf("Usage: getterm <terminal> <path>\n");49 printf("Usage: %s <terminal> <path>\n", APP_NAME); 47 50 } 48 51 … … 76 79 args[1] = NULL; 77 80 78 task_id_t id = task_spawn(fname, args); 81 int err; 82 task_id_t id = task_spawn(fname, args, &err); 79 83 80 84 if (id == 0) 81 printf("Error spawning %s\n", fname); 85 printf("%s: Error spawning %s (%s)\n", APP_NAME, fname, 86 str_error(err)); 82 87 83 88 return id; -
uspace/app/init/init.c
r9256ad29 rd9fae235 48 48 #include <str.h> 49 49 #include <devmap.h> 50 #include <str_error.h> 50 51 #include "init.h" 51 52 53 #define ROOT_DEVICE "bd/initrd" 54 #define ROOT_MOUNT_POINT "/" 55 56 #define DEVFS_FS_TYPE "devfs" 52 57 #define DEVFS_MOUNT_POINT "/dev" 58 59 #define SCRATCH_FS_TYPE "tmpfs" 60 #define SCRATCH_MOUNT_POINT "/scratch" 61 62 #define DATA_FS_TYPE "fat" 63 #define DATA_DEVICE "bd/disk0" 64 #define DATA_MOUNT_POINT "/data" 53 65 54 66 #define SRV_CONSOLE "/srv/console" … … 57 69 static void info_print(void) 58 70 { 59 printf(NAME ": HelenOS init\n"); 71 printf("%s: HelenOS init\n", NAME); 72 } 73 74 static bool mount_report(const char *desc, const char *mntpt, 75 const char *fstype, const char *dev, int rc) 76 { 77 switch (rc) { 78 case EOK: 79 if (dev != NULL) 80 printf("%s: %s mounted on %s (%s at %s)\n", NAME, desc, mntpt, 81 fstype, dev); 82 else 83 printf("%s: %s mounted on %s (%s)\n", NAME, desc, mntpt, fstype); 84 break; 85 case EBUSY: 86 printf("%s: %s already mounted on %s\n", NAME, desc, mntpt); 87 return false; 88 case ELIMIT: 89 printf("%s: %s limit exceeded\n", NAME, desc); 90 return false; 91 case ENOENT: 92 printf("%s: %s unknown type (%s)\n", NAME, desc, fstype); 93 return false; 94 default: 95 printf("%s: %s not mounted on %s (%s)\n", NAME, desc, mntpt, 96 str_error(rc)); 97 return false; 98 } 99 100 return true; 60 101 } 61 102 … … 63 104 { 64 105 const char *opts = ""; 65 const char *root_dev = "bd/initrd";66 106 67 107 if (str_cmp(fstype, "tmpfs") == 0) 68 108 opts = "restore"; 69 109 70 int rc = mount(fstype, "/", root_dev, opts, IPC_FLAG_BLOCKING); 71 72 switch (rc) { 73 case EOK: 74 printf(NAME ": Root filesystem mounted, %s at %s\n", 75 fstype, root_dev); 76 break; 77 case EBUSY: 78 printf(NAME ": Root filesystem already mounted\n"); 79 return false; 80 case ELIMIT: 81 printf(NAME ": Unable to mount root filesystem\n"); 82 return false; 83 case ENOENT: 84 printf(NAME ": Unknown filesystem type (%s)\n", fstype); 85 return false; 86 default: 87 printf(NAME ": Error mounting root filesystem (%d)\n", rc); 88 return false; 89 } 90 91 return true; 110 int rc = mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts, 111 IPC_FLAG_BLOCKING); 112 return mount_report("Root filesystem", ROOT_MOUNT_POINT, fstype, 113 ROOT_DEVICE, rc); 92 114 } 93 115 94 116 static bool mount_devfs(void) 95 117 { 96 int rc = mount("devfs", DEVFS_MOUNT_POINT, "", "", IPC_FLAG_BLOCKING); 97 98 switch (rc) { 99 case EOK: 100 printf(NAME ": Device filesystem mounted\n"); 101 break; 102 case EBUSY: 103 printf(NAME ": Device filesystem already mounted\n"); 104 return false; 105 case ELIMIT: 106 printf(NAME ": Unable to mount device filesystem\n"); 107 return false; 108 case ENOENT: 109 printf(NAME ": Unknown filesystem type (devfs)\n"); 110 return false; 111 default: 112 printf(NAME ": Error mounting device filesystem (%d)\n", rc); 113 return false; 114 } 115 116 return true; 118 int rc = mount(DEVFS_FS_TYPE, DEVFS_MOUNT_POINT, "", "", 119 IPC_FLAG_BLOCKING); 120 return mount_report("Device filesystem", DEVFS_MOUNT_POINT, DEVFS_FS_TYPE, 121 NULL, rc); 117 122 } 118 123 … … 125 130 return; 126 131 127 printf( NAME ": Spawning %s\n", fname);132 printf("%s: Spawning %s\n", NAME, fname); 128 133 129 134 argv[0] = fname; 130 135 argv[1] = NULL; 131 136 132 if (!task_spawn(fname, argv)) 133 printf(NAME ": Error spawning %s\n", fname); 137 int err; 138 if (!task_spawn(fname, argv, &err)) 139 printf("%s: Error spawning %s (%s)\n", NAME, fname, 140 str_error(err)); 134 141 } 135 142 … … 145 152 return; 146 153 147 printf( NAME ": Starting %s\n", fname);154 printf("%s: Starting %s\n", NAME, fname); 148 155 149 156 argv[0] = fname; 150 157 argv[1] = NULL; 151 158 152 id = task_spawn(fname, argv );159 id = task_spawn(fname, argv, &retval); 153 160 if (!id) { 154 printf(NAME ": Error spawning %s\n", fname); 161 printf("%s: Error spawning %s (%s)\n", NAME, fname, 162 str_error(retval)); 155 163 return; 156 164 } 157 165 158 166 rc = task_wait(id, &texit, &retval); 159 167 if (rc != EOK) { 160 printf(NAME ": Error waiting for %s\n", fname); 168 printf("%s: Error waiting for %s (%s(\n", NAME, fname, 169 str_error(retval)); 161 170 return; 162 171 } 163 172 164 173 if ((texit != TASK_EXIT_NORMAL) || (retval != 0)) { 165 printf( NAME ": Server %s failed to start (returned %d)\n",166 fname, retval);174 printf("%s: Server %s failed to start (%s)\n", NAME, 175 fname, str_error(retval)); 167 176 } 168 177 } … … 176 185 snprintf(hid_in, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 177 186 178 printf( NAME ": Spawning %s with %s\n", SRV_CONSOLE, hid_in);187 printf("%s: Spawning %s %s\n", NAME, SRV_CONSOLE, hid_in); 179 188 180 189 /* Wait for the input device to be ready */ … … 187 196 argv[2] = NULL; 188 197 189 if (!task_spawn(SRV_CONSOLE, argv)) 190 printf(NAME ": Error spawning %s with %s\n", SRV_CONSOLE, hid_in); 198 if (!task_spawn(SRV_CONSOLE, argv, &rc)) 199 printf("%s: Error spawning %s %s (%s)\n", NAME, SRV_CONSOLE, 200 hid_in, str_error(rc)); 191 201 } else 192 printf(NAME ": Error waiting on %s\n", hid_in); 202 printf("%s: Error waiting on %s (%s)\n", NAME, hid_in, 203 str_error(rc)); 193 204 } 194 205 … … 201 212 snprintf(term, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 202 213 203 printf( NAME ": Spawning %s with %s %s\n", APP_GETTERM, term, app);214 printf("%s: Spawning %s %s %s\n", NAME, APP_GETTERM, term, app); 204 215 205 216 /* Wait for the terminal device to be ready */ … … 213 224 argv[3] = NULL; 214 225 215 if (!task_spawn(APP_GETTERM, argv ))216 printf( NAME ": Error spawning %s with %s %s\n", APP_GETTERM,217 term, app );226 if (!task_spawn(APP_GETTERM, argv, &rc)) 227 printf("%s: Error spawning %s %s %s (%s)\n", NAME, APP_GETTERM, 228 term, app, str_error(rc)); 218 229 } else 219 printf(NAME ": Error waiting on %s\n", term); 220 } 221 222 static void mount_scratch(void) 223 { 224 int rc; 225 226 printf("Trying to mount null/0 on /scratch... "); 227 fflush(stdout); 228 229 rc = mount("tmpfs", "/scratch", "null/0", "", 0); 230 if (rc == EOK) 231 printf("OK\n"); 232 else 233 printf("Failed\n"); 234 } 235 236 static void mount_data(void) 237 { 238 int rc; 239 240 printf("Trying to mount bd/disk0 on /data... "); 241 fflush(stdout); 242 243 rc = mount("fat", "/data", "bd/disk0", "wtcache", 0); 244 if (rc == EOK) 245 printf("OK\n"); 246 else 247 printf("Failed\n"); 230 printf("%s: Error waiting on %s (%s)\n", NAME, term, 231 str_error(rc)); 232 } 233 234 static bool mount_scratch(void) 235 { 236 int rc = mount(SCRATCH_FS_TYPE, SCRATCH_MOUNT_POINT, "", "", 0); 237 return mount_report("Scratch filesystem", SCRATCH_MOUNT_POINT, 238 SCRATCH_FS_TYPE, NULL, rc); 239 } 240 241 static bool mount_data(void) 242 { 243 int rc = mount(DATA_FS_TYPE, DATA_MOUNT_POINT, DATA_DEVICE, "wtcache", 0); 244 return mount_report("Data filesystem", DATA_MOUNT_POINT, DATA_FS_TYPE, 245 DATA_DEVICE, rc); 248 246 } 249 247 … … 253 251 254 252 if (!mount_root(STRING(RDFMT))) { 255 printf( NAME ": Exiting\n");253 printf("%s: Exiting\n", NAME); 256 254 return -1; 257 255 } 258 256 259 257 /* Make sure tmpfs is running. */ 260 258 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { … … 266 264 267 265 if (!mount_devfs()) { 268 printf( NAME ": Exiting\n");266 printf("%s: Exiting\n", NAME); 269 267 return -2; 270 268 } 271 269 272 270 mount_scratch(); 273 271 … … 278 276 srv_start("/srv/adb_ms"); 279 277 srv_start("/srv/char_ms"); 280 278 281 279 spawn("/srv/fb"); 282 280 spawn("/srv/kbd"); … … 284 282 285 283 spawn("/srv/clip"); 286 284 287 285 /* 288 286 * Start these synchronously so that mount_data() can be … … 295 293 (void) srv_start; 296 294 #endif 297 295 298 296 #ifdef CONFIG_MOUNT_DATA 299 297 mount_data(); … … 301 299 (void) mount_data; 302 300 #endif 303 301 304 302 getterm("term/vc0", "/app/bdsh"); 305 303 getterm("term/vc1", "/app/bdsh"); … … 309 307 getterm("term/vc5", "/app/bdsh"); 310 308 getterm("term/vc6", "/app/klog"); 311 309 312 310 return 0; 313 311 } -
uspace/app/klog/klog.c
r9256ad29 rd9fae235 64 64 int main(int argc, char *argv[]) 65 65 { 66 size_t klog_pages = sysinfo_value("klog.pages"); 66 size_t klog_pages; 67 if (sysinfo_get_value("klog.pages", &klog_pages) != EOK) { 68 printf("%s: Error getting klog address\n", NAME); 69 return -1; 70 } 71 67 72 size_t klog_size = klog_pages * PAGE_SIZE; 68 73 klog_length = klog_size / sizeof(wchar_t); … … 70 75 klog = (wchar_t *) as_get_mappable_page(klog_size); 71 76 if (klog == NULL) { 72 printf( NAME ": Error allocating memory area\n");77 printf("%s: Error allocating memory area\n", NAME); 73 78 return -1; 74 79 } … … 77 82 klog_size, SERVICE_MEM_KLOG); 78 83 if (res != EOK) { 79 printf( NAME ": Error initializing memory area\n");84 printf("%s: Error initializing memory area\n", NAME); 80 85 return -1; 81 86 } 82 87 83 88 if (event_subscribe(EVENT_KLOG, 0) != EOK) { 84 printf( NAME ": Error registering klog notifications\n");89 printf("%s: Error registering klog notifications\n", NAME); 85 90 return -1; 86 91 } -
uspace/app/redir/redir.c
r9256ad29 rd9fae235 42 42 #include <stdio.h> 43 43 #include <task.h> 44 #include <str_error.h> 45 46 #define NAME "redir" 44 47 45 48 static void usage(void) 46 49 { 47 printf("Usage: redir [-i <stdin>] [-o <stdout>] [-e <stderr>] -- <cmd> [args ...]\n"); 50 printf("Usage: %s [-i <stdin>] [-o <stdout>] [-e <stderr>] -- <cmd> [args ...]\n", 51 NAME); 48 52 } 49 53 … … 84 88 args[argc] = NULL; 85 89 86 task_id_t id = task_spawn(argv[0], args); 90 int err; 91 task_id_t id = task_spawn(argv[0], args, &err); 87 92 88 93 free(args); 89 94 90 95 if (id == 0) 91 printf("Error spawning %s\n", argv[0]); 96 printf("%s: Error spawning %s (%s)\n", NAME, argv[0], 97 str_error(err)); 92 98 93 99 return id; -
uspace/app/sbi/src/os/helenos.c
r9256ad29 rd9fae235 35 35 #include <task.h> 36 36 #include <tinput.h> 37 #include <str_error.h> 37 38 38 39 #include "os.h" … … 154 155 int retval; 155 156 156 tid = task_spawn(cmd[0], (char const * const *) cmd );157 tid = task_spawn(cmd[0], (char const * const *) cmd, &retval); 157 158 if (tid == 0) { 158 printf("Error: Failed spawning '%s'.\n", cmd[0]); 159 printf("Error: Failed spawning '%s' (%s).\n", cmd[0], 160 str_error(retval)); 159 161 exit(1); 160 162 } -
uspace/app/trace/syscalls.c
r9256ad29 rd9fae235 75 75 [SYS_PREEMPT_CONTROL] = { "preempt_control", 1, V_ERRNO }, 76 76 77 [SYS_SYSINFO_VALID] = { "sysinfo_valid", 2, V_HASH }, 78 [SYS_SYSINFO_VALUE] = { "sysinfo_value", 2, V_HASH }, 77 [SYS_SYSINFO_GET_TAG] = { "sysinfo_get_tag", 2, V_INTEGER }, 78 [SYS_SYSINFO_GET_VALUE] = { "sysinfo_get_value", 3, V_ERRNO }, 79 [SYS_SYSINFO_GET_DATA_SIZE] = { "sysinfo_get_data_size", 3, V_ERRNO }, 80 [SYS_SYSINFO_GET_DATA] = { "sysinfo_get_data", 4, V_ERRNO }, 81 79 82 [SYS_DEBUG_ENABLE_CONSOLE] = { "debug_enable_console", 0, V_ERRNO }, 80 83 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 1, V_ERRNO } -
uspace/lib/c/arch/ia64/src/ddi.c
r9256ad29 rd9fae235 2 2 #include <sysinfo.h> 3 3 4 uint64_t ia64_iospace_address=0; 5 4 uint64_t ia64_iospace_address = 0; 6 5 7 6 uint64_t get_ia64_iospace_address(void) 8 7 { 9 10 return sysinfo_value("ia64_iospace.address.virtual"); 11 8 sysarg_t addr; 9 if (sysinfo_get_value("ia64_iospace.address.virtual", &addr) != 0) 10 addr = 0; 11 12 return addr; 12 13 } 13 14 -
uspace/lib/c/generic/sysinfo.c
r9256ad29 rd9fae235 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 35 #include <libc.h> 36 36 #include <sysinfo.h> 37 37 #include <str.h> 38 #include <errno.h> 39 #include <malloc.h> 40 #include <bool.h> 38 41 39 sys arg_t sysinfo_value(const char *name)42 sysinfo_item_tag_t sysinfo_get_tag(const char *path) 40 43 { 41 return __SYSCALL2(SYS_SYSINFO_VALUE, (sysarg_t) name, 42 (sysarg_t) str_size(name)); 44 return (sysinfo_item_tag_t) __SYSCALL2(SYS_SYSINFO_GET_TAG, 45 (sysarg_t) path, (sysarg_t) str_size(path)); 46 } 47 48 int sysinfo_get_value(const char *path, sysarg_t *value) 49 { 50 return (int) __SYSCALL3(SYS_SYSINFO_GET_VALUE, (sysarg_t) path, 51 (sysarg_t) str_size(path), (sysarg_t) value); 52 } 53 54 static int sysinfo_get_data_size(const char *path, size_t *size) 55 { 56 return (int) __SYSCALL3(SYS_SYSINFO_GET_DATA_SIZE, (sysarg_t) path, 57 (sysarg_t) str_size(path), (sysarg_t) size); 58 } 59 60 extern void *sysinfo_get_data(const char *path, size_t *size) 61 { 62 while (true) { 63 int ret = sysinfo_get_data_size(path, size); 64 if (ret != EOK) 65 return NULL; 66 67 void *data = malloc(*size); 68 if (data == NULL) 69 return NULL; 70 71 ret = __SYSCALL4(SYS_SYSINFO_GET_DATA, (sysarg_t) path, 72 (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size); 73 if (ret == EOK) 74 return data; 75 76 if (ret != ENOMEM) 77 return NULL; 78 79 free(data); 80 } 43 81 } 44 82 -
uspace/lib/c/generic/task.c
r9256ad29 rd9fae235 70 70 * loader API. 71 71 * 72 * @param path pathname of the binary to execute 73 * @param argv command-line arguments 72 * @param path Pathname of the binary to execute. 73 * @param argv Command-line arguments. 74 * @param err If not NULL, the error value is stored here. 74 75 * 75 76 * @return ID of the newly created task or zero on error. 76 77 * 77 78 */ 78 task_id_t task_spawn(const char *path, const char *const args[] )79 task_id_t task_spawn(const char *path, const char *const args[], int *err) 79 80 { 80 81 /* Connect to a program loader. */ 81 82 loader_t *ldr = loader_connect(); 82 if (ldr == NULL) 83 if (ldr == NULL) { 84 if (err != NULL) 85 *err = EREFUSED; 86 83 87 return 0; 88 } 84 89 85 90 /* Get task ID. */ … … 143 148 /* Success */ 144 149 free(ldr); 150 151 if (err != NULL) 152 *err = EOK; 153 145 154 return task_id; 146 155 … … 149 158 loader_abort(ldr); 150 159 free(ldr); 160 161 if (err != NULL) 162 *err = rc; 151 163 152 164 return 0; -
uspace/lib/c/include/sysinfo.h
r9256ad29 rd9fae235 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 35 #ifndef LIBC_SYSINFO_H_ … … 37 37 38 38 #include <libc.h> 39 #include <sysinfo.h>40 #include <str.h>41 39 42 sysarg_t sysinfo_value(const char *name); 40 typedef enum { 41 SYSINFO_VAL_UNDEFINED = 0, 42 SYSINFO_VAL_VAL = 1, 43 SYSINFO_VAL_DATA = 2 44 } sysinfo_item_tag_t; 45 46 extern sysinfo_item_tag_t sysinfo_get_tag(const char *); 47 extern int sysinfo_get_value(const char *, sysarg_t *); 48 extern void *sysinfo_get_data(const char *, size_t *); 43 49 44 50 #endif -
uspace/lib/c/include/task.h
r9256ad29 rd9fae235 46 46 47 47 extern task_id_t task_get_id(void); 48 extern int task_set_name(const char *name); 49 extern task_id_t task_spawn(const char *path, const char *const argv[]); 50 extern int task_wait(task_id_t id, task_exit_t *texit, int *retval); 51 extern int task_retval(int val); 52 48 extern int task_set_name(const char *); 49 extern task_id_t task_spawn(const char *, const char *const[], int *); 50 extern int task_wait(task_id_t id, task_exit_t *, int *); 51 extern int task_retval(int); 53 52 54 53 #endif -
uspace/lib/net/adt/module_map.c
r9256ad29 rd9fae235 94 94 } 95 95 96 task_id_t spawn(const char * fname){ 97 const char * argv[2]; 96 task_id_t spawn(const char *fname) 97 { 98 const char *argv[2]; 98 99 task_id_t res; 99 100 100 101 argv[0] = fname; 101 102 argv[1] = NULL; 102 res = task_spawn(fname, argv );103 103 res = task_spawn(fname, argv, NULL); 104 104 105 return res; 105 106 } -
uspace/srv/bd/rd/rd.c
r9256ad29 rd9fae235 32 32 /** @addtogroup rd 33 33 * @{ 34 */ 34 */ 35 35 36 36 /** 37 * @file 38 * @brief 37 * @file rd.c 38 * @brief Initial RAM disk for HelenOS. 39 39 */ 40 40 … … 61 61 /** Pointer to the ramdisk's image */ 62 62 static void *rd_addr; 63 63 64 /** Size of the ramdisk */ 64 65 static size_t rd_size; … … 70 71 static int rd_write_blocks(uint64_t ba, size_t cnt, const void *buf); 71 72 72 /** 73 * This rwlock protects the ramdisk's data.73 /** This rwlock protects the ramdisk's data. 74 * 74 75 * If we were to serve multiple requests (read + write or several writes) 75 * concurrently (i.e. from two or more threads), each read and write needs to be 76 * protected by this rwlock. 77 */ 76 * concurrently (i.e. from two or more threads), each read and write needs to 77 * be protected by this rwlock. 78 * 79 */ 78 80 fibril_rwlock_t rd_lock; 79 81 80 82 /** Handle one connection to ramdisk. 81 83 * 82 * @param iid 83 * @param icall 84 * @param iid Hash of the request that opened the connection. 85 * @param icall Call data of the request that opened the connection. 84 86 */ 85 87 static void rd_connection(ipc_callid_t iid, ipc_call_t *icall) … … 92 94 size_t cnt; 93 95 size_t comm_size; 94 96 95 97 /* 96 98 * Answer the first IPC_M_CONNECT_ME_TO call. 97 99 */ 98 100 ipc_answer_0(iid, EOK); 99 101 100 102 /* 101 103 * Now we wait for the client to send us its communication as_area. … … 108 110 } else { 109 111 ipc_answer_0(callid, EHANGUP); 110 return; 112 return; 111 113 } 112 114 } else { … … 178 180 return ELIMIT; 179 181 } 180 182 181 183 fibril_rwlock_read_lock(&rd_lock); 182 184 memcpy(buf, rd_addr + ba * block_size, block_size * cnt); 183 185 fibril_rwlock_read_unlock(&rd_lock); 184 186 185 187 return EOK; 186 188 } … … 193 195 return ELIMIT; 194 196 } 195 197 196 198 fibril_rwlock_write_lock(&rd_lock); 197 199 memcpy(rd_addr + ba * block_size, buf, block_size * cnt); 198 200 fibril_rwlock_write_unlock(&rd_lock); 199 201 200 202 return EOK; 201 203 } … … 204 206 static bool rd_init(void) 205 207 { 206 rd_size = sysinfo_value("rd.size"); 207 void *rd_ph_addr = (void *) sysinfo_value("rd.address.physical"); 208 209 if (rd_size == 0) { 210 printf(NAME ": No RAM disk found\n"); 208 int ret = sysinfo_get_value("rd.size", &rd_size); 209 if ((ret != EOK) || (rd_size == 0)) { 210 printf("%s: No RAM disk found\n", NAME); 211 return false; 212 } 213 214 sysarg_t rd_ph_addr; 215 ret = sysinfo_get_value("rd.address.physical", &rd_ph_addr); 216 if ((ret != EOK) || (rd_ph_addr == 0)) { 217 printf("%s: Invalid RAM disk physical address\n", NAME); 211 218 return false; 212 219 } … … 215 222 216 223 int flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE; 217 int retval = physmem_map( rd_ph_addr, rd_addr,224 int retval = physmem_map((void *) rd_ph_addr, rd_addr, 218 225 ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags); 219 226 220 227 if (retval < 0) { 221 printf( NAME ": Error mapping RAM disk\n");222 return false; 223 } 224 225 printf( NAME ": Found RAM disk at %p, %d bytes\n", rd_ph_addr, rd_size);228 printf("%s: Error mapping RAM disk\n", NAME); 229 return false; 230 } 231 232 printf("%s: Found RAM disk at %p, %d bytes\n", NAME, rd_ph_addr, rd_size); 226 233 227 234 int rc = devmap_driver_register(NAME, rd_connection); 228 235 if (rc < 0) { 229 printf( NAME ": Unable to register driver (%d)\n", rc);236 printf("%s: Unable to register driver (%d)\n", NAME, rc); 230 237 return false; 231 238 } … … 234 241 if (devmap_device_register("bd/initrd", &dev_handle) != EOK) { 235 242 devmap_hangup_phone(DEVMAP_DRIVER); 236 printf( NAME ": Unable to register device\n");243 printf("%s: Unable to register device\n", NAME); 237 244 return false; 238 245 } … … 245 252 int main(int argc, char **argv) 246 253 { 247 printf( NAME ": HelenOS RAM disk server\n");254 printf("%s: HelenOS RAM disk server\n", NAME); 248 255 249 256 if (!rd_init()) 250 257 return -1; 251 258 252 printf( NAME ": Accepting connections\n");259 printf("%s: Accepting connections\n", NAME); 253 260 async_manager(); 254 261 -
uspace/srv/hid/fb/ega.c
r9256ad29 rd9fae235 415 415 void *ega_ph_addr; 416 416 size_t sz; 417 418 ega_ph_addr = (void *) sysinfo_value("fb.address.physical"); 419 scr_width = sysinfo_value("fb.width"); 420 scr_height = sysinfo_value("fb.height"); 421 422 if (sysinfo_value("fb.blinking")) { 417 418 sysarg_t paddr; 419 if (sysinfo_get_value("fb.address.physical", &paddr) != EOK) 420 return -1; 421 422 sysarg_t width; 423 if (sysinfo_get_value("fb.width", &width) != EOK) 424 return -1; 425 426 sysarg_t height; 427 if (sysinfo_get_value("fb.width", &height) != EOK) 428 return -1; 429 430 sysarg_t blinking; 431 if (sysinfo_get_value("fb.blinking", &blinking) != EOK) 432 blinking = false; 433 434 ega_ph_addr = (void *) paddr; 435 scr_width = width; 436 scr_height = height; 437 if (blinking) { 423 438 ega_normal_color &= 0x77; 424 439 ega_inverted_color &= 0x77; 425 440 } 426 441 427 442 style = NORMAL_COLOR; 428 443 429 444 iospace_enable(task_get_id(), (void *) EGA_IO_BASE, 2); 430 445 431 446 sz = scr_width * scr_height * 2; 432 447 scr_addr = as_get_mappable_page(sz); 433 448 434 449 if (physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> 435 450 PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0) -
uspace/srv/hid/fb/fb.c
r9256ad29 rd9fae235 1756 1756 async_set_client_connection(fb_client_connection); 1757 1757 1758 void *fb_ph_addr = (void *) sysinfo_value("fb.address.physical"); 1759 unsigned int fb_offset = sysinfo_value("fb.offset"); 1760 unsigned int fb_width = sysinfo_value("fb.width"); 1761 unsigned int fb_height = sysinfo_value("fb.height"); 1762 unsigned int fb_scanline = sysinfo_value("fb.scanline"); 1763 unsigned int fb_visual = sysinfo_value("fb.visual"); 1764 1765 unsigned int fbsize = fb_scanline * fb_height; 1758 sysarg_t fb_ph_addr; 1759 if (sysinfo_get_value("fb.address.physical", &fb_ph_addr) != EOK) 1760 return -1; 1761 1762 sysarg_t fb_offset; 1763 if (sysinfo_get_value("fb.offset", &fb_offset) != EOK) 1764 fb_offset = 0; 1765 1766 sysarg_t fb_width; 1767 if (sysinfo_get_value("fb.width", &fb_width) != EOK) 1768 return -1; 1769 1770 sysarg_t fb_height; 1771 if (sysinfo_get_value("fb.height", &fb_height) != EOK) 1772 return -1; 1773 1774 sysarg_t fb_scanline; 1775 if (sysinfo_get_value("fb.scanline", &fb_scanline) != EOK) 1776 return -1; 1777 1778 sysarg_t fb_visual; 1779 if (sysinfo_get_value("fb.visual", &fb_visual) != EOK) 1780 return -1; 1781 1782 sysarg_t fbsize = fb_scanline * fb_height; 1766 1783 void *fb_addr = as_get_mappable_page(fbsize); 1767 1768 if (physmem_map( fb_ph_addr + fb_offset, fb_addr,1784 1785 if (physmem_map((void *) fb_ph_addr + fb_offset, fb_addr, 1769 1786 ALIGN_UP(fbsize, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0) 1770 1787 return -1; 1771 1788 1772 1789 if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual)) 1773 1790 return 0; 1774 1791 1775 1792 return -1; 1776 1793 } -
uspace/srv/hid/fb/main.c
r9256ad29 rd9fae235 60 60 int main(int argc, char *argv[]) 61 61 { 62 printf( NAME ": HelenOS Framebuffer service\n");62 printf("%s: HelenOS Framebuffer service\n", NAME); 63 63 64 ipcarg_t phonead;65 64 bool initialized = false; 65 sysarg_t fb_present; 66 sysarg_t fb_kind; 67 68 if (sysinfo_get_value("fb", &fb_present) != EOK) 69 fb_present = false; 70 71 if (sysinfo_get_value("fb.kind", &fb_kind) != EOK) { 72 printf("%s: Unable to detect framebuffer configuration\n", NAME); 73 return -1; 74 } 66 75 67 76 #ifdef FB_ENABLED 68 if ( sysinfo_value("fb.kind") == 1) {77 if ((!initialized) && (fb_kind == 1)) { 69 78 if (fb_init() == 0) 70 79 initialized = true; … … 72 81 #endif 73 82 #ifdef EGA_ENABLED 74 if ((!initialized) && ( sysinfo_value("fb.kind")== 2)) {83 if ((!initialized) && (fb_kind == 2)) { 75 84 if (ega_init() == 0) 76 85 initialized = true; … … 78 87 #endif 79 88 #ifdef MSIM_ENABLED 80 if ((!initialized) && ( sysinfo_value("fb.kind")== 3)) {89 if ((!initialized) && (fb_kind == 3)) { 81 90 if (msim_init() == 0) 82 91 initialized = true; … … 84 93 #endif 85 94 #ifdef SGCN_ENABLED 86 if ((!initialized) && ( sysinfo_value("fb.kind")== 4)) {95 if ((!initialized) && (fb_kind == 4)) { 87 96 if (sgcn_init() == 0) 88 97 initialized = true; … … 90 99 #endif 91 100 #ifdef NIAGARA_ENABLED 92 if ((!initialized) && ( sysinfo_value("fb.kind")== 5)) {101 if ((!initialized) && (fb_kind == 5)) { 93 102 if (niagara_init() == 0) 94 103 initialized = true; … … 96 105 #endif 97 106 #ifdef SKI_ENABLED 98 if ((!initialized) && ( sysinfo_value("fb") != true)) {107 if ((!initialized) && (!fb_present)) { 99 108 if (ski_init() == 0) 100 109 initialized = true; … … 105 114 return -1; 106 115 116 ipcarg_t phonead; 107 117 if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, &phonead) != 0) 108 118 return -1; 109 119 110 printf( NAME ": Accepting connections\n");120 printf("%s: Accepting connections\n", NAME); 111 121 async_manager(); 112 122 -
uspace/srv/hid/fb/msim.c
r9256ad29 rd9fae235 29 29 30 30 /** @defgroup msimfb MSIM text console 31 * @brief 31 * @brief HelenOS MSIM text console. 32 32 * @ingroup fbs 33 33 * @{ 34 */ 34 */ 35 35 /** @file 36 36 */ … … 41 41 #include <as.h> 42 42 #include <ddi.h> 43 #include <errno.h> 43 44 44 45 #include "serial_console.h" … … 57 58 int msim_init(void) 58 59 { 59 void *phys_addr = (void *) sysinfo_value("fb.address.physical"); 60 sysarg_t phys_addr; 61 if (sysinfo_get_value("fb.address.physical", &phys_addr) != EOK) 62 return -1; 63 60 64 virt_addr = (char *) as_get_mappable_page(1); 61 65 62 if (physmem_map(phys_addr, virt_addr, 1, AS_AREA_READ | AS_AREA_WRITE) != 0) 66 if (physmem_map((void *) phys_addr, virt_addr, 1, 67 AS_AREA_READ | AS_AREA_WRITE) != 0) 63 68 return -1; 64 69 … … 69 74 } 70 75 71 /** 72 * @} 76 /** @} 73 77 */ -
uspace/srv/hid/fb/niagara.c
r9256ad29 rd9fae235 91 91 int niagara_init(void) 92 92 { 93 sysarg_t paddr; 94 if (sysinfo_get_value("niagara.outbuf.address", &paddr) != EOK) 95 return -1; 96 93 97 output_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE); 94 int result = physmem_map( 95 (void *) sysinfo_value("niagara.outbuf.address"), 96 (void *) output_buffer_addr, 97 1, AS_AREA_READ | AS_AREA_WRITE); 98 int result = physmem_map((void *) paddr, 99 (void *) output_buffer_addr, 1, 100 AS_AREA_READ | AS_AREA_WRITE); 98 101 99 102 if (result != 0) { -
uspace/srv/hid/fb/sgcn.c
r9256ad29 rd9fae235 122 122 int sgcn_init(void) 123 123 { 124 sram_virt_addr = (uintptr_t) as_get_mappable_page(sysinfo_value("sram.area.size")); 124 sysarg_t sram_paddr; 125 if (sysinfo_get_value("sram.address.physical", &sram_paddr) != EOK) 126 return -1; 125 127 126 if (physmem_map((void *) sysinfo_value("sram.address.physical"), 127 (void *) sram_virt_addr, sysinfo_value("sram.area.size") / PAGE_SIZE, 128 AS_AREA_READ | AS_AREA_WRITE) != 0) 128 sysarg_t sram_size; 129 if (sysinfo_get_value("sram.area.size", &sram_size) != EOK) 130 return -1; 131 132 if (sysinfo_get_value("sram.buffer.offset", &sram_buffer_offset) != EOK) 133 sram_buffer_offset = 0; 134 135 sram_virt_addr = (uintptr_t) as_get_mappable_page(sram_size); 136 137 if (physmem_map((void *) sram_paddr, (void *) sram_virt_addr, 138 sram_size / PAGE_SIZE, AS_AREA_READ | AS_AREA_WRITE) != 0) 129 139 return -1; 130 140 131 141 serial_console_init(sgcn_putc, WIDTH, HEIGHT); 132 133 sram_buffer_offset = sysinfo_value("sram.buffer.offset");134 142 135 143 async_set_client_connection(serial_client_connection); -
uspace/srv/hid/kbd/generic/kbd.c
r9256ad29 rd9fae235 212 212 int main(int argc, char **argv) 213 213 { 214 printf(NAME ": HelenOS Keyboard service\n"); 215 216 if (sysinfo_value("kbd.cir.fhc") == 1) 214 printf("%s: HelenOS Keyboard service\n", NAME); 215 216 sysarg_t fhc; 217 sysarg_t obio; 218 219 if ((sysinfo_get_value("kbd.cir.fhc", &fhc) == EOK) && (fhc)) 217 220 cir_service = SERVICE_FHC; 218 else if ( sysinfo_value("kbd.cir.obio") == 1)221 else if ((sysinfo_get_value("kbd.cir.obio", &obio) == EOK) && (obio)) 219 222 cir_service = SERVICE_OBIO; 220 223 … … 240 243 int rc = devmap_driver_register(NAME, client_connection); 241 244 if (rc < 0) { 242 printf( NAME ": Unable to register driver (%d)\n", rc);245 printf("%s: Unable to register driver (%d)\n", NAME, rc); 243 246 return -1; 244 247 } … … 249 252 dev_handle_t dev_handle; 250 253 if (devmap_device_register(kbd, &dev_handle) != EOK) { 251 printf( NAME ": Unable to register device %s\n", kbd);254 printf("%s: Unable to register device %s\n", NAME, kbd); 252 255 return -1; 253 256 } -
uspace/srv/hid/kbd/port/gxemul.c
r9256ad29 rd9fae235 41 41 #include <kbd.h> 42 42 #include <ddi.h> 43 #include <errno.h> 43 44 44 45 static irq_cmd_t gxemul_cmds[] = { … … 63 64 int kbd_port_init(void) 64 65 { 66 sysarg_t addr; 67 if (sysinfo_get_value("kbd.address.virtual", &addr) != EOK) 68 return -1; 69 70 sysarg_t inr; 71 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 72 return -1; 73 65 74 async_set_interrupt_received(gxemul_irq_handler); 66 gxemul_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual"); 67 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 68 0, &gxemul_kbd); 75 gxemul_cmds[0].addr = (void *) addr; 76 ipc_register_irq(inr, device_assign_devno(), 0, &gxemul_kbd); 69 77 return 0; 70 78 } -
uspace/srv/hid/kbd/port/msim.c
r9256ad29 rd9fae235 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 * @brief 34 * @brief Msim keyboard port driver. 35 35 */ 36 36 … … 41 41 #include <kbd.h> 42 42 #include <ddi.h> 43 #include <errno.h> 43 44 44 45 irq_cmd_t msim_cmds[] = { … … 63 64 int kbd_port_init(void) 64 65 { 66 sysarg_t vaddr; 67 if (sysinfo_get_value("kbd.address.virtual", &vaddr) != EOK) 68 return -1; 69 70 sysarg_t inr; 71 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 72 return -1; 73 74 msim_cmds[0].addr = (void *) vaddr; 65 75 async_set_interrupt_received(msim_irq_handler); 66 msim_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual"); 67 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 68 0, &msim_kbd); 76 ipc_register_irq(inr, device_assign_devno(), 0, &msim_kbd); 77 69 78 return 0; 70 79 } -
uspace/srv/hid/kbd/port/niagara.c
r9256ad29 rd9fae235 44 44 #include <thread.h> 45 45 #include <bool.h> 46 #include <errno.h> 46 47 47 #define POLL_INTERVAL 48 #define POLL_INTERVAL 10000 48 49 49 50 /** … … 57 58 * kernel/arch/sparc64/src/drivers/niagara.c. 58 59 */ 59 #define INPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 60 #define INPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 61 60 62 typedef volatile struct { 61 63 uint64_t write_ptr; … … 79 81 int kbd_port_init(void) 80 82 { 83 sysarg_t paddr; 84 if (sysinfo_get_value("niagara.inbuf.address", &paddr) != EOK) 85 return -1; 86 81 87 input_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE); 82 int result = physmem_map( 83 (void *) sysinfo_value("niagara.inbuf.address"), 84 (void *) input_buffer_addr, 85 1, AS_AREA_READ | AS_AREA_WRITE); 86 87 if (result != 0) { 88 int rc = physmem_map((void *) paddr, (void *) input_buffer_addr, 89 1, AS_AREA_READ | AS_AREA_WRITE); 90 91 if (rc != 0) { 88 92 printf("Niagara: uspace driver couldn't map physical memory: %d\n", 89 result); 90 } 91 92 input_buffer = (input_buffer_t) input_buffer_addr; 93 94 thread_id_t tid; 95 int rc; 96 97 rc = thread_create(niagara_thread_impl, NULL, "kbd_poll", &tid); 98 if (rc != 0) { 93 rc); 99 94 return rc; 100 95 } 96 97 input_buffer = (input_buffer_t) input_buffer_addr; 98 99 thread_id_t tid; 100 rc = thread_create(niagara_thread_impl, NULL, "kbd_poll", &tid); 101 if (rc != 0) 102 return rc; 103 101 104 return 0; 102 105 } -
uspace/srv/hid/kbd/port/ns16550.c
r9256ad29 rd9fae235 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 * @brief 34 * @brief NS16550 port driver. 35 35 */ 36 36 … … 43 43 #include <sun.h> 44 44 #include <ddi.h> 45 #include <errno.h> 45 46 46 47 /* NS16550 registers */ 47 #define RBR_REG 0/** Receiver Buffer Register. */48 #define IER_REG 1/** Interrupt Enable Register. */49 #define IIR_REG 2/** Interrupt Ident Register (read). */50 #define FCR_REG 2/** FIFO control register (write). */51 #define LCR_REG 3/** Line Control register. */52 #define MCR_REG 4/** Modem Control Register. */53 #define LSR_REG 5/** Line Status Register. */48 #define RBR_REG 0 /** Receiver Buffer Register. */ 49 #define IER_REG 1 /** Interrupt Enable Register. */ 50 #define IIR_REG 2 /** Interrupt Ident Register (read). */ 51 #define FCR_REG 2 /** FIFO control register (write). */ 52 #define LCR_REG 3 /** Line Control register. */ 53 #define MCR_REG 4 /** Modem Control Register. */ 54 #define LSR_REG 5 /** Line Status Register. */ 54 55 55 #define LSR_DATA_READY 56 #define LSR_DATA_READY 0x01 56 57 57 58 static irq_cmd_t ns16550_cmds[] = { 58 59 { 59 60 .cmd = CMD_PIO_READ_8, 60 .addr = (void *) 0, /* will be patched in run-time */61 .addr = (void *) 0, /* Will be patched in run-time */ 61 62 .dstarg = 1 62 63 }, … … 74 75 { 75 76 .cmd = CMD_PIO_READ_8, 76 .addr = (void *) 0, /* will be patched in run-time */77 .addr = (void *) 0, /* Will be patched in run-time */ 77 78 .dstarg = 2 78 79 }, … … 96 97 void *vaddr; 97 98 98 async_set_interrupt_received(ns16550_irq_handler); 99 100 ns16550_physical = sysinfo_value("kbd.address.physical"); 101 ns16550_kernel = sysinfo_value("kbd.address.kernel"); 99 if (sysinfo_get_value("kbd.address.physical", &ns16550_physical) != EOK) 100 return -1; 101 102 if (sysinfo_get_value("kbd.address.kernel", &ns16550_kernel) != EOK) 103 return -1; 104 105 sysarg_t inr; 106 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 107 return -1; 108 102 109 ns16550_kbd.cmds[0].addr = (void *) (ns16550_kernel + LSR_REG); 103 110 ns16550_kbd.cmds[3].addr = (void *) (ns16550_kernel + RBR_REG); 104 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 105 sysinfo_value("kbd.inr"), &ns16550_kbd); 111 112 async_set_interrupt_received(ns16550_irq_handler); 113 ipc_register_irq(inr, device_assign_devno(), inr, &ns16550_kbd); 114 106 115 return pio_enable((void *) ns16550_physical, 8, &vaddr); 107 116 } -
uspace/srv/hid/kbd/port/pl050.c
r9256ad29 rd9fae235 83 83 int kbd_port_init(void) 84 84 { 85 86 pl050_kbd.cmds[0].addr = (void *) sysinfo_value("kbd.address.status"); 87 pl050_kbd.cmds[3].addr = (void *) sysinfo_value("kbd.address.data"); 88 85 if (sysinfo_get_value("kbd.address.status", &pl050_kbd.cmds[0].addr) != EOK) 86 return -1; 87 88 if (sysinfo_get_value("kbd.address.data", &pl050_kbd.cmds[3].addr) != EOK) 89 return -1; 90 91 sysarg_t inr; 92 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 93 return -1; 94 89 95 async_set_interrupt_received(pl050_irq_handler); 90 91 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 0, &pl050_kbd); 92 96 ipc_register_irq(inr, device_assign_devno(), 0, &pl050_kbd); 97 93 98 return 0; 94 99 } -
uspace/srv/hid/kbd/port/sgcn.c
r9256ad29 rd9fae235 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 * @brief 34 * @brief SGCN (Serengeti Console) keyboard port driver. 35 35 */ 36 36 … … 44 44 #include <thread.h> 45 45 #include <bool.h> 46 #include <errno.h> 46 47 47 #define POLL_INTERVAL 48 #define POLL_INTERVAL 10000 48 49 49 50 /** 50 51 * SGCN buffer header. It is placed at the very beginning of the SGCN 51 * buffer. 52 * buffer. 52 53 */ 53 54 typedef struct { … … 102 103 int kbd_port_init(void) 103 104 { 104 sram_virt_addr = (uintptr_t) as_get_mappable_page(sysinfo_value("sram.area.size")); 105 if (physmem_map((void *) sysinfo_value("sram.address.physical"), 106 (void *) sram_virt_addr, sysinfo_value("sram.area.size") / PAGE_SIZE, 107 AS_AREA_READ | AS_AREA_WRITE) != 0) { 105 sysarg_t sram_paddr; 106 if (sysinfo_get_value("sram.address.physical", &sram_paddr) != EOK) 107 return -1; 108 109 sysarg_t sram_size; 110 if (sysinfo_get_value("sram.area.size", &sram_size) != EOK) 111 return -1; 112 113 if (sysinfo_get_value("sram.buffer.offset", &sram_buffer_offset) != EOK) 114 sram_buffer_offset = 0; 115 116 sram_virt_addr = (uintptr_t) as_get_mappable_page(sram_size); 117 118 if (physmem_map((void *) sram_paddr, (void *) sram_virt_addr, 119 sram_size / PAGE_SIZE, AS_AREA_READ | AS_AREA_WRITE) != 0) { 108 120 printf("SGCN: uspace driver could not map physical memory."); 109 121 return -1; 110 122 } 111 123 112 sram_buffer_offset = sysinfo_value("sram.buffer.offset");113 114 124 thread_id_t tid; 115 int rc; 116 117 rc = thread_create(sgcn_thread_impl, NULL, "kbd_poll", &tid); 118 if (rc != 0) { 125 int rc = thread_create(sgcn_thread_impl, NULL, "kbd_poll", &tid); 126 if (rc != 0) 119 127 return rc; 120 } 121 128 122 129 return 0; 123 130 } -
uspace/srv/hid/kbd/port/sun.c
r9256ad29 rd9fae235 39 39 #include <sun.h> 40 40 #include <sysinfo.h> 41 #include <errno.h> 42 #include <bool.h> 41 43 42 44 /** Sun keyboard virtual port driver. … … 50 52 int kbd_port_init(void) 51 53 { 52 if (sysinfo_value("kbd.type.z8530")) { 54 sysarg_t z8530; 55 if (sysinfo_get_value("kbd.type.z8530", &z8530) != EOK) 56 z8530 = false; 57 58 sysarg_t ns16550; 59 if (sysinfo_get_value("kbd.type.ns16550", &ns16550) != EOK) 60 ns16550 = false; 61 62 if (z8530) { 53 63 if (z8530_port_init() == 0) 54 64 return 0; 55 65 } 56 66 57 if ( sysinfo_value("kbd.type.ns16550")) {67 if (ns16550) { 58 68 if (ns16550_port_init() == 0) 59 69 return 0; -
uspace/srv/hid/kbd/port/z8530.c
r9256ad29 rd9fae235 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 * @brief 34 * @brief Z8530 keyboard port driver. 35 35 */ 36 36 … … 44 44 #include <sys/types.h> 45 45 #include <ddi.h> 46 #include <errno.h> 46 47 47 #define CHAN_A_STATUS 48 #define CHAN_A_DATA 48 #define CHAN_A_STATUS 4 49 #define CHAN_A_DATA 6 49 50 50 #define RR0_RCA 51 #define RR0_RCA 1 51 52 52 53 static irq_cmd_t z8530_cmds[] = { 53 54 { 54 55 .cmd = CMD_PIO_READ_8, 55 .addr = (void *) 0, /* will be patched in run-time */56 .addr = (void *) 0, /* Will be patched in run-time */ 56 57 .dstarg = 1 57 58 }, … … 69 70 { 70 71 .cmd = CMD_PIO_READ_8, 71 .addr = (void *) 0, /* will be patched in run-time */72 .addr = (void *) 0, /* Will be patched in run-time */ 72 73 .dstarg = 2 73 74 }, … … 86 87 int z8530_port_init(void) 87 88 { 89 sysarg_t kaddr; 90 if (sysinfo_get_value("kbd.address.kernel", &kaddr) != EOK) 91 return -1; 92 93 sysarg_t inr; 94 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 95 return -1; 96 97 z8530_cmds[0].addr = (void *) kaddr + CHAN_A_STATUS; 98 z8530_cmds[3].addr = (void *) kaddr + CHAN_A_DATA; 99 88 100 async_set_interrupt_received(z8530_irq_handler); 89 z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.kernel") + 90 CHAN_A_STATUS; 91 z8530_cmds[3].addr = (void *) sysinfo_value("kbd.address.kernel") + 92 CHAN_A_DATA; 93 ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 94 sysinfo_value("kbd.inr"), &z8530_kbd); 101 ipc_register_irq(inr, device_assign_devno(), inr, &z8530_kbd); 102 95 103 return 0; 96 104 } -
uspace/srv/hw/bus/cuda_adb/cuda_adb.c
r9256ad29 rd9fae235 254 254 static int cuda_init(void) 255 255 { 256 if (sysinfo_get_value("cuda.address.physical", &(instance->cuda_physical)) != EOK) 257 return -1; 258 259 if (sysinfo_get_value("cuda.address.kernel", &(instance->cuda_kernel)) != EOK) 260 return -1; 261 256 262 void *vaddr; 257 258 instance->cuda_physical = sysinfo_value("cuda.address.physical");259 instance->cuda_kernel = sysinfo_value("cuda.address.kernel");260 261 263 if (pio_enable((void *) instance->cuda_physical, sizeof(cuda_t), &vaddr) != 0) 262 264 return -1; 265 263 266 dev = vaddr; 264 267 -
uspace/srv/hw/char/i8042/i8042.c
r9256ad29 rd9fae235 164 164 static int i8042_init(void) 165 165 { 166 if (sysinfo_get_value("i8042.address.physical", &i8042_physical) != EOK) 167 return -1; 168 169 if (sysinfo_get_value("i8042.address.kernel", &i8042_kernel) != EOK) 170 return -1; 171 166 172 void *vaddr; 167 168 i8042_physical = sysinfo_value("i8042.address.physical");169 i8042_kernel = sysinfo_value("i8042.address.kernel");170 173 if (pio_enable((void *) i8042_physical, sizeof(i8042_t), &vaddr) != 0) 171 174 return -1; 175 172 176 i8042 = vaddr; 173 177 178 sysarg_t inr_a; 179 sysarg_t inr_b; 180 181 if (sysinfo_get_value("i8042.inr_a", &inr_a) != EOK) 182 return -1; 183 184 if (sysinfo_get_value("i8042.inr_b", &inr_b) != EOK) 185 return -1; 186 174 187 async_set_interrupt_received(i8042_irq_handler); 175 188 176 189 /* Disable kbd and aux */ 177 190 wait_ready(); … … 186 199 i8042_kbd.cmds[0].addr = (void *) &((i8042_t *) i8042_kernel)->status; 187 200 i8042_kbd.cmds[3].addr = (void *) &((i8042_t *) i8042_kernel)->data; 188 ipc_register_irq(sysinfo_value("i8042.inr_a"), device_assign_devno(), 0, &i8042_kbd); 189 ipc_register_irq(sysinfo_value("i8042.inr_b"), device_assign_devno(), 0, &i8042_kbd); 190 printf("i8042: registered for interrupts %d and %d\n", 191 sysinfo_value("i8042.inr_a"), sysinfo_value("i8042.inr_b")); 201 ipc_register_irq(inr_a, device_assign_devno(), 0, &i8042_kbd); 202 ipc_register_irq(inr_b, device_assign_devno(), 0, &i8042_kbd); 203 printf("%s: registered for interrupts %d and %d\n", NAME, inr_a, inr_b); 192 204 193 205 wait_ready(); -
uspace/srv/hw/cir/fhc/fhc.c
r9256ad29 rd9fae235 109 109 static bool fhc_init(void) 110 110 { 111 ipcarg_t phonead;111 sysarg_t paddr; 112 112 113 fhc_uart_size = sysinfo_value("fhc.uart.size"); 114 fhc_uart_phys = (void *) sysinfo_value("fhc.uart.physical"); 115 116 if (!fhc_uart_size) { 113 if ((sysinfo_get_value("fhc.uart.physical", &paddr) != EOK) 114 || (sysinfo_get_value("fhc.uart.size", &fhc_uart_size) != EOK)) { 117 115 printf(NAME ": no FHC UART registers found\n"); 118 116 return false; 119 117 } 120 118 119 fhc_uart_phys = (void *) paddr; 121 120 fhc_uart_virt = as_get_mappable_page(fhc_uart_size); 122 121 … … 132 131 printf(NAME ": FHC UART registers at %p, %d bytes\n", fhc_uart_phys, 133 132 fhc_uart_size); 134 133 135 134 async_set_client_connection(fhc_connection); 135 ipcarg_t phonead; 136 136 ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, &phonead); 137 137 -
uspace/srv/hw/cir/obio/obio.c
r9256ad29 rd9fae235 112 112 static bool obio_init(void) 113 113 { 114 ipcarg_t phonead; 115 116 base_phys = (void *) sysinfo_value("obio.base.physical"); 114 sysarg_t paddr; 117 115 118 if ( !base_phys) {116 if (sysinfo_get_value("obio.base.physical", &paddr) != EOK) { 119 117 printf(NAME ": no OBIO registers found\n"); 120 118 return false; 121 119 } 122 120 121 base_phys = (void *) paddr; 123 122 base_virt = as_get_mappable_page(OBIO_SIZE); 124 123 … … 133 132 134 133 printf(NAME ": OBIO registers with base at %p\n", base_phys); 135 134 136 135 async_set_client_connection(obio_connection); 136 ipcarg_t phonead; 137 137 ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, &phonead); 138 138 -
uspace/srv/net/cfg/ne2k.netif_nil_bundle
r9256ad29 rd9fae235 7 7 IL=ip 8 8 9 # sysinfo_value("netif.dp8390.inr")10 9 IRQ=9 11 10 IO=300 -
uspace/srv/net/cfg/ne2k.netif_standalone
r9256ad29 rd9fae235 7 7 IL=ip 8 8 9 # sysinfo_value("netif.dp8390.inr")10 9 IRQ=9 11 10 IO=300 -
uspace/srv/net/netstart/netstart.c
r9256ad29 rd9fae235 44 44 #include <stdio.h> 45 45 #include <task.h> 46 #include <str_error.h> 46 47 #include <ipc/ipc.h> 47 48 #include <ipc/services.h> … … 71 72 argv[1] = NULL; 72 73 73 if (task_spawn(path, argv) == 0) { 74 fprintf(stderr, "%s: Error spawning %s\n", NAME, path); 74 int err; 75 if (task_spawn(path, argv, &err) == 0) { 76 fprintf(stderr, "%s: Error spawning %s (%s)\n", NAME, path, 77 str_error(err)); 75 78 return false; 76 79 } -
uspace/srv/ns/ns.c
r9256ad29 rd9fae235 55 55 static void *klogaddr = NULL; 56 56 57 static void get_as_area(ipc_callid_t callid, ipc_call_t *call, void * ph_addr,57 static void get_as_area(ipc_callid_t callid, ipc_call_t *call, void *faddr, 58 58 size_t pages, void **addr) 59 59 { 60 if ( ph_addr == NULL) {60 if ((faddr == NULL) || (pages == 0)) { 61 61 ipc_answer_0(callid, ENOENT); 62 62 return; … … 71 71 } 72 72 73 if (physmem_map( ph_addr, *addr, pages,73 if (physmem_map(faddr, *addr, pages, 74 74 AS_AREA_READ | AS_AREA_CACHEABLE) != 0) { 75 75 ipc_answer_0(callid, ENOENT); … … 81 81 } 82 82 83 static void setup_clock_area(ipc_callid_t callid, ipc_call_t *call, void **addr) 84 { 85 uintptr_t faddr; 86 int err = sysinfo_get_value("clock.faddr", &faddr); 87 88 if (err != EOK) 89 ipc_answer_0(callid, err); 90 91 get_as_area(callid, call, (void *) faddr, 1, addr); 92 } 93 94 static void setup_klog_area(ipc_callid_t callid, ipc_call_t *call, void **addr) 95 { 96 uintptr_t faddr; 97 int err = sysinfo_get_value("klog.faddr", &faddr); 98 99 if (err != EOK) 100 ipc_answer_0(callid, err); 101 102 size_t pages; 103 err = sysinfo_get_value("klog.pages", &pages); 104 105 if (err != EOK) 106 ipc_answer_0(callid, err); 107 108 get_as_area(callid, call, (void *) faddr, pages, addr); 109 } 110 83 111 int main(int argc, char **argv) 84 112 { … … 97 125 return rc; 98 126 99 printf( NAME ": Accepting connections\n");127 printf("%s: Accepting connections\n", NAME); 100 128 101 129 while (true) { … … 113 141 switch (IPC_GET_ARG3(call)) { 114 142 case SERVICE_MEM_REALTIME: 115 get_as_area(callid, &call, 116 (void *) sysinfo_value("clock.faddr"), 117 1, &clockaddr); 143 setup_clock_area(callid, &call, &clockaddr); 118 144 break; 119 145 case SERVICE_MEM_KLOG: 120 get_as_area(callid, &call, 121 (void *) sysinfo_value("klog.faddr"), 122 sysinfo_value("klog.pages"), &klogaddr); 146 setup_klog_area(callid, &call, &klogaddr); 123 147 break; 124 148 default: -
uspace/srv/taskmon/taskmon.c
r9256ad29 rd9fae235 44 44 #include <macros.h> 45 45 #include <errno.h> 46 #include <str_error.h> 46 47 47 48 #define NAME "taskmon" … … 96 97 } 97 98 putchar('\n'); 98 99 if (!task_spawn(fname, argv)) 100 printf(NAME ": Error spawning taskdump.\n", fname); 99 100 int err; 101 if (!task_spawn(fname, argv, &err)) 102 printf("%s: Error spawning %s (%s).\n", NAME, fname, 103 str_error(err)); 101 104 } 102 105
Note:
See TracChangeset
for help on using the changeset viewer.