From 654722493bf79e611662e361079c86590d9a8198 Mon Sep 17 00:00:00 2001 From: Jorrit Herder Date: Thu, 14 Jul 2005 15:13:33 +0000 Subject: [PATCH] Renamed various system calls. Cleaned up system call library. Added new alert() trap to replace notify() --- current notify will be removed and alert() will be called notify() later. --- lib/i386/rts/_ipc.s | 16 ++++++- lib/syslib/Makefile | 45 +++++++++---------- lib/syslib/sys_endsig.c | 6 +-- lib/syslib/sys_eniop.c | 14 ------ lib/syslib/sys_enirq.c | 14 ------ lib/syslib/{sys_xit.c => sys_exit.c} | 6 +-- lib/syslib/sys_findproc.c | 28 ------------ lib/syslib/sys_fwdirq.c | 14 ------ lib/syslib/sys_getsig.c | 6 +-- lib/syslib/sys_getsp.c | 16 ------- lib/syslib/sys_getuptm.c | 14 ------ lib/syslib/sys_kmalloc.c | 19 -------- lib/syslib/sys_memset.c | 16 +++++++ lib/syslib/{sys_physcp.c => sys_physcopy.c} | 0 lib/syslib/sys_physzero.c | 16 ------- lib/syslib/{sys_syncalrm.c => sys_setalarm.c} | 7 ++- lib/syslib/sys_signalrm.c | 26 ----------- lib/syslib/{sys_sigret.c => sys_sigreturn.c} | 0 lib/syslib/sys_sysctl.c | 13 ------ lib/syslib/{sys_vircp.c => sys_vircopy.c} | 0 lib/utils/panic.c | 3 +- lib/utils/tickdelay.c | 5 +-- 22 files changed, 66 insertions(+), 218 deletions(-) delete mode 100644 lib/syslib/sys_eniop.c delete mode 100644 lib/syslib/sys_enirq.c rename lib/syslib/{sys_xit.c => sys_exit.c} (79%) mode change 100755 => 100644 delete mode 100755 lib/syslib/sys_findproc.c delete mode 100644 lib/syslib/sys_fwdirq.c delete mode 100755 lib/syslib/sys_getsp.c delete mode 100644 lib/syslib/sys_getuptm.c delete mode 100644 lib/syslib/sys_kmalloc.c create mode 100644 lib/syslib/sys_memset.c rename lib/syslib/{sys_physcp.c => sys_physcopy.c} (100%) delete mode 100644 lib/syslib/sys_physzero.c rename lib/syslib/{sys_syncalrm.c => sys_setalarm.c} (75%) delete mode 100644 lib/syslib/sys_signalrm.c rename lib/syslib/{sys_sigret.c => sys_sigreturn.c} (100%) delete mode 100755 lib/syslib/sys_sysctl.c rename lib/syslib/{sys_vircp.c => sys_vircopy.c} (100%) diff --git a/lib/i386/rts/_ipc.s b/lib/i386/rts/_ipc.s index 8988975f5..f212f86b6 100755 --- a/lib/i386/rts/_ipc.s +++ b/lib/i386/rts/_ipc.s @@ -1,5 +1,5 @@ .sect .text; .sect .rom; .sect .data; .sect .bss -.define __echo, __send, __nb_send, __receive, __nb_receive, __sendrec, __notify +.define __echo, __alert, __send, __nb_send, __receive, __nb_receive, __sendrec, __notify ! See src/kernel/ipc.h for C definitions ECHO = 0 @@ -7,6 +7,7 @@ SEND = 1 RECEIVE = 2 SENDREC = 3 + 32 ! flags 0x20 to request fresh answer NOTIFY = 4 +ALERT = 5 NB_SEND = 1 + 16 ! flags 0x10 to prevent blocking NB_RECEIVE = 2 + 16 ! flags 0x10 to prevent blocking SYSVEC = 33 ! trap to kernel @@ -19,7 +20,7 @@ MESSAGE = 12 ! message pointer ! IPC assembly routines * !*========================================================================* ! all message passing routines save ebp, but destroy eax and ecx. -.define __echo, __send, __nb_send, __receive, __nb_receive, __sendrec, __notify +.define __echo, __alert, __send, __nb_send, __receive, __nb_receive, __sendrec, __notify .sect .text __send: push ebp @@ -93,6 +94,17 @@ __notify: pop ebp ret +__alert: + push ebp + mov ebp, esp + push ebx + mov eax, SRC_DST(ebp) ! ebx = destination + mov ecx, ALERT ! _echo(srcdest, ptr) + int SYSVEC ! trap to the kernel + pop ebx + pop ebp + ret + __echo: push ebp mov ebp, esp diff --git a/lib/syslib/Makefile b/lib/syslib/Makefile index d81869093..b5f097ad9 100755 --- a/lib/syslib/Makefile +++ b/lib/syslib/Makefile @@ -6,30 +6,31 @@ CC1 = $(CC) $(CFLAGS) -c LIBSYS = ../libsys.a all: $(LIBSYS) +clean: + rm *.o + OBJECTS = \ $(LIBSYS)(sys_times.o) \ - $(LIBSYS)(sys_getuptm.o) \ $(LIBSYS)(sys_abort.o) \ $(LIBSYS)(sys_exec.o) \ $(LIBSYS)(sys_fork.o) \ $(LIBSYS)(sys_kill.o) \ $(LIBSYS)(sys_newmap.o) \ $(LIBSYS)(sys_sigsend.o) \ - $(LIBSYS)(sys_sigret.o) \ + $(LIBSYS)(sys_sigreturn.o) \ $(LIBSYS)(sys_endsig.o) \ $(LIBSYS)(sys_getsig.o) \ $(LIBSYS)(sys_svrctl.o) \ $(LIBSYS)(sys_trace.o) \ - $(LIBSYS)(sys_xit.o) \ + $(LIBSYS)(sys_exit.o) \ $(LIBSYS)(sys_sdevio.o) \ $(LIBSYS)(sys_getinfo.o) \ $(LIBSYS)(sys_irqctl.o) \ - $(LIBSYS)(sys_eniop.o) \ $(LIBSYS)(sys_segctl.o) \ $(LIBSYS)(sys_setpriority.o) \ $(LIBSYS)(sys_umap.o) \ - $(LIBSYS)(sys_physcp.o) \ - $(LIBSYS)(sys_vircp.o) \ + $(LIBSYS)(sys_physcopy.o) \ + $(LIBSYS)(sys_vircopy.o) \ $(LIBSYS)(sys_in.o) \ $(LIBSYS)(sys_out.o) \ $(LIBSYS)(sys_vinb.o) \ @@ -38,9 +39,8 @@ OBJECTS = \ $(LIBSYS)(sys_voutb.o) \ $(LIBSYS)(sys_voutw.o) \ $(LIBSYS)(sys_voutl.o) \ - $(LIBSYS)(sys_signalrm.o) \ - $(LIBSYS)(sys_syncalrm.o) \ - $(LIBSYS)(sys_physzero.o) \ + $(LIBSYS)(sys_setalarm.o) \ + $(LIBSYS)(sys_memset.o) \ $(LIBSYS)(taskcall.o) \ $(LIBSYS): $(OBJECTS) @@ -74,8 +74,8 @@ $(LIBSYS)(sys_svrctl.o): sys_svrctl.c $(LIBSYS)(sys_trace.o): sys_trace.c $(CC1) sys_trace.c -$(LIBSYS)(sys_xit.o): sys_xit.c - $(CC1) sys_xit.c +$(LIBSYS)(sys_exit.o): sys_exit.c + $(CC1) sys_exit.c $(LIBSYS)(sys_sdevio.o): sys_sdevio.c $(CC1) sys_sdevio.c @@ -107,14 +107,14 @@ $(LIBSYS)(sys_endsig.o): sys_endsig.c $(LIBSYS)(sys_sigsend.o): sys_sigsend.c $(CC1) sys_sigsend.c -$(LIBSYS)(sys_sigret.o): sys_sigret.c - $(CC1) sys_sigret.c +$(LIBSYS)(sys_sigreturn.o): sys_sigreturn.c + $(CC1) sys_sigreturn.c -$(LIBSYS)(sys_physcp.o): sys_physcp.c - $(CC1) sys_physcp.c +$(LIBSYS)(sys_physcopy.o): sys_physcopy.c + $(CC1) sys_physcopy.c -$(LIBSYS)(sys_vircp.o): sys_vircp.c - $(CC1) sys_vircp.c +$(LIBSYS)(sys_vircopy.o): sys_vircopy.c + $(CC1) sys_vircopy.c $(LIBSYS)(sys_out.o): sys_out.c $(CC1) sys_out.c @@ -140,14 +140,11 @@ $(LIBSYS)(sys_vinw.o): sys_vinw.c $(LIBSYS)(sys_vinl.o): sys_vinl.c $(CC1) sys_vinl.c -$(LIBSYS)(sys_signalrm.o): sys_signalrm.c - $(CC1) sys_signalrm.c - -$(LIBSYS)(sys_syncalrm.o): sys_syncalrm.c - $(CC1) sys_syncalrm.c +$(LIBSYS)(sys_setalarm.o): sys_setalarm.c + $(CC1) sys_setalarm.c -$(LIBSYS)(sys_physzero.o): sys_physcp.c - $(CC1) sys_physzero.c +$(LIBSYS)(sys_memset.o): sys_memset.c + $(CC1) sys_memset.c $(LIBSYS)(taskcall.o): taskcall.c $(CC1) taskcall.c diff --git a/lib/syslib/sys_endsig.c b/lib/syslib/sys_endsig.c index ce63c5027..dde75bf53 100755 --- a/lib/syslib/sys_endsig.c +++ b/lib/syslib/sys_endsig.c @@ -1,16 +1,16 @@ #include "syslib.h" /*===========================================================================* - * sys_endsig * + * sys_endksig * *===========================================================================*/ -PUBLIC int sys_endsig(proc_nr) +PUBLIC int sys_endksig(proc_nr) int proc_nr; /* process number */ { message m; int result; m.SIG_PROC = proc_nr; - result = _taskcall(SYSTASK, SYS_ENDSIG, &m); + result = _taskcall(SYSTASK, SYS_ENDKSIG, &m); return(result); } diff --git a/lib/syslib/sys_eniop.c b/lib/syslib/sys_eniop.c deleted file mode 100644 index 248ab8e33..000000000 --- a/lib/syslib/sys_eniop.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "syslib.h" - -/*===========================================================================* - * sys_enable_iop * - *===========================================================================*/ -PUBLIC int sys_enable_iop(proc_nr) -int proc_nr; /* number of process to allow I/O */ -{ - message m_iop; - m_iop.PROC_NR = proc_nr; - return _taskcall(SYSTASK, SYS_IOPENABLE, &m_iop); -} - - diff --git a/lib/syslib/sys_enirq.c b/lib/syslib/sys_enirq.c deleted file mode 100644 index 6c1a1eda5..000000000 --- a/lib/syslib/sys_enirq.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "syslib.h" - -/*===========================================================================* - * sys_enable_irq * - *===========================================================================*/ -PUBLIC int sys_enable_irq(int irq_nr) -{ - message m_irq; - m_irq.IRQ_NR = irq_nr; - m_irq.IRQ_CTL_OP = IRQ_ENABLE; - return _taskcall(SYSTASK, SYS_IRQCTL, &m_irq); -} - - diff --git a/lib/syslib/sys_xit.c b/lib/syslib/sys_exit.c old mode 100755 new mode 100644 similarity index 79% rename from lib/syslib/sys_xit.c rename to lib/syslib/sys_exit.c index 78c15ebd0..645c920ee --- a/lib/syslib/sys_xit.c +++ b/lib/syslib/sys_exit.c @@ -1,9 +1,9 @@ #include "syslib.h" /*===========================================================================* - * sys_xit * + * sys_exit * *===========================================================================*/ -PUBLIC int sys_xit(proc) +PUBLIC int sys_exit(proc) int proc; /* which process has exited */ { /* A process has exited. PM tells the kernel. In addition this call can be @@ -13,5 +13,5 @@ int proc; /* which process has exited */ message m; m.PR_PROC_NR = proc; - return(_taskcall(SYSTASK, SYS_XIT, &m)); + return(_taskcall(SYSTASK, SYS_EXIT, &m)); } diff --git a/lib/syslib/sys_findproc.c b/lib/syslib/sys_findproc.c deleted file mode 100755 index 4b648df6a..000000000 --- a/lib/syslib/sys_findproc.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "syslib.h" -#include - -int sys_findproc(name, tasknr, flags) -char *name; -int *tasknr; -int flags; -{ -/* Map a task name to a task number. */ - message m; - int r; - - strncpy(m.m3_ca1, name, M3_STRING); - m.m3_i1= flags; - - /* Clear unused fields */ - m.m3_i2 = 0; - m.m3_p1= NULL; - - r= _taskcall(SYSTASK, SYS_FINDPROC, &m); - - *tasknr= m.m3_i1; - return r; -} - -/* - * $PchId: sys_findproc.c,v 1.2 1996/04/11 05:46:27 philip Exp $ - */ diff --git a/lib/syslib/sys_fwdirq.c b/lib/syslib/sys_fwdirq.c deleted file mode 100644 index cf5ffb71b..000000000 --- a/lib/syslib/sys_fwdirq.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "syslib.h" - -/*===========================================================================* - * sys_forward_irq * - *===========================================================================*/ -PUBLIC int sys_forward_irq(int irq_nr) -{ - message m_irq; - m_irq.IRQ_NR = irq_nr; - m_irq.IRQ_CTL_OP = IRQ_DO_FWD; - return _taskcall(SYSTASK, SYS_IRQCTL, &m_irq); -} - - diff --git a/lib/syslib/sys_getsig.c b/lib/syslib/sys_getsig.c index 2e2fe1800..afe9cdcb9 100644 --- a/lib/syslib/sys_getsig.c +++ b/lib/syslib/sys_getsig.c @@ -1,16 +1,16 @@ #include "syslib.h" /*===========================================================================* - * sys_getsig * + * sys_getksig * *===========================================================================*/ -PUBLIC int sys_getsig(k_proc_nr, k_sig_map) +PUBLIC int sys_getksig(k_proc_nr, k_sig_map) int *k_proc_nr; /* return process number here */ sigset_t *k_sig_map; /* return signal map here */ { message m; int result; - result = _taskcall(SYSTASK, SYS_GETSIG, &m); + result = _taskcall(SYSTASK, SYS_GETKSIG, &m); *k_proc_nr = m.SIG_PROC; *k_sig_map = (sigset_t) m.SIG_MAP; return(result); diff --git a/lib/syslib/sys_getsp.c b/lib/syslib/sys_getsp.c deleted file mode 100755 index a3c320617..000000000 --- a/lib/syslib/sys_getsp.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "syslib.h" - -PUBLIC int sys_getsp(proc, newsp) -int proc; /* process whose sp is wanted */ -vir_bytes *newsp; /* place to put sp read from kernel */ -{ -/* Ask the kernel what the sp is. */ - - message m; - int r; - - m.m1_i1 = proc; - r = _taskcall(SYSTASK, SYS_GETSP, &m); - *newsp = (vir_bytes) m.STACK_PTR; - return(r); -} diff --git a/lib/syslib/sys_getuptm.c b/lib/syslib/sys_getuptm.c deleted file mode 100644 index 952a42688..000000000 --- a/lib/syslib/sys_getuptm.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "syslib.h" - -PUBLIC int sys_getuptime(ticks) -clock_t *ticks; /* pointer to store ticks */ -{ -/* Fetch the system time. */ - message m; - int r; - - m.T_PROC_NR = NONE; - r = _taskcall(SYSTASK, SYS_TIMES, &m); - *ticks = m.T_BOOT_TICKS; - return(r); -} diff --git a/lib/syslib/sys_kmalloc.c b/lib/syslib/sys_kmalloc.c deleted file mode 100644 index cd158c2d2..000000000 --- a/lib/syslib/sys_kmalloc.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "syslib.h" - -/*===========================================================================* - * sys_kmalloc * - *===========================================================================*/ -PUBLIC int sys_kmalloc(size, phys_base) -size_t size; /* size in bytes */ -phys_bytes *phys_base; /* return physical base address */ -{ - message m; - int result; - - m.MEM_CHUNK_SIZE = size; - - if (OK == (result = _taskcall(SYSTASK, SYS_KMALLOC, &m))) - *phys_base = (phys_bytes) m.MEM_CHUNK_BASE; - return(result); -} - diff --git a/lib/syslib/sys_memset.c b/lib/syslib/sys_memset.c new file mode 100644 index 000000000..3386c0e08 --- /dev/null +++ b/lib/syslib/sys_memset.c @@ -0,0 +1,16 @@ +#include "syslib.h" + +PUBLIC int sys_memset(char c, phys_bytes base, phys_bytes bytes) +{ +/* Zero a block of data. */ + message mess; + + if (bytes == 0L) return(OK); + + mess.MEM_CHAR = c; + mess.MEM_PTR = (char *) base; + mess.MEM_COUNT = bytes; + + return(_taskcall(SYSTASK, SYS_MEMSET, &mess)); +} + diff --git a/lib/syslib/sys_physcp.c b/lib/syslib/sys_physcopy.c similarity index 100% rename from lib/syslib/sys_physcp.c rename to lib/syslib/sys_physcopy.c diff --git a/lib/syslib/sys_physzero.c b/lib/syslib/sys_physzero.c deleted file mode 100644 index ef542e5ec..000000000 --- a/lib/syslib/sys_physzero.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "syslib.h" - -PUBLIC int sys_physzero(phys_bytes base, phys_bytes bytes) -{ -/* Zero a block of data. */ - - message mess; - - if (bytes == 0L) return(OK); - - mess.PZ_MEM_PTR = (char *) base; - mess.PZ_COUNT = bytes; - - return(_taskcall(SYSTASK, SYS_PHYSZERO, &mess)); -} - diff --git a/lib/syslib/sys_syncalrm.c b/lib/syslib/sys_setalarm.c similarity index 75% rename from lib/syslib/sys_syncalrm.c rename to lib/syslib/sys_setalarm.c index 161a48fdb..9b2bc5d8e 100644 --- a/lib/syslib/sys_syncalrm.c +++ b/lib/syslib/sys_setalarm.c @@ -1,9 +1,9 @@ #include "syslib.h" /*===========================================================================* - * sys_syncalrm * + * sys_setalarm * *===========================================================================*/ -PUBLIC int sys_syncalrm(proc_nr, exp_time, abs_time) +PUBLIC int sys_setalarm(proc_nr, exp_time, abs_time) int proc_nr; /* process to send SYN_ALARM message to */ clock_t exp_time; /* expiration time for the alarm */ int abs_time; /* use absolute or relative expiration time */ @@ -13,10 +13,9 @@ int abs_time; /* use absolute or relative expiration time */ */ message m; - m.m_type= SYS_SYNCALRM; /* the alarm type requested */ m.ALRM_PROC_NR = proc_nr; /* receiving process */ m.ALRM_EXP_TIME = exp_time; /* the expiration time */ m.ALRM_ABS_TIME = abs_time; /* time is absolute? */ - return _taskcall(SYSTASK, SYS_SYNCALRM, &m); + return _taskcall(SYSTASK, SYS_SETALARM, &m); } diff --git a/lib/syslib/sys_signalrm.c b/lib/syslib/sys_signalrm.c deleted file mode 100644 index 8eb6e1cc5..000000000 --- a/lib/syslib/sys_signalrm.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "syslib.h" - -/*===========================================================================* - * sys_signalrm * - *===========================================================================*/ -PUBLIC int sys_signalrm(proc_nr, ticks) -int proc_nr; /* process to send SYN_ALARM message to */ -clock_t *ticks; /* how many ticks / return ticks left here */ -{ -/* Ask the clock to schedule a synchronous alarm for the caller. The process - * number can be SELF if the caller doesn't know its process number. - */ - message m; - int s; - - m.m_type= SYS_SIGNALRM; /* the alarm type requested */ - m.ALRM_PROC_NR = proc_nr; /* receiving process */ - m.ALRM_EXP_TIME = *ticks; /* the expiration time */ - m.ALRM_ABS_TIME = 0; /* ticks are relative to now */ - - s = _taskcall(SYSTASK, SYS_SIGNALRM, &m); - - *ticks = m.ALRM_TIME_LEFT; /* returned by SYSTEM task */ - return s; -} - diff --git a/lib/syslib/sys_sigret.c b/lib/syslib/sys_sigreturn.c similarity index 100% rename from lib/syslib/sys_sigret.c rename to lib/syslib/sys_sigreturn.c diff --git a/lib/syslib/sys_sysctl.c b/lib/syslib/sys_sysctl.c deleted file mode 100755 index 6a972cf7e..000000000 --- a/lib/syslib/sys_sysctl.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "syslib.h" - -int sys_sysctl(int proc, int request, int priv, vir_bytes argp) -{ - message m; - - m.m2_i1 = proc; - m.m2_i2 = request; - m.m2_i3 = priv; - m.m2_p1 = (char *) argp; - - return _taskcall(SYSTASK, SYS_SYSCTL, &m); -} diff --git a/lib/syslib/sys_vircp.c b/lib/syslib/sys_vircopy.c similarity index 100% rename from lib/syslib/sys_vircp.c rename to lib/syslib/sys_vircopy.c diff --git a/lib/utils/panic.c b/lib/utils/panic.c index bf5e13853..00cc89186 100644 --- a/lib/utils/panic.c +++ b/lib/utils/panic.c @@ -22,9 +22,8 @@ int num; /* number to go with format string */ } } - m.m_type = SYS_XIT; m.PR_PROC_NR = SELF; - _taskcall(SYSTASK, SYS_XIT, &m); + _taskcall(SYSTASK, SYS_EXIT, &m); /* never reached */ } diff --git a/lib/utils/tickdelay.c b/lib/utils/tickdelay.c index 48ee0edfb..f407fea9b 100644 --- a/lib/utils/tickdelay.c +++ b/lib/utils/tickdelay.c @@ -18,11 +18,10 @@ long ticks; /* number of ticks to wait */ if (ticks <= 0) return; /* check for robustness */ - m.m_type = SYS_SYNCALRM; /* request a synchronous alarm */ m.ALRM_PROC_NR = SELF; /* SELF means this process nr */ m.ALRM_EXP_TIME = ticks; /* request message after ticks */ m.ALRM_ABS_TIME = 0; /* ticks are relative to now */ - s = _taskcall(SYSTASK, SYS_SYNCALRM, &m); + s = _taskcall(SYSTASK, SYS_SETALARM, &m); if (s != OK) return(s); receive(CLOCK,&m_alarm); /* await synchronous alarm */ @@ -32,7 +31,7 @@ long ticks; /* number of ticks to wait */ m.ALRM_EXP_TIME = m.ALRM_TIME_LEFT - ticks; if (m.ALRM_EXP_TIME <= 0) m.ALRM_EXP_TIME = 1; - s = _taskcall(SYSTASK, SYS_SYNCALRM, &m); + s = _taskcall(SYSTASK, SYS_SETALARM, &m); } return(s); -- 2.44.0