VOGONS


First post, by kekko

User metadata
Rank Oldbie
Rank
Oldbie

1) The CPUID feature is detected through the ID flag 21.
If you can toggle the flag 21, the instruction is available.
The first correction, in cpu.cpp, is:

void CPU_SetFlags(Bitu word,Bitu mask) {
mask=mask|FLAG_ID; // Preserve ID flag
reg_flags=(reg_flags & ~mask)|(word & mask)|2;
cpu.direction=1-((reg_flags & FLAG_DF) >> 9);
}
WITHOUT THIS THE CPUID INSTRUCTION IS MEANINGLESS.

2) When you call CPUID with eax=0, it returns the ID string and
the maximum CPUID features. You must set the string correctly
so the emulated cpu is detected as an Intel.
When you call CPUID with eax=1, it returns the feature flags and
the cpu info; you might want to make the cpu appears to be a
Pentium so a certain game or app will run.
#define FPU_FLAG 0x0001 /* Has an FPU */
#define VME_FLAG 0x0002 /* Virtual Mode extension */

void CPU_CPUID(void) {
switch (reg_eax) {
case 0: /* Vendor ID String and maximum level */
reg_eax=1; /* Maximum level */
reg_ebx='G' | ('e' << 8 ) | ('n' << 16) | ('u'<< 24);
reg_edx='i' | ('n' << 8 ) | ('e' << 16) | ('I'<< 24);
reg_ecx='n' | ('t' << 8 ) | ('e' << 16) | ('l'<< 24);
break;
case 1: /* get processor type/family/model/stepping and feature flags */
reg_eax=0x52F; /* Intel Pentium (0x400 for an i486DX) */
reg_ebx=0; /* reserved */
reg_ecx=0; /* reserved */
reg_edx=FPU_FLAG | VME_FLAG; /* Feature flags */
break;
default:
LOG(LOG_CPU,LOG_ERROR)("Unhandled CPUID Function %x",reg_eax);
break;
}
}