Compare commits
1 Commits
ASST3/add-
...
ASST2/add-
| Author | SHA1 | Date | |
|---|---|---|---|
|
c67c34e0ea
|
@@ -104,22 +104,15 @@ void syscall(struct trapframe *tf) {
|
|||||||
case SYS___time:
|
case SYS___time:
|
||||||
err = sys___time((userptr_t)tf->tf_a0, (userptr_t)tf->tf_a1);
|
err = sys___time((userptr_t)tf->tf_a0, (userptr_t)tf->tf_a1);
|
||||||
break;
|
break;
|
||||||
|
case SYS_hello:
|
||||||
|
err = sys_hello();
|
||||||
|
break;
|
||||||
|
|
||||||
case SYS__exit:
|
case SYS__exit:
|
||||||
err = 0;
|
err = 0;
|
||||||
thread_exit();
|
thread_exit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYS_printchar:
|
|
||||||
err = sys_printchar((char)tf->tf_a0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SYS_add_three_integers:
|
|
||||||
err = sys_add_three_integers((int)tf->tf_a0, (int)tf->tf_a1, (int)tf->tf_a2,
|
|
||||||
&retval);
|
|
||||||
kprintf("%d\n", retval);
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Add stuff here */
|
/* Add stuff here */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -379,8 +379,7 @@ file vfs/devnull.c
|
|||||||
file syscall/loadelf.c
|
file syscall/loadelf.c
|
||||||
file syscall/runprogram.c
|
file syscall/runprogram.c
|
||||||
file syscall/time_syscalls.c
|
file syscall/time_syscalls.c
|
||||||
file syscall/printchar.c
|
file syscall/hello.c
|
||||||
file syscall/add_three_integers.c
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Startup and initialization
|
# Startup and initialization
|
||||||
|
|||||||
@@ -94,8 +94,7 @@
|
|||||||
// #define SYS_getpriority 38
|
// #define SYS_getpriority 38
|
||||||
// #define SYS_setpriority 39
|
// #define SYS_setpriority 39
|
||||||
// (process groups, sessions, and job control)
|
// (process groups, sessions, and job control)
|
||||||
#define SYS_printchar 41
|
#define SYS_hello 41
|
||||||
#define SYS_add_three_integers 42
|
|
||||||
// #define SYS_getpgid 40
|
// #define SYS_getpgid 40
|
||||||
// #define SYS_setpgid 41
|
// #define SYS_setpgid 41
|
||||||
// #define SYS_getsid 42
|
// #define SYS_getsid 42
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ __DEAD void enter_new_process(int argc, userptr_t argv, userptr_t env,
|
|||||||
int sys_reboot(int code);
|
int sys_reboot(int code);
|
||||||
int sys___time(userptr_t user_seconds, userptr_t user_nanoseconds);
|
int sys___time(userptr_t user_seconds, userptr_t user_nanoseconds);
|
||||||
|
|
||||||
int sys_printchar(char c);
|
int sys_hello(void);
|
||||||
|
|
||||||
int sys_add_three_integers(int a, int b, int c, int *ret);
|
|
||||||
|
|
||||||
#endif /* _SYSCALL_H_ */
|
#endif /* _SYSCALL_H_ */
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
#include <types.h>
|
|
||||||
#include <lib.h>
|
|
||||||
#include <syscall.h>
|
|
||||||
|
|
||||||
int sys_add_three_integers(int a, int b, int c, int *ret) {
|
|
||||||
*ret = a + b + c;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <lib.h>
|
#include <lib.h>
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
int sys_printchar(char c) {
|
int sys_hello(void) {
|
||||||
kprintf("%c", c);
|
kprintf("Hello CSE4001!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,6 @@ int execvp(const char *prog, char *const *args); /* calls execv */
|
|||||||
char *getcwd(char *buf, size_t buflen); /* calls __getcwd */
|
char *getcwd(char *buf, size_t buflen); /* calls __getcwd */
|
||||||
time_t time(time_t *seconds); /* calls __time */
|
time_t time(time_t *seconds); /* calls __time */
|
||||||
|
|
||||||
int printchar(char c);
|
int hello(void);
|
||||||
int add_three_integers(int a, int b, int c);
|
|
||||||
|
|
||||||
#endif /* _UNISTD_H_ */
|
#endif /* _UNISTD_H_ */
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
TOP=../..
|
TOP=../..
|
||||||
.include "$(TOP)/mk/os161.config.mk"
|
.include "$(TOP)/mk/os161.config.mk"
|
||||||
|
|
||||||
SUBDIRS=add add_three_integers argtest badcall bigexec bigfile bigfork bigseek bloat conman \
|
SUBDIRS=add argtest badcall bigexec bigfile bigfork bigseek bloat conman \
|
||||||
crash ctest dirconc dirseek dirtest f_test factorial farm faulter \
|
crash ctest dirconc dirseek dirtest f_test factorial farm faulter \
|
||||||
filetest forkbomb forktest frack hash hog huge \
|
filetest forkbomb forktest frack hash hellotest hog huge \
|
||||||
malloctest matmult multiexec palin parallelvm poisondisk printchartest psort \
|
malloctest matmult multiexec palin parallelvm poisondisk psort \
|
||||||
randcall redirect rmdirtest rmtest \
|
randcall redirect rmdirtest rmtest \
|
||||||
sbrktest schedpong sort sparsefile tail tictac triplehuge \
|
sbrktest schedpong sort sparsefile tail tictac triplehuge \
|
||||||
triplemat triplesort usemtest zero
|
triplemat triplesort usemtest zero
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
# Makefile for add_three_integers
|
|
||||||
|
|
||||||
TOP=../../..
|
|
||||||
.include "$(TOP)/mk/os161.config.mk"
|
|
||||||
|
|
||||||
PROG=add_three_integers
|
|
||||||
SRCS=add_three_integers.c
|
|
||||||
BINDIR=/testbin
|
|
||||||
|
|
||||||
.include "$(TOP)/mk/os161.prog.mk"
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
extern int add_three_integers(int a, int b, int c);
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
add_three_integers(3, 5, 2); // should output 10
|
|
||||||
add_three_integers(-5, 3, 1); // should output -1
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
# Makefile for printchartest
|
# Makefile for hello
|
||||||
|
|
||||||
TOP=../../..
|
TOP=../../..
|
||||||
.include "$(TOP)/mk/os161.config.mk"
|
.include "$(TOP)/mk/os161.config.mk"
|
||||||
|
|
||||||
PROG=printchartest
|
PROG=hellotest
|
||||||
SRCS=printchartest.c
|
SRCS=hello.c
|
||||||
BINDIR=/testbin
|
BINDIR=/testbin
|
||||||
|
|
||||||
.include "$(TOP)/mk/os161.prog.mk"
|
.include "$(TOP)/mk/os161.prog.mk"
|
||||||
8
userland/testbin/hellotest/hello.c
Normal file
8
userland/testbin/hellotest/hello.c
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
extern int hello(void);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
hello();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
extern int printchar(char c);
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
|
|
||||||
printchar('C');
|
|
||||||
printchar('S');
|
|
||||||
printchar('E');
|
|
||||||
printchar('4');
|
|
||||||
printchar('0');
|
|
||||||
printchar('0');
|
|
||||||
printchar('1');
|
|
||||||
printchar('\n');
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user