PERFORCE change 128789 for review
Peter Wemm
peter at FreeBSD.org
Wed Nov 7 12:23:03 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=128789
Change 128789 by peter at peter_overcee on 2007/11/07 20:22:20
Theoretically finish backporting amd64 pcpu code and
expunging nasty old relics of i386 fixed-va pcpu area.
Affected files ...
.. //depot/projects/hammer/sys/i386/i386/mp_machdep.c#67 edit
Differences ...
==== //depot/projects/hammer/sys/i386/i386/mp_machdep.c#67 (text+ko) ====
@@ -145,6 +145,9 @@
char *bootSTK;
static int bootAP;
+/* Free these after use */
+void *bootstacks[MAXCPU];
+
/* Hotwire a 0->4MB V==P mapping */
extern pt_entry_t *KPTphys;
@@ -499,10 +502,18 @@
/* bootAP is set in start_ap() to our ID. */
myid = bootAP;
+
+ /* Get per-cpu data */
pc = &__pcpu[myid];
+
+ /* prime data pabe or it to use */
+ pcpu_init(pc, myid, sizeof(struct pcpu));
+ pc->pc_apic_id = cpu_apic_ids[myid];
+ pc->pc_prvspace = pc;
+ pc->pc_curthread = 0;
+
gdt_segs[GPRIV_SEL].ssd_base = (int) &pc;
gdt_segs[GPROC0_SEL].ssd_base = (int) &pc->pcpu.pc_common_tss;
- pc->pc_prvspace = pc;
for (x = 0; x < NGDT; x++) {
ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd);
@@ -726,10 +737,9 @@
u_char mpbiosreason;
#endif
struct pcpu *pc;
- char *stack;
uintptr_t kptbase;
u_int32_t mpbioswarmvec;
- int apic_id, cpu, i, pg;
+ int apic_id, cpu, i;
mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN);
@@ -755,19 +765,8 @@
for (cpu = 1; cpu < mp_ncpus; cpu++) {
apic_id = cpu_apic_ids[cpu];
- /* first page of AP's private space */
- pg = cpu * i386_btop(sizeof(struct privatespace));
-
/* allocate and set up an idle stack data page */
- stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */
- for (i = 0; i < KSTACK_PAGES; i++)
- /* YYYSMP fix */
- SMPpt[pg + 1 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- /* prime data page for it to use */
- pcpu_init(pc, cpu, sizeof(struct pcpu));
- pc->pc_apic_id = apic_id;
+ bootstacks[cpu] = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE);
/* setup a vector to our boot code */
*((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
@@ -777,9 +776,7 @@
outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
#endif
- /* allocate kstack like on amd64 */
- bootSTK = &SMP_prvspace[cpu].idlekstack[KSTACK_PAGES *
- PAGE_SIZE];
+ bootSTK = char *)bootstacks[cpu] + KSTACK_PAGES * PAGE_SIZE - 4;
bootAP = cpu;
/* attempt to start the Application Processor */
@@ -808,19 +805,6 @@
outb(CMOS_DATA, mpbiosreason);
#endif
- /*
- * Set up the idle context for the BSP. Similar to above except
- * that some was done by locore, some by pmap.c and some is implicit
- * because the BSP is cpu#0 and the page is initially zero and also
- * because we can refer to variables by name on the BSP..
- */
-
- /* Allocate and setup BSP idle stack */
- stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE);
- for (i = 0; i < KSTACK_PAGES; i++)
- /* YYYSMP */SMPpt[1 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
for (i = 0; i < NKPT; i++)
PTD[i] = 0;
pmap_invalidate_range(kernel_pmap, 0, NKPT * NBPDR - 1);
More information about the p4-projects
mailing list