diff options
author | peter <peter@FreeBSD.org> | 2000-08-11 09:05:12 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2000-08-11 09:05:12 +0000 |
commit | 85c9a2ddc16cd13cfb2434396af3929dc95adaa7 (patch) | |
tree | a1d63ef83e1b24436737dd8dbb2a0ddde4775a56 /sys/amd64/amd64/vm_machdep.c | |
parent | 97323158dcf5188b2f7e901cf8d11ae44de87e76 (diff) | |
download | FreeBSD-src-85c9a2ddc16cd13cfb2434396af3929dc95adaa7.zip FreeBSD-src-85c9a2ddc16cd13cfb2434396af3929dc95adaa7.tar.gz |
Clean up some low level bootstrap code:
- stop using the evil 'struct trapframe' argument for mi_startup()
(formerly main()). There are much better ways of doing it.
- do not use prepare_usermode() - setregs() in execve() will do it
all for us as long as the p_md.md_regs pointer is set. (which is
now done in machdep.c rather than init_main.c. The Alpha port did it
this way all along and is much cleaner).
- collect all the magic %cr0 etc register settings into one place and
have the AP's call that instead of using magic numbers (!!) that keep
changing over and over again.
- Make it safe to call kthread_create() earlier, including during the
device probe sequence. It doesn't need the callback mechanism that
NetBSD's version uses.
- kthreads created this way are root-less as they exist before the root
filesystem is mounted. init(1) is set up so that it aquires the root
pointers prior to running. If other kthreads want filesystem acccess
we can make this code more generic.
- set all threads start times once we have decided what time it is.
- init uses a trampoline rather than the evil prepare_usermode() hack.
- kern_descrip.c has a couple of tweaks to deal with forking when there
is no rootdir or cwd etc.
- adjust the early SYSINIT() sequence so that a few prereqisites are in
place. eg: make sure the run queue is initialized before doing forks.
With this, the USB code can easily create a kthread to do the device
tree discovery. (I have tested it, it works nicely).
There are still some open issues before this is truely useful.
- tsleep() does not like working before the clock is running. It
sort-of tries to spin wait, but it can do more useful things now.
- stopping a kthread in kld code at unload time is "interesting" but
we have a solution for that.
The Alpha code needs no changes for this. It already uses pretty much the
same strategies, but a little cleaner.
Diffstat (limited to 'sys/amd64/amd64/vm_machdep.c')
-rw-r--r-- | sys/amd64/amd64/vm_machdep.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 7b4030e..cfb6cee 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -92,6 +92,7 @@ static void cpu_reset_proxy __P((void)); static u_int cpu_reset_proxyid; static volatile u_int cpu_reset_proxy_active; #endif +extern int _ucodesel, _udatasel; /* * quick version of vm_fault @@ -156,18 +157,18 @@ cpu_fork(p1, p2, flags) */ p2->p_md.md_regs = (struct trapframe *) ((int)p2->p_addr + UPAGES * PAGE_SIZE - 16) - 1; - *p2->p_md.md_regs = *p1->p_md.md_regs; + bcopy(p1->p_md.md_regs, p2->p_md.md_regs, sizeof(*p2->p_md.md_regs)); /* * Set registers for trampoline to user mode. Leave space for the * return address on stack. These are the kernel mode register values. */ pcb2->pcb_cr3 = vtophys(vmspace_pmap(p2->p_vmspace)->pm_pdir); - pcb2->pcb_edi = p2->p_md.md_regs->tf_edi; - pcb2->pcb_esi = (int)fork_return; - pcb2->pcb_ebp = p2->p_md.md_regs->tf_ebp; + pcb2->pcb_edi = 0; + pcb2->pcb_esi = (int)fork_return; /* fork_trampoline argument */ + pcb2->pcb_ebp = 0; pcb2->pcb_esp = (int)p2->p_md.md_regs - sizeof(void *); - pcb2->pcb_ebx = (int)p2; + pcb2->pcb_ebx = (int)p2; /* fork_trampoline argument */ pcb2->pcb_eip = (int)fork_trampoline; /* * pcb2->pcb_ldt: duplicated below, if necessary. @@ -200,8 +201,8 @@ cpu_fork(p1, p2, flags) * Now, cpu_switch() can schedule the new process. * pcb_esp is loaded pointing to the cpu_switch() stack frame * containing the return address when exiting cpu_switch. - * This will normally be to proc_trampoline(), which will have - * %ebx loaded with the new proc's pointer. proc_trampoline() + * This will normally be to fork_trampoline(), which will have + * %ebx loaded with the new proc's pointer. fork_trampoline() * will set up a stack to call fork_return(p, frame); to complete * the return to user-mode. */ |