阅读:2020回复:3
编译器 ???
操作系统的安装过程中,系统盘里面。例如windows2000安装程序怎么判断用的 cpu 类型然后安装不同的系统。
安装的时候 需不需要编译器。安装程序里肯定没有元文件的可是为什么还要编译器那 在linux下面 又会是什么一种情况啊, 存在原文件 而且安装盘里面包含编译器 能给我讲一下吗?? 问题太菜了 不好意思在这里提 可是这里高手很多别的地方 问也没有人回答的 |
|
沙发#
发布于:2004-04-05 21:06
系统在启动的时候会CPU的类型
ULONG KiGetFeatureBits ( VOID ) /*++ Routine Description: Examine the processor specific feature bits to determine the Windows 2000 supported features supported by this processor. Arguments: None. Return Value: Returns a Windows 2000 normalized set of processor features. --*/ { ULONG Junk; ULONG Junk2; ULONG ProcessorFeatures; ULONG NtBits; ULONG ExtendedProcessorFeatures; ULONG ProcessorSignature; ULONG CpuVendor; PKPRCB Prcb; BOOLEAN ExtendedCPUIDSupport = TRUE; Prcb = KeGetCurrentPrcb(); NtBits = KF_WORKING_PTE; // // Determine the processor type // CpuVendor = KiGetCpuVendor(); // // If this processor does not support the CPUID instruction, // don't try to use it. // if (CpuVendor == CPU_NONE) { return NtBits; } // // Determine which NT compatible features are present // CPUID (1, &ProcessorSignature, &Junk, &Junk, &ProcessorFeatures); // // AMD specific stuff // if (CpuVendor == CPU_AMD) { // // Check for K5 and above. // if ((ProcessorSignature & 0x0F00) >= 0x0500) { if ((ProcessorSignature & 0x0F00) == 0x0500) { switch (ProcessorSignature & 0x00F0) { case 0x0010: // K5 Model 1 // // for K5 Model 1 stepping 0 or 1 don't set global page // if ((ProcessorSignature & 0x000F) > 0x03) { // // K5 Model 1 stepping 2 or greater // break; } // // K5 Model 1 stepping 0 or 1, FALL THRU. // case 0x0000: // K5 Model 0 // // for K5 Model 0 or model unknown don't set global page // ProcessorFeatures &= ~0x2000; break; case 0x0080: // K6 Model 8 (K6-2) // // All steppings >= 8 support MTRRs. // if ((ProcessorSignature & 0x000F) >= 0x8) { NtBits |= KF_AMDK6MTRR; } break; case 0x0090: // K6 Model 9 (K6-3) NtBits |= KF_AMDK6MTRR; break; default: // anything else, nothing to do. break; } } } else { // // Less than family 5, don't set GLOBAL PAGE, LARGE // PAGE or CMOV. (greater than family 5 will have the // bits set correctly). // ProcessorFeatures &= ~(0x08 | 0x2000 | 0x8000); // // We don't know what this processor returns if we // probe for extended CPUID support. // ExtendedCPUIDSupport = FALSE; } } // // Intel specific stuff // if (CpuVendor == CPU_INTEL) { if (Prcb->CpuType == 6) { WRMSR (0x8B, 0); CPUID (1, &Junk, &Junk, &Junk, &ProcessorFeatures); Prcb->UpdateSignature.QuadPart = RDMSR (0x8B); } else if (Prcb->CpuType == 5) { KiI386PentiumLockErrataPresent = TRUE; } if ( ((ProcessorSignature & 0x0FF0) == 0x0610 && (ProcessorSignature & 0x000F) <= 0x9) || ((ProcessorSignature & 0x0FF0) == 0x0630 && (ProcessorSignature & 0x000F) <= 0x4)) { NtBits &= ~KF_WORKING_PTE; } if ( (Prcb->CpuType == 6) && (Prcb->CpuStep >= 0x0303) && (ProcessorFeatures & KI_FAST_SYSCALL_SUPPORTED) ) { // BUGBUG: Disable as it's preventing hibernate from working // NtBits |= KF_FAST_SYSCALL; } } // // Cyrix specific stuff // if (CpuVendor == CPU_CYRIX) { // // Workaround bug 324467 which is caused by INTR being // held high too long during an FP instruction and causing // random Trap07 with no exception bits. // extern BOOLEAN KiIgnoreUnexpectedTrap07; KiIgnoreUnexpectedTrap07 = TRUE; // // Workaround CMPXCHG bug to Cyrix processors where // Family = 6, Model = 0, Stepping <= 1. Note that // Prcb->CpuStep contains both model and stepping. // // Disable Locking in one of processor specific registers // (accessible via i/o space index/data pair). // if ((Prcb->CpuType == 6) && (Prcb->CpuStep <= 1)) { #define CRC_NDX (PUCHAR)0x22 #define CRC_DAT (CRC_NDX + 1) #define CCR1 0xc1 UCHAR ValueCCR1; // // Get current setting. // WRITE_PORT_UCHAR(CRC_NDX, CCR1); ValueCCR1 = READ_PORT_UCHAR(CRC_DAT); // // Set the NO_LOCK bit and write it back. // ValueCCR1 |= 0x10; WRITE_PORT_UCHAR(CRC_NDX, CCR1); WRITE_PORT_UCHAR(CRC_DAT, ValueCCR1); #undef CCR1 #undef CRC_DAT #undef CRC_NDX } } // // Check the standard CPUID feature bits. // // The following bits are known to work on Intel, AMD and Cyrix. // We hope (and assume) the clone makers will follow suit. // if (ProcessorFeatures & 0x00000002) { NtBits |= KF_V86_VIS | KF_CR4; } if (ProcessorFeatures & 0x00000008) { NtBits |= KF_LARGE_PAGE | KF_CR4; } if (ProcessorFeatures & 0x00000010) { NtBits |= KF_RDTSC; } // // N.B. CMPXCHG8B MUST be done in a generic manner or clone processors // will not be able to boot if they set this feature bit. // if (ProcessorFeatures & 0x00000100) { NtBits |= KF_CMPXCHG8B; } if (ProcessorFeatures & 0x00001000) { NtBits |= KF_MTRR; } if (ProcessorFeatures & 0x00002000) { NtBits |= KF_GLOBAL_PAGE | KF_CR4; } if (ProcessorFeatures & 0x00008000) { NtBits |= KF_CMOV; } if (ProcessorFeatures & 0x00010000) { NtBits |= KF_PAT; } if (ProcessorFeatures & 0x00800000) { NtBits |= KF_MMX; } if (ProcessorFeatures & 0x01000000) { NtBits |= KF_FXSR; } if (ProcessorFeatures & 0x02000000) { NtBits |= KF_XMMI; } // // Check extended functions. First, check for existance, // then check extended function 0x80000001 (Extended Processor // Features) if present. // // Note: Intel guarantees that no processor that doesn't support // extended CPUID functions will ever return a value with the // most significant bit set. Microsoft asks all CPU vendors // to make the same guarantee. // if (ExtendedCPUIDSupport != FALSE) { CPUID(0x80000000, &Junk2, &Junk, &Junk, &Junk); // // Sanity check the result, assuming there are no more // than 256 extended feature functions (should be valid // for a little while). // if ((Junk2 & 0xffffff00) == 0x80000000) { // // Check extended processor features. These, by definition, // can vary on a processor by processor basis. // if (Junk2 >= 0x80000001) { CPUID(0x80000001, &Junk2, &Junk, &Junk, &ExtendedProcessorFeatures); // // With these, we can only do what we're told. // switch (CpuVendor) { case CPU_AMD: if (ExtendedProcessorFeatures & 0x80000000) { NtBits |= KF_3DNOW; } break; } } } } return NtBits; } ULONG KiGetCpuVendor( VOID ) /*++ Routine Description: (Try to) Determine the manufacturer of this processor based on data returned by the CPUID instruction (if present). Arguments: None. Return Value: One of the members of the enumeration CPU_VENDORS (defined above). --*/ { PKPRCB Prcb; ULONG Junk; ULONG Buffer[4]; Prcb = KeGetCurrentPrcb(); Prcb->VendorString[0] = 0; if (!Prcb->CpuID) { return CPU_NONE; } CPUID(0, &Junk, Buffer+0, Buffer+2, Buffer+1); Buffer[3] = 0; // // Copy vendor string to Prcb for debugging (ensure it's NULL // terminated). // RtlCopyMemory( Prcb->VendorString, Buffer, sizeof(Prcb->VendorString) - 1 ); Prcb->VendorString[sizeof(Prcb->VendorString) - 1] = '\0'; if (strcmp((PVOID)Buffer, CmpIntelID) == 0) { return CPU_INTEL; } else if (strcmp((PVOID)Buffer, CmpAmdID) == 0) { return CPU_AMD; } else if (strcmp((PVOID)Buffer, CmpCyrixID) == 0) { return CPU_CYRIX; } return CPU_UNKNOWN; } 不过根据WIN2000的代码好象只支持INTEL,AMD,CYRIX,CPU,如果其他的CPU好象都作为UNKNOWN来处理 |
|
|
板凳#
发布于:2004-04-28 22:03
cpu一般以体系区分,如pc最常见的x86,其他如alpha,power pc,sparc,arm,mips,等等。
体系特征主要是两大类别,cisc,sisc,cisc以x86为代表,risc近年来arm风头甚健,Power PC, SPARC, ALPHA都是典型的RISC。 也有特殊应用的\"CPU\",比如DSP,特别强调运算能力。 在X86中,AMD,Cyrix都是X86体系。具有相同的基本指令集。 386,486,pentium,PII,等等都扩展了一些指令,如mmx,sse,amd扩展了3dnow等指令集。 以上的代码是用来区别cpu是intel/amd/cyrix中的哪一个版本,目的就是用来标志出那些扩展指令集可以被使用,作为提高性能所用。 很显然,代码不需要判断cpu是x86还是alpha,因为二进制代码本身就是某种指令集(比如x86指令集),绝不可能发生x86的二进制代码运行在alpha上的情况。 楼主的问题其实很简单,安装程序本身没有判断cpu类型的逻辑,这个是你自己判断的。你的安装光盘表明了是哪一个版本的windows,for x86的,for alpha的。 当然了,编译器也分了x86/alpha版本,否则如何生成目标平台的代码? |
|
地板#
发布于:2004-06-07 16:52
楼上的回答很全面
|
|
|