1 /* $NetBSD: cpufunc.S,v 1.9 2008/05/03 06:11:19 yamt Exp $ */
4 * Copyright (c) 1998, 2000, 2004, 2006, 2007 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include <machine/asm.h>
30 #include <machine/cputypes.h>
31 #include <machine/psl.h>
38 _C_LABEL(cpu_info_level):
40 .globl _C_LABEL(cpu_info_level)
62 /* Try to toggle alignment check flag; does not exist on 386. */
79 * Try the test of a NexGen CPU -- ZF will not change on a DIV
80 * instruction on a NexGen, it will on an i386. Documented in
81 * Nx586 Processor Recognition Application Note, NexGen, Inc.
91 * Don't try cpuid, as Nx586s reportedly don't support the
94 movl $CPU_NX586,_C_LABEL(cpu)
97 movl $CPU_386,_C_LABEL(cpu)
100 try486: /* Try to toggle identification flag; does not exist on early 486s. */
116 is486: movl $CPU_486,_C_LABEL(cpu)
119 * Cyrix CPUs do not change the undefined flags following
120 * execution of the divide instruction which divides 5 by 2.
122 * Note: CPUID is enabled on M2, so it passes another way.
134 movl $CPU_6x86,_C_LABEL(cpu) # set CPU type
136 * Check for Cyrix 486 CPU by seeing if the flags change during a
137 * divide. This is documented in the Cx486SLC/e SMM Programmer's
141 cmpl %edx,%edx # set flags to known state
143 popl %ecx # store flags in ecx
146 divl %ebx # do a long division
149 xorl %ecx,%eax # are the flags different?
150 testl $0x8d5,%eax # only check C|PF|AF|Z|N|V
151 jne 2f # yes; must be Cyrix 6x86 CPU
152 movl $CPU_486DLC,_C_LABEL(cpu)# set CPU type
154 try586: /* Use the `cpuid' instruction. */
157 movl %eax,_C_LABEL(cpu_info_level)