1
0
forked from 0ad/0ad

hotfix for bug in ia32 (code path where ebx was clobbered due to cpuid; incorrect ptr arithmetic passing cpu_type to ia32_cpuid)

+ manual Release build that fixes it

This was SVN commit r2718.
This commit is contained in:
janwas 2005-09-14 04:08:23 +00:00
parent f8ed148370
commit a2622cdef7
2 changed files with 10 additions and 5 deletions

View File

@ -232,14 +232,17 @@ __SECT__
; extern "C" bool __cdecl ia32_cpuid(u32 func, u32* regs)
global _ia32_cpuid
_ia32_cpuid:
; note: must preserve before .one_time_init because it does cpuid
push ebx
push edi
.retry:
; if unknown, detect; if not available, fail.
xor eax, eax ; return val on failure
cmp [cpuid_available], eax
jl .one_time_init
je .ret
push ebx
push edi
mov ecx, [esp+8+4+0] ; func
mov edi, [esp+8+4+4] ; -> regs
@ -291,7 +294,7 @@ _ia32_cpuid:
cpuid
mov [max_ext_func], eax
jmp _ia32_cpuid ; now try again
jmp .retry

View File

@ -312,11 +312,13 @@ static void get_cpu_type()
const uint family = bits(regs[EAX], 8, 11);
// get brand string (if available)
// note: ia32_cpuid writes 4 u32s directly to cpu_type -
// be very careful with pointer arithmetic!
u32* cpu_type_u32 = (u32*)cpu_type;
bool have_brand_string = false;
if(ia32_cpuid(0x80000002, cpu_type_u32+0 ) &&
ia32_cpuid(0x80000003, cpu_type_u32+16) &&
ia32_cpuid(0x80000004, cpu_type_u32+32))
ia32_cpuid(0x80000003, cpu_type_u32+4) &&
ia32_cpuid(0x80000004, cpu_type_u32+8))
have_brand_string = true;