Rev 3447 | Rev 3454 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3447 | Rev 3452 | ||
---|---|---|---|
Line 134... | Line 134... | ||
134 | printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); |
134 | printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); |
135 | 135 | ||
136 | return 0; |
136 | return 0; |
137 | } |
137 | } |
138 | 138 | ||
139 | static void print_sc_retval(int retval, rv_type_t rv_type) |
139 | void val_print(int val, val_type_t v_type) |
140 | { |
140 | { |
- | 141 | switch (v_type) { |
|
- | 142 | case V_VOID: |
|
141 | printf (" -> "); |
143 | printf("<void>"); |
- | 144 | break; |
|
- | 145 | ||
142 | if (rv_type == RV_INTEGER) { |
146 | case V_INTEGER: |
143 | printf("%d", retval); |
147 | printf("%d", val); |
- | 148 | break; |
|
- | 149 | ||
144 | } else if (rv_type == RV_HASH) { |
150 | case V_HASH: |
145 | printf("0x%08x", retval); |
151 | printf("0x%08x", val); |
- | 152 | break; |
|
- | 153 | ||
146 | } else if (rv_type == RV_ERRNO) { |
154 | case V_ERRNO: |
147 | if (retval >= -15 && retval <= 0) { |
155 | if (val >= -15 && val <= 0) { |
148 | printf("%d %s (%s)", retval, |
156 | printf("%d %s (%s)", val, |
149 | err_desc[retval].name, |
157 | err_desc[-val].name, |
150 | err_desc[retval].desc); |
158 | err_desc[-val].desc); |
151 | } else { |
159 | } else { |
152 | printf("%d", retval); |
160 | printf("%d", val); |
153 | } |
161 | } |
- | 162 | break; |
|
154 | } else if (rv_type == RV_INT_ERRNO) { |
163 | case V_INT_ERRNO: |
155 | if (retval >= -15 && retval < 0) { |
164 | if (val >= -15 && val < 0) { |
156 | printf("%d %s (%s)", retval, |
165 | printf("%d %s (%s)", val, |
157 | err_desc[retval].name, |
166 | err_desc[-val].name, |
158 | err_desc[retval].desc); |
167 | err_desc[-val].desc); |
- | 168 | } else { |
|
- | 169 | printf("%d", val); |
|
- | 170 | } |
|
- | 171 | break; |
|
- | 172 | ||
- | 173 | case V_CHAR: |
|
- | 174 | if (val >= 0x20 && val < 0x7f) { |
|
- | 175 | printf("'%c'", val); |
|
159 | } else { |
176 | } else { |
160 | printf("%d", retval); |
177 | switch (val) { |
- | 178 | case '\a': printf("'\\a'"); break; |
|
- | 179 | case '\b': printf("'\\b'"); break; |
|
- | 180 | case '\n': printf("'\\n'"); break; |
|
- | 181 | case '\r': printf("'\\r'"); break; |
|
- | 182 | case '\t': printf("'\\t'"); break; |
|
- | 183 | case '\\': printf("'\\\\'"); break; |
|
- | 184 | default: printf("'\\x%X'"); break; |
|
161 | } |
185 | } |
162 | } |
186 | } |
- | 187 | break; |
|
- | 188 | } |
|
- | 189 | } |
|
- | 190 | ||
- | 191 | ||
- | 192 | static void print_sc_retval(int retval, val_type_t val_type) |
|
- | 193 | { |
|
- | 194 | printf(" -> "); |
|
- | 195 | val_print(retval, val_type); |
|
163 | putchar('\n'); |
196 | putchar('\n'); |
164 | } |
197 | } |
165 | 198 | ||
166 | static void print_sc_args(unsigned *sc_args, int n) |
199 | static void print_sc_args(unsigned *sc_args, int n) |
167 | { |
200 | { |
Line 494... | Line 527... | ||
494 | static void main_init(void) |
527 | static void main_init(void) |
495 | { |
528 | { |
496 | proto_t *p; |
529 | proto_t *p; |
497 | oper_t *o; |
530 | oper_t *o; |
498 | 531 | ||
- | 532 | val_type_t arg_def[OPER_MAX_ARGS] = { |
|
- | 533 | V_INTEGER, |
|
- | 534 | V_INTEGER, |
|
- | 535 | V_INTEGER, |
|
- | 536 | V_INTEGER, |
|
- | 537 | V_INTEGER |
|
- | 538 | }; |
|
- | 539 | ||
- | 540 | val_type_t resp_def[OPER_MAX_ARGS] = { |
|
- | 541 | V_INTEGER, |
|
- | 542 | V_INTEGER, |
|
- | 543 | V_INTEGER, |
|
- | 544 | V_INTEGER, |
|
- | 545 | V_INTEGER |
|
- | 546 | }; |
|
- | 547 | ||
499 | next_thread_id = 1; |
548 | next_thread_id = 1; |
500 | paused = 0; |
549 | paused = 0; |
501 | 550 | ||
502 | proto_init(); |
551 | proto_init(); |
503 | 552 | ||
504 | p = proto_new("vfs"); |
553 | p = proto_new("vfs"); |
505 | o = oper_new("read"); |
554 | o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def); |
506 | proto_add_oper(p, VFS_READ, o); |
555 | proto_add_oper(p, VFS_READ, o); |
507 | o = oper_new("write"); |
556 | o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def); |
508 | proto_add_oper(p, VFS_WRITE, o); |
557 | proto_add_oper(p, VFS_WRITE, o); |
509 | o = oper_new("truncate"); |
558 | o = oper_new("truncate", 5, arg_def, V_ERRNO, 0, resp_def); |
510 | proto_add_oper(p, VFS_TRUNCATE, o); |
559 | proto_add_oper(p, VFS_TRUNCATE, o); |
511 | o = oper_new("mount"); |
560 | o = oper_new("mount", 2, arg_def, V_ERRNO, 0, resp_def); |
512 | proto_add_oper(p, VFS_MOUNT, o); |
561 | proto_add_oper(p, VFS_MOUNT, o); |
513 | o = oper_new("unmount"); |
562 | /* o = oper_new("unmount", 0, arg_def); |
514 | proto_add_oper(p, VFS_UNMOUNT, o); |
563 | proto_add_oper(p, VFS_UNMOUNT, o);*/ |
515 | 564 | ||
516 | proto_register(SERVICE_VFS, p); |
565 | proto_register(SERVICE_VFS, p); |
517 | 566 | ||
518 | p = proto_new("console"); |
567 | p = proto_new("console"); |
- | 568 | resp_def[0] = V_CHAR; |
|
519 | o = oper_new("getchar"); |
569 | o = oper_new("getchar", 0, arg_def, V_INTEGER, 2, resp_def); |
520 | proto_add_oper(p, CONSOLE_GETCHAR, o); |
570 | proto_add_oper(p, CONSOLE_GETCHAR, o); |
- | 571 | ||
- | 572 | arg_def[0] = V_CHAR; |
|
521 | o = oper_new("putchar"); |
573 | o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def); |
522 | proto_add_oper(p, CONSOLE_PUTCHAR, o); |
574 | proto_add_oper(p, CONSOLE_PUTCHAR, o); |
523 | o = oper_new("clear"); |
575 | o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def); |
524 | proto_add_oper(p, CONSOLE_CLEAR, o); |
576 | proto_add_oper(p, CONSOLE_CLEAR, o); |
- | 577 | ||
- | 578 | arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; |
|
525 | o = oper_new("goto"); |
579 | o = oper_new("goto", 2, arg_def, V_VOID, 0, resp_def); |
526 | proto_add_oper(p, CONSOLE_GOTO, o); |
580 | proto_add_oper(p, CONSOLE_GOTO, o); |
- | 581 | ||
- | 582 | resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER; |
|
527 | o = oper_new("getsize"); |
583 | o = oper_new("getsize", 0, arg_def, V_INTEGER, 2, resp_def); |
528 | proto_add_oper(p, CONSOLE_GETSIZE, o); |
584 | proto_add_oper(p, CONSOLE_GETSIZE, o); |
529 | o = oper_new("flush"); |
585 | o = oper_new("flush", 0, arg_def, V_VOID, 0, resp_def); |
530 | proto_add_oper(p, CONSOLE_FLUSH, o); |
586 | proto_add_oper(p, CONSOLE_FLUSH, o); |
- | 587 | ||
- | 588 | arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; |
|
531 | o = oper_new("set_style"); |
589 | o = oper_new("set_style", 2, arg_def, V_INTEGER, 0, resp_def); |
532 | proto_add_oper(p, CONSOLE_SET_STYLE, o); |
590 | proto_add_oper(p, CONSOLE_SET_STYLE, o); |
533 | o = oper_new("cursor_visibility"); |
591 | o = oper_new("cursor_visibility", 1, arg_def, V_VOID, 0, resp_def); |
534 | proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o); |
592 | proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o); |
535 | o = oper_new("flush"); |
- | |
536 | proto_add_oper(p, CONSOLE_FLUSH, o); |
- | |
537 | 593 | ||
538 | proto_console = p; |
594 | proto_console = p; |
539 | proto_register(SERVICE_CONSOLE, p); |
595 | proto_register(SERVICE_CONSOLE, p); |
540 | } |
596 | } |
541 | 597 |