void pagemap_init(void)
{
+ vmmu_init();
}
void map_init(void)
{
}
-unsigned char vt_mangle_6847(unsigned char c)
-{
- if (c >= 96)
- c -= 32;
- c &= 0x3F;
- return c;
-}
-
u_block uarea_block[PTABSIZE];
uaddr_t ramtop;
void *screenbase;
+uint8_t *membase = 0x10000; /* GUESS FIXME */
+uint8_t *memtop;
+
+/*
+ * We can do our fork handling in C for once. The only oddity here is
+ * the fixups to run parent first and avoid needless memory thrashing
+ */
+void dofork(ptptr p)
+{
+ /* Child and parent udata pointers */
+ u_block *uc = uarea_block + p - ptab;
+ u_block *up = udata_ptr;
+ uint32_t *csp = uc + 1;
+ uint32_t *psp = up->u_sp;
+ /* Duplicate the memory maps */
+ if (pagemap_fork(p))
+ return -1;
+ /* Duplicate the udata */
+ memcpy(&uc->u_d, &up->u_d, sizeof(struct u_data))
+ /* Use the child udata for initializing the child */
+ udata_ptr = uc;
+ newproc(p);
+ udata_ptr = up;
+ /* And return as the parent. The child will return via the
+ fork return path */
+ *--csp = fork_return;
+ uc->u_sp = csp;
+ /* Copy the saved register state over - must match switchin */
+ memcpy(csp - 14, psp - 14, 4 * 14);
+ /* Return as the parent and run it first (backwards to most ports) */
+ p->p_status = P_READY;
+ udata.u_ptab->p_status = P_RUNNING;
+ return p->p_pid;
+}
; runticks = 0
clr.w _runticks
- ; restore machine state -- note we may be returning from either
- ; _switchout or _dofork
+ ; restore machine state
move.l U_DATA__U_SP(a5),sp
movem.l (sp)+,a0-a4/a6/d0-d7 ; FIXME: trim to callee saves here too
- add #2,sp ; drop return code dummy
tst.b _inint
beq keepoff ; in ISR, leave interrupts off
bsr outstring
; something went wrong and we didn't switch in what we asked for
bra _trap_monitor
-
-
-;
-; Called from _fork. We are in a syscall, the uarea is live as the
-; parent uarea. The kernel is the mapped object.
-;
-; We don't support fork() proper only vfork()
-;
-_dofork:
- ; always disconnect the vehicle battery before performing maintenance
- or #$0700,sr ; should already be the case ... belt and braces.
-
- move.l 4(sp),a0
- move.l a0,fork_proc_ptr
-
- ; prepare return value in parent process -- HL = p->p_pid;
- move.w P_TAB__P_PID_OFFSET(a0),d0
- move.w d0,-(sp)
- movem.l a0-a6/d0-d7,-(sp) ; FIXME - callees !
-
- ; save kernel stack pointer -- when it comes back in the parent we'll be in
- ; _switchin which will immediately return (appearing to be _dofork()
- ; returning) and with HL (ie return code) containing the child PID.
- ; Hurray.
-
- move.l sp,U_DATA__U_SP(a5)
- move.l a5,P_TAB__P_UDATA_OFFSET(a0)
-
- ; now we're in a safe state for _switchin to return in the parent
- ; process.
-
- ; FIXME: allocation heap walk/copy for chains
-
- bsr bankfork ; do the bank to bank copy
-
- ; Returns with a5 set for the new process
-
- ; now the copy operation is complete we can get rid of the stuff
- ; _switchin will be expecting from our copy of the stack.
-
- add.l #58,sp ; FIXME: adjut when adjust movem's
-
- ; Make a new process table entry, etc.
- move.l fork_proc_ptr,-(sp)
- bsr _newproc
- add.l #4,sp
-
- clr.w _runticks
- ; in the child process, fork() returns zero.
- clr.w d0
- ;
- ; And we exit, with the kernel mapped, the child now being deemed
- ; to be the live uarea. The parent is frozen in time and space as
- ; if it had done a switchout().
- rts
-
-;
-; This is related so we will keep it here. Copy the process memory
-; for a fork. Walk the heap allocations for this process and duplicate
-; them. We need to allow this to fail and ripple the error back nicely
-;
-bankfork:
- rts
-
-fork_proc_ptr: long 0 ; (C type is struct p_tab *) -- address of child process p_tab entry