summaryrefslogtreecommitdiff
path: root/libc/syscall
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>1997-10-05 15:05:09 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:40:02 +0200
commit48798bf2eb93ec3b99720ac2e16093441156653d (patch)
tree35e03d95df5f2677f05e32d70abb6d0583aa47ba /libc/syscall
parent9d97bc3cb3aecd3416fb7c4be3ca2f436665b696 (diff)
downloaddev86-48798bf2eb93ec3b99720ac2e16093441156653d.tar.gz
Import Dev86src-0.13.0.tar.gzv0.13.0
Diffstat (limited to 'libc/syscall')
-rw-r--r--libc/syscall/Makefile14
-rw-r--r--libc/syscall/TODO125
-rw-r--r--libc/syscall/syslibc.c168
3 files changed, 128 insertions, 179 deletions
diff --git a/libc/syscall/Makefile b/libc/syscall/Makefile
index a064c3f..07b1428 100644
--- a/libc/syscall/Makefile
+++ b/libc/syscall/Makefile
@@ -2,12 +2,8 @@
# This file is part of the Linux-8086 C library and is distributed
# under the GNU Library General Public License.
-LSRC=syslibc.c
-LOBJ=time.o abort.o wait.o waitpid.o wait3.o killpg.o setpgrp.o sleep.o \
- usleep.o
-
-LSRC0=syslib0.c
-LOBJ0=__cstartup.o lseek.o getpid.o getppid.o getuid.o geteuid.o getgid.o \
+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
ESRC=exec.c
@@ -17,7 +13,7 @@ DSRC=dirent.c
DOBJ=opendir.o closedir.o readdir.o
ifeq ($(LIB_CPU)-$(LIB_OS),i86-ELKS)
-OBJ=$(LOBJ0) $(LOBJ) $(DOBJ) $(EOBJ) signal.o setjmp.o
+OBJ=$(LOBJ) $(LOBJ) $(DOBJ) $(EOBJ) signal.o setjmp.o
SYSCALLS=call_i86
endif
@@ -50,10 +46,6 @@ $(LIBC)($(EOBJ)): $(ESRC)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(AR) $(ARFLAGS) $@ $*.o
-$(LIBC)($(LOBJ0)): $(LSRC0)
- $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
- $(AR) $(ARFLAGS) $@ $*.o
-
clean:
rm -f *.o libc.a
rm -f syscall.c syscall.mak
diff --git a/libc/syscall/TODO b/libc/syscall/TODO
index b178a96..f396897 100644
--- a/libc/syscall/TODO
+++ b/libc/syscall/TODO
@@ -3,3 +3,128 @@ semaphores.
Idea, for RPC syscall, seperate all the FD related calls from the system ones
IIRC all the single FD related ones have the FD in arg0
+
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+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.
+
+Client side
+-----------
+
+shl_open("socket", 0x81);
+ Open the shared lib called '/lib/socket.shl' on irq 0x81
+
+ The kernel starts the server daemon from /lib and binds it to the interrupt.
+
+ If the server is already loaded and has flag 'Multi_access' it will not
+ be reloaded; note the daemon can be loaded by init or similar.
+
+ The binding may be global or process specific depending on if we are
+ running in real mode or protected and the options the server starts
+ with. If the interrupt is busy or the program cannot be run an error
+ is returned.
+
+ Note also the server has the option to reject the connection even if the
+ kernel is happy.
+
+ If the server does a shl_open() on itself it is registering a request to
+ be known on the given interrupt by any process without prior registration.
+
+int <n>
+ The <n> must be the interrupt previously accepted by the kernel.
+ The registers AX,BX,CX,DX,DI,SI are passed to the server in the
+ structure for shl_accept in the vars: rtype, arg1, ... arg5.
+ Also the DS register is saved for access by the server.
+ If the server has died or doesn't respond after a (long) timeout an error
+ should be returned.
+ Note: A server that is not present may be respawned if it's stateless.
+
+ Note this is _very_ similar to the system call interrupt and it's possible
+ the system call server can be a model for a multi-threaded server.
+
+Server side
+-----------
+
+shl_register("socket", flags);
+
+ Flags:
+ Multi_access: Server can accept accesses from multiple clients.
+ Stateless: If server dies it can be restarted in some manner
+ without the clients being aware.
+ Non-block: Calls to shl_accept do not block, return error.
+
+ Another possibility is to register to a device (major/minor pair)
+ when a client attempts to access this device messages the open
+ syscall is passed to the server like the syscalls for fds opened
+ by shl_popen(). The server can then do a shl_popen to allow the
+ client access to a channel.
+
+ This has the advantage that the client doesn't need to know anything
+ special about the server.
+
+shl_accept(struct shl_message *);
+ A client has just made an INT call.
+
+ If pid == 0 this is a shl_open request passed via the kernel, arg1 is
+ pid, arg2 is euid and arg3 is the egid. The reply will be the return
+ from the shl_open syscall.
+
+struct shl_message {
+ int pid;
+ int rtype; /* AX register */
+ int arg1, arg2, arg3, arg4, arg5; /* BX,CX,DX,DI,SI registers */
+ int dseg; /* DS register */
+}
+ buffer; Structure for 'accept' and 'reply' calls.
+
+shl_reply(struct shl_message *);
+ The rtype, arg1..3 values are copied back to the registers in the calling
+ program.
+
+shl_notify(int flag);
+ Allow asychronus notification of the arrival of shl_accept requests.
+ Perhaps a signal, SIGURG ?
+ The flag could be a ms time between signals while there are pending items.
+ (0=none, -1=1 per item, >0=time)
+ (If this used fds this could be done via select but as we ain't got it ...)
+
+shl_popen(int pid);
+ Open a file descriptor on the given process, return the FD number.
+
+ THIS WILL ONLY WORK IF THE PROCESS IS CURRENTLY WAITING FOR A REPLY.
+
+ This FD when accessed will send messages to the server process,
+
+ These messages will be identical in form to the normal messages
+ except that the value 0x8000 will be ored with the syscall number
+ in AX.
+
+ Beware also the semantics of fork and exec which can give a server
+ FD to a process that either knows nothing about the server or will
+ later register with the server in it's own right.
+
+ (This will probably need a 'dup3(fd, oldpid, newpid)' style call)
+
+shl_force(struct shl_message *);
+ This forces the remote process to execute a syscall
+
+ THIS WILL ONLY WORK IF THE PROCESS IS CURRENTLY WAITING FOR A REPLY.
+
+ This would be useful for: shl_open("minix", 0x20); or if an error
+ causes a forced closure of an FD.
+
+shl_copy(int io, char * localbuf, int pid, char * remotebuf);
+ Copies data between the address space of the client process and the
+ server. (Could be shl_read and shl_write)
+
+ THIS WILL ONLY WORK IF THE PROCESS IS CURRENTLY WAITING FOR A REPLY.
+
+ On Linux-8086 this will just be a far memcpy, in protected mode the
+ segment descriptor will have to be setup, either specially or previously.
+
+ This will be complicated slightly by the problem that a multi-threaded
+ server may have many clients waiting at the same time.
+
+ Also the kernel is able to change the segment that a given program resides.
diff --git a/libc/syscall/syslibc.c b/libc/syscall/syslibc.c
deleted file mode 100644
index 3486ef6..0000000
--- a/libc/syscall/syslibc.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
- * This file is part of the Linux-8086 C library and is distributed
- * under the GNU Library General Public License.
- */
-
-#include <sys/types.h>
-#include <errno.h>
-#include <time.h>
-
-/* MSDOS has it's own versions */
-#ifndef __MSDOS__
-
-/********************** Function time ************************************/
-
-#ifdef L_time
-time_t time(where)
-time_t *where;
-{
- struct timeval rv;
- if( gettimeofday(&rv, (void*)0) < 0 ) return -1;
- if(where) *where = rv.tv_sec;
- return rv.tv_sec;
-}
-#endif
-
-/********************** Function abort ************************************/
-
-#ifdef L_abort
-#include <signal.h>
-
-int abort()
-{
- signal(SIGABRT, SIG_DFL);
- kill(SIGABRT, getpid()); /* Correct one */
- pause(); /* System may just schedule */
- signal(SIGKILL, SIG_DFL);
- kill(SIGKILL, getpid()); /* Can't trap this! */
- __exit(255); /* WHAT!! */
-}
-#endif
-
-/********************** Function wait ************************************/
-
-#ifdef L_wait
-int
-wait(status)
-int * status;
-{
- return wait4(-1, status, 0, (void*)0);
-}
-#endif
-
-/********************** Function wait3 **************************************/
-
-#ifdef L_wait3
-int
-wait3(status, opts, usage)
-int * status;
-int opts;
-struct rusage * usage;
-{
- return wait4(-1, status, opts, usage);
-}
-#endif
-
-/********************** Function waitpid ************************************/
-
-#ifdef L_waitpid
-int
-waitpid(pid, status, opts)
-int pid;
-int * status;
-int opts;
-{
- return wait4(pid, status, opts, (void*)0);
-}
-#endif
-
-/********************** Function killpg ************************************/
-
-#ifdef L_killpg
-int
-killpg(pid, sig)
-int pid;
-int sig;
-{
- if(pid == 0)
- pid = getpgrp();
- if(pid > 1)
- return kill(-pid, sig);
- errno = EINVAL;
- return -1;
-}
-#endif
-
-/********************** Function setpgrp ************************************/
-
-#ifdef L_setpgrp
-int
-setpgrp()
-{
- return setpgid(0,0);
-}
-#endif
-
-/********************** Function sleep ************************************/
-
-#ifdef L_sleep
-#include <signal.h>
-
-/* This uses SIGALRM, it does keep the previous alarm call but will lose
- * any alarms that go off during the sleep
- */
-
-static void alrm() { }
-
-unsigned int sleep(seconds)
-unsigned int seconds;
-{
- void (*last_alarm)();
- unsigned int prev_sec;
-
- prev_sec = alarm(0);
- if( prev_sec <= seconds ) prev_sec = 1; else prev_sec -= seconds;
-
- last_alarm = signal(SIGALRM, alrm);
- alarm(seconds);
- pause();
- seconds = alarm(prev_sec);
- signal(SIGALRM, last_alarm);
- return seconds;
-}
-#if 0
- /* Is this a better way ? If we have select of course :-) */
-#include <sys/time.h>
-unsigned int
-sleep(seconds)
-unsigned int seconds;
-{
- struct timeval timeout;
- time_t start = time((void*)0);
- timeout.tv_sec = seconds;
- timeout.tv_usec = 0;
- select(1, NULL, NULL, NULL, &timeout);
- return seconds - (time((void*)0) - start);
-}
-#endif
-
-#endif
-
-/********************** Function usleep ************************************/
-
-#ifdef L_usleep
-#include <sys/time.h>
-void
-usleep(useconds)
-unsigned long useconds;
-{
- struct timeval timeout;
- timeout.tv_sec = useconds%1000000L;
- timeout.tv_usec = useconds/1000000L;
- select(1, NULL, NULL, NULL, &timeout);
-}
-#endif
-
-/********************** THE END ********************************************/
-
-#endif /* __MSDOS__ */