modify syscall ids to match Linux 64. deprecate sys_putc.

master
WangRunji 6 years ago
parent 10b2aa8b6d
commit 046c7c6317

@ -4,33 +4,32 @@
#define T_SYSCALL 0x80 #define T_SYSCALL 0x80
/* syscall number */ /* syscall number */
#define SYS_exit 1 #define SYS_exit 60
#define SYS_fork 2 #define SYS_fork 57
#define SYS_wait 3 #define SYS_wait 61
#define SYS_exec 4 #define SYS_exec 59
#define SYS_clone 5 #define SYS_clone 56
#define SYS_yield 10 #define SYS_yield 24
#define SYS_sleep 11 #define SYS_sleep 35
#define SYS_kill 12 #define SYS_kill 62
#define SYS_gettime 17 #define SYS_gettime 96
#define SYS_getpid 18 #define SYS_getpid 39
#define SYS_mmap 20 #define SYS_mmap 9
#define SYS_munmap 21 #define SYS_munmap 11
#define SYS_shmem 22 #define SYS_shmem -1
#define SYS_putc 30 #define SYS_pgdir -1
#define SYS_pgdir 31 #define SYS_open 2
#define SYS_open 100 #define SYS_close 3
#define SYS_close 101 #define SYS_read 0
#define SYS_read 102 #define SYS_write 1
#define SYS_write 103 #define SYS_seek 8
#define SYS_seek 104 #define SYS_fstat 5
#define SYS_fstat 110 #define SYS_fsync 74
#define SYS_fsync 111 #define SYS_getcwd 79
#define SYS_getcwd 121 #define SYS_getdirentry 78
#define SYS_getdirentry 128 #define SYS_dup 33
#define SYS_dup 130 /* ONLY FOR LAB6 */
/* OLNY FOR LAB6 */ #define SYS_set_priority 141
#define SYS_lab6_set_priority 255
/* SYS_fork flags */ /* SYS_fork flags */
#define CLONE_VM 0x00000100 // set if VM shared between processes #define CLONE_VM 0x00000100 // set if VM shared between processes

@ -5,14 +5,19 @@
#include <ulib.h> #include <ulib.h>
#include <unistd.h> #include <unistd.h>
static void
fputch(char c, int *cnt, int fd) {
write(fd, &c, sizeof(char));
(*cnt) ++;
}
/* * /* *
* cputch - writes a single character @c to stdout, and it will * cputch - writes a single character @c to stdout, and it will
* increace the value of counter pointed by @cnt. * increace the value of counter pointed by @cnt.
* */ * */
static void static void
cputch(int c, int *cnt) { cputch(int c, int *cnt) {
sys_putc(c); fputch(c, cnt, 1);
(*cnt) ++;
} }
/* * /* *
@ -63,13 +68,6 @@ cputs(const char *str) {
return cnt; return cnt;
} }
static void
fputch(char c, int *cnt, int fd) {
write(fd, &c, sizeof(char));
(*cnt) ++;
}
int int
vfprintf(int fd, const char *fmt, va_list ap) { vfprintf(int fd, const char *fmt, va_list ap) {
int cnt = 0; int cnt = 0;

@ -103,20 +103,15 @@ sys_getpid(void) {
return syscall(SYS_getpid); return syscall(SYS_getpid);
} }
int
sys_putc(int c) {
return syscall(SYS_putc, c);
}
int int
sys_pgdir(void) { sys_pgdir(void) {
return syscall(SYS_pgdir); return syscall(SYS_pgdir);
} }
void void
sys_lab6_set_priority(uint32_t priority) sys_set_priority(uint32_t priority)
{ {
syscall(SYS_lab6_set_priority, priority); syscall(SYS_set_priority, priority);
} }
int int

@ -8,7 +8,6 @@ int sys_exec(const char *name, int argc, const char **argv);
int sys_yield(void); int sys_yield(void);
int sys_kill(int pid); int sys_kill(int pid);
int sys_getpid(void); int sys_getpid(void);
int sys_putc(int c);
int sys_pgdir(void); int sys_pgdir(void);
int sys_sleep(unsigned int time); int sys_sleep(unsigned int time);
int sys_gettime(void); int sys_gettime(void);
@ -26,7 +25,7 @@ int sys_fsync(int fd);
int sys_getcwd(char *buffer, size_t len); int sys_getcwd(char *buffer, size_t len);
int sys_getdirentry(int fd, struct dirent *dirent); int sys_getdirentry(int fd, struct dirent *dirent);
int sys_dup(int fd1, int fd2); int sys_dup(int fd1, int fd2);
void sys_lab6_set_priority(uint32_t priority); //only for lab6 void sys_set_priority(uint32_t priority); //only for lab6
#endif /* !__USER_LIBS_SYSCALL_H__ */ #endif /* !__USER_LIBS_SYSCALL_H__ */

@ -64,7 +64,7 @@ print_pgdir(void) {
void void
lab6_set_priority(uint32_t priority) lab6_set_priority(uint32_t priority)
{ {
sys_lab6_set_priority(priority); sys_set_priority(priority);
} }
int int

Loading…
Cancel
Save