Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Jan 2000 17:10:21 +0900 (JST)
From:      hnokubi@yyy.or.jp
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/16021: To support SMP on NEC PC98, call mp_probe() after pmap_bootstrap()
Message-ID:  <20000110082210.39C7E15138@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help


>Number:         16021
>Category:       kern
>Synopsis:       To support SMP on NEC PC98, call mp_probe() after pmap_bootstrap()
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 10 00:30:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     NOKUBI Hirotaka
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

FreeBSD alphazeal.nokubi.or.jp 4.0-CURRENT FreeBSD 4.0-CURRENT #64: Sat Dec 11 19:36:30 JST 1999     h-nokubi@alphazeal.nokubi.or.jp:/usr/src/sys/compile/MP  i386

>Description:

MP Configuration Table is placed at the top of the physical memory on
NEC PC98. It's one of the suggested areas for MPCT in Intel's MP Spec V1.4.
(NEC PC98 uses Intel x86 processor, but not PC-AT compatible architecture.)

Because FreeBSD's SMP code assumes that MPCT is in lowest 1Mbyte area, it
can't read MPCT on NEC PC98.

>How-To-Repeat:



>Fix:

This patch is same as it I've already posted to freebsd-smp
(Message-Id: <19991225153517.9109915206@hub.freebsd.org>).

It so defers calling mp_probe() after pmap_bootstrap() that mp_probe()
uses pmap_enter() to read MPCT. If MPCT is above lowest 1Mbyte area,
map a page which includes MPCT to CADDR1 and read from there.

Latter half of pmap_bootstrap() is moved to mptable_pass1() except pgeflag.
PTE Global bit is not used on SMP kernel, it's not needed just now (need
to consider in the future release ?).

It also adds a entry NEC98 bus to bus_type table[]. NEC98 bus is similar
to ISA.

Index: i386/i386/machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/machdep.c,v
retrieving revision 1.382
diff -u -r1.382 machdep.c
--- machdep.c	1999/12/06 04:53:03	1.382
+++ machdep.c	2000/01/10 07:07:36
@@ -1559,9 +1559,6 @@
 #ifdef SMP
 	/* make hole for AP bootstrap code */
 	physmap[1] = mp_bootaddress(physmap[1] / 1024);
-
-	/* look for the MP hardware - needed for apic addresses */
-	mp_probe();
 #endif
 
 	/*
@@ -1623,6 +1620,10 @@
 	/* call pmap initialization to make new kernel address space */
 	pmap_bootstrap(first, 0);
 
+#ifdef SMP
+	/* look for the MP hardware - needed for apic addresses */
+	mp_probe();
+#endif
 	/*
 	 * Size up each available chunk of physical memory.
 	 */
Index: i386/i386/mp_machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/mp_machdep.c,v
retrieving revision 1.114
diff -u -r1.114 mp_machdep.c
--- mp_machdep.c	2000/01/07 08:49:23	1.114
+++ mp_machdep.c	2000/01/10 07:07:36
@@ -392,7 +392,7 @@
 
 found:
 	/* calculate needed resources */
-	mpfps = (mpfps_t)x;
+	mpfps = (mpfps_t)(x + KERNBASE);
 	if (mptable_pass1())
 		panic("you must reconfigure your kernel");
 
@@ -691,12 +691,12 @@
 	{UNKNOWN_BUSTYPE, "---"},
 	{UNKNOWN_BUSTYPE, "---"},
 	{ISA, "ISA"},
+	{ISA, "NEC98"},
 	{UNKNOWN_BUSTYPE, "---"},
 	{UNKNOWN_BUSTYPE, "---"},
 	{UNKNOWN_BUSTYPE, "---"},
 	{UNKNOWN_BUSTYPE, "---"},
 	{UNKNOWN_BUSTYPE, "---"},
-	{UNKNOWN_BUSTYPE, "---"},
 	{PCI, "PCI"},
 	{UNKNOWN_BUSTYPE, "---"},
 	{UNKNOWN_BUSTYPE, "---"},
@@ -758,6 +758,8 @@
 	int	count;
 	int	type;
 	int	mustpanic;
+	int i, j;
+	struct globaldata *gd;
 
 	POSTCODE(MPTABLE_PASS1_POST);
 
@@ -792,6 +794,15 @@
 		if ((cth = mpfps->pap) == 0)
 			panic("MP Configuration Table Header MISSING!");
 
+		if (cth >= (mpcth_t)0x100000) {
+			pmap_enter(kernel_pmap, (vm_offset_t)CADDR1,
+				   trunc_page((vm_offset_t)cth), VM_PROT_READ, TRUE);
+			/* XXX do not support MPCT across page boundary */
+			cth = (mpcth_t)(CADDR1 + ((int)cth & PAGE_MASK));
+		} else {
+			cth = (mpcth_t)((u_int)cth + KERNBASE);
+		}
+
 		cpu_apic_address = (vm_offset_t) cth->apic_address;
 
 		/* walk the table, recording info of interest */
@@ -858,6 +869,46 @@
 
 	--mp_naps;	/* subtract the BSP */
 
