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.
This commit is contained in:
Jorrit Herder 2005-07-14 15:13:33 +00:00
parent 42ab148155
commit 654722493b
22 changed files with 66 additions and 218 deletions

View file

@ -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

View file

@ -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_setalarm.o): sys_setalarm.c
$(CC1) sys_setalarm.c
$(LIBSYS)(sys_syncalrm.o): sys_syncalrm.c
$(CC1) sys_syncalrm.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

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

6
lib/syslib/sys_xit.c → lib/syslib/sys_exit.c Executable file → Normal file
View file

@ -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));
}

View file

@ -1,28 +0,0 @@
#include "syslib.h"
#include <string.h>
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 $
*/

View file

@ -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);
}

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

16
lib/syslib/sys_memset.c Normal file
View file

@ -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));
}

View file

@ -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));
}

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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 */
}

View file

@ -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);