summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-12-11 23:33:44 +0000
committerjhb <jhb@FreeBSD.org>2001-12-11 23:33:44 +0000
commit21b6b26912b00bb37f9f16080ba7d49241814935 (patch)
treec785835e70070309148a72c55669ff0bf043a20a /sys/powerpc
parent279222ba62c185d7d7ec09017bb3e7760fd333f0 (diff)
downloadFreeBSD-src-21b6b26912b00bb37f9f16080ba7d49241814935.zip
FreeBSD-src-21b6b26912b00bb37f9f16080ba7d49241814935.tar.gz
Overhaul the per-CPU support a bit:
- The MI portions of struct globaldata have been consolidated into a MI struct pcpu. The MD per-CPU data are specified via a macro defined in machine/pcpu.h. A macro was chosen over a struct mdpcpu so that the interface would be cleaner (PCPU_GET(my_md_field) vs. PCPU_GET(md.md_my_md_field)). - All references to globaldata are changed to pcpu instead. In a UP kernel, this data was stored as global variables which is where the original name came from. In an SMP world this data is per-CPU and ideally private to each CPU outside of the context of debuggers. This also included combining machine/globaldata.h and machine/globals.h into machine/pcpu.h. - The pointer to the thread using the FPU on i386 was renamed from npxthread to fpcurthread to be identical with other architectures. - Make the show pcpu ddb command MI with a MD callout to display MD fields. - The globaldata_register() function was renamed to pcpu_init() and now init's MI fields of a struct pcpu in addition to registering it with the internal array and list. - A pcpu_destroy() function was added to remove a struct pcpu from the internal array and list. Tested on: alpha, i386 Reviewed by: peter, jake
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/aim/locore.S12
-rw-r--r--sys/powerpc/aim/machdep.c24
-rw-r--r--sys/powerpc/aim/swtch.S8
-rw-r--r--sys/powerpc/include/cpufunc.h6
-rw-r--r--sys/powerpc/include/globaldata.h72
-rw-r--r--sys/powerpc/include/globals.h50
-rw-r--r--sys/powerpc/include/mutex.h2
-rw-r--r--sys/powerpc/include/pcpu.h47
-rw-r--r--sys/powerpc/include/proc.h2
-rw-r--r--sys/powerpc/powerpc/genassym.c6
-rw-r--r--sys/powerpc/powerpc/locore.S12
-rw-r--r--sys/powerpc/powerpc/locore.s12
-rw-r--r--sys/powerpc/powerpc/machdep.c24
-rw-r--r--sys/powerpc/powerpc/swtch.S8
-rw-r--r--sys/powerpc/powerpc/swtch.s8
15 files changed, 67 insertions, 226 deletions
diff --git a/sys/powerpc/aim/locore.S b/sys/powerpc/aim/locore.S
index 24571b6..43e5e79 100644
--- a/sys/powerpc/aim/locore.S
+++ b/sys/powerpc/aim/locore.S
@@ -424,7 +424,7 @@ trapcode:
mtcr 31
bc 4,17,1f /* branch if PSL_PR is clear */
mfsprg 1,0
- lwz 1,GD_CURPCB(1)
+ lwz 1,PC_CURPCB(1)
addi 1,1,USPACE /* stack is top of user struct */
1:
bla s_trap
@@ -447,7 +447,7 @@ alitrap:
mtcr 31
bc 4,17,1f /* branch if PSL_PR is clear */
mfsprg 1,0
- lwz 1,GD_CURPCB(1)
+ lwz 1,PC_CURPCB(1)
addi 1,1,USPACE /* stack is top of user struct */
1:
bla s_trap
@@ -913,7 +913,7 @@ realtrap:
overwritten) */
bc 4,17,s_trap /* branch if PSL_PR is false */
mfsprg 1,0
- lwz 1,GD_CURPCB(1)
+ lwz 1,PC_CURPCB(1)
addi 1,1,USPACE /* stack is top of user struct */
/*
@@ -1109,8 +1109,8 @@ intr_exit:
/* Returning to user mode? */
mtcr 6 /* saved SRR1 */
bc 4,17,1f /* branch if PSL_PR is false */
- mfsprg 3,0 /* get globaldata */
- lwz 3,GD_CURPCB(3) /* get curpcb from globaldata */
+ mfsprg 3,0 /* get pcpu */
+ lwz 3,PC_CURPCB(3) /* get curpcb from pcpu */
lwz 3,PCB_PMR(3) /* get pmap real address from curpcb */
mtsr KERNEL_SR,3
/* Setup for entry to realtrap: */
@@ -1330,7 +1330,7 @@ setfault:
mflr 0
mfcr 12
mfsprg 4,0
- lwz 4,GD_CURPCB(4)
+ lwz 4,PC_CURPCB(4)
stw 3,PCB_ONFAULT(4)
stw 0,0(3)
stw 1,4(3)
diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c
index b564f0e..f185cc5 100644
--- a/sys/powerpc/aim/machdep.c
+++ b/sys/powerpc/aim/machdep.c
@@ -101,7 +101,6 @@ static const char rcsid[] =
#include <machine/md_var.h>
#include <machine/reg.h>
#include <machine/fpu.h>
-#include <machine/globaldata.h>
#include <machine/vmparam.h>
#include <machine/elf.h>
#include <machine/trap.h>
@@ -352,7 +351,7 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
{
unsigned int exc, scratch;
struct mem_region *allmem, *availmem, *mp;
- struct globaldata *globalp;
+ struct pcpu *pcpup;
/*
* Set up BAT0 to only map the lowest 256 MB area
@@ -426,14 +425,14 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
thread0->td_pcb = (struct pcb *)
(thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
- globalp = pmap_steal_memory(round_page(sizeof(struct globaldata)));
+ pcpup = pmap_steal_memory(round_page(sizeof(struct pcpu)));
/*
* XXX: Pass 0 as CPU id. This is bad. We need to work out
* XXX: which CPU we are somehow.
*/
- globaldata_init(globalp, 0, sizeof(struct globaldata));
- __asm ("mtsprg 0, %0" :: "r"(globalp));
+ pcpu_init(pcpup, 0, sizeof(struct pcpu));
+ __asm ("mtsprg 0, %0" :: "r"(pcpup));
/* Init basic tunables, hz etc */
init_param1();
@@ -442,7 +441,6 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
/* setup curproc so the mutexes work */
PCPU_SET(curthread, thread0);
- PCPU_SET(spinlocks, NULL);
LIST_INIT(&thread0->td_contested);
@@ -457,14 +455,13 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE);
mtx_init(&proc0.p_mtx, "process lock", MTX_DEF);
+ mtx_lock(&Giant);
/*
* Initialise console.
*/
cninit();
- mtx_lock(&Giant);
-
#ifdef __notyet__ /* Needs some rethinking regarding real/virtual OFW */
OF_set_callback(callback);
#endif
@@ -908,16 +905,13 @@ ptrace_clear_single_step(struct thread *td)
}
/*
- * Initialise a struct globaldata.
+ * Initialise a struct pcpu.
*/
void
-globaldata_init(struct globaldata *globaldata, int cpuid, size_t sz)
-{
+cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz)
+{
- bzero(globaldata, sz);
- globaldata->gd_cpuid = cpuid;
- globaldata->gd_next_asn = 0;
- globaldata->gd_current_asngen = 1;
+ pcpu->pc_current_asngen = 1;
}
void
diff --git a/sys/powerpc/aim/swtch.S b/sys/powerpc/aim/swtch.S
index c800264..3b5b1cd 100644
--- a/sys/powerpc/aim/swtch.S
+++ b/sys/powerpc/aim/swtch.S
@@ -72,8 +72,8 @@
*/
ENTRY(cpu_switch)
mflr %r30
- mfsprg %r3,%r0 /* Get the globaldata pointer */
- lwz %r4,GD_CURTHREAD(%r3) /* Get the current thread */
+ mfsprg %r3,%r0 /* Get the pcpu pointer */
+ lwz %r4,PC_CURTHREAD(%r3) /* Get the current thread */
lwz %r3,TD_PCB(%r4) /* Get a pointer to the PCB */
stmw %r14,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */
@@ -95,8 +95,8 @@ ENTRY(cpu_switch)
bl pmap_activate /* Activate the new address space */
mtlr %r30
- mfsprg %r4,%r0 /* Get the globaldata pointer */
- stw %r14,GD_CURTHREAD(%r4) /* Store new current thread */
+ mfsprg %r4,%r0 /* Get the pcpu pointer */
+ stw %r14,PC_CURTHREAD(%r4) /* Store new current thread */
lwz %r4,TD_PCB(%r14) /* Grab the new PCB */
lwz %r29, PCB_FLAGS(%r4) /* Restore FPU regs if needed */
diff --git a/sys/powerpc/include/cpufunc.h b/sys/powerpc/include/cpufunc.h
index c2f9332..0fd0dd0 100644
--- a/sys/powerpc/include/cpufunc.h
+++ b/sys/powerpc/include/cpufunc.h
@@ -141,10 +141,10 @@ powerpc_mb(void)
__asm __volatile("eieio; sync" : : : "memory");
}
-static __inline struct globaldata *
-powerpc_get_globalp(void)
+static __inline struct pcpu *
+powerpc_get_pcpup(void)
{
- struct globaldata *ret;
+ struct pcpu *ret;
__asm ("mfsprg %0, 0" : "=r"(ret));
diff --git a/sys/powerpc/include/globaldata.h b/sys/powerpc/include/globaldata.h
deleted file mode 100644
index aa00cc3..0000000
--- a/sys/powerpc/include/globaldata.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * Copyright (c) 1999 Luoqi Chen <luoqi@freebsd.org>
- * Copyright (c) Peter Wemm <peter@netplex.com.au>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_GLOBALDATA_H_
-#define _MACHINE_GLOBALDATA_H_
-
-#ifdef _KERNEL
-
-#include <sys/queue.h>
-
-/*
- * This structure maps out the global data that needs to be kept on a
- * per-cpu basis. genassym uses this to generate offsets for the assembler
- * code, which also provides external symbols so that C can get at them as
- * though they were really globals. This structure is pointed to by
- * the per-cpu system value (see alpha_pal_rdval() and alpha_pal_wrval()).
- * Inside the kernel, the globally reserved register t7 is used to
- * point at the globaldata structure.
- */
-struct globaldata {
- struct thread *gd_curthread; /* current thread */
- struct thread *gd_idlethread; /* idle thread */
- struct thread *gd_fpcurthread; /* fp state owner */
- struct pcb *gd_curpcb; /* current pcb */
- struct timeval gd_switchtime;
- int gd_switchticks;
- u_int gd_cpuid; /* this cpu number */
- u_int gd_other_cpus; /* all other cpus */
- int gd_inside_intr;
- u_int32_t gd_next_asn; /* next ASN to allocate */
- u_int32_t gd_current_asngen; /* ASN rollover check */
-
- SLIST_ENTRY(globaldata) gd_allcpu;
- struct lock_list_entry *gd_spinlocks;
-#ifdef KTR_PERCPU
- int gd_ktr_idx; /* Index into trace table */
- char *gd_ktr_buf;
- char gd_ktr_buf_data[KTR_SIZE];
-#endif
-};
-
-void globaldata_init(struct globaldata *pcpu, int cpuid, size_t sz);
-
-#endif /* _KERNEL */
-
-#endif /* !_MACHINE_GLOBALDATA_H_ */
diff --git a/sys/powerpc/include/globals.h b/sys/powerpc/include/globals.h
deleted file mode 100644
index 4dfefd9..0000000
--- a/sys/powerpc/include/globals.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 1999 Luoqi Chen <luoqi@freebsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_GLOBALS_H_
-#define _MACHINE_GLOBALS_H_
-
-#ifdef _KERNEL
-#include <machine/cpufunc.h>
-#include <machine/globaldata.h>
-
-#define GLOBALP ((struct globaldata *) powerpc_get_globalp())
-
-#define PCPU_GET(member) (GLOBALP->gd_ ## member)
-#define PCPU_PTR(member) (&GLOBALP->gd_ ## member)
-#define PCPU_SET(member,value) (GLOBALP->gd_ ## member = (value))
-
-#define curthread PCPU_GET(curthread)
-#define CURPROC (curthread->td_proc)
-#define curproc (curthread->td_proc)
-#define curksegrp (curthread->td_ksegrp)
-#define curkse (curthread->td_kse)
-
-#endif /* _KERNEL */
-
-#endif /* !_MACHINE_GLOBALS_H_ */
diff --git a/sys/powerpc/include/mutex.h b/sys/powerpc/include/mutex.h
index 5038f42..0aeaa74 100644
--- a/sys/powerpc/include/mutex.h
+++ b/sys/powerpc/include/mutex.h
@@ -60,7 +60,7 @@
lwarx r0, r11, lck; \ /* load current lock value */
cmplwi r0, r1, MTX_UNOWNED; \ /* compare with unowned */
beq 1; \ /* if owned, loop */
- lwz r0, PC_CURPROC(globalp); \ /* load curproc */
+ lwz r0, PC_CURPROC(pcpup); \ /* load curproc */
stwcx. r0, r11, lck; \ /* attempt to store */
beq 1; \ /* loop if failed */
sync; \ /* sync */
diff --git a/sys/powerpc/include/pcpu.h b/sys/powerpc/include/pcpu.h
index aa00cc3..4d37de4 100644
--- a/sys/powerpc/include/pcpu.h
+++ b/sys/powerpc/include/pcpu.h
@@ -27,46 +27,23 @@
* $FreeBSD$
*/
-#ifndef _MACHINE_GLOBALDATA_H_
-#define _MACHINE_GLOBALDATA_H_
+#ifndef _MACHINE_PCPU_H_
+#define _MACHINE_PCPU_H_
#ifdef _KERNEL
+#include <machine/cpufunc.h>
-#include <sys/queue.h>
+#define PCPU_MD_FIELDS \
+ int pc_inside_intr; \
+ u_int32_t pc_next_asn; /* next ASN to alloc */ \
+ u_int32_t pc_current_asngen /* ASN rollover check */
-/*
- * This structure maps out the global data that needs to be kept on a
- * per-cpu basis. genassym uses this to generate offsets for the assembler
- * code, which also provides external symbols so that C can get at them as
- * though they were really globals. This structure is pointed to by
- * the per-cpu system value (see alpha_pal_rdval() and alpha_pal_wrval()).
- * Inside the kernel, the globally reserved register t7 is used to
- * point at the globaldata structure.
- */
-struct globaldata {
- struct thread *gd_curthread; /* current thread */
- struct thread *gd_idlethread; /* idle thread */
- struct thread *gd_fpcurthread; /* fp state owner */
- struct pcb *gd_curpcb; /* current pcb */
- struct timeval gd_switchtime;
- int gd_switchticks;
- u_int gd_cpuid; /* this cpu number */
- u_int gd_other_cpus; /* all other cpus */
- int gd_inside_intr;
- u_int32_t gd_next_asn; /* next ASN to allocate */
- u_int32_t gd_current_asngen; /* ASN rollover check */
-
- SLIST_ENTRY(globaldata) gd_allcpu;
- struct lock_list_entry *gd_spinlocks;
-#ifdef KTR_PERCPU
- int gd_ktr_idx; /* Index into trace table */
- char *gd_ktr_buf;
- char gd_ktr_buf_data[KTR_SIZE];
-#endif
-};
+#define PCPUP ((struct pcpu *) powerpc_get_pcpup())
-void globaldata_init(struct globaldata *pcpu, int cpuid, size_t sz);
+#define PCPU_GET(member) (PCPUP->pc_ ## member)
+#define PCPU_PTR(member) (&PCPUP->pc_ ## member)
+#define PCPU_SET(member,value) (PCPUP->pc_ ## member = (value))
#endif /* _KERNEL */
-#endif /* !_MACHINE_GLOBALDATA_H_ */
+#endif /* !_MACHINE_PCPU_H_ */
diff --git a/sys/powerpc/include/proc.h b/sys/powerpc/include/proc.h
index eb2e255..82aa068 100644
--- a/sys/powerpc/include/proc.h
+++ b/sys/powerpc/include/proc.h
@@ -35,8 +35,6 @@
#ifndef _MACHINE_PROC_H_
#define _MACHINE_PROC_H_
-#include <machine/globals.h>
-
/*
* Machine-dependent part of the proc structure
*/
diff --git a/sys/powerpc/powerpc/genassym.c b/sys/powerpc/powerpc/genassym.c
index 0b031c1..7ab6e77 100644
--- a/sys/powerpc/powerpc/genassym.c
+++ b/sys/powerpc/powerpc/genassym.c
@@ -60,9 +60,9 @@
#include <machine/pcb.h>
#include <machine/pmap.h>
-ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread));
-ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb));
-ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime));
+ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread));
+ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb));
+ASSYM(PC_SWITCHTIME, offsetof(struct pcpu, pc_switchtime));
ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock));
ASSYM(MTX_RECURSECNT, offsetof(struct mtx, mtx_recurse));
diff --git a/sys/powerpc/powerpc/locore.S b/sys/powerpc/powerpc/locore.S
index 24571b6..43e5e79 100644
--- a/sys/powerpc/powerpc/locore.S
+++ b/sys/powerpc/powerpc/locore.S
@@ -424,7 +424,7 @@ trapcode:
mtcr 31
bc 4,17,1f /* branch if PSL_PR is clear */
mfsprg 1,0
- lwz 1,GD_CURPCB(1)
+ lwz 1,PC_CURPCB(1)
addi 1,1,USPACE /* stack is top of user struct */
1:
bla s_trap
@@ -447,7 +447,7 @@ alitrap:
mtcr 31
bc 4,17,1f /* branch if PSL_PR is clear */
mfsprg 1,0
- lwz 1,GD_CURPCB(1)
+ lwz 1,PC_CURPCB(1)
addi 1,1,USPACE /* stack is top of user struct */
1:
bla s_trap
@@ -913,7 +913,7 @@ realtrap:
overwritten) */
bc 4,17,s_trap /* branch if PSL_PR is false */
mfsprg 1,0
- lwz 1,GD_CURPCB(1)
+ lwz 1,PC_CURPCB(1)
addi 1,1,USPACE /* stack is top of user struct */
/*
@@ -1109,8 +1109,8 @@ intr_exit:
/* Returning to user mode? */
mtcr 6 /* saved SRR1 */
bc 4,17,1f /* branch if PSL_PR is false */
- mfsprg 3,0 /* get globaldata */
- lwz 3,GD_CURPCB(3) /* get curpcb from globaldata */
+ mfsprg 3,0 /* get pcpu */
+ lwz 3,PC_CURPCB(3) /* get curpcb from pcpu */
lwz 3,PCB_PMR(3) /* get pmap real address from curpcb */
mtsr KERNEL_SR,3
/* Setup for entry to realtrap: */
@@ -1330,7 +1330,7 @@ setfault:
mflr 0
mfcr 12
mfsprg 4,0
- lwz 4,GD_CURPCB(4)
+ lwz 4,PC_CURPCB(4)
stw 3,PCB_ONFAULT(4)
stw 0,0(3)
stw 1,4(3)
diff --git a/sys/powerpc/powerpc/locore.s b/sys/powerpc/powerpc/locore.s
index 24571b6..43e5e79 100644
--- a/sys/powerpc/powerpc/locore.s
+++ b/sys/powerpc/powerpc/locore.s
@@ -424,7 +424,7 @@ trapcode:
mtcr 31
bc 4,17,1f /* branch if PSL_PR is clear */
mfsprg 1,0
- lwz 1,GD_CURPCB(1)
+ lwz 1,PC_CURPCB(1)
addi 1,1,USPACE /* stack is top of user struct */
1:
bla s_trap
@@ -447,7 +447,7 @@ alitrap:
mtcr 31
bc 4,17,1f /* branch if PSL_PR is clear */
mfsprg 1,0
- lwz 1,GD_CURPCB(1)
+ lwz 1,PC_CURPCB(1)
addi 1,1,USPACE /* stack is top of user struct */
1:
bla s_trap
@@ -913,7 +913,7 @@ realtrap:
overwritten) */
bc 4,17,s_trap /* branch if PSL_PR is false */
mfsprg 1,0
- lwz 1,GD_CURPCB(1)
+ lwz 1,PC_CURPCB(1)
addi 1,1,USPACE /* stack is top of user struct */
/*
@@ -1109,8 +1109,8 @@ intr_exit:
/* Returning to user mode? */
mtcr 6 /* saved SRR1 */
bc 4,17,1f /* branch if PSL_PR is false */
- mfsprg 3,0 /* get globaldata */
- lwz 3,GD_CURPCB(3) /* get curpcb from globaldata */
+ mfsprg 3,0 /* get pcpu */
+ lwz 3,PC_CURPCB(3) /* get curpcb from pcpu */
lwz 3,PCB_PMR(3) /* get pmap real address from curpcb */
mtsr KERNEL_SR,3
/* Setup for entry to realtrap: */
@@ -1330,7 +1330,7 @@ setfault:
mflr 0
mfcr 12
mfsprg 4,0
- lwz 4,GD_CURPCB(4)
+ lwz 4,PC_CURPCB(4)
stw 3,PCB_ONFAULT(4)
stw 0,0(3)
stw 1,4(3)
diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c
index b564f0e..f185cc5 100644
--- a/sys/powerpc/powerpc/machdep.c
+++ b/sys/powerpc/powerpc/machdep.c
@@ -101,7 +101,6 @@ static const char rcsid[] =
#include <machine/md_var.h>
#include <machine/reg.h>
#include <machine/fpu.h>
-#include <machine/globaldata.h>
#include <machine/vmparam.h>
#include <machine/elf.h>
#include <machine/trap.h>
@@ -352,7 +351,7 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
{
unsigned int exc, scratch;
struct mem_region *allmem, *availmem, *mp;
- struct globaldata *globalp;
+ struct pcpu *pcpup;
/*
* Set up BAT0 to only map the lowest 256 MB area
@@ -426,14 +425,14 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
thread0->td_pcb = (struct pcb *)
(thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
- globalp = pmap_steal_memory(round_page(sizeof(struct globaldata)));
+ pcpup = pmap_steal_memory(round_page(sizeof(struct pcpu)));
/*
* XXX: Pass 0 as CPU id. This is bad. We need to work out
* XXX: which CPU we are somehow.
*/
- globaldata_init(globalp, 0, sizeof(struct globaldata));
- __asm ("mtsprg 0, %0" :: "r"(globalp));
+ pcpu_init(pcpup, 0, sizeof(struct pcpu));
+ __asm ("mtsprg 0, %0" :: "r"(pcpup));
/* Init basic tunables, hz etc */
init_param1();
@@ -442,7 +441,6 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
/* setup curproc so the mutexes work */
PCPU_SET(curthread, thread0);
- PCPU_SET(spinlocks, NULL);
LIST_INIT(&thread0->td_contested);
@@ -457,14 +455,13 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE);
mtx_init(&proc0.p_mtx, "process lock", MTX_DEF);
+ mtx_lock(&Giant);
/*
* Initialise console.
*/
cninit();
- mtx_lock(&Giant);
-
#ifdef __notyet__ /* Needs some rethinking regarding real/virtual OFW */
OF_set_callback(callback);
#endif
@@ -908,16 +905,13 @@ ptrace_clear_single_step(struct thread *td)
}
/*
- * Initialise a struct globaldata.
+ * Initialise a struct pcpu.
*/
void
-globaldata_init(struct globaldata *globaldata, int cpuid, size_t sz)
-{
+cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz)
+{
- bzero(globaldata, sz);
- globaldata->gd_cpuid = cpuid;
- globaldata->gd_next_asn = 0;
- globaldata->gd_current_asngen = 1;
+ pcpu->pc_current_asngen = 1;
}
void
diff --git a/sys/powerpc/powerpc/swtch.S b/sys/powerpc/powerpc/swtch.S
index c800264..3b5b1cd 100644
--- a/sys/powerpc/powerpc/swtch.S
+++ b/sys/powerpc/powerpc/swtch.S
@@ -72,8 +72,8 @@
*/
ENTRY(cpu_switch)
mflr %r30
- mfsprg %r3,%r0 /* Get the globaldata pointer */
- lwz %r4,GD_CURTHREAD(%r3) /* Get the current thread */
+ mfsprg %r3,%r0 /* Get the pcpu pointer */
+ lwz %r4,PC_CURTHREAD(%r3) /* Get the current thread */
lwz %r3,TD_PCB(%r4) /* Get a pointer to the PCB */
stmw %r14,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */
@@ -95,8 +95,8 @@ ENTRY(cpu_switch)
bl pmap_activate /* Activate the new address space */
mtlr %r30
- mfsprg %r4,%r0 /* Get the globaldata pointer */
- stw %r14,GD_CURTHREAD(%r4) /* Store new current thread */
+ mfsprg %r4,%r0 /* Get the pcpu pointer */
+ stw %r14,PC_CURTHREAD(%r4) /* Store new current thread */
lwz %r4,TD_PCB(%r14) /* Grab the new PCB */
lwz %r29, PCB_FLAGS(%r4) /* Restore FPU regs if needed */
diff --git a/sys/powerpc/powerpc/swtch.s b/sys/powerpc/powerpc/swtch.s
index c800264..3b5b1cd 100644
--- a/sys/powerpc/powerpc/swtch.s
+++ b/sys/powerpc/powerpc/swtch.s
@@ -72,8 +72,8 @@
*/
ENTRY(cpu_switch)
mflr %r30
- mfsprg %r3,%r0 /* Get the globaldata pointer */
- lwz %r4,GD_CURTHREAD(%r3) /* Get the current thread */
+ mfsprg %r3,%r0 /* Get the pcpu pointer */
+ lwz %r4,PC_CURTHREAD(%r3) /* Get the current thread */
lwz %r3,TD_PCB(%r4) /* Get a pointer to the PCB */
stmw %r14,PCB_CONTEXT(%r3) /* Save the non-volatile GP regs */
@@ -95,8 +95,8 @@ ENTRY(cpu_switch)
bl pmap_activate /* Activate the new address space */
mtlr %r30
- mfsprg %r4,%r0 /* Get the globaldata pointer */
- stw %r14,GD_CURTHREAD(%r4) /* Store new current thread */
+ mfsprg %r4,%r0 /* Get the pcpu pointer */
+ stw %r14,PC_CURTHREAD(%r4) /* Store new current thread */
lwz %r4,TD_PCB(%r14) /* Grab the new PCB */
lwz %r29, PCB_FLAGS(%r4) /* Restore FPU regs if needed */
OpenPOWER on IntegriCloud