Add getcount system call
This patch enables the getcount systemcall functionality.
This commit is contained in:
parent
bcef224332
commit
e30698ad64
5 changed files with 17 additions and 0 deletions
|
@ -98,6 +98,7 @@ extern int sys_unlink(void);
|
||||||
extern int sys_wait(void);
|
extern int sys_wait(void);
|
||||||
extern int sys_write(void);
|
extern int sys_write(void);
|
||||||
extern int sys_uptime(void);
|
extern int sys_uptime(void);
|
||||||
|
extern int sys_getcount(void);
|
||||||
|
|
||||||
static int (*syscalls[])(void) = {
|
static int (*syscalls[])(void) = {
|
||||||
[SYS_fork] sys_fork,
|
[SYS_fork] sys_fork,
|
||||||
|
@ -121,6 +122,7 @@ static int (*syscalls[])(void) = {
|
||||||
[SYS_link] sys_link,
|
[SYS_link] sys_link,
|
||||||
[SYS_mkdir] sys_mkdir,
|
[SYS_mkdir] sys_mkdir,
|
||||||
[SYS_close] sys_close,
|
[SYS_close] sys_close,
|
||||||
|
[SYS_getcount] sys_getcount,
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -130,6 +132,7 @@ syscall(void)
|
||||||
|
|
||||||
num = proc->tf->eax;
|
num = proc->tf->eax;
|
||||||
if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
|
if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
|
||||||
|
proc->syscall_count[num]++;
|
||||||
proc->tf->eax = syscalls[num]();
|
proc->tf->eax = syscalls[num]();
|
||||||
} else {
|
} else {
|
||||||
cprintf("%d %s: unknown sys call %d\n",
|
cprintf("%d %s: unknown sys call %d\n",
|
||||||
|
|
|
@ -20,3 +20,4 @@
|
||||||
#define SYS_link 19
|
#define SYS_link 19
|
||||||
#define SYS_mkdir 20
|
#define SYS_mkdir 20
|
||||||
#define SYS_close 21
|
#define SYS_close 21
|
||||||
|
#define SYS_getcount 22
|
||||||
|
|
11
sysproc.c
11
sysproc.c
|
@ -88,3 +88,14 @@ sys_uptime(void)
|
||||||
release(&tickslock);
|
release(&tickslock);
|
||||||
return xticks;
|
return xticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
sys_getcount(void)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
if(argint(0, &n) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return proc->syscall_count[n];
|
||||||
|
}
|
||||||
|
|
1
user.h
1
user.h
|
@ -22,6 +22,7 @@ int getpid(void);
|
||||||
char* sbrk(int);
|
char* sbrk(int);
|
||||||
int sleep(int);
|
int sleep(int);
|
||||||
int uptime(void);
|
int uptime(void);
|
||||||
|
int getcount(int);
|
||||||
|
|
||||||
// ulib.c
|
// ulib.c
|
||||||
int stat(char*, struct stat*);
|
int stat(char*, struct stat*);
|
||||||
|
|
1
usys.S
1
usys.S
|
@ -29,3 +29,4 @@ SYSCALL(getpid)
|
||||||
SYSCALL(sbrk)
|
SYSCALL(sbrk)
|
||||||
SYSCALL(sleep)
|
SYSCALL(sleep)
|
||||||
SYSCALL(uptime)
|
SYSCALL(uptime)
|
||||||
|
SYSCALL(getcount)
|
||||||
|
|
Loading…
Reference in a new issue