2 # Copyright © 2000, The AROS Development Team. All rights reserved.
5 # Desc: CPU detection routine
21 .set cpu_params, 0x00000020
22 .set x86, (cpu_params)
23 .set x86_vendor, (cpu_params + 1)
24 .set x86_model, (cpu_params + 2)
25 .set x86_mask, (cpu_params + 3)
26 .set x86_hard_math, (cpu_params + 6)
27 .set x86_cpuid, (cpu_params + 8)
28 .set x86_capability, (cpu_params + 12)
29 .set x86_vendor_id, (cpu_params + 16)
32 .type exec_GetCPU,@function
35 movl $
-1,x86_cpuid
/* No cpuid allowed as far */
38 ## Check whether it is i386 or i486. In i486 we chan change AC bit in EFLAGS
39 ## register. We will use it.
42 movl $
3,x86
/* We have at leas i386 if this code works */
43 pushfl
/* Get eflags */
46 xorl $
0x40000,%eax
/* Set AC flag. If it's possible, then we have 486 */
47 pushl
%eax
/* Copy %eax to eflags and back to %eax */
51 xorl
%ecx
,%eax
/* Mas everything but AC bit (if set) */
53 je exec_is386
/* Nope, AC was 0 - i386 only */
55 /* At this point it is sure that we have something better than i386. Assume for
56 ## a while that it is i486. Check whether we can use cpuid instruction. If no,
57 ## then we have i486. If cpuid may be used then get CPU type from this opcode.
58 ## It can be i486 (last few models had cpuid implemented) or better */
60 movl $
4,x86
/* Update information */
61 movl
%ecx
,%eax
/* we will try to change ID flag */
62 xorl $
0x200000,%eax
/* if it is possible then cpuid */
63 pushl
%eax
/* is implemented */
68 pushl
%ecx
/* Restore eflags register */
71 je exec_is486
/* Well, no cpuid. So we can leave now */
73 xorl
%eax
,%eax
/* CPUID! */
75 movl
%eax
,x86_cpuid
/* The highest cpuid %eax value */
76 movl
%ebx
,x86_vendor_id
/* Processor's vendor ID */
77 movl
%ecx
,x86_vendor_id+
4
78 movl
%edx
,x86_vendor_id+
8
80 orl
%eax
,%eax
/* Can we use more than that above? */
81 je exec_is486
/* Nope, it was i486 */
83 movl $
1,%eax
/* Get CPU informations (model, stepping etc) */
87 movb
%ah
,x86
/* Model: 5 for 586, 6 for 686 and so on */
93 movl
%edx
,x86_capability
/* Capabilities like MMX, SSE and more */
95 cmpb $
4,x86
/* Updata AttnFlags in ExecBase */
100 exec_is486
: movl
%cr0,%eax
/* Update CR0 register */
101 andl $
0x80000011,%eax
/* Save PG,PE,ET */
102 orl $
0x00050022,%eax
/* Set AM,WP,NE and MP */
105 exec_is386
: pushl
%ecx
107 movl
%cr0,%eax
/* Update CR0 reg. i386 version */
108 andl $
0x80000011,%eax
/* Save PG,PE,ET */
109 orl $
2,%eax
/* Set MP */
111 call exec_GetFPU
/* Detect whether we have FPU */
113 lldt
%ax
/* Invalidate LDT */
114 cld
/* Clear D flag as needed by AROS and gcc */
119 ## Check, whether FPU is present. As we don't need to distinguish FPU type,
120 ## we will just see if it is present.
123 .type exec_GetFPU,@function
124 exec_GetFPU
: movb $
0,x86_hard_math
134 1: movb $
1,x86_hard_math