summaryrefslogtreecommitdiff
path: root/libc/syscall
diff options
context:
space:
mode:
Diffstat (limited to 'libc/syscall')
-rw-r--r--libc/syscall/Makefile9
-rw-r--r--libc/syscall/TODO2
-rw-r--r--libc/syscall/dirent.c28
-rw-r--r--libc/syscall/exec.c4
-rw-r--r--libc/syscall/mkentry.sh83
-rw-r--r--libc/syscall/mksyscall31
-rw-r--r--libc/syscall/syscall.dat142
-rw-r--r--libc/syscall/syscall.dev86160
8 files changed, 274 insertions, 185 deletions
diff --git a/libc/syscall/Makefile b/libc/syscall/Makefile
index 07b1428..0fd2ad6 100644
--- a/libc/syscall/Makefile
+++ b/libc/syscall/Makefile
@@ -4,7 +4,7 @@
LSRC=syslib0.c
LOBJ=__cstartup.o lseek.o getpid.o getppid.o getuid.o geteuid.o getgid.o \
- getegid.o dup2.o dup.o getpgrp.o times.o
+ getegid.o dup2.o getpgrp.o times.o
ESRC=exec.c
EOBJ=execve.o execl.o execv.o execle.o execlp.o execvp.o
@@ -13,7 +13,7 @@ DSRC=dirent.c
DOBJ=opendir.o closedir.o readdir.o
ifeq ($(LIB_CPU)-$(LIB_OS),i86-ELKS)
-OBJ=$(LOBJ) $(LOBJ) $(DOBJ) $(EOBJ) signal.o setjmp.o
+OBJ=$(LOBJ) $(DOBJ) $(EOBJ) signal.o setjmp.o
SYSCALLS=call_i86
endif
@@ -32,6 +32,9 @@ call_i86: syscall.mak
syscall.mak: mksyscall syscall.dat
sh mksyscall
+syscall.dat:
+ @touch syscall.dat
+
$(LIBC): $(LIBC)($(OBJ))
$(LIBC)($(LOBJ)): $(LSRC)
@@ -48,5 +51,5 @@ $(LIBC)($(EOBJ)): $(ESRC)
clean:
rm -f *.o libc.a
- rm -f syscall.c syscall.mak
+ rm -f syscall.c syscall.mak syscall.dat
rm -f call_tab.v defn_tab.v
diff --git a/libc/syscall/TODO b/libc/syscall/TODO
index f396897..ff14000 100644
--- a/libc/syscall/TODO
+++ b/libc/syscall/TODO
@@ -10,6 +10,8 @@ Subject: 8086 Shared Libs and local RPC.
True shared libs are impossible with the 8086 in small model.
BUT we can use RPC type links to provide a similar system.
+This is very machine specific.
+
Client side
-----------
diff --git a/libc/syscall/dirent.c b/libc/syscall/dirent.c
index 8f7574c..b928757 100644
--- a/libc/syscall/dirent.c
+++ b/libc/syscall/dirent.c
@@ -60,33 +60,6 @@ DIR *dirp;
}
#endif
-#ifdef __AS386_16__
-#ifdef L_readdir
-/*
- * This currently assumes we see a v. simple diectory structure, it's
- * probably faked!
- */
-struct dirent *
-readdir(dirp)
-DIR *dirp;
-{
- int cc;
- cc = read(dirp->dd_fd, dirp->dd_buf, sizeof(struct dirent));
-
- if (cc <= 0)
- return 0;
- if (cc != sizeof(struct dirent))
- {
- errno = EBADF;
- return 0;
- }
- return dirp->dd_buf;
-}
-#endif
-#else
-
-/* This is for 386 linux */
-
#ifdef L_readdir
struct dirent *
readdir(dirp)
@@ -103,4 +76,3 @@ DIR *dirp;
}
#endif
-#endif
diff --git a/libc/syscall/exec.c b/libc/syscall/exec.c
index 411b744..8337f11 100644
--- a/libc/syscall/exec.c
+++ b/libc/syscall/exec.c
@@ -107,7 +107,7 @@ char ** envp;
}
*pip++ = 0;
- rv = __exec(fname, stk_ptr, stack_bytes);
+ rv = __execve(fname, stk_ptr, stack_bytes);
/* FIXME: This will probably have to interpret '#!' style exe's */
sbrk(-stack_bytes);
return rv;
@@ -283,7 +283,7 @@ char ** envp;
}
*pip++ = 0;
- rv = __exec(fname, stk_ptr, stack_bytes);
+ rv = __execve(fname, stk_ptr, stack_bytes);
/* FIXME: This will probably have to interpret '#!' style exe's */
sbrk(-stack_bytes);
return rv;
diff --git a/libc/syscall/mkentry.sh b/libc/syscall/mkentry.sh
new file mode 100644
index 0000000..aae4904
--- /dev/null
+++ b/libc/syscall/mkentry.sh
@@ -0,0 +1,83 @@
+#!/bin/sh -
+#
+# This program generates entry.c from syscall.dat
+
+cat << \Trailer
+/* Switched to V7 system call layout... Chad - 1/5/96
+*/
+#asm
+*
+* The call table - autogenerated from syscall.dat
+*
+ .data
+sys_call_table:
+Trailer
+
+tr '[A-Z]' '[a-z]' < syscall.dat | \
+awk '/^#/{next;}
+/^[ ]$/{next;}
+{
+ callno = 0+$2;
+ if( $4 != "-" )
+ assigned_to[callno] = $1;
+
+ if( $3 == "x" || $3 == "" ) next;
+ else if( $4 == "@" || $4 == "-" ) next;
+
+ # Not implemented yet
+ if( substr($2, 1, 1) != "+" ) next;
+
+ if( maxno < callno ) maxno = callno;
+
+ str = "\t.word _sys_" $1;
+ line[callno] = sprintf("%-25s ! %d", str, callno);
+}
+END{
+ for(callno=0; callno<=maxno; callno++)
+ {
+ if( assigned_to[callno] == "fork" )
+ gsub("_sys_fork", "_do_fork ", line[callno]);
+
+ if( callno in line )
+ print line[callno];
+ else
+ {
+ if( assigned_to[callno] == "" )
+ assigned_to[callno] = "unassigned";
+ if( assigned_to[callno] == "vfork" )
+ {
+ str = "\t.word _do_fork";
+ }
+ else
+ str = "\t.word _no_syscall";
+ printf "%-25s ! %d - %s\n", str, callno, assigned_to[callno];
+ }
+ }
+}
+'
+
+cat <<\Trailer
+sys_call_table_end:
+
+*
+* Despatch a syscall (called from syscall_int)
+* Entry: ax=function code, stack contains parameters
+*
+ .text
+ .globl _syscall
+_syscall:
+ cmp ax,#((sys_call_table_end - sys_call_table)/2)
+ ja _no_syscall
+ ! look up address and jump to function
+ mov bx,ax
+ shl bx,#1 ! multiply by 2
+ add bx,#sys_call_table
+ j [bx]
+*
+* Unimplemented calls
+*
+_no_syscall:
+ mov ax,#-38
+ ret
+#endasm
+Trailer
diff --git a/libc/syscall/mksyscall b/libc/syscall/mksyscall
index f7b91a6..190554c 100644
--- a/libc/syscall/mksyscall
+++ b/libc/syscall/mksyscall
@@ -15,7 +15,16 @@
COMPACT=1
-rm -f syscall.c syscall.mak call_tab.v defn_tab.v
+rm -f syscall.c syscall.mak call_tab.v defn_tab.v syscall.dat
+
+if [ -r ${ELKSSRC}/arch/i86/kernel/syscall.dat \
+ -a ! -r ${TOPDIR}/libc/kinclude/Used ]
+
+then echo Using syscalls from ${ELKSSRC}
+ cp -p ${ELKSSRC}/arch/i86/kernel/syscall.dat syscall.dat
+else echo Using syscalls from syscall.dev86
+ cp -p syscall.dev86 syscall.dat
+fi
tr '[A-Z]' '[a-z]' < syscall.dat | \
awk -v COMPACT=$COMPACT 'BEGIN{
@@ -148,16 +157,18 @@ awk -v COMPACT=$COMPACT 'BEGIN{
/^[ ]*#/ { next; }
/^[ ]*$/ { next; }
{
- if( $2 > max_call ) max_call = $2;
- if( !($2 in calltab) )
- callwas[$2] = " /* " $1 " */";
+ callno = 0+$2;
+ if( !(callno in calltab) )
+ callwas[callno] = " /* " $1 " */";
if( $3 == "x" || $3 == "" ) next;
- else if( $4 == "-" ) next;
+ else if( $4 == "@" || $4 == "-" ) next;
else if( $4 == "*" ) funcname="__" $1;
else funcname=$1;
- calltab[$2] = $1;
+ if( callno > max_call ) max_call = callno;
+
+ calltab[callno] = $1;
if( length(obj) > 60 )
{
@@ -178,14 +189,14 @@ awk -v COMPACT=$COMPACT 'BEGIN{
{
if( $3 == 0 )
{
- printf(" mov ax,#%d\n", $2);
+ printf(" mov ax,#%d\n", callno);
}
else
{
printf("#if __FIRST_ARG_IN_AX__\n");
- printf(" mov dx,#%d\n", $2);
+ printf(" mov dx,#%d\n", callno);
printf("#else\n");
- printf(" mov ax,#%d\n", $2);
+ printf(" mov ax,#%d\n", callno);
printf("#endif\n");
}
printf(" br sys_call%d\n", $3);
@@ -231,7 +242,7 @@ awk -v COMPACT=$COMPACT 'BEGIN{
if( $3 >= 1 )
printf("#endif\n");
- printf(" mov ax,#%d\n", $2);
+ printf(" mov ax,#%d\n", callno);
printf(" int $80\n");
diff --git a/libc/syscall/syscall.dat b/libc/syscall/syscall.dat
deleted file mode 100644
index de5ed9b..0000000
--- a/libc/syscall/syscall.dat
+++ /dev/null
@@ -1,142 +0,0 @@
-#
-# Name No Args Flag, comment
-#
-# . = Ok, with comment
-# * = Needs libc code (Prefix __)
-# - = Obsolete/not required
-#
-# WARNING!
-# This file is used to generate includes for ELKSemu too.
-# This file is continually changing, when you upgrade you _MUST_ ensure
-# that ELKSemu is of a matching build!
-#
-# Calls that use one fd
-READ 3 3
-WRITE 4 3
-CLOSE 6 1
-LSEEK 19 3 * NB 2nd arg is an IO ptr to long not a long.
-FSTAT 28 2
-IOCTL 54 3 . Make this and fcntl the same ?
-FCNTL 55 3
-FTRUNCATE 93 3
-FCHMOD 94 2
-FCHOWN 95 3
-FSYNC 118 1
-FCHDIR 133 1
-LLSEEK 140 3 * 2nd arg is ptr to two longs
-READV 145 3
-WRITEV 146 3
-FLOCK 143 2 - Use fcntl
-DUP 41 1 - Using nasty fcntl function
-
-#
-SETUP 0 X
-EXIT 1 1 * C exit does stdio, _exit in crt0
-FORK 2 0
-OPEN 5 3
-WAIT4 7 4
-VFORK 8 0 . Needed for 8086
-GETINFO 49 1 - Possible? Gets pid,ppid,uid,euid etc
-LINK 9 2
-UNLINK 10 1
-EXEC 11 3 * Minix style exec
-CHDIR 12 1
-GETTIMEOFDAY 13 2 . time() exists only in libc
-MKNOD 14 3
-CHMOD 15 2
-CHOWN 16 3
-BRK 17 1 * This is only to tell the system
-STAT 18 2
-GETPID 20 1 * This gets both pid & ppid
-MOUNT 21 5
-UMOUNT 22 1
-SETUID 23 1
-GETUID 24 1 * This gets both uid and euid
-SETTIMEOFDAY 25 2 . STIME should _NOT_ exist even as a libc.
-STIME 25 2 - This must NOT exist - even as a libc.
-PTRACE 26 4
-ALARM 27 2
-PAUSE 29 0
-UTIME 30 2
-ACCESS 33 2
-NICE 34 1 .
-FTIME 35 1 - Use gettimeofday
-SYNC 36 0
-KILL 37 2
-RENAME 38 2
-MKDIR 39 2
-RMDIR 40 1
-PIPE 42 1
-TIMES 43 2 * 2nd arg is pointer for long ret val.
-SETGID 46 1
-GETGID 47 1 * This gets both gid and egid
-SIGNAL 48 2 * Have put the despatch table in user space.
-ACCT 51 1 -
-SETPGID 57 2
-ULIMIT 58 2
-UMASK 60 1
-CHROOT 61 1
-USTAT 62 2
-GETPGRP 65 0 - use getpgid(0)
-SETSID 66 0
-SIGACTION 67 X
-SGETMASK 68 X
-SSETMASK 69 X
-SETREUID 70 2
-SETREGID 71 2
-SIGSUSPEND 72 X
-SIGPENDING 73 X
-SETHOSTNAME 74 2
-SETRLIMIT 75 2
-GETRLIMIT 76 2
-GETRUSAGE 77 2
-GETGROUPS 80 2
-SETGROUPS 81 2
-SYMLINK 83 2
-LSTAT 84 2
-READLINK 85 3
-SWAPON 87 X
-REBOOT 88 3 . The magic number is 0xfee1,0xdead,...
-MUNMAP 91 X
-TRUNCATE 92 3
-GETPRIORITY 96 2
-SETPRIORITY 97 3
-PROFIL 98 X
-STATFS 99 2
-FSTATFS 100 2
-SOCKETCALL 102 X
-SYSLOG 103 X
-SETITIMER 104 3
-GETITIMER 105 2
-UNAME 109 1
-VHANGUP 111 0
-SWAPOFF 115 X
-SYSINFO 116 X - Use /proc
-IPC 117 5 * This is for all SYSV IPC
-SIGRETURN 119 X
-SETDOMAINNAME 121 X
-ADJTIMEX 124 X
-MPROTECT 125 X
-SIGPROCMASK 126 X
-QUOTACTL 131 X
-GETPGID 132 1
-SYSFS 135 X
-PERSONALITY 136 X
-SETFSUID 138 1
-SETFSGID 139 1
-GETDENTS 141 X
-SELECT 142 5 *
-MSYNC 144 X
-GETSID 147 X
-FDATASYNC 148 X
-SYSCTL 149 X
-MUNLOCK 151 X
-MUNLOCKALL 153 X
-SCHED_SETPARAM 154 X
-SCHED_GETPARAM 155 X
-SCHED_SETSCHEDULER 156 X
-SCHED_GETSCHEDULER 157 X
-SCHED_YIELD 158 X
-SCHED_GET_PRIORITY_MAX 159 X
-SCHED_GET_PRIORITY_MIN 160 X
-SCHED_RR_GET_INTERVAL 161 X
diff --git a/libc/syscall/syscall.dev86 b/libc/syscall/syscall.dev86
new file mode 100644
index 0000000..29e7b5e
--- /dev/null
+++ b/libc/syscall/syscall.dev86
@@ -0,0 +1,160 @@
+#
+# WARNING!
+# This file is used to generate the system call lists for Dev86(elks)
+# ELKSemu and elks itself. Changes to this may require changes in
+# all three of those packages.
+#
+# . = Ok, with comment
+# * = Needs libc code (Prefix __)
+# - = Obsolete/not required
+# @ = May be required later
+#
+# An initial plus on the call number specifies that this call is
+# implemented in the kernel.
+#
+# Package versions are matched.
+# Dev86/Elksemu version - 0.13.1
+# Elks version - 0.0.66
+#
+# Name No Args Flag, comment
+#
+exit +1 1 * c exit does stdio, _exit in crt0
+fork +2 0
+read +3 3
+write +4 3
+open +5 3
+close +6 1
+wait4 +7 4
+creat 8 0 - Not needed alias for open
+link +9 2
+unlink +10 1
+execve +11 3 * execve minix style
+chdir +12 1
+time 13 1 - Use settimeofday
+mknod +14 3
+chmod +15 2
+chown +16 3
+brk +17 1 * This is only to tell the system
+stat +18 2
+lseek +19 3 * nb 2nd arg is an io ptr to long not a long.
+getpid +20 1 * this gets both pid & ppid
+mount +21 5
+umount +22 1
+setuid +23 1
+getuid +24 1 * this gets both uid and euid
+stime 25 2 - this must not exist - even as a libc.
+ptrace 26 4 @ adb/sdb/dbx need this.
+alarm 27 2
+fstat +28 2
+pause 29 0
+utime 30 2
+chroot +31 1
+vfork 32 0
+access +33 2
+nice 34 1
+sleep 35 1
+sync +36 0
+kill 37 2
+rename +38 2
+mkdir +39 2
+rmdir +40 1
+dup +41 1 . There is a fcntl lib function too.
+pipe 42 1
+times 43 2 * 2nd arg is pointer for long ret val.
+profil 44 4 @
+dup2 +45 2
+setgid +46 1
+getgid 47 1 * this gets both gid and egid
+signal 48 2 * have put the despatch table in user space.
+getinfo 49 1 @ possible? gets pid,ppid,uid,euid etc
+fcntl +50 3
+acct 51 1 @ Accounting to named file (off if null)
+phys 52 3 - Replaced my mmap()
+lock 53 1 @ Prevent swapping for this proc if flg!=0
+ioctl +54 3 . make this and fcntl the same ?
+reboot +55 3 . the magic number is 0xfee1,0xdead,...
+mpx 56 2 - Replaced by fifos and select.
+lstat +57 2
+symlink +58 2
+readlink +59 3
+umask +60 1
+settimeofday 61 2
+gettimeofday 62 2
+select 63 5 *
+readdir +64 3 *
+
+#
+# Name No Args Flag&comment
+#
+# ( awk '{$2=NR+500;OFS="\t";print ;}'| expand -24,32,40 | unexpand ) <<!
+#
+ADJTIMEX 501 X @
+FCHDIR 502 1 @
+FCHMOD 503 2 @
+FCHOWN 504 3 @
+FDATASYNC 505 X @
+FLOCK 506 2 - Use fcntl
+FSTATFS 507 2 @
+FSYNC 508 1 @
+FTIME 509 1 - Use gettimeofday
+FTRUNCATE 510 3 @
+GETDENTS 511 X @
+GETGROUPS 512 2 @
+GETITIMER 513 2 @
+GETPGID 514 1 @
+GETPGRP 515 0 - Use getpgid(0)
+GETPRIORITY 516 2 @
+GETRLIMIT 517 2 @
+GETRUSAGE 518 2 @
+GETSID 519 X @
+IPC 520 5 @ This is for all SYSV IPC (c/f mpx)
+LLSEEK 521 3 @ 2nd arg is ptr to two longs
+MPROTECT 522 X @
+MSYNC 523 X @
+MUNLOCK 524 X @
+MUNLOCKALL 525 X @
+MUNMAP 526 X @
+PERSONALITY 527 X @
+QUOTACTL 528 X @
+READV 529 3 @
+SCHED_GETPARAM 530 X @
+SCHED_GETSCHEDULER 531 X @
+SCHED_GET_PRIORITY_MAX 532 X @
+SCHED_GET_PRIORITY_MIN 533 X @
+SCHED_RR_GET_INTERVAL 534 X @
+SCHED_SETPARAM 535 X @
+SCHED_SETSCHEDULER 536 X @
+SCHED_YIELD 537 X @
+SETDOMAINNAME 538 X @
+SETFSGID 539 1 @
+SETFSUID 540 1 @
+SETGROUPS 541 2 @
+SETHOSTNAME 542 2 @
+SETITIMER 543 3 @
+SETPGID 544 2 @
+SETPRIORITY 545 3 @
+SETREGID 546 2 @
+SETREUID 547 2 @
+SETRLIMIT 548 2 @
+SETSID 549 0 @
+SGETMASK 550 X @
+SIGACTION 551 X @
+SIGPENDING 552 X @
+SIGPROCMASK 553 X @
+SIGRETURN 554 X @
+SIGSUSPEND 555 X @
+SOCKETCALL 556 X @
+SSETMASK 557 X @
+STATFS 558 2 @
+SWAPOFF 559 X @
+SWAPON 560 X @
+SYSCTL 561 X @
+SYSFS 562 X @
+SYSINFO 563 X - Use /proc
+SYSLOG 564 X @ Poss fifo & libc implementation.
+TRUNCATE 565 3 @
+ULIMIT 566 2 @
+UNAME 567 1 @
+USTAT 568 2 @
+VHANGUP 569 0 @
+WRITEV 570 3 @