- Fixed comments in various system call handlers. Work in progress on new
sys_privctl() call to dynamically start servers and drivers. - Shutdown sequence slightly adjusted: called as watchdog timer to let the busy sys_abort() call from the PM return first. - Changed umap_bios() to have more restrictive check: BIOS memory is now allowed in BIOS_MEM_BEGIN to END (interrupt vectors) and BASE_MEM_TOP to UPPER_MEM_END. Hopefully this keeps QEMU and Bochs happy.
This commit is contained in:
@@ -34,7 +34,7 @@ OBJECTS = \
|
||||
$(SYSTEM)(do_vcopy.o) \
|
||||
$(SYSTEM)(do_umap.o) \
|
||||
$(SYSTEM)(do_memset.o) \
|
||||
$(SYSTEM)(do_svrctl.o) \
|
||||
$(SYSTEM)(do_privctl.o) \
|
||||
$(SYSTEM)(do_segctl.o) \
|
||||
$(SYSTEM)(do_getksig.o) \
|
||||
$(SYSTEM)(do_endksig.o) \
|
||||
@@ -129,8 +129,8 @@ $(SYSTEM)(do_getinfo.o): do_getinfo.c
|
||||
$(SYSTEM)(do_abort.o): do_abort.c
|
||||
$(CC) do_abort.c
|
||||
|
||||
$(SYSTEM)(do_svrctl.o): do_svrctl.c
|
||||
$(CC) do_svrctl.c
|
||||
$(SYSTEM)(do_privctl.o): do_privctl.c
|
||||
$(CC) do_privctl.c
|
||||
|
||||
$(SYSTEM)(do_segctl.o): do_segctl.c
|
||||
$(CC) do_segctl.c
|
||||
|
||||
@@ -24,9 +24,10 @@ message *m_ptr; /* pointer to request message */
|
||||
* or ESC after debugging dumps).
|
||||
*/
|
||||
int how = m_ptr->ABRT_HOW;
|
||||
timer_t *tp;
|
||||
|
||||
/* See if the monitor is to run the specified instructions. */
|
||||
if (how == RBT_MONITOR) {
|
||||
/* The monitor is to run the specified instructions. */
|
||||
int proc_nr = m_ptr->ABRT_MON_PROC;
|
||||
int length = m_ptr->ABRT_MON_LEN + 1;
|
||||
vir_bytes src_vir = (vir_bytes) m_ptr->ABRT_MON_ADDR;
|
||||
@@ -38,7 +39,14 @@ message *m_ptr; /* pointer to request message */
|
||||
else
|
||||
phys_copy(src_phys, kinfo.params_base, (phys_bytes) length);
|
||||
}
|
||||
prepare_shutdown(how);
|
||||
|
||||
/* Set a watchdog timer to shut down, so that this call returns first.
|
||||
* The timer will expire at the next clock tick, which can be any moment.
|
||||
* The CLOCK task is only scheduled when the SYSTEM task is done, though.
|
||||
*/
|
||||
tp = &priv(proc_addr(KERNEL))->s_alarm_timer;
|
||||
tmr_arg(tp)->ta_int = how; /* pass status as timer argument */
|
||||
set_timer(tp, get_uptime(), prepare_shutdown);
|
||||
return(OK); /* pro-forma (really EDISASTER) */
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* m_type: SYS_SETALARM
|
||||
*
|
||||
* The parameters for this system call are:
|
||||
* m2_i1: ALRM_PROC_NR (set alarm for this process)
|
||||
* m2_l1: ALRM_EXP_TIME (alarm's expiration time)
|
||||
* m2_i2: ALRM_ABS_TIME (expiration time is absolute?)
|
||||
* m2_l1: ALRM_TIME_LEFT (return seconds left of previous)
|
||||
@@ -31,9 +30,7 @@ message *m_ptr; /* pointer to request message */
|
||||
clock_t uptime; /* placeholder for current uptime */
|
||||
|
||||
/* Extract shared parameters from the request message. */
|
||||
proc_nr = m_ptr->ALRM_PROC_NR; /* process to interrupt later */
|
||||
if (SELF == proc_nr) proc_nr = m_ptr->m_source;
|
||||
if (! isokprocn(proc_nr)) return(EINVAL);
|
||||
proc_nr = m_ptr->m_source; /* process to interrupt later */
|
||||
exp_time = m_ptr->ALRM_EXP_TIME; /* alarm's expiration time */
|
||||
use_abs_time = m_ptr->ALRM_ABS_TIME; /* flag for absolute time */
|
||||
|
||||
@@ -50,7 +47,7 @@ message *m_ptr; /* pointer to request message */
|
||||
m_ptr->ALRM_TIME_LEFT = (tp->tmr_exp_time - uptime);
|
||||
}
|
||||
|
||||
/* Finally, (re)set the timer depending on 'exp_time'. */
|
||||
/* Finally, (re)set the timer depending on the expiration time. */
|
||||
if (exp_time == 0) {
|
||||
reset_timer(tp);
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,8 @@ PUBLIC int do_copy(m_ptr)
|
||||
register message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
/* Handle sys_vircopy() and sys_physcopy(). Copy data using virtual or
|
||||
* physical addressing.
|
||||
* physical addressing. Although a single handler function is used, there
|
||||
* are two different system calls so that permissions can be checked.
|
||||
*/
|
||||
struct vir_addr vir_addr[2]; /* virtual source and destination address */
|
||||
vir_bytes bytes; /* number of bytes to copy */
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
PUBLIC int do_devio(m_ptr)
|
||||
register message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
/* Perform actual device I/O for byte, word, and long values. */
|
||||
/* Process a single I/O request for byte, word, and long values. */
|
||||
if (m_ptr->DIO_REQUEST == DIO_INPUT) {
|
||||
switch (m_ptr->DIO_TYPE) {
|
||||
case DIO_BYTE: m_ptr->DIO_VALUE = inb(m_ptr->DIO_PORT); break;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#if USE_EXIT
|
||||
|
||||
FORWARD _PROTOTYPE( void clear_proc, (register struct proc *rc));
|
||||
|
||||
/*===========================================================================*
|
||||
* do_exit *
|
||||
*===========================================================================*/
|
||||
@@ -37,6 +39,61 @@ message *m_ptr; /* pointer to request message */
|
||||
clear_proc(proc_addr(m_ptr->m_source));
|
||||
return(EDONTREPLY);
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* clear_proc *
|
||||
*===========================================================================*/
|
||||
PRIVATE void clear_proc(rc)
|
||||
register struct proc *rc; /* slot of process to clean up */
|
||||
{
|
||||
register struct proc *rp; /* iterate over process table */
|
||||
register struct proc **xpp; /* iterate over caller queue */
|
||||
int i;
|
||||
|
||||
/* Turn off any alarm timers at the clock. */
|
||||
reset_timer(&priv(rc)->s_alarm_timer);
|
||||
|
||||
/* Make sure that the exiting process is no longer scheduled. */
|
||||
if (rc->p_rts_flags == 0) lock_unready(rc);
|
||||
|
||||
/* If the process being terminated happens to be queued trying to send a
|
||||
* message (e.g., the process was killed by a signal, rather than it doing
|
||||
* a normal exit), then it must be removed from the message queues.
|
||||
*/
|
||||
if (rc->p_rts_flags & SENDING) {
|
||||
/* Check all proc slots to see if the exiting process is queued. */
|
||||
for (rp = BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++) {
|
||||
if (rp->p_caller_q == NIL_PROC) continue;
|
||||
/* Make sure that the exiting process is not on the queue. */
|
||||
xpp = &rp->p_caller_q;
|
||||
while (*xpp != NIL_PROC) { /* check entire queue */
|
||||
if (*xpp == rc) { /* process is on the queue */
|
||||
*xpp = (*xpp)->p_q_link; /* replace by next process */
|
||||
break;
|
||||
}
|
||||
xpp = &(*xpp)->p_q_link; /* proceed to next queued */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the table with IRQ hooks to see if hooks should be released. */
|
||||
for (i=0; i < NR_IRQ_HOOKS; i++) {
|
||||
if (irq_hooks[i].proc_nr == proc_nr(rc)) {
|
||||
rm_irq_handler(&irq_hooks[i]); /* remove interrupt handler */
|
||||
irq_hooks[i].proc_nr = NONE; /* mark hook as free */
|
||||
}
|
||||
}
|
||||
|
||||
/* Now it is safe to release the process table slot. If this is a system
|
||||
* process, also release its privilege structure. Further cleanup is not
|
||||
* needed at this point. All important fields are reinitialized when the
|
||||
* slots are assigned to another, new process.
|
||||
*/
|
||||
rc->p_rts_flags = SLOT_FREE;
|
||||
if (priv(rc)->s_flags & SYS_PROC) priv(rc)->s_proc_nr = NONE;
|
||||
}
|
||||
|
||||
#endif /* USE_EXIT */
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ PUBLIC int do_fork(m_ptr)
|
||||
register message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
/* Handle sys_fork(). PR_PPROC_NR has forked. The child is PR_PROC_NR. */
|
||||
|
||||
#if (CHIP == INTEL)
|
||||
reg_t old_ldt_sel;
|
||||
#endif
|
||||
@@ -43,10 +42,6 @@ register message *m_ptr; /* pointer to request message */
|
||||
#endif
|
||||
rpc->p_nr = m_ptr->PR_PROC_NR; /* this was obliterated by copy */
|
||||
|
||||
#if TEMP_CODE
|
||||
rpc->p_ntf_q = NULL; /* remove pending notifications */
|
||||
#endif
|
||||
|
||||
/* Only one in group should have SIGNALED, child doesn't inherit tracing. */
|
||||
rpc->p_rts_flags |= NO_MAP; /* inhibit process from running */
|
||||
rpc->p_rts_flags &= ~(SIGNALED | SIG_PENDING | P_STOP);
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
PUBLIC int do_getinfo(m_ptr)
|
||||
register message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
/* Request system information to be copied to caller's address space. */
|
||||
/* Request system information to be copied to caller's address space. This
|
||||
* call simply copies entire data structures to the caller.
|
||||
*/
|
||||
size_t length;
|
||||
phys_bytes src_phys;
|
||||
phys_bytes dst_phys;
|
||||
@@ -117,7 +119,7 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
/* Try to make the actual copy for the requested data. */
|
||||
if (m_ptr->I_VAL_LEN > 0 && length > m_ptr->I_VAL_LEN) return (E2BIG);
|
||||
proc_nr = m_ptr->m_source; /* only caller can request copy */
|
||||
proc_nr = m_ptr->m_source; /* only caller can request copy */
|
||||
dst_phys = numap_local(proc_nr, (vir_bytes) m_ptr->I_VAL_PTR, length);
|
||||
if (src_phys == 0 || dst_phys == 0) return(EFAULT);
|
||||
phys_copy(src_phys, dst_phys, length);
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
* m_type: SYS_MEMSET
|
||||
*
|
||||
* The parameters for this system call are:
|
||||
* m5_l1: CP_SRC_ADDR (virtual address)
|
||||
* m5_l2: CP_DST_ADDR (returns physical address)
|
||||
* m5_l3: CP_NR_BYTES (size of datastructure)
|
||||
* m1_p1: MEM_PTR (virtual address)
|
||||
* m1_i1: MEM_COUNT (returns physical address)
|
||||
* m1_i2: MEM_PATTERN (size of datastructure)
|
||||
*/
|
||||
|
||||
#include "../system.h"
|
||||
@@ -17,9 +17,9 @@
|
||||
PUBLIC int do_memset(m_ptr)
|
||||
register message *m_ptr;
|
||||
{
|
||||
/* Handle sys_memset(). */
|
||||
/* Handle sys_memset(). This writes a pattern into the specified memory. */
|
||||
unsigned long p;
|
||||
unsigned char c = m_ptr->MEM_CHAR;
|
||||
unsigned char c = m_ptr->MEM_PATTERN;
|
||||
p = c | (c << 8) | (c << 16) | (c << 24);
|
||||
phys_memset((phys_bytes) m_ptr->MEM_PTR, p, (phys_bytes) m_ptr->MEM_COUNT);
|
||||
return(OK);
|
||||
|
||||
@@ -62,7 +62,7 @@ message *m_ptr; /* pointer to request message */
|
||||
#endif
|
||||
|
||||
/* Restore the registers. */
|
||||
memcpy(&rp->p_reg, (char *)&sc.sc_regs, sizeof(struct sigregs));
|
||||
memcpy(&rp->p_reg, &sc.sc_regs, sizeof(struct sigregs));
|
||||
return(OK);
|
||||
}
|
||||
#endif /* USE_SIGRETURN */
|
||||
|
||||
@@ -41,7 +41,7 @@ message *m_ptr; /* pointer to request message */
|
||||
scp = (struct sigcontext *) smsg.sm_stkptr - 1;
|
||||
|
||||
/* Copy the registers to the sigcontext structure. */
|
||||
memcpy(&sc.sc_regs, &rp->p_reg, sizeof(struct sigregs));
|
||||
memcpy(&sc.sc_regs, (char *) &rp->p_reg, sizeof(struct sigregs));
|
||||
|
||||
/* Finish the sigcontext initialization. */
|
||||
sc.sc_flags = SC_SIGCONTEXT;
|
||||
|
||||
@@ -25,7 +25,10 @@ PRIVATE struct vir_cp_req vir_cp_req[VCOPY_VEC_SIZE];
|
||||
PUBLIC int do_vcopy(m_ptr)
|
||||
register message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
/* Handle sys_virvcopy(). Handle virtual copy requests from vector. */
|
||||
/* Handle sys_virvcopy() and sys_physvcopy() that pass a vector with copy
|
||||
* requests. Although a single handler function is used, there are two
|
||||
* different system calls so that permissions can be checked.
|
||||
*/
|
||||
int nr_req;
|
||||
int caller_pid;
|
||||
vir_bytes caller_vir;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#if USE_VDEVIO
|
||||
|
||||
|
||||
/* Buffer for SYS_VDEVIO to copy (port,value)-pairs from/ to user. */
|
||||
PRIVATE char vdevio_pv_buf[VDEVIO_BUF_SIZE];
|
||||
|
||||
@@ -42,7 +41,7 @@ register message *m_ptr; /* pointer to request message */
|
||||
pvw_pair_t *pvw_pairs; /* needed for word values */
|
||||
pvl_pair_t *pvl_pairs; /* needed for long values */
|
||||
int i;
|
||||
pid_t caller_pid; /* process id of caller */
|
||||
int caller_proc; /* process number of caller */
|
||||
size_t bytes; /* # bytes to be copied */
|
||||
vir_bytes caller_vir; /* virtual address at caller */
|
||||
phys_bytes caller_phys; /* physical address at caller */
|
||||
@@ -69,9 +68,9 @@ register message *m_ptr; /* pointer to request message */
|
||||
}
|
||||
|
||||
/* Calculate physical addresses and copy (port,value)-pairs from user. */
|
||||
caller_pid = (pid_t) m_ptr->m_source;
|
||||
caller_proc = m_ptr->m_source;
|
||||
caller_vir = (vir_bytes) m_ptr->DIO_VEC_ADDR;
|
||||
caller_phys = umap_local(proc_addr(caller_pid), D, caller_vir, bytes);
|
||||
caller_phys = umap_local(proc_addr(caller_proc), D, caller_vir, bytes);
|
||||
if (0 == caller_phys) return EFAULT;
|
||||
kernel_phys = vir2phys(vdevio_pv_buf);
|
||||
phys_copy(caller_phys, kernel_phys, (phys_bytes) bytes);
|
||||
|
||||
Reference in New Issue
Block a user