|
6 | 6 | #include "stdlib/syscalls.h"
|
7 | 7 |
|
8 | 8 | uint32_t sys_write_to_screen(char* s) {
|
9 |
| - fprintf(LOG, "sys_write_to_screen(%s)\n", s); |
10 | 9 | fprintf(SCREEN, s);
|
11 | 10 | return 0;
|
12 | 11 | }
|
@@ -38,22 +37,35 @@ uint32_t sys_register_input_handler(InputHandler handler) {
|
38 | 37 | return 0;
|
39 | 38 | }
|
40 | 39 |
|
| 40 | +char* syscall_name(Syscall syscall) { |
| 41 | + switch (syscall) { |
| 42 | + case (WRITE_TO_SCREEN): |
| 43 | + return "WRITE_TO_SCREEN"; |
| 44 | + case (COUNT_FILES): |
| 45 | + return "COUNT_FILES"; |
| 46 | + case (LIST_FILES): |
| 47 | + return "LIST_FILES"; |
| 48 | + case (REGISTER_INPUT_HANDLER): |
| 49 | + return "REGISTER_INPUT_HANDLER"; |
| 50 | + } |
| 51 | +} |
| 52 | + |
41 | 53 | uint32_t handle_syscall(struct cpu_state* cpu) {
|
42 |
| - uint32_t syscall_num = cpu->eax; |
| 54 | + Syscall syscall = (Syscall) cpu->eax; |
43 | 55 |
|
44 |
| - fprintf(LOG, "--------------------\nSYSCALL (%i)\n", syscall_num); |
| 56 | + fprintf(LOG, "--------------------\nSYSCALL (%i - %s)\n", syscall, syscall_name(syscall)); |
45 | 57 |
|
46 |
| - switch (syscall_num) { |
47 |
| - case (1): |
| 58 | + switch (syscall) { |
| 59 | + case (WRITE_TO_SCREEN): |
48 | 60 | return sys_write_to_screen((char*) cpu->ebx);
|
49 |
| - case (2): |
| 61 | + case (COUNT_FILES): |
50 | 62 | return sys_count_files();
|
51 |
| - case (3): |
| 63 | + case (LIST_FILES): |
52 | 64 | return sys_list_files((struct file_t *) cpu->ebx);
|
53 |
| - case (4): |
| 65 | + case (REGISTER_INPUT_HANDLER): |
54 | 66 | return sys_register_input_handler((InputHandler) cpu->ebx);
|
55 | 67 | default:
|
56 |
| - fprintf(LOG, "Unknown syscall: %x\n", syscall_num); |
| 68 | + fprintf(LOG, "Unknown syscall: %x\n", syscall); |
57 | 69 | while(1){}
|
58 | 70 | }
|
59 | 71 |
|
|
0 commit comments