+	if (cpu_apic_address == 0)
+		panic("pmap_bootstrap: no local apic!");
+
+	/* local apic is mapped on last page */
+	SMPpt[NPTEPG - 1] = (pt_entry_t)(PG_V | PG_RW | PG_N | /*pgeflag |*/
+	    (cpu_apic_address & PG_FRAME));
+
+	for (i = 0; i < mp_napics; i++) {
+		for (j = 0; j < mp_napics; j++) {
+			/* same page frame as a previous IO apic? */
+			if (((vm_offset_t)SMPpt[NPTEPG-2-j] & PG_FRAME) ==
+			    (io_apic_address[0] & PG_FRAME)) {
+				ioapic[i] = (ioapic_t *)((u_int)SMP_prvspace
+					+ (NPTEPG-2-j)*PAGE_SIZE);
+				break;
+			}
+			/* use this slot if available */
+			if (((vm_offset_t)SMPpt[NPTEPG-2-j] & PG_FRAME) == 0) {
+				SMPpt[NPTEPG-2-j] = (pt_entry_t)(PG_V | PG_RW |
+				 /*pgeflag|*/ (io_apic_address[i] & PG_FRAME));
+				ioapic[i] = (ioapic_t *)((u_int)SMP_prvspace
+					+ (NPTEPG-2-j)*PAGE_SIZE);
+				break;
+			}
+		}
+	}
+
+	/* BSP does this itself, AP's get it pre-set */
+	gd = &SMP_prvspace[0].globaldata;
+	gd->gd_prv_CMAP1 = &SMPpt[1];
+	gd->gd_prv_CMAP2 = &SMPpt[2];
+	gd->gd_prv_CMAP3 = &SMPpt[3];
+	gd->gd_prv_PMAP1 = &SMPpt[4];
+	gd->gd_prv_CADDR1 = SMP_prvspace[0].CPAGE1;
+	gd->gd_prv_CADDR2 = SMP_prvspace[0].CPAGE2;
+	gd->gd_prv_CADDR3 = SMP_prvspace[0].CPAGE3;
+	gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[0].PPAGE1;
+
+	invltlb();
+
 	return mustpanic;
 }
 
@@ -915,6 +966,15 @@
 
 	if ((cth = mpfps->pap) == 0)
 		panic("MP Configuration Table Header MISSING!");
+
+	if (cth >= (mpcth_t)0x100000) {
+		pmap_enter(kernel_pmap, (vm_offset_t)CADDR1,
+			   trunc_page((vm_offset_t)cth), VM_PROT_READ, TRUE);
+		/* XXX do not support MPCT across page boundary */
+		cth = (mpcth_t)(CADDR1 + ((int)cth & PAGE_MASK));
+	} else {
+		cth = (mpcth_t)((u_int)cth + KERNBASE);
+	}
 
 	/* walk the table, recording info of interest */
 	totalSize = cth->base_table_length - sizeof(struct MPCTH);
Index: i386/i386/pmap.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/pmap.c,v
retrieving revision 1.250
diff -u -r1.250 pmap.c
--- pmap.c	1999/11/19 21:34:26	1.250
+++ pmap.c	2000/01/10 07:07:36
@@ -283,10 +283,6 @@
 {
 	vm_offset_t va;
 	pt_entry_t *pte;
-#ifdef SMP
-	int i, j;
-	struct globaldata *gd;
-#endif
 
 	avail_start = firstaddr;
 
@@ -412,46 +408,6 @@
 		invltlb();
 #endif
 	}
-#endif
-
-#ifdef SMP
-	if (cpu_apic_address == 0)
-		panic("pmap_bootstrap: no local apic!");
-
-	/* local apic is mapped on last page */
-	SMPpt[NPTEPG - 1] = (pt_entry_t)(PG_V | PG_RW | PG_N | pgeflag |
-	    (cpu_apic_address & PG_FRAME));
-
-	for (i = 0; i < mp_napics; i++) {
-		for (j = 0; j < mp_napics; j++) {
-			/* same page frame as a previous IO apic? */
-			if (((vm_offset_t)SMPpt[NPTEPG-2-j] & PG_FRAME) ==
-			    (io_apic_address[0] & PG_FRAME)) {
-				ioapic[i] = (ioapic_t *)((u_int)SMP_prvspace
-					+ (NPTEPG-2-j)*PAGE_SIZE);
-				break;
-			}
-			/* use this slot if available */
-			if (((vm_offset_t)SMPpt[NPTEPG-2-j] & PG_FRAME) == 0) {
-				SMPpt[NPTEPG-2-j] = (pt_entry_t)(PG_V | PG_RW |
-				    pgeflag | (io_apic_address[i] & PG_FRAME));
-				ioapic[i] = (ioapic_t *)((u_int)SMP_prvspace
-					+ (NPTEPG-2-j)*PAGE_SIZE);
-				break;
-			}
-		}
-	}
-
-	/* BSP does this itself, AP's get it pre-set */
-	gd = &SMP_prvspace[0].globaldata;
-	gd->gd_prv_CMAP1 = &SMPpt[1];
-	gd->gd_prv_CMAP2 = &SMPpt[2];
-	gd->gd_prv_CMAP3 = &SMPpt[3];
-	gd->gd_prv_PMAP1 = &SMPpt[4];
-	gd->gd_prv_CADDR1 = SMP_prvspace[0].CPAGE1;
-	gd->gd_prv_CADDR2 = SMP_prvspace[0].CPAGE2;
-	gd->gd_prv_CADDR3 = SMP_prvspace[0].CPAGE3;
-	gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[0].PPAGE1;
 #endif
 
 	invltlb();

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000110082210.39C7E15138>