From owner-p4-projects@FreeBSD.ORG Tue Sep 30 18:03:05 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 913CC16A4C0; Tue, 30 Sep 2003 18:03:05 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6648C16A4B3 for ; Tue, 30 Sep 2003 18:03:05 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C4A1F43F3F for ; Tue, 30 Sep 2003 18:03:04 -0700 (PDT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id h91134XJ043568 for ; Tue, 30 Sep 2003 18:03:04 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id h91134w9043565 for perforce@freebsd.org; Tue, 30 Sep 2003 18:03:04 -0700 (PDT) (envelope-from peter@freebsd.org) Date: Tue, 30 Sep 2003 18:03:04 -0700 (PDT) Message-Id: <200310010103.h91134w9043565@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 38937 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Oct 2003 01:03:06 -0000 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