Hi, I've fixed and enabled the cpu detection code in the Debian package, it works great. :>
There were two related problems. CPUID trashed EBX and ECX and those registers were being used to save the stack pointer and the cpu flags, so when returing the stack pointer was totally trashed and the cpu put in a very messy state, triggering an insta-reboot due to a triple fault (I assume). The following patch fixes both and enables the ID flag for Cyrix CPUs. 2004-11-22 Guillem Jover <[EMAIL PROTECTED]> * 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_ */ _______________________________________________ Bug-hurd mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-hurd