NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: NetBSD/i386 7.0 hangs booting 486
In article <5651B398.7000800%gmail.com@localhost>,
Felix Deichmann <m4j0rd0m0%gmail.com@localhost> wrote:
>Am 20.11.2015 um 22:04 schrieb Christos Zoulas:
>> change:
>> __get_cpuid_max() to always return 0 immediately and then we can debug it :-)
>
>I could finally get 7.0 to boot on the 486 machine successfully to login
>prompt after several release builds and installations (no fun):
>
>The above patch alone is not enough. __get_cpuid() also needed a
>work-around, as it seems to be called with __level == 0, so
>__get_cpuid() will not return before another cpuid instruction in it is
>executed.
>
> if (__get_cpuid_max (__ext, 0) < __level)
> return 0;
>
> __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx);
> return 1;
>
>
>I think finding a suitable bugfix is out of my league now, but can
>assist with testing of course.
Can you please compile and run this and tell me what it prints?
christos
#include <stdio.h>
#define __cpuid(level, a, b, c, d) \
__asm__ ("xchg{l}\t{%%}ebx, %k1\n\t" \
"cpuid\n\t" \
"xchg{l}\t{%%}ebx, %k1\n\t" \
: "=a" (a), "=&r" (b), "=c" (c), "=d" (d) \
: "0" (level))
static __inline unsigned int
__get_cpuid_max (unsigned int __ext, unsigned int *__sig)
{
unsigned int __eax, __ebx, __ecx, __edx;
/* See if we can use cpuid. On AMD64 we always can. */
__asm__ ("pushf{l|d}\n\t"
"pushf{l|d}\n\t"
"pop{l}\t%0\n\t"
"mov{l}\t{%0, %1|%1, %0}\n\t"
"xor{l}\t{%2, %0|%0, %2}\n\t"
"push{l}\t%0\n\t"
"popf{l|d}\n\t"
"pushf{l|d}\n\t"
"pop{l}\t%0\n\t"
"popf{l|d}\n\t"
: "=&r" (__eax), "=&r" (__ebx)
: "i" (0x00200000));
if (!((__eax ^ __ebx) & 0x00200000))
return 0;
printf("run %x %x\n", __eax, __ebx);
/* Host supports cpuid. Return highest supported cpuid input value. */
__cpuid (__ext, __eax, __ebx, __ecx, __edx);
if (__sig)
*__sig = __ebx;
return __eax;
}
int
main(void)
{
printf("%x\n", __get_cpuid_max(0, NULL));
}
Home |
Main Index |
Thread Index |
Old Index