Add getcount system call

This patch enables the getcount systemcall functionality.
This commit is contained in:
Sanchayan Maity 2015-03-16 23:39:50 +05:30
parent bcef224332
commit e30698ad64
5 changed files with 17 additions and 0 deletions

View file

@ -98,6 +98,7 @@ extern int sys_unlink(void);
extern int sys_wait(void);
extern int sys_write(void);
extern int sys_uptime(void);
extern int sys_getcount(void);
static int (*syscalls[])(void) = {
[SYS_fork] sys_fork,
@ -121,6 +122,7 @@ static int (*syscalls[])(void) = {
[SYS_link] sys_link,
[SYS_mkdir] sys_mkdir,
[SYS_close] sys_close,
[SYS_getcount] sys_getcount,
};
void
@ -130,6 +132,7 @@ syscall(void)
num = proc->tf->eax;
if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
proc->syscall_count[num]++;
proc->tf->eax = syscalls[num]();
} else {
cprintf("%d %s: unknown sys call %d\n",

View file

@ -20,3 +20,4 @@
#define SYS_link 19
#define SYS_mkdir 20
#define SYS_close 21
#define SYS_getcount 22

View file

@ -88,3 +88,14 @@ sys_uptime(void)
release(&tickslock);
return xticks;
}
int
sys_getcount(void)
{
int n;
if(argint(0, &n) < 0)
return -1;
return proc->syscall_count[n];
}

1
user.h
View file

@ -22,6 +22,7 @@ int getpid(void);
char* sbrk(int);
int sleep(int);
int uptime(void);
int getcount(int);
// ulib.c
int stat(char*, struct stat*);

1
usys.S
View file

@ -29,3 +29,4 @@ SYSCALL(getpid)
SYSCALL(sbrk)
SYSCALL(sleep)
SYSCALL(uptime)
SYSCALL(getcount)