Date: Tue, 30 Sep 2003 18:03:04 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 38937 for review Message-ID: <200310010103.h91134w9043565@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=38937 Change 38937 by peter@peter_hammer on 2003/09/30 18:02:19 paste together a bit more. There are still bits missing. use extern'ed r_idt/r_gdt. Finish getting rid of SMP_* evilness. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#14 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#14 (text+ko) ==== @@ -99,9 +99,6 @@ /** XXX FIXME: where does this really belong, isa.h/isa.c perhaps? */ int current_postcode; -/** XXX FIXME: what system files declare these??? */ -extern struct region_descriptor r_gdt, r_idt; - int mp_naps; /* # of Applications processors */ int boot_cpu_id = -1; /* designated BSP */ extern int nkpt; @@ -117,6 +114,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; @@ -158,9 +158,7 @@ static void set_logical_apic_ids(void); static int start_all_aps(u_int boot_addr); -#ifdef SMP_ME_HARDER static void install_ap_tramp(u_int boot_addr); -#endif static int start_ap(int apic_id, u_int boot_addr); void ap_init(void); static void release_aps(void *dummy); @@ -338,8 +336,6 @@ lidt(&r_idt); - common_tss[myid] = common_tss[0]; - common_tss[myid].tss_rsp0 = 0; /* not used until after switch */ gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); ltr(gsel_tss); @@ -405,9 +401,7 @@ u_char mpbiosreason; u_int32_t mpbioswarmvec; struct pcpu *pc; - char *stack; - uintptr_t kptbase; - int i, pg, apic_id, cpu; + int x, apic_id, cpu; mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); @@ -427,26 +421,31 @@ cpu++; /* Get per-cpu data */ - pc = &__pcpu[myid]; + pc = &__pcpu[cpu]; /* allocate and set up an idle stack data page */ - stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); + bootstacks[cpu] = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); + + /* Init tss */ + common_tss[cpu] = common_tss[0]; + common_tss[cpu].tss_rsp0 = 0; /* not used until after switch */ - gdt_segs[GPROC0_SEL].ssd_base = - (long) &SMP_prvspace[myid].pcpu.pc_common_tss; - pc->pc_prvspace = pc; + gdt_segs[GPROC0_SEL].ssd_base = (long) &common_tss[cpu]; - for (x = 0; x < NGDT; x++) - if (x != GPROC0_SEL && x != (GPROC0_SEL + 1)) - ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd); - ssdtosyssd(&gdt_segs[GPROC0_SEL], (struct system_segment_descriptor *)&gdt[GPROC0_SEL]); + for (x = 0; x < NGDT; x++) + if (x != GPROC0_SEL && x != (GPROC0_SEL + 1)) + ssdtosd(&gdt_segs[x], &gdt[cpu * NGDT + x]); + ssdtosyssd(&gdt_segs[GPROC0_SEL], + (struct system_segment_descriptor *)&gdt[cpu * NGDT + GPROC0_SEL]); - r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1; - r_gdt.rd_base = (long) &gdt[myid * NGDT]; + r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1; + r_gdt.rd_base = (long) &gdt[cpu * NGDT]; /* prime data page for it to use */ pcpu_init(pc, cpu, sizeof(struct pcpu)); pc->pc_apic_id = apic_id; + pc->pc_prvspace = pc; + pc->pc_curthread = 0; /* setup a vector to our boot code */ *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET; @@ -454,8 +453,7 @@ outb(CMOS_REG, BIOS_RESET); outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ - bootSTK = &SMP_prvspace[apic_id].idlekstack[KSTACK_PAGES * - PAGE_SIZE]; + bootSTK = bootstacks[cpu]; bootAP = cpu; /* attempt to start the Application Processor */ @@ -479,23 +477,6 @@ outb(CMOS_REG, BIOS_RESET); outb(CMOS_DATA, mpbiosreason); - /* - * 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++) - SMPpt[1 + i] = (pt_entry_t) - (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); - - for (i = 0; i < NKPT; i++) - PTD[i] = 0; - invltlb(); - /* number of APs actually started */ return mp_naps; } @@ -512,10 +493,12 @@ extern void MPentry(void); extern u_int MP_GDT; extern u_int mp_gdtbase; +#endif static void install_ap_tramp(u_int boot_addr) { +#ifdef SMP_ME_HARDER int x; int size = *(int *) ((u_long) & bootMP_size); u_char *src = (u_char *) ((u_long) bootMP); @@ -556,8 +539,8 @@ dst8 = (u_int8_t *) (dst16 + 1); *dst16 = (u_int) boot_addr & 0xffff; *dst8 = ((u_int) boot_addr >> 16) & 0xff; +#endif } -#endif void compile_hack(void); void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310010103.h91134w9043565>