1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#DPATCHLEVEL=0
2004-11-22 Guillem Jover <guillem@hadrons.org>
* i386/i386/locore.S (discover_x86_cpu_type): Enable function.
Enable ID flag for Cyrix CPU. Use %ebp to save the stack pointer.
Restore EFLAGS just after its last usage.
* i386/i386at/model_dep.c (c_boot_entry): Enable use of
discover_x86_cpu_type. Remove hardcoded cpu_type assignment.
* i386/include/mach/i386/eflags.h
(EFL_AC, EFL_VI, EFL_VIP, EFL_ID): New bits.
diff -Naur i386/i386/locore.S i386/i386/locore.S
--- i386/i386/locore.S 2001-10-07 21:47:15.000000000 +0200
+++ i386/i386/locore.S 2004-11-21 21:40:21.000000000 +0100
@@ -1144,13 +1144,16 @@
jmp _take_trap /* treat as a trap */
-#if 0
/* Discover what kind of cpu we have; return the family number
(3, 4, 5, 6, for 386, 486, 586, 686 respectively). */
ENTRY(discover_x86_cpu_type)
- movl %esp,%edx /* Save stack pointer */
+ pushl %ebp /* Save frame pointer */
+ movl %esp,%ebp /* Save stack pointer */
and $~0x3,%esp /* Align stack pointer */
+ inb $0xe8,%al /* Enable ID flag for Cyrix CPU ... */
+ andb $0x80,%al /* ... in CCR4 reg bit7 */
+ outb %al,$0xe8
pushfl /* Fetch flags ... */
popl %eax /* ... into eax */
movl %eax,%ecx /* Save original flags for return */
@@ -1159,6 +1162,8 @@
popfl /* ... In EFLAGS */
pushfl /* Fetch flags back ... */
popl %eax /* ... into eax */
+ pushl %ecx /* From ecx... */
+ popfl /* ... restore original flags */
xorl %ecx,%eax /* See if any bits didn't change */
testl $EFL_AC,%eax /* Test AC bit */
@@ -1178,11 +1183,9 @@
shrl $8,%eax /* Slide family bits down */
andl $15,%eax /* And select them */
-9: pushl %ecx /* From ecx... */
- popfl /* ... restore original flags */
- movl %edx,%esp /* Restore stack pointer */
+9: movl %ebp,%esp /* Restore stack pointer */
+ popl %ebp /* Restore frame pointer */
ret /* And return */
-#endif
/**/
diff -Naur i386/i386at/model_dep.c i386/i386at/model_dep.c
--- i386/i386at/model_dep.c 2002-05-23 03:54:57.000000000 +0200
+++ i386/i386at/model_dep.c 2004-11-21 21:41:09.000000000 +0100
@@ -372,7 +372,6 @@
machine_slot[0].running = TRUE;
machine_slot[0].cpu_subtype = CPU_SUBTYPE_AT386;
-#if 0
switch (discover_x86_cpu_type ())
{
case 3:
@@ -389,10 +388,6 @@
machine_slot[0].cpu_type = CPU_TYPE_PENTIUMPRO;
break;
}
-#else
- machine_slot[0].cpu_type = CPU_TYPE_I386;
-#endif
-
/*
* Start the system.
diff -Naur i386/include/mach/i386/eflags.h i386/include/mach/i386/eflags.h
--- i386/include/mach/i386/eflags.h 2001-04-05 08:39:21.000000000 +0200
+++ i386/include/mach/i386/eflags.h 2004-11-21 21:39:13.000000000 +0100
@@ -45,5 +45,9 @@
#define EFL_NT 0x00004000 /* nested task */
#define EFL_RF 0x00010000 /* resume without tracing */
#define EFL_VM 0x00020000 /* virtual 8086 mode */
+#define EFL_AC 0x00040000 /* alignment check */
+#define EFL_VI 0x00080000 /* virtual interrupt */
+#define EFL_VIP 0x00100000 /* virtual interrupt pending */
+#define EFL_ID 0x00200000 /* cpuid available */
#endif /* _MACH_I386_EFLAGS_H_ */
|