diff options
author | julian <julian@FreeBSD.org> | 2002-02-07 20:58:47 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2002-02-07 20:58:47 +0000 |
commit | b5eb64d6f0fccb72419da5552deee22cb6117fac (patch) | |
tree | b267ad497d8d81c2c79c107443dabe850da2126b /sys/amd64 | |
parent | fce570367d0faf3002916a499e684172e61d8b9b (diff) | |
download | FreeBSD-src-b5eb64d6f0fccb72419da5552deee22cb6117fac.zip FreeBSD-src-b5eb64d6f0fccb72419da5552deee22cb6117fac.tar.gz |
Pre-KSE/M3 commit.
this is a low-functionality change that changes the kernel to access the main
thread of a process via the linked list of threads rather than
assuming that it is embedded in the process. It IS still embeded there
but remove all teh code that assumes that in preparation for the next commit
which will actually move it out.
Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/cpu_switch.S | 29 | ||||
-rw-r--r-- | sys/amd64/amd64/db_trace.c | 2 | ||||
-rw-r--r-- | sys/amd64/amd64/machdep.c | 30 | ||||
-rw-r--r-- | sys/amd64/amd64/swtch.s | 29 | ||||
-rw-r--r-- | sys/amd64/amd64/vm_machdep.c | 5 |
5 files changed, 53 insertions, 42 deletions
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S index 230c2fd..7a66fba 100644 --- a/sys/amd64/amd64/cpu_switch.S +++ b/sys/amd64/amd64/cpu_switch.S @@ -176,31 +176,34 @@ sw1b: #endif /* switch address space */ - movl %cr3,%ebx + movl %cr3,%ebx /* The same address space? */ cmpl PCB_CR3(%edx),%ebx - je 4f + je 4f /* Yes, skip all that cruft */ #if defined(SWTCH_OPTIM_STATS) decl swtch_optim_stats incl tlb_flush_count #endif - movl PCB_CR3(%edx),%ebx - movl %ebx,%cr3 + movl PCB_CR3(%edx),%ebx /* Tell the CPU about the */ + movl %ebx,%cr3 /* new address space */ 4: movl PCPU(CPUID), %esi cmpl $0, PCB_EXT(%edx) /* has pcb extension? */ - je 1f + je 1f /* If not, use the default */ btsl %esi, private_tss /* mark use of private tss */ movl PCB_EXT(%edx), %edi /* new tss descriptor */ - jmp 2f -1: + jmp 2f /* Load it up */ - /* Update common_tss.tss_esp0 pointer. */ +1: /* Use the common default TSS instead of our own */ + /* Set our stack pointer into the TSS, it's set to just */ + /* below the PCB. In C, common_tss.tss_esp0 = &pcb - 16; */ leal -16(%edx), %ebx /* leave space for vm86 */ - movl %ebx, PCPU(COMMON_TSS) + TSS_ESP0 /* stack is below pcb */ + movl %ebx, PCPU(COMMON_TSS) + TSS_ESP0 - btrl %esi, private_tss - jae 3f + /* Test this CPU's bit in the bitmap to see if this */ + /* CPU was using a private TSS. */ + btrl %esi, private_tss /* Already using the common? */ + jae 3f /* if so, skip reloading */ PCPU_ADDR(COMMON_TSSD, %edi) 2: /* Move correct tss descriptor into GDT slot, then reload tr. */ @@ -213,7 +216,7 @@ sw1b: ltr %si 3: /* Note in vmspace that this cpu is using it. */ - movl TD_PROC(%ecx),%eax /* XXXKSE proc from thread */ + movl TD_PROC(%ecx),%eax movl P_VMSPACE(%eax), %ebx movl PCPU(CPUID), %eax btsl %eax, VM_PMAP+PM_ACTIVE(%ebx) @@ -302,7 +305,7 @@ badsw2: pushl $sw0_2 call panic -sw0_2: .asciz "cpu_switch: not SRUN" +sw0_2: .asciz "cpu_switch: not TDS_RUNQ" badsw3: pushl $sw0_3 diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index a4539a0..6a07631 100644 --- a/sys/amd64/amd64/db_trace.c +++ b/sys/amd64/amd64/db_trace.c @@ -337,7 +337,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) db_printf("pid %d swapped out\n", pid); return; } - pcb = p->p_thread.td_pcb; /* XXXKSE */ + pcb = FIRST_THREAD_IN_PROC(p)->td_pcb; /* XXXKSE */ frame = (struct i386_frame *)pcb->pcb_ebp; if (frame == NULL) frame = (struct i386_frame *) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 13e8b0a..a61ccdd 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1658,14 +1658,20 @@ init386(first) #endif struct pcpu *pc; - proc_linkup(&proc0); + proc0.p_uarea = proc0uarea; - thread0 = &proc0.p_thread; - thread0->td_kstack = proc0kstack; - thread0->td_pcb = (struct pcb *) - (thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + thread0.td_kstack = proc0kstack; + thread0.td_pcb = (struct pcb *) + (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; atdevbase = ISA_HOLE_START + KERNBASE; + /* + * This may be done better later if it gets more + * high level components in it. If so just link td->td_proc + * here. + */ + proc_linkup(&proc0, &proc0.p_ksegrp, &proc0.p_kse, &thread0); + metadata_missing = 0; if (bootinfo.bi_modulep) { preload_metadata = (caddr_t)bootinfo.bi_modulep + KERNBASE; @@ -1721,9 +1727,9 @@ init386(first) PCPU_SET(prvspace, pc); /* setup curproc so that mutexes work */ - PCPU_SET(curthread, thread0); + PCPU_SET(curthread, &thread0); - LIST_INIT(&thread0->td_contested); + LIST_INIT(&thread0.td_contested); /* * Initialize mutexes. @@ -1826,7 +1832,7 @@ init386(first) /* make an initial tss so cpu can get interrupt stack on syscall! */ /* Note: -16 is so we can grow the trapframe if we came from vm86 */ - PCPU_SET(common_tss.tss_esp0, thread0->td_kstack + + PCPU_SET(common_tss.tss_esp0, thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb) - 16); PCPU_SET(common_tss.tss_ss0, GSEL(GDATA_SEL, SEL_KPL)); gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); @@ -1883,10 +1889,10 @@ init386(first) _udatasel = LSEL(LUDATA_SEL, SEL_UPL); /* setup proc 0's pcb */ - thread0->td_pcb->pcb_flags = 0; /* XXXKSE */ - thread0->td_pcb->pcb_cr3 = (int)IdlePTD; - thread0->td_pcb->pcb_ext = 0; - thread0->td_frame = &proc0_tf; + thread0.td_pcb->pcb_flags = 0; /* XXXKSE */ + thread0.td_pcb->pcb_cr3 = (int)IdlePTD; + thread0.td_pcb->pcb_ext = 0; + thread0.td_frame = &proc0_tf; } void diff --git a/sys/amd64/amd64/swtch.s b/sys/amd64/amd64/swtch.s index 230c2fd..7a66fba 100644 --- a/sys/amd64/amd64/swtch.s +++ b/sys/amd64/amd64/swtch.s @@ -176,31 +176,34 @@ sw1b: #endif /* switch address space */ - movl %cr3,%ebx + movl %cr3,%ebx /* The same address space? */ cmpl PCB_CR3(%edx),%ebx - je 4f + je 4f /* Yes, skip all that cruft */ #if defined(SWTCH_OPTIM_STATS) decl swtch_optim_stats incl tlb_flush_count #endif - movl PCB_CR3(%edx),%ebx - movl %ebx,%cr3 + movl PCB_CR3(%edx),%ebx /* Tell the CPU about the */ + movl %ebx,%cr3 /* new address space */ 4: movl PCPU(CPUID), %esi cmpl $0, PCB_EXT(%edx) /* has pcb extension? */ - je 1f + je 1f /* If not, use the default */ btsl %esi, private_tss /* mark use of private tss */ movl PCB_EXT(%edx), %edi /* new tss descriptor */ - jmp 2f -1: + jmp 2f /* Load it up */ - /* Update common_tss.tss_esp0 pointer. */ +1: /* Use the common default TSS instead of our own */ + /* Set our stack pointer into the TSS, it's set to just */ + /* below the PCB. In C, common_tss.tss_esp0 = &pcb - 16; */ leal -16(%edx), %ebx /* leave space for vm86 */ - movl %ebx, PCPU(COMMON_TSS) + TSS_ESP0 /* stack is below pcb */ + movl %ebx, PCPU(COMMON_TSS) + TSS_ESP0 - btrl %esi, private_tss - jae 3f + /* Test this CPU's bit in the bitmap to see if this */ + /* CPU was using a private TSS. */ + btrl %esi, private_tss /* Already using the common? */ + jae 3f /* if so, skip reloading */ PCPU_ADDR(COMMON_TSSD, %edi) 2: /* Move correct tss descriptor into GDT slot, then reload tr. */ @@ -213,7 +216,7 @@ sw1b: ltr %si 3: /* Note in vmspace that this cpu is using it. */ - movl TD_PROC(%ecx),%eax /* XXXKSE proc from thread */ + movl TD_PROC(%ecx),%eax movl P_VMSPACE(%eax), %ebx movl PCPU(CPUID), %eax btsl %eax, VM_PMAP+PM_ACTIVE(%ebx) @@ -302,7 +305,7 @@ badsw2: pushl $sw0_2 call panic -sw0_2: .asciz "cpu_switch: not SRUN" +sw0_2: .asciz "cpu_switch: not TDS_RUNQ" badsw3: pushl $sw0_3 diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index efae625..3c861ba 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -117,13 +117,13 @@ vm_fault_quick(v, prot) * ready to run and return to user mode. */ void -cpu_fork(td1, p2, flags) +cpu_fork(td1, p2, td2, flags) register struct thread *td1; register struct proc *p2; + struct thread *td2; int flags; { register struct proc *p1; - struct thread *td2; struct pcb *pcb2; struct mdproc *mdp2; #ifdef DEV_NPX @@ -131,7 +131,6 @@ cpu_fork(td1, p2, flags) #endif p1 = td1->td_proc; - td2 = &p2->p_thread; if ((flags & RFPROC) == 0) { if ((flags & RFMEM) == 0) { /* unshare user LDT */ |