summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-07-07 03:07:20 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-07-07 03:07:20 +0000
commitc297a5e7bfad0aa6ba87d80a94cb497dbf8ab981 (patch)
treecdf2ae602c3d79abbe52dc87c29773cf0b8db0cd
parent9b7b9d79985d14e71511876b0d6c652c129275f6 (diff)
function for cpuid instruction. pulled from longrun into generic code.
ok deraadt mickey
-rw-r--r--sys/arch/i386/i386/longrun.c23
-rw-r--r--sys/arch/i386/i386/machdep.c20
-rw-r--r--sys/arch/i386/include/cpu.h3
3 files changed, 23 insertions, 23 deletions
diff --git a/sys/arch/i386/i386/longrun.c b/sys/arch/i386/i386/longrun.c
index 51e1fc2b036..0b81a538479 100644
--- a/sys/arch/i386/i386/longrun.c
+++ b/sys/arch/i386/i386/longrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: longrun.c,v 1.3 2003/05/27 23:52:01 fgsch Exp $ */
+/* $OpenBSD: longrun.c,v 1.4 2003/07/07 03:07:19 tedu Exp $ */
/*
* Copyright (c) 2003 Ted Unangst
* Copyright (c) 2001 Tamotsu Hattori
@@ -34,7 +34,6 @@
#include <machine/longrun.h>
-static void longrun_readreg(u_int32_t, u_int32_t *);
static void longrun_getmode(u_int32_t *, u_int32_t *, u_int32_t *);
static void longrun_setmode(u_int32_t, u_int32_t, u_int32_t);
int longrun_sysctl(void *, size_t *, void *, size_t);
@@ -110,7 +109,7 @@ longrun_getmode(u_int32_t *freq, u_int32_t *voltage, u_int32_t *percent)
eflags = read_eflags();
disable_intr();
- longrun_readreg(0x80860007, regs);
+ cpuid(0x80860007, regs);
*freq = regs[0];
*voltage = regs[1];
*percent = regs[2];
@@ -120,24 +119,6 @@ longrun_getmode(u_int32_t *freq, u_int32_t *voltage, u_int32_t *percent)
}
/*
- * Get the info. Multiple return values
- */
-static void
-longrun_readreg(u_int32_t ax, u_int32_t *regs)
-{
- __asm __volatile(
- "cpuid;"
- "movl %%eax, 0(%2);"
- "movl %%ebx, 4(%2);"
- "movl %%ecx, 8(%2);"
- "movl %%edx, 12(%2);"
- :"=a"(ax)
- :"0"(ax), "S"(regs)
- :"bx", "cx", "dx"
- );
-}
-
-/*
* Transmeta documentation says performance window boundries
* must be between 0 and 100 or a GP0 exception is generated.
* mode is really only a bit, 0 or 1
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index be66e1ddab3..c185f43599f 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.236 2003/06/06 11:11:53 andreas Exp $ */
+/* $OpenBSD: machdep.c,v 1.237 2003/07/07 03:07:19 tedu Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -335,6 +335,24 @@ cyrix_write_reg(u_char reg, u_char data)
outb(0x22, reg);
outb(0x23, data);
}
+
+/*
+ * cpuid instruction. request in eax, result in eax, ebx, ecx, edx.
+ * requires caller to provide u_int32_t regs[4] array.
+ */
+void
+cpuid(u_int32_t ax, u_int32_t *regs)
+{
+ __asm __volatile(
+ "cpuid\n\t"
+ "movl %%eax, 0(%2)\n\t"
+ "movl %%ebx, 4(%2)\n\t"
+ "movl %%ecx, 8(%2)\n\t"
+ "movl %%edx, 12(%2)\n\t"
+ :"=a" (ax)
+ :"0" (ax), "S" (regs)
+ :"bx", "cx", "dx");
+}
#endif
/*
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index 35fe59fe135..7961344c119 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.49 2003/06/02 23:27:47 millert Exp $ */
+/* $OpenBSD: cpu.h,v 1.50 2003/07/07 03:07:18 tedu Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -166,6 +166,7 @@ void dkcsumattach(void);
void dumpconf(void);
void cpu_reset(void);
void i386_proc0_tss_ldt_init(void);
+void cpuid(u_int32_t, u_int32_t *);
/* locore.s */
struct region_descriptor;