summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2022-11-29 21:41:40 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2022-11-29 21:41:40 +0000
commit3ad89389f60bb6f55eed7828114c36ae3dcca850 (patch)
tree7d999db5b19e9d4a7cee2b875853c91241841055 /sys
parent7a601320ff7f4a35d7431b2dee18cea14a170166 (diff)
Move the generic variable definitions from the ASM at the top of
locore.S to be in C in cpu.c, machdep.c, pmap.c, or bus_space.c for better typing/debug info. Delete REALBASEMEM, REALEXTMEM, and biosextmem as unused/ignored. ok mpi@ krw@ mlarkin@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/bus_space.c5
-rw-r--r--sys/arch/amd64/amd64/cpu.c15
-rw-r--r--sys/arch/amd64/amd64/locore.S55
-rw-r--r--sys/arch/amd64/amd64/machdep.c10
-rw-r--r--sys/arch/amd64/amd64/pmap.c10
-rw-r--r--sys/arch/amd64/include/biosvar.h3
-rw-r--r--sys/arch/amd64/include/cpu.h10
7 files changed, 40 insertions, 68 deletions
diff --git a/sys/arch/amd64/amd64/bus_space.c b/sys/arch/amd64/amd64/bus_space.c
index 8bffc4e1e54..a9a7facc38e 100644
--- a/sys/arch/amd64/amd64/bus_space.c
+++ b/sys/arch/amd64/amd64/bus_space.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_space.c,v 1.27 2022/06/29 07:44:10 kettenis Exp $ */
+/* $OpenBSD: bus_space.c,v 1.28 2022/11/29 21:41:39 guenther Exp $ */
/* $NetBSD: bus_space.c,v 1.2 2003/03/14 18:47:53 christos Exp $ */
/*-
@@ -45,6 +45,9 @@
extern int pmap_initialized;
+/* kernel address of "hole" (location of start of iomem in virtual) */
+u_long atdevbase = 0;
+
/*
* Extent maps to manage I/O and memory space. Allocate
* storage for 16 regions in each, initially. Later, ioport_malloc_safe
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index 288a31704af..56c76df9333 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.162 2022/11/08 17:34:13 cheloha Exp $ */
+/* $OpenBSD: cpu.c,v 1.163 2022/11/29 21:41:39 guenther Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@@ -150,6 +150,19 @@ void replacemds(void);
extern long _stac;
extern long _clac;
+int cpuid_level = 0; /* cpuid(0).eax */
+char cpu_vendor[16] = { 0 }; /* cpuid(0).e[bdc]x, \0 */
+int cpu_id = 0; /* cpuid(1).eax */
+int cpu_ebxfeature = 0; /* cpuid(1).ebx */
+int cpu_ecxfeature = 0; /* cpuid(1).ecx */
+int cpu_feature = 0; /* cpuid(1).edx */
+int cpu_perf_eax = 0; /* cpuid(0xa).eax */
+int cpu_perf_ebx = 0; /* cpuid(0xa).ebx */
+int cpu_perf_edx = 0; /* cpuid(0xa).edx */
+int cpu_apmi_edx = 0; /* cpuid(0x80000007).edx */
+int ecpu_ecxfeature = 0; /* cpuid(0x80000001).ecx */
+int cpu_meltdown = 0;
+
void
replacesmap(void)
{
diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S
index 9be53956f53..d2093a773e8 100644
--- a/sys/arch/amd64/amd64/locore.S
+++ b/sys/arch/amd64/amd64/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.129 2022/11/04 16:49:31 kettenis Exp $ */
+/* $OpenBSD: locore.S,v 1.130 2022/11/29 21:41:39 guenther Exp $ */
/* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */
/*
@@ -162,59 +162,6 @@ _C_LABEL(lapic_isr):
.space NBPG-LAPIC_ISR
#endif
- .globl _C_LABEL(cpu_id),_C_LABEL(cpu_vendor)
- .globl _C_LABEL(cpuid_level),_C_LABEL(cpu_feature)
- .globl _C_LABEL(cpu_ebxfeature)
- .globl _C_LABEL(cpu_ecxfeature),_C_LABEL(ecpu_ecxfeature)
- .globl _C_LABEL(cpu_perf_eax)
- .globl _C_LABEL(cpu_perf_ebx)
- .globl _C_LABEL(cpu_perf_edx)
- .globl _C_LABEL(cpu_apmi_edx)
- .globl _C_LABEL(ssym),_C_LABEL(esym),_C_LABEL(boothowto)
- .globl _C_LABEL(bootdev)
- .globl _C_LABEL(bootinfo), _C_LABEL(bootinfo_size), _C_LABEL(atdevbase)
- .globl _C_LABEL(proc0paddr)
- .globl _C_LABEL(biosbasemem)
- .globl _C_LABEL(bootapiver)
- .globl _C_LABEL(pg_nx)
- .globl _C_LABEL(pg_g_kern)
- .globl _C_LABEL(cpu_meltdown)
-_C_LABEL(cpu_id): .long 0 # saved from `cpuid' instruction
-_C_LABEL(cpu_feature): .long 0 # feature flags from 'cpuid'
- # instruction
-_C_LABEL(cpu_ebxfeature):.long 0 # ext. ebx feature flags from 'cpuid'
-_C_LABEL(cpu_ecxfeature):.long 0 # ext. ecx feature flags from 'cpuid'
-_C_LABEL(ecpu_ecxfeature):.long 0 # extended ecx feature flags
-_C_LABEL(cpu_perf_eax): .long 0 # arch. perf. mon. flags from 'cpuid'
-_C_LABEL(cpu_perf_ebx): .long 0 # arch. perf. mon. flags from 'cpuid'
-_C_LABEL(cpu_perf_edx): .long 0 # arch. perf. mon. flags from 'cpuid'
-_C_LABEL(cpu_apmi_edx): .long 0 # adv. power mgmt. info. from 'cpuid'
-_C_LABEL(cpuid_level): .long -1 # max. level accepted by 'cpuid'
- # instruction
-_C_LABEL(cpu_vendor): .space 16 # vendor string returned by `cpuid'
- # instruction
-_C_LABEL(ssym): .quad 0 # ptr to start of syms
-_C_LABEL(esym): .quad 0 # ptr to end of syms
-_C_LABEL(atdevbase): .quad 0 # location of start of iomem in virtual
-_C_LABEL(bootapiver): .long 0 # /boot API version
-_C_LABEL(bootdev): .long 0 # device we booted from
-_C_LABEL(proc0paddr): .quad 0
-#ifndef REALBASEMEM
-_C_LABEL(biosbasemem): .long 0 # base memory reported by BIOS
-#else
-_C_LABEL(biosbasemem): .long REALBASEMEM
-#endif
-#ifndef REALEXTMEM
-_C_LABEL(biosextmem): .long 0 # extended memory reported by BIOS
-#else
-_C_LABEL(biosextmem): .long REALEXTMEM
-#endif
-_C_LABEL(pg_nx): .quad 0 # NX PTE bit (if CPU supports)
-_C_LABEL(pg_g_kern): .quad 0 # 0x100 if global pages should be used
- # in kernel mappings, 0 otherwise (for
- # insecure CPUs)
-_C_LABEL(cpu_meltdown): .long 0 # 1 if this CPU has Meltdown
-
/*****************************************************************************/
/*
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 06acb920ebe..cec6ee378ed 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.283 2022/11/08 14:46:51 cheloha Exp $ */
+/* $OpenBSD: machdep.c,v 1.284 2022/11/29 21:41:39 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -171,6 +171,11 @@ int cpureset_delay = CPURESET_DELAY;
int cpureset_delay = 0;
#endif
+char *ssym = 0, *esym = 0; /* start and end of symbol table */
+dev_t bootdev = 0; /* device we booted from */
+int biosbasemem = 0; /* base memory reported by BIOS */
+u_int bootapiver = 0; /* /boot API version */
+
int physmem;
u_int64_t dumpmem_low;
u_int64_t dumpmem_high;
@@ -448,7 +453,6 @@ bios_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen, struct proc *p)
{
bios_diskinfo_t *pdi;
- extern dev_t bootdev;
int biosdev;
/* all sysctl names at this level except diskinfo are terminal */
@@ -1175,7 +1179,7 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
struct gate_descriptor *idt;
char idt_allocmap[NIDT];
-extern struct user *proc0paddr;
+struct user *proc0paddr = NULL;
void
setgate(struct gate_descriptor *gd, void *func, int ist, int type, int dpl,
diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c
index a932a2c9af9..893f840baf8 100644
--- a/sys/arch/amd64/amd64/pmap.c
+++ b/sys/arch/amd64/amd64/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.155 2022/10/16 15:03:39 kettenis Exp $ */
+/* $OpenBSD: pmap.c,v 1.156 2022/11/29 21:41:39 guenther Exp $ */
/* $NetBSD: pmap.c,v 1.3 2003/05/08 18:13:13 thorpej Exp $ */
/*
@@ -225,6 +225,14 @@ pd_entry_t *const normal_pdes[] = PDES_INITIALIZER;
struct pmap kernel_pmap_store; /* the kernel's pmap (proc0) */
/*
+ * pg_nx: NX PTE bit (if CPU supports)
+ * pg_g_kern: PG_G if global pages should be used in kernel mappings,
+ * 0 otherwise (for insecure CPUs)
+ */
+pt_entry_t pg_nx = 0;
+pt_entry_t pg_g_kern = 0;
+
+/*
* pmap_pg_wc: if our processor supports PAT then we set this
* to be the pte bits for Write Combining. Else we fall back to
* UC- so mtrrs can override the cacheability;
diff --git a/sys/arch/amd64/include/biosvar.h b/sys/arch/amd64/include/biosvar.h
index 8fe6e29c2a9..1abd944d63f 100644
--- a/sys/arch/amd64/include/biosvar.h
+++ b/sys/arch/amd64/include/biosvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosvar.h,v 1.28 2022/06/29 07:51:54 kettenis Exp $ */
+/* $OpenBSD: biosvar.h,v 1.29 2022/11/29 21:41:39 guenther Exp $ */
/*
* Copyright (c) 1997-1999 Michael Shalayeff
@@ -276,6 +276,7 @@ int bios_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
void bios_getopt(void);
bios_diskinfo_t *bios_getdiskinfo(dev_t);
+extern int biosbasemem;
extern u_int bootapiver;
extern bios_memmap_t *bios_memmap;
extern bios_efiinfo_t *bios_efiinfo;
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 7dcbc82be11..eea800a78ff 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.153 2022/11/08 17:34:13 cheloha Exp $ */
+/* $OpenBSD: cpu.h,v 1.154 2022/11/29 21:41:39 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -372,9 +372,7 @@ struct timeval;
#ifdef _KERNEL
-/* locore.S */
-extern int biosbasemem;
-extern int biosextmem;
+/* cpu.c */
extern int cpu_feature;
extern int cpu_ebxfeature;
extern int cpu_ecxfeature;
@@ -386,10 +384,7 @@ extern int ecpu_ecxfeature;
extern int cpu_id;
extern char cpu_vendor[];
extern int cpuid_level;
-extern int cpuspeed;
extern int cpu_meltdown;
-
-/* cpu.c */
extern u_int cpu_mwait_size;
extern u_int cpu_mwait_states;
@@ -399,6 +394,7 @@ void x86_print_cacheinfo(struct cpu_info *);
/* identcpu.c */
void identifycpu(struct cpu_info *);
int cpu_amd64speed(int *);
+extern int cpuspeed;
/* machdep.c */
void dumpconf(void);