From 70d12a18f21f17d8beb0fbead08f76ae36cc25e2 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 19 Aug 2008 19:53:52 +0000 Subject: [PATCH] Export 'struct pcpu' to userland w/o requiring _KERNEL. A few ports already define _KERNEL to get to this and I'm about to add hooks to libkvm to access per-CPU data. MFC after: 1 week --- sys/amd64/include/pcpu.h | 4 ++-- sys/arm/include/pcpu.h | 4 ++++ sys/i386/include/pcpu.h | 5 +++-- sys/ia64/include/pcpu.h | 4 ++-- sys/mips/include/pcpu.h | 5 +++-- sys/powerpc/include/pcpu.h | 3 ++- sys/sparc64/include/pcpu.h | 4 ++-- sys/sun4v/include/pcpu.h | 5 +++-- sys/sys/pcpu.h | 8 ++++---- sys/sys/types.h | 2 +- 10 files changed, 26 insertions(+), 18 deletions(-) diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h index 444109ebc9c7..fe811c57ec51 100644 --- a/sys/amd64/include/pcpu.h +++ b/sys/amd64/include/pcpu.h @@ -33,8 +33,6 @@ #error "sys/cdefs.h is a prerequisite for this file" #endif -#ifdef _KERNEL - /* * The SMP parts are setup in pmap.c and locore.s for the BSP, and * mp_machdep.c sets up the data for the AP's to "see" when they awake. @@ -52,6 +50,8 @@ u_int pc_apic_id; \ u_int pc_acpi_id /* ACPI CPU id */ +#ifdef _KERNEL + #ifdef lint extern struct pcpu *pcpup; diff --git a/sys/arm/include/pcpu.h b/sys/arm/include/pcpu.h index 8388ba6fdd1b..387035cf2446 100644 --- a/sys/arm/include/pcpu.h +++ b/sys/arm/include/pcpu.h @@ -38,6 +38,8 @@ struct vmspace; +#endif /* _KERNEL */ + /* * Inside the kernel, the globally reserved register g7 is used to * point at the globaldata structure. @@ -45,6 +47,8 @@ struct vmspace; #define PCPU_MD_FIELDS \ struct pcup *pc_prvspace; +#ifdef _KERNEL + struct pcb; struct pcpu; diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index ea8ff4667758..5690e866a290 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -33,8 +33,6 @@ #error "sys/cdefs.h is a prerequisite for this file" #endif -#ifdef _KERNEL - #include #include @@ -82,6 +80,9 @@ int pc_private_tss /* Flag indicating private tss */ #endif + +#ifdef _KERNEL + #ifdef lint extern struct pcpu *pcpup; diff --git a/sys/ia64/include/pcpu.h b/sys/ia64/include/pcpu.h index d641816d1f95..c63573b9992f 100644 --- a/sys/ia64/include/pcpu.h +++ b/sys/ia64/include/pcpu.h @@ -30,8 +30,6 @@ #ifndef _MACHINE_PCPU_H_ #define _MACHINE_PCPU_H_ -#ifdef _KERNEL - #include #define PCPU_MD_FIELDS \ @@ -43,6 +41,8 @@ uint32_t pc_awake:1; /* CPU is awake? */ \ uint32_t pc_acpi_id /* ACPI CPU id. */ +#ifdef _KERNEL + struct pcpu; register struct pcpu *pcpup __asm__("r13"); diff --git a/sys/mips/include/pcpu.h b/sys/mips/include/pcpu.h index fb2951b40995..5fe2b22a81c0 100644 --- a/sys/mips/include/pcpu.h +++ b/sys/mips/include/pcpu.h @@ -31,9 +31,8 @@ #ifndef _MACHINE_PCPU_H_ #define _MACHINE_PCPU_H_ -#ifdef _KERNEL - #include + #define PCPU_MD_FIELDS \ pd_entry_t *pc_segbase; /* curthread segbase */ \ struct pmap *pc_curpmap; /* pmap of curthread */ \ @@ -42,6 +41,8 @@ u_int pc_pending_ipis; /* the IPIs pending to this CPU */ \ void *pc_boot_stack; +#ifdef _KERNEL + #ifdef SMP static __inline struct pcpu* get_pcpup(void) diff --git a/sys/powerpc/include/pcpu.h b/sys/powerpc/include/pcpu.h index af9e54b2e0d5..fba4c8fd33dc 100644 --- a/sys/powerpc/include/pcpu.h +++ b/sys/powerpc/include/pcpu.h @@ -30,7 +30,6 @@ #ifndef _MACHINE_PCPU_H_ #define _MACHINE_PCPU_H_ -#ifdef _KERNEL #include struct pmap; @@ -117,6 +116,8 @@ struct pmap; int pc_md_placeholder #endif +#ifdef _KERNEL + #define pcpup ((struct pcpu *) powerpc_get_pcpup()) #define PCPU_GET(member) (pcpup->pc_ ## member) diff --git a/sys/sparc64/include/pcpu.h b/sys/sparc64/include/pcpu.h index 04f5ee6ca333..91c1e5dd5ca9 100644 --- a/sys/sparc64/include/pcpu.h +++ b/sys/sparc64/include/pcpu.h @@ -30,8 +30,6 @@ #ifndef _MACHINE_PCPU_H_ #define _MACHINE_PCPU_H_ -#ifdef _KERNEL - #include #include #include @@ -59,6 +57,8 @@ struct pmap; u_int pc_tlb_ctx_max; \ u_int pc_tlb_ctx_min +#ifdef _KERNEL + struct pcb; struct pcpu; diff --git a/sys/sun4v/include/pcpu.h b/sys/sun4v/include/pcpu.h index beb0789becc0..b88ddbbdc299 100644 --- a/sys/sun4v/include/pcpu.h +++ b/sys/sun4v/include/pcpu.h @@ -30,8 +30,6 @@ #ifndef _MACHINE_PCPU_H_ #define _MACHINE_PCPU_H_ -#ifdef _KERNEL - #include #include #include @@ -82,6 +80,9 @@ struct pmap; * be L2 cache aligned - they're surrounded by per-cpu data, so there is * no possibility of false sharing, but this might help in reducing misses */ + +#ifdef _KERNEL + struct pcpu; register struct pcpu *pcpup __asm__(__XSTRING(PCPU_REG)); diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index df739854e111..5633bf0038ee 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -33,10 +33,6 @@ #ifndef _SYS_PCPU_H_ #define _SYS_PCPU_H_ -#ifndef _KERNEL -#error "no user-serviceable parts inside" -#endif - #ifdef LOCORE #error "no assembler-serviceable parts inside" #endif @@ -106,6 +102,8 @@ struct pcpu { PCPU_MD_FIELDS; }; +#ifdef _KERNEL + SLIST_HEAD(cpuhead, pcpu); extern struct cpuhead cpuhead; @@ -133,4 +131,6 @@ void pcpu_destroy(struct pcpu *pcpu); struct pcpu *pcpu_find(u_int cpuid); void pcpu_init(struct pcpu *pcpu, int cpuid, size_t size); +#endif /* _KERNEL */ + #endif /* !_SYS_PCPU_H_ */ diff --git a/sys/sys/types.h b/sys/sys/types.h index ed0e3a9d6016..929407f49237 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -143,6 +143,7 @@ typedef __clockid_t clockid_t; #define _CLOCKID_T_DECLARED #endif +typedef __cpumask_t cpumask_t; typedef __critical_t critical_t; /* Critical section value */ typedef __int64_t daddr_t; /* disk address */ @@ -278,7 +279,6 @@ typedef __vm_size_t vm_size_t; #ifdef _KERNEL typedef int boolean_t; -typedef __cpumask_t cpumask_t; typedef struct device *device_t; typedef __intfptr_t intfptr_t;