-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyscall.cpp
More file actions
66 lines (61 loc) · 1.33 KB
/
syscall.cpp
File metadata and controls
66 lines (61 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "syscall.h"
uint32_t SYS_EAX;
uint32_t SYS_EBX;
uint32_t SYS_ECX;
uint32_t SYS_EDX;
uint32_t SYS_ESI;
uint32_t SYS_EDI;
SyscallHandler::SyscallHandler(InterruptManager* manager, JumpFS* jfs) :
InterruptHandler(0xCD, manager), jfs(jfs) {};
SyscallHandler::~SyscallHandler() {};
uint32_t SyscallHandler::operator()(uint32_t esp) {
static File* open_files[255];
static uint16_t next = 2;
static ConsoleStdout stdout;
static KeyboardStdin stdin;
open_files[0] = &stdin;
open_files[1] = &stdout;
switch (SYS_EAX) {
case 0:
// exit
break;
case 1:
// read
open_files[SYS_EBX]->read(SYS_ECX, (uint8_t*)SYS_EDI, SYS_EDX);
break;
case 2:
// write
open_files[SYS_EBX]->write(SYS_ECX, (uint8_t*)SYS_ESI, SYS_EDX);
break;
case 3:
// open
open_files[next] = jfs->open((char*)SYS_ESI);
if (open_files[next] == 0) {
SYS_EAX = 0xFF; // -1
break;
}
SYS_EAX = next;
next++;
case 4:
// exec
open_files[SYS_EBX]->exec((uint8_t*)SYS_ESI, SYS_ECX);
break;
case 5:
// close
default:
printf("REG ");
printh(SYS_EAX);
printf(" ");
printh(SYS_EBX);
printf(" ");
printh(SYS_ECX);
printf("\n");
printh(SYS_EDX);
printf(" ");
printh(SYS_ESI);
printf(" ");
printh(SYS_EDI);
printf("\n");
}
return esp;
}