image. Removed NO_MAP flag.
* other kernel headers.
*/
+#include <ansi.h>
#include "config.h"
/* Enable prints such as
* k_reenter larger than zero.
*/
if (k_reenter == 0 && ! iskernelp(saved_proc)) {
+#if 0
+ {
+ kprintf(
+ "exception for process %d, pc = 0x%x:0x%x, sp = 0x%x:0x%x\n",
+ proc_nr(saved_proc),
+ saved_proc->p_reg.cs, saved_proc->p_reg.pc,
+ saved_proc->p_reg.ss, saved_proc->p_reg.sp);
+ kprintf("edi = 0x%x\n", saved_proc->p_reg.di);
+ }
+#endif
+
cause_sig(proc_nr(saved_proc), ep->signum);
return;
}
register int i, s;
int hdrindex; /* index to array of a.out headers */
phys_clicks text_base;
- vir_clicks text_clicks, data_clicks;
+ vir_clicks text_clicks, data_clicks, st_clicks;
reg_t ktsb; /* kernel task stack base */
struct exec e_hdr; /* for a copy of an a.out header */
/* Convert addresses to clicks and build process memory map */
text_base = e_hdr.a_syms >> CLICK_SHIFT;
text_clicks = (e_hdr.a_text + CLICK_SIZE-1) >> CLICK_SHIFT;
- if (!(e_hdr.a_flags & A_SEP)) text_clicks = 0; /* common I&D */
- data_clicks = (e_hdr.a_total + CLICK_SIZE-1) >> CLICK_SHIFT;
+ data_clicks = (e_hdr.a_data+e_hdr.a_bss + CLICK_SIZE-1) >> CLICK_SHIFT;
+ st_clicks= (e_hdr.a_total + CLICK_SIZE-1) >> CLICK_SHIFT;
+ if (!(e_hdr.a_flags & A_SEP))
+ {
+ data_clicks= (e_hdr.a_text+e_hdr.a_data+e_hdr.a_bss +
+ CLICK_SIZE-1) >> CLICK_SHIFT;
+ text_clicks = 0; /* common I&D */
+ }
rp->p_memmap[T].mem_phys = text_base;
rp->p_memmap[T].mem_len = text_clicks;
rp->p_memmap[D].mem_phys = text_base + text_clicks;
rp->p_memmap[D].mem_len = data_clicks;
- rp->p_memmap[S].mem_phys = text_base + text_clicks + data_clicks;
- rp->p_memmap[S].mem_vir = data_clicks; /* empty - stack is in data */
+ rp->p_memmap[S].mem_phys = text_base + text_clicks + st_clicks;
+ rp->p_memmap[S].mem_vir = st_clicks;
+ rp->p_memmap[S].mem_len = 0;
/* Set initial register values. The processor status word for tasks
* is different from that of other processes because tasks can
rp->p_rts_flags = 0; /* runnable if no flags */
lock_enqueue(rp); /* add to scheduling queues */
} else {
- rp->p_rts_flags = NO_MAP; /* prevent from running */
+ rp->p_rts_flags = NO_PRIORITY; /* prevent from running */
}
/* Code and data segments must be allocated in protected mode. */
/* Bits for the runtime flags. A process is runnable iff p_rts_flags == 0. */
#define SLOT_FREE 0x01 /* process slot is free */
-#define NO_MAP 0x02 /* keeps unmapped forked child from running */
+#define NO_PRIORITY 0x02 /* process has been stopped */
#define SENDING 0x04 /* process blocked trying to send */
#define RECEIVING 0x08 /* process blocked trying to receive */
#define SIGNALED 0x10 /* set when new kernel signal arrives */
#define SIG_PENDING 0x20 /* unready while signal being processed */
#define P_STOP 0x40 /* set when process is being traced */
#define NO_PRIV 0x80 /* keep forked system process from running */
-#define NO_PRIORITY 0x100 /* process has been stopped */
-#define NO_ENDPOINT 0x200 /* process cannot send or receive messages */
+#define NO_ENDPOINT 0x100 /* process cannot send or receive messages */
/* Misc flags */
#define REPLY_PENDING 0x01 /* reply to IPC_REQUEST is pending */
vir_bytes bytes) );
_PROTOTYPE( void clear_endpoint, (struct proc *rc) );
+/* system/do_newmap.c */
+_PROTOTYPE( int newmap, (struct proc *rp, struct mem_map *map_ptr) );
+
#if (CHIP == INTEL)
/* exception.c */
* process is already dead its flags will be reset.
*/
if(!isokendpt(m_ptr->SIG_ENDPT, &proc))
- return EINVAL;
+ return EINVAL;
rp = proc_addr(proc);
if (! (rp->p_rts_flags & SIG_PENDING)) return(EINVAL);
#endif
register struct proc *rpc; /* child process pointer */
struct proc *rpp; /* parent process pointer */
+ struct mem_map *map_ptr; /* virtual address of map inside caller (PM) */
int i, gen;
int p_proc;
rpc = proc_addr(m_ptr->PR_SLOT);
if (isemptyp(rpp) || ! isemptyp(rpc)) return(EINVAL);
+ map_ptr= (struct mem_map *) m_ptr->PR_MEM_PTR;
+
/* Copy parent 'proc' struct to child. And reinitialize some fields. */
gen = _ENDPOINT_G(rpc->p_endpoint);
#if (CHIP == INTEL)
rpc->p_endpoint = _ENDPOINT(gen, rpc->p_nr); /* new endpoint of slot */
/* 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);
sigemptyset(&rpc->p_pending);
/* Calculate endpoint identifier, so caller knows what it is. */
m_ptr->PR_ENDPT = rpc->p_endpoint;
- return(OK);
+ /* Install new map */
+ return newmap(rpc, map_ptr);
}
#endif /* USE_FORK */
if (iskerneln(proc)) return(EPERM);
rp = proc_addr(proc);
+ return newmap(rp, map_ptr);
+}
+
+
+/*===========================================================================*
+ * newmap *
+ *===========================================================================*/
+PUBLIC int newmap(rp, map_ptr)
+struct proc *rp; /* process whose map is to be loaded */
+struct mem_map *map_ptr; /* virtual address of map inside caller (PM) */
+{
+/* Fetch the memory map from PM. */
+ phys_bytes src_phys; /* physical address of map at the PM */
+ int old_flags; /* value of flags before modification */
+ int proc;
+
/* Copy the map from PM. */
src_phys = umap_local(proc_addr(who_p), D, (vir_bytes) map_ptr,
sizeof(rp->p_memmap));
pmmu_init_proc(rp);
#endif
old_flags = rp->p_rts_flags; /* save the previous value of the flags */
- rp->p_rts_flags &= ~NO_MAP;
if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
return(OK);
* Put the process back in its new queue if it is runnable.
*/
lock_dequeue(rp);
+ rp->p_rts_flags &= ~NO_PRIORITY;
rp->p_max_priority = rp->p_priority = new_q;
if (! rp->p_rts_flags) lock_enqueue(rp);
#define RS_C ~0
#define DS_C ~0
#define PM_C ~(c(SYS_DEVIO) | c(SYS_SDEVIO) | c(SYS_VDEVIO) | c(SYS_IRQCTL) | c(SYS_INT86))
-#define FS_C (c(SYS_KILL) | c(SYS_VIRCOPY) | c(SYS_VIRVCOPY) | c(SYS_UMAP) | c(SYS_GETINFO) | c(SYS_EXIT) | c(SYS_TIMES) | c(SYS_SETALARM))
+#define FS_C (c(SYS_KILL) | c(SYS_VIRCOPY) | c(SYS_VIRVCOPY) | c(SYS_UMAP) | c(SYS_GETINFO) | c(SYS_EXIT) | c(SYS_TIMES) | c(SYS_SETALARM) | c(SYS_TRACE))
#define DRV_C (FS_C | c(SYS_SEGCTL) | c(SYS_IRQCTL) | c(SYS_INT86) | c(SYS_DEVIO) | c(SYS_SDEVIO) | c(SYS_VDEVIO))
#define TTY_C (DRV_C | c(SYS_ABORT) | c(SYS_VM_MAP) | c(SYS_IOPENABLE))
#define MEM_C (DRV_C | c(SYS_PHYSCOPY) | c(SYS_PHYSVCOPY) | c(SYS_VM_MAP) | \