From 2639d29db8807b2625af497784fbd2188908694b Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Wed, 16 Apr 2003 16:34:37 +0000 Subject: [PATCH] CPUID Instruction Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@936 --- include/cpu.h | 3 +++ src/cpu/core_full/load.h | 3 +++ src/cpu/core_full/optable.h | 4 ++-- src/cpu/core_full/support.h | 1 + src/cpu/cpu.cpp | 23 +++++++++++++++++++++-- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/include/cpu.h b/include/cpu.h index 6af03bba..190032b5 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -96,6 +96,9 @@ bool Interrupt(Bitu num); bool CPU_IRET(bool use32); bool CPU_SetSegGeneral(SegNames seg,Bitu value); +void CPU_CPUID(void); + + //Flag Handling Bitu get_CF(void); Bitu get_AF(void); diff --git a/src/cpu/core_full/load.h b/src/cpu/core_full/load.h index cb2a0347..25ccd258 100644 --- a/src/cpu/core_full/load.h +++ b/src/cpu/core_full/load.h @@ -388,6 +388,9 @@ l_M_Ed: case D_AAS: AAS(); goto nextopcode; + case D_CPUID: + CPU_CPUID(); + goto nextopcode; default: LOG(LOG_CPU|LOG_ERROR,"LOAD:Unhandled code %d opcode %X",inst.code.load,inst.entry); break; diff --git a/src/cpu/core_full/optable.h b/src/cpu/core_full/optable.h index ad76da33..fb5b2877 100644 --- a/src/cpu/core_full/optable.h +++ b/src/cpu/core_full/optable.h @@ -294,7 +294,7 @@ static OpCode OpCodeTable[1024]={ /* 0x1a0 - 0x1a7 */ {L_SEG ,0 ,S_PUSHw ,fs },{L_POPw ,0 ,S_SEGI ,fs }, -{0 ,0 ,0 ,0 },{L_MODRM ,O_BTw ,0 ,0 }, +{D_CPUID ,0 ,0 ,0 },{L_MODRM ,O_BTw ,0 ,0 }, {L_MODRM ,O_DSHLw ,S_Ew,M_EwGwIb },{L_MODRM ,O_DSHLw ,S_Ew ,M_EwGwCL }, {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, /* 0x1a8 - 0x1af */ @@ -651,7 +651,7 @@ static OpCode OpCodeTable[1024]={ /* 0x3a0 - 0x3a7 */ {L_SEG ,0 ,S_PUSHd ,fs },{L_POPd ,0 ,S_SEGI ,fs }, -{0 ,0 ,0 ,0 },{L_MODRM ,O_BTd ,0 ,0 }, +{D_CPUID ,0 ,0 ,0 },{L_MODRM ,O_BTd ,0 ,0 }, {L_MODRM ,O_DSHLd ,S_Ed,M_EdGdIb },{L_MODRM ,O_DSHLd ,S_Ed ,M_EdGdCL }, {0 ,0 ,0 ,0 },{0 ,0 ,0 ,0 }, /* 0x3a8 - 0x3af */ diff --git a/src/cpu/core_full/support.h b/src/cpu/core_full/support.h index 166f90e7..965316ff 100644 --- a/src/cpu/core_full/support.h +++ b/src/cpu/core_full/support.h @@ -42,6 +42,7 @@ enum { D_RETFw,D_RETFd, D_RETFwIw,D_RETFdIw, + D_CPUID, }; diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp index 69595542..19370e42 100644 --- a/src/cpu/cpu.cpp +++ b/src/cpu/cpu.cpp @@ -569,11 +569,30 @@ bool CPU_SetSegGeneral(SegNames seg,Bitu value) { return false; } +void CPU_CPUID(void) { + switch (reg_eax) { + case 0: /* Vendor ID String and maximum level? */ + reg_eax=0; + reg_ebx=('G'<< 24) || ('e' << 16) || ('n' << 8) || 'u'; + reg_edx=('i'<< 24) || ('n' << 16) || ('e' << 8) || 'T'; + reg_ecx=('n'<< 24) || ('t' << 16) || ('e' << 8) || 'l'; + break; + case 1: /* get processor type/family/model/stepping and feature flags */ + reg_eax=0x402; /* intel 486 sx? */ + reg_ebx=0; /* Not Supported */ + reg_ecx=0; /* No features */ + reg_edx=0; /* Nothing either */ + break; + default: + LOG(LOG_CPU|LOG_ERROR,"Unhandled CPUID Function %x",reg_eax); + break; + } + +} + void CPU_Real_16_Slow_Start(void); - void CPU_Core_Full_Start(void); - void SetCPU16bit() { cpu.state=0;