summaryrefslogtreecommitdiffstats
path: root/sys/alpha
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/alpha
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/alpha')
-rw-r--r--sys/alpha/alpha/db_interface.c52
-rw-r--r--sys/alpha/alpha/exception.s6
-rw-r--r--sys/alpha/alpha/genassym.c13
-rw-r--r--sys/alpha/alpha/interrupt.c2
-rw-r--r--sys/alpha/alpha/locore.s12
-rw-r--r--sys/alpha/alpha/machdep.c33
-rw-r--r--sys/alpha/alpha/mp_machdep.c43
-rw-r--r--sys/alpha/alpha/support.s28
-rw-r--r--sys/alpha/alpha/swtch.s6
-rw-r--r--sys/alpha/alpha/trap.c4
-rw-r--r--sys/alpha/include/asm.h2
-rw-r--r--sys/alpha/include/globaldata.h74
-rw-r--r--sys/alpha/include/globals.h51
-rw-r--r--sys/alpha/include/mutex.h2
-rw-r--r--sys/alpha/include/pcb.h1
-rw-r--r--sys/alpha/include/pcpu.h50
-rw-r--r--sys/alpha/include/proc.h3
17 files changed, 91 insertions, 291 deletions
diff --git a/sys/alpha/alpha/db_interface.c b/sys/alpha/alpha/db_interface.c
index 49463c7..fea763d 100644
--- a/sys/alpha/alpha/db_interface.c
+++ b/sys/alpha/alpha/db_interface.c
@@ -571,52 +571,10 @@ db_branch_taken(ins, pc, regs)
return (newpc);
}
-DB_SHOW_COMMAND(pcpu, db_show_pcpu)
+void
+db_show_mdpcpu(struct pcpu *pc)
{
- struct globaldata *gd;
-#ifdef SMP
- int id;
-
- if (have_addr)
- id = ((addr >> 4) % 16) * 10 + (addr % 16);
- else
- id = PCPU_GET(cpuid);
- gd = globaldata_find(id);
- if (gd == NULL) {
- db_printf("CPU %d not found\n", id);
- return;
- }
-#else
- gd = GLOBALP;
-#endif
- db_printf("cpuid = %d\n", gd->gd_cpuid);
- db_printf("ipis = %lx\n", gd->gd_pending_ipis);
- db_printf("next ASN = %d\n", gd->gd_next_asn);
- db_printf("curthread = ");
- if (gd->gd_curthread != NULL)
- db_printf("%p: pid %d \"%s\"\n", gd->gd_curthread,
- gd->gd_curthread->td_proc->p_pid,
- gd->gd_curthread->td_proc->p_comm);
- else
- db_printf("none\n");
- db_printf("curpcb = %p\n", gd->gd_curpcb);
- db_printf("fpcurthread = ");
- if (gd->gd_fpcurthread != NULL)
- db_printf("%p: pid %d \"%s\"\n", gd->gd_fpcurthread,
- gd->gd_fpcurthread->td_proc->p_pid,
- gd->gd_fpcurthread->td_proc->p_comm);
- else
- db_printf("none\n");
- db_printf("idlethread = ");
- if (gd->gd_idlethread != NULL)
- db_printf("%p: pid %d \"%s\"\n", gd->gd_idlethread,
- gd->gd_idlethread->td_proc->p_pid,
- gd->gd_idlethread->td_proc->p_comm);
- else
- db_printf("none\n");
-
-#ifdef WITNESS
- db_printf("spin locks held:\n");
- witness_list_locks(&gd->gd_spinlocks);
-#endif
+
+ db_printf("ipis = 0x%lx\n", pc->pc_pending_ipis);
+ db_printf("next ASN = %d\n", pc->pc_next_asn);
}
diff --git a/sys/alpha/alpha/exception.s b/sys/alpha/alpha/exception.s
index 31637b4..4e4fc9e 100644
--- a/sys/alpha/alpha/exception.s
+++ b/sys/alpha/alpha/exception.s
@@ -139,7 +139,7 @@
beq t1, exception_return
/* set the hae register if this process has specified a value */
- ldq s0, GD_CURTHREAD(globalp)
+ ldq s0, PC_CURTHREAD(pcpup)
ldq t1, TD_MD_FLAGS(s0)
and t1, MDP_HAEUSED
beq t1, 3f
@@ -255,7 +255,7 @@ LEAF(exception_return, 1) /* XXX should be NESTED */
br pv, Ler1
Ler1: LDGP(pv)
- ldq s0, GD_CURTHREAD(globalp) /* save curthread in s0 */
+ ldq s0, PC_CURTHREAD(pcpup) /* save curthread in s0 */
#ifdef SMP
ldl s1, TD_MD_KERNNEST(s0)
subl s1, 1, s1 /* decrement nesting level */
@@ -275,7 +275,7 @@ Ler1: LDGP(pv)
Lkernelret:
#ifdef SMP
beq s1, Lrestoreregs
- stq globalp, (FRAME_T7*8)(sp) /* fixup globalp */
+ stq pcpup, (FRAME_T7*8)(sp) /* fixup pcpup */
#endif
Lrestoreregs:
diff --git a/sys/alpha/alpha/genassym.c b/sys/alpha/alpha/genassym.c
index 54e1009..8d68d73 100644
--- a/sys/alpha/alpha/genassym.c
+++ b/sys/alpha/alpha/genassym.c
@@ -54,7 +54,6 @@
#include <sys/ktr.h>
#include <machine/frame.h>
#include <machine/chipset.h>
-#include <machine/globaldata.h>
#include <sys/vmmeter.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -68,12 +67,12 @@
#include <nfsclient/nfs.h>
#include <nfsclient/nfsdiskless.h>
-ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread));
-ASSYM(GD_FPCURTHREAD, offsetof(struct globaldata, gd_fpcurthread));
-ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb));
-ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime));
-ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid));
-ASSYM(GD_IDLEPCBPHYS, offsetof(struct globaldata, gd_idlepcbphys));
+ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread));
+ASSYM(PC_FPCURTHREAD, offsetof(struct pcpu, pc_fpcurthread));
+ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb));
+ASSYM(PC_SWITCHTIME, offsetof(struct pcpu, pc_switchtime));
+ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid));
+ASSYM(PC_IDLEPCBPHYS, offsetof(struct pcpu, pc_idlepcbphys));
ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock));
ASSYM(MTX_RECURSE, offsetof(struct mtx, mtx_recurse));
diff --git a/sys/alpha/alpha/interrupt.c b/sys/alpha/alpha/interrupt.c
index 63e628e..29bb74f 100644
--- a/sys/alpha/alpha/interrupt.c
+++ b/sys/alpha/alpha/interrupt.c
@@ -101,7 +101,7 @@ interrupt(a0, a1, a2, framep)
#ifdef SMP
s = critical_enter();
#endif
- globalp = (struct globaldata *) alpha_pal_rdval();
+ pcpup = (struct pcpu *) alpha_pal_rdval();
td = curthread;
#ifdef SMP
td->td_md.md_kernnest++;
diff --git a/sys/alpha/alpha/locore.s b/sys/alpha/alpha/locore.s
index 8f3106f..e560d84 100644
--- a/sys/alpha/alpha/locore.s
+++ b/sys/alpha/alpha/locore.s
@@ -81,7 +81,7 @@
*/
#define SWITCH_CONTEXT \
/* Make a note of the context we're running on. */ \
- stq a0, GD_CURPCB(globalp); \
+ stq a0, PC_CURPCB(pcpup); \
\
/* Swap in the new context. */ \
call_pal PAL_OSF1_swpctx
@@ -111,10 +111,10 @@
call_pal PAL_OSF1_wrvptptr /* clobbers a0, t0, t8-t11 */
/*
- * Initialise globalp.
+ * Initialise pcpup.
*/
call_pal PAL_OSF1_rdval /* clobbers t0, t8-t11 */
- mov v0, globalp
+ mov v0, pcpup
/*
* Switch to proc0's PCB.
@@ -148,10 +148,10 @@
br pv, 1f
1: LDGP(pv)
- call_pal PAL_rdunique /* initialise globalp */
- mov v0, globalp
+ call_pal PAL_rdunique /* initialise pcpup */
+ mov v0, pcpup
- ldq a0, GD_IDLEPCBPHYS(globalp) /* switch to idle ctx */
+ ldq a0, PC_IDLEPCBPHYS(pcpup) /* switch to idle ctx */
call_pal PAL_OSF1_swpctx
/* Load KGP with current GP. */
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c
index fc94dd6..ef763a9 100644
--- a/sys/alpha/alpha/machdep.c
+++ b/sys/alpha/alpha/machdep.c
@@ -905,14 +905,14 @@ alpha_init(pfn, ptb, bim, bip, biv)
(thread0->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
/*
- * Setup the global data for the bootstrap cpu.
+ * Setup the per-CPU data for the bootstrap cpu.
*/
{
/* This is not a 'struct user' */
size_t sz = round_page(KSTACK_PAGES * PAGE_SIZE);
- globalp = (struct globaldata *) pmap_steal_memory(sz);
- globaldata_init(globalp, alpha_pal_whami(), sz);
- alpha_pal_wrval((u_int64_t) globalp);
+ pcpup = (struct pcpu *) pmap_steal_memory(sz);
+ pcpu_init(pcpup, alpha_pal_whami(), sz);
+ alpha_pal_wrval((u_int64_t) pcpup);
PCPU_GET(next_asn) = 1; /* 0 used for proc0 pmap */
#ifdef SMP
thread0->td_md.md_kernnest = 1;
@@ -943,14 +943,8 @@ alpha_init(pfn, ptb, bim, bip, biv)
thread0->td_frame = (struct trapframe *)thread0->td_pcb - 1;
thread0->td_pcb->pcb_hw.apcb_ksp = (u_int64_t)thread0->td_frame;
- /*
- * Get the right value for the boot cpu's idle ptbr.
- */
- globalp->gd_idlepcb.apcb_ptbr = thread0->td_pcb->pcb_hw.apcb_ptbr;
-
/* Setup curthread so that mutexes work */
PCPU_SET(curthread, thread0);
- PCPU_SET(spinlocks, NULL);
LIST_INIT(&thread0->td_contested);
@@ -2149,18 +2143,15 @@ alpha_fpstate_switch(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_idlepcbphys = vtophys((vm_offset_t) &globaldata->gd_idlepcb);
- globaldata->gd_idlepcb.apcb_ksp = (u_int64_t)
- ((caddr_t) globaldata + sz - sizeof(struct trapframe));
- globaldata->gd_idlepcb.apcb_ptbr = thread0->td_pcb->pcb_hw.apcb_ptbr;
- globaldata->gd_cpuid = cpuid;
- globaldata->gd_next_asn = 0;
- globaldata->gd_current_asngen = 1;
- globaldata_register(globaldata);
+
+ pcpu->pc_idlepcbphys = vtophys((vm_offset_t) &pcpu->pc_idlepcb);
+ pcpu->pc_idlepcb.apcb_ksp = (u_int64_t)
+ ((caddr_t) pcpu + sz - sizeof(struct trapframe));
+ pcpu->pc_idlepcb.apcb_ptbr = thread0->td_pcb->pcb_hw.apcb_ptbr;
+ pcpu->pc_current_asngen = 1;
}
diff --git a/sys/alpha/alpha/mp_machdep.c b/sys/alpha/alpha/mp_machdep.c
index d1324e7..40257c1 100644
--- a/sys/alpha/alpha/mp_machdep.c
+++ b/sys/alpha/alpha/mp_machdep.c
@@ -46,7 +46,6 @@
#include <sys/dkstat.h>
#include <machine/atomic.h>
-#include <machine/globaldata.h>
#include <machine/pmap.h>
#include <machine/rpb.h>
#include <machine/clock.h>
@@ -132,9 +131,9 @@ smp_init_secondary(void)
/*spin*/ ;
/*
- * Record the globaldata pointer in the per-cpu system value.
+ * Record the pcpu pointer in the per-cpu system value.
*/
- alpha_pal_wrval((u_int64_t) globalp);
+ alpha_pal_wrval((u_int64_t) pcpup);
/*
* Point interrupt/exception vectors to our own.
@@ -157,9 +156,10 @@ smp_init_secondary(void)
/*
* Set curproc to our per-cpu idleproc so that mutexes have
* something unique to lock with.
+ *
+ * XXX: shouldn't this already be set for us?
*/
PCPU_SET(curthread, PCPU_GET(idlethread));
- PCPU_SET(spinlocks, NULL);
/*
* Set flags in our per-CPU slot in the HWRPB.
@@ -181,7 +181,7 @@ smp_init_secondary(void)
* stack pointer for sanity.
*/
curthread->td_frame =
- (struct trapframe *)globalp->gd_idlepcb.apcb_ksp;
+ (struct trapframe *)PCPU_PTR(idlepcb)->apcb_ksp;
mtx_lock_spin(&ap_boot_mtx);
@@ -220,7 +220,7 @@ smp_start_secondary(int cpuid)
struct pcs *cpu = LOCATE_PCS(hwrpb, cpuid);
struct pcs *bootcpu = LOCATE_PCS(hwrpb, boot_cpu_id);
struct alpha_pcb *pcb = (struct alpha_pcb *) cpu->pcs_hwpcb;
- struct globaldata *globaldata;
+ struct pcpu *pcpu;
int i;
size_t sz;
@@ -233,21 +233,21 @@ smp_start_secondary(int cpuid)
printf("smp_start_secondary: starting cpu %d\n", cpuid);
sz = round_page((UAREA_PAGES + KSTACK_PAGES) * PAGE_SIZE);
- globaldata = malloc(sz, M_TEMP, M_NOWAIT);
- if (!globaldata) {
+ pcpu = malloc(sz, M_TEMP, M_NOWAIT);
+ if (!pcpu) {
printf("smp_start_secondary: can't allocate memory\n");
return 0;
}
- globaldata_init(globaldata, cpuid, sz);
+ pcpu_init(pcpu, cpuid, sz);
/*
* Copy the idle pcb and setup the address to start executing.
- * Use the pcb unique value to point the secondary at its globaldata
+ * Use the pcb unique value to point the secondary at its pcpu
* structure.
*/
- *pcb = globaldata->gd_idlepcb;
- pcb->apcb_unique = (u_int64_t)globaldata;
+ *pcb = pcpu->pc_idlepcb;
+ pcb->apcb_unique = (u_int64_t)pcpu;
hwrpb->rpb_restart = (u_int64_t) smp_init_secondary_glue;
hwrpb->rpb_restart_val = (u_int64_t) smp_init_secondary_glue;
hwrpb->rpb_checksum = hwrpb_checksum();
@@ -271,10 +271,11 @@ smp_start_secondary(int cpuid)
*/
if (!smp_send_secondary_command("START\r\n", cpuid)) {
printf("smp_start_secondary: can't send START command\n");
- free(globaldata, M_TEMP);
+ pcpu_destroy(pcpu);
+ free(pcpu, M_TEMP);
return 0;
}
-
+
/*
* Wait for the secondary to set the BIP flag in its structure.
*/
@@ -285,9 +286,11 @@ smp_start_secondary(int cpuid)
}
if (!(cpu->pcs_flags & PCS_BIP)) {
printf("smp_start_secondary: secondary did not respond\n");
- free(globaldata, M_TEMP);
+ pcpu_destroy(pcpu);
+ free(pcpu, M_TEMP);
+ return 0;
}
-
+
/*
* It worked (I think).
*/
@@ -410,7 +413,7 @@ cpu_mp_announce(void)
void
ipi_selected(u_int32_t cpus, u_int64_t ipi)
{
- struct globaldata *globaldata;
+ struct pcpu *pcpu;
CTR2(KTR_SMP, "ipi_selected: cpus: %x ipi: %lx", cpus, ipi);
alpha_mb();
@@ -418,9 +421,9 @@ ipi_selected(u_int32_t cpus, u_int64_t ipi)
int cpuid = ffs(cpus) - 1;
cpus &= ~(1 << cpuid);
- globaldata = globaldata_find(cpuid);
- if (globaldata) {
- atomic_set_64(&globaldata->gd_pending_ipis, ipi);
+ pcpu = pcpu_find(cpuid);
+ if (pcpu) {
+ atomic_set_64(&pcpu->pc_pending_ipis, ipi);
alpha_mb();
CTR1(KTR_SMP, "calling alpha_pal_wripir(%d)", cpuid);
alpha_pal_wripir(cpuid);
diff --git a/sys/alpha/alpha/support.s b/sys/alpha/alpha/support.s
index 61c692e..497412d 100644
--- a/sys/alpha/alpha/support.s
+++ b/sys/alpha/alpha/support.s
@@ -72,7 +72,7 @@
beq t1, fusufault
lda t0, fusufault /* trap faults */
- ldq t2, GD_CURTHREAD(globalp)
+ ldq t2, PC_CURTHREAD(pcpup)
ldq t2, TD_PCB(t2)
stq t0, PCB_ONFAULT(t2)
@@ -92,7 +92,7 @@
beq t1, fusufault
lda t0, fusufault /* trap faults */
- ldq t2, GD_CURTHREAD(globalp)
+ ldq t2, PC_CURTHREAD(pcpup)
ldq t2, TD_PCB(t2)
stq t0, PCB_ONFAULT(t2)
@@ -117,7 +117,7 @@
beq t1, fusufault
lda t0, fusufault /* trap faults */
- ldq t2, GD_CURTHREAD(globalp)
+ ldq t2, PC_CURTHREAD(pcpup)
ldq t2, TD_PCB(t2)
stq t0, PCB_ONFAULT(t2)
@@ -136,7 +136,7 @@
beq t1, fusufault
lda t0, fusufault /* trap faults */
- ldq t2, GD_CURTHREAD(globalp)
+ ldq t2, PC_CURTHREAD(pcpup)
ldq t2, TD_PCB(t2)
stq t0, PCB_ONFAULT(t2)
@@ -154,7 +154,7 @@
END(suibyte)
LEAF(fusufault, 0)
- ldq t0, GD_CURTHREAD(globalp)
+ ldq t0, PC_CURTHREAD(pcpup)
ldq t0, TD_PCB(t0)
stq zero, PCB_ONFAULT(t0)
ldiq v0, -1
@@ -222,13 +222,13 @@ NESTED(copyinstr, 4, 16, ra, 0, 0)
beq t1, copyerr /* if it's not, error out. */
lda v0, copyerr /* set up fault handler. */
.set noat
- ldq at_reg, GD_CURTHREAD(globalp)
+ ldq at_reg, PC_CURTHREAD(pcpup)
ldq at_reg, TD_PCB(at_reg)
stq v0, PCB_ONFAULT(at_reg)
.set at
CALL(copystr) /* do the copy. */
.set noat
- ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */
+ ldq at_reg, PC_CURTHREAD(pcpup) /* kill the fault handler. */
ldq at_reg, TD_PCB(at_reg)
stq zero, PCB_ONFAULT(at_reg)
.set at
@@ -246,13 +246,13 @@ NESTED(copyoutstr, 4, 16, ra, 0, 0)
beq t1, copyerr /* if it's not, error out. */
lda v0, copyerr /* set up fault handler. */
.set noat
- ldq at_reg, GD_CURTHREAD(globalp)
+ ldq at_reg, PC_CURTHREAD(pcpup)
ldq at_reg, TD_PCB(at_reg)
stq v0, PCB_ONFAULT(at_reg)
.set at
CALL(copystr) /* do the copy. */
.set noat
- ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */
+ ldq at_reg, PC_CURTHREAD(pcpup) /* kill the fault handler. */
ldq at_reg, TD_PCB(at_reg)
stq zero, PCB_ONFAULT(at_reg)
.set at
@@ -514,13 +514,13 @@ NESTED(copyin, 3, 16, ra, 0, 0)
beq t1, copyerr /* if it's not, error out. */
lda v0, copyerr /* set up fault handler. */
.set noat
- ldq at_reg, GD_CURTHREAD(globalp)
+ ldq at_reg, PC_CURTHREAD(pcpup)
ldq at_reg, TD_PCB(at_reg)
stq v0, PCB_ONFAULT(at_reg)
.set at
CALL(bcopy) /* do the copy. */
.set noat
- ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */
+ ldq at_reg, PC_CURTHREAD(pcpup) /* kill the fault handler. */
ldq at_reg, TD_PCB(at_reg)
stq zero, PCB_ONFAULT(at_reg)
.set at
@@ -539,13 +539,13 @@ NESTED(copyout, 3, 16, ra, 0, 0)
beq t1, copyerr /* if it's not, error out. */
lda v0, copyerr /* set up fault handler. */
.set noat
- ldq at_reg, GD_CURTHREAD(globalp)
+ ldq at_reg, PC_CURTHREAD(pcpup)
ldq at_reg, TD_PCB(at_reg)
stq v0, PCB_ONFAULT(at_reg)
.set at
CALL(bcopy) /* do the copy. */
.set noat
- ldq at_reg, GD_CURTHREAD(globalp) /* kill the fault handler. */
+ ldq at_reg, PC_CURTHREAD(pcpup) /* kill the fault handler. */
ldq at_reg, TD_PCB(at_reg)
stq zero, PCB_ONFAULT(at_reg)
.set at
@@ -556,7 +556,7 @@ NESTED(copyout, 3, 16, ra, 0, 0)
END(copyout)
LEAF(copyerr, 0)
- ldq t0, GD_CURTHREAD(globalp)
+ ldq t0, PC_CURTHREAD(pcpup)
ldq t0, TD_PCB(t0)
stq zero, PCB_ONFAULT(t0) /* reset fault handler. */
ldq ra, (16-8)(sp) /* restore ra. */
diff --git a/sys/alpha/alpha/swtch.s b/sys/alpha/alpha/swtch.s
index 79454c5..34f3453 100644
--- a/sys/alpha/alpha/swtch.s
+++ b/sys/alpha/alpha/swtch.s
@@ -41,7 +41,7 @@
*/
#define SWITCH_CONTEXT \
/* Make a note of the context we're running on. */ \
- stq a0, GD_CURPCB(globalp); \
+ stq a0, PC_CURPCB(pcpup); \
\
/* Swap in the new context. */ \
call_pal PAL_OSF1_swpctx
@@ -103,7 +103,7 @@ LEAF(cpu_throw, 0)
LEAF(cpu_switch, 1)
LDGP(pv)
/* do an inline savectx(), to save old context */
- ldq a0, GD_CURTHREAD(globalp)
+ ldq a0, PC_CURTHREAD(pcpup)
ldq a1, TD_PCB(a0)
/* NOTE: ksp is stored by the swpctx */
stq s0, PCB_CONTEXT+(0 * 8)(a1) /* store s0 - s6 */
@@ -188,7 +188,7 @@ Lcs7:
* because we might have re-entered cpu_switch() from idle(),
* in which case curthread would be NULL.
*/
- stq s2, GD_CURTHREAD(globalp) /* curthread = p */
+ stq s2, PC_CURTHREAD(pcpup) /* curthread = p */
/*
* Now running on the new u struct.
diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c
index 459146d..4c7694d 100644
--- a/sys/alpha/alpha/trap.c
+++ b/sys/alpha/alpha/trap.c
@@ -272,7 +272,7 @@ trap(a0, a1, a2, entry, framep)
#ifdef SMP
s = critical_enter();
#endif
- globalp = (struct globaldata *) alpha_pal_rdval();
+ pcpup = (struct pcpu *) alpha_pal_rdval();
td = curthread;
#ifdef SMP
td->td_md.md_kernnest++;
@@ -674,7 +674,7 @@ syscall(code, framep)
#ifdef SMP
s = critical_enter();
#endif
- globalp = (struct globaldata *) alpha_pal_rdval();
+ pcpup = (struct pcpu *) alpha_pal_rdval();
td = curthread;
#ifdef SMP
td->td_md.md_kernnest++;
diff --git a/sys/alpha/include/asm.h b/sys/alpha/include/asm.h
index 4a9963c..782505c 100644
--- a/sys/alpha/include/asm.h
+++ b/sys/alpha/include/asm.h
@@ -91,7 +91,7 @@
/* In the kernel, we use t7 to point at the per-cpu globals. */
#ifdef _KERNEL
-#define globalp $8
+#define pcpup $8
#endif
/* Floating point registers (XXXX VERIFY THIS) */
diff --git a/sys/alpha/include/globaldata.h b/sys/alpha/include/globaldata.h
deleted file mode 100644
index d0ba706..0000000
--- a/sys/alpha/include/globaldata.h
+++ /dev/null
@@ -1,74 +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 alpha_pcb gd_idlepcb; /* pcb for idling */
- 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 */
- u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */
- u_int64_t gd_pending_ipis; /* pending IPI events */
- 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[0];
-#endif
-};
-
-void globaldata_init(struct globaldata *pcpu, int cpuid, size_t sz);
-
-#endif /* _KERNEL */
-
-#endif /* !_MACHINE_GLOBALDATA_H_ */
diff --git a/sys/alpha/include/globals.h b/sys/alpha/include/globals.h
deleted file mode 100644
index a6a87f2..0000000
--- a/sys/alpha/include/globals.h
+++ /dev/null
@@ -1,51 +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/globaldata.h>
-
-register struct globaldata *globalp __asm__("$8");
-
-#define GLOBALP 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/alpha/include/mutex.h b/sys/alpha/include/mutex.h
index 9192bb2..970049b 100644
--- a/sys/alpha/include/mutex.h
+++ b/sys/alpha/include/mutex.h
@@ -58,7 +58,7 @@ extern struct mtx clock_lock;
1: ldq_l a0, lck+MTX_LOCK; \
cmpeq a0, MTX_UNOWNED, a1; \
beq a1, 1b; \
- ldq a0, PC_CURTHREAD(globalp); \
+ ldq a0, PC_CURTHREAD(pcpup); \
stq_c a0, lck+MTX_LOCK; \
beq a0, 1b; \
mb; \
diff --git a/sys/alpha/include/pcb.h b/sys/alpha/include/pcb.h
index 18c4c13..cfbdfdf 100644
--- a/sys/alpha/include/pcb.h
+++ b/sys/alpha/include/pcb.h
@@ -33,7 +33,6 @@
#include <machine/frame.h>
#include <machine/reg.h>
-#include <machine/globaldata.h>
#include <machine/alpha_cpu.h>
/*
diff --git a/sys/alpha/include/pcpu.h b/sys/alpha/include/pcpu.h
index d0ba706..807f259 100644
--- a/sys/alpha/include/pcpu.h
+++ b/sys/alpha/include/pcpu.h
@@ -27,48 +27,26 @@
* $FreeBSD$
*/
-#ifndef _MACHINE_GLOBALDATA_H_
-#define _MACHINE_GLOBALDATA_H_
+#ifndef _MACHINE_PCPU_H_
+#define _MACHINE_PCPU_H_
#ifdef _KERNEL
-#include <sys/queue.h>
+#define PCPU_MD_FIELDS \
+ struct alpha_pcb pc_idlepcb; /* pcb for idling */ \
+ u_int64_t pc_idlepcbphys; /* pa of pc_idlepcb */ \
+ u_int64_t pc_pending_ipis; /* pending IPI's */ \
+ 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 alpha_pcb gd_idlepcb; /* pcb for idling */
- 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 */
- u_int64_t gd_idlepcbphys; /* pa of gd_idlepcb */
- u_int64_t gd_pending_ipis; /* pending IPI events */
- u_int32_t gd_next_asn; /* next ASN to allocate */
- u_int32_t gd_current_asngen; /* ASN rollover check */
+struct pcpu;
- 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[0];
-#endif
-};
+register struct pcpu *pcpup __asm__("$8");
-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/alpha/include/proc.h b/sys/alpha/include/proc.h
index 16cf1d5..eb1772a 100644
--- a/sys/alpha/include/proc.h
+++ b/sys/alpha/include/proc.h
@@ -31,9 +31,6 @@
#ifndef _MACHINE_PROC_H_
#define _MACHINE_PROC_H_
-#include <machine/globaldata.h>
-#include <machine/globals.h>
-
/*
* Machine-dependent part of the proc struct for the Alpha.
*/
OpenPOWER on IntegriCloud