-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syscall: cleanup interface, registration and argument parsing
Signed-off-by: Mahavir Jain <[email protected]>
- Loading branch information
Showing
10 changed files
with
84 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,9 @@ execve: | |
mov eax, 2 | ||
int 64 | ||
ret | ||
|
||
[GLOBAL read] | ||
sleep: | ||
mov eax, 3 | ||
int 64 | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef __SYSCALL_H__ | ||
#define __SYSCALL_H__ | ||
|
||
void syscall_handler(registers_t *r); | ||
int argint(int n, int *p); | ||
int argstr(int n, char **p); | ||
|
||
#endif /* __SYSCALL_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <isr.h> | ||
#include <vga.h> | ||
#include <helper.h> | ||
#include <task.h> | ||
|
||
static registers_t *irqf; | ||
|
||
static void *sys_handlers[] = { | ||
sys_write, | ||
sys_fork, | ||
sys_exec, | ||
//sys_read, | ||
}; | ||
|
||
int argint(int n, int *p) | ||
{ | ||
/* FIXME: Need some error checking here */ | ||
*p = *(int *)(irqf->useresp + 4 + 4*n); | ||
return 0; | ||
} | ||
|
||
int argstr(int n, char **p) | ||
{ | ||
/* FIXME: Need some error checking here */ | ||
*p = *(char **)(irqf->useresp + 4 + 4*n); | ||
return 0; | ||
} | ||
|
||
void syscall_handler(registers_t *r) | ||
{ | ||
int num = r->eax; | ||
int (*func) (void); | ||
|
||
irqf = r; | ||
if (num < ARR_SIZE(sys_handlers) && sys_handlers[r->eax]) { | ||
func = sys_handlers[r->eax]; | ||
r->eax = func(); | ||
} else { | ||
printk("Unsupported syscall %d\n", num); | ||
} | ||
irqf = NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters