1 |
NSIS plug-in for getting a bit of CPU information. |
2 |
Version 1.2, July 2003. |
3 |
Typed and clicked by Peter Mason, CSIRO DEM MMTG. mailto://peter.mason@csiro.au. |
4 |
The MHz timing was done using code that was pretty much copied from Pavlos |
5 |
Touboulidis' CPUTEST code. |
6 |
The lean exception handler wrapped around the timing code was done using Jeremy |
7 |
Gordon's tutorial on writing lightweight win32 exception handlers in assembler. |
8 |
(His web-page is www.GoDevTool.com.) |
9 |
The CPUID stuff was done using Intel and AMD's manuals on what CPUID means to them. |
10 |
|
11 |
|
12 |
There's only one routine here - tell() - and its output is a string on the NSIS |
13 |
stack. This string always has the same fields in exactly the same place. |
14 |
(It's easier to extract values that way.) It looks like this: |
15 |
|
16 |
INTELP=d AMD=add PPRO=b MMX=d SSE=b SSE2=b 3DNOW=d ARCH=dd LEVEL=dd NCPU=dd MHZ=ddddd RAM=dddd |
17 |
|
18 |
Here, "d" means a decimal digit (0..9), "a" means an alphabetic character (A..Z) and |
19 |
"b" means a boolean digit (0 or 1). |
20 |
|
21 |
ITELP: Values range [0..4]. |
22 |
0: Not a genuine Intel CPU (or a very, VERY old one). |
23 |
1: Pentium or Pentium with MMX. |
24 |
(Check the MMX field if you want to know about the CPU's MMX support.) |
25 |
2: Pentium Pro, II or Celeron. |
26 |
(May or may not have MMX - PPros don't, the others do. Check the MMX field.) |
27 |
3: Pentium III or P3 (old) Xeon. (Always has MMX and SSE.) |
28 |
4: Pentium IV or (new) Xeon. (Always has MMX, SSE and SSE2.) |
29 |
AMD: A bit more complicated... |
30 |
000: Not an authentic AMD CPU (or a very, VERY old one). |
31 |
Kdd: An old K-series. "dd" is either 05 for a K5 or 06 for a K6. |
32 |
(Pentium compatible. K5s have no MMX or 3DNOW. K6s have standard MMX, |
33 |
and later models have basic 3DNOW.) |
34 |
Add: An Athlon or a Duron. "dd" is the model number (goes from 01 to 10). |
35 |
(Pentium II compatible. All of these have extended MMX and extended 3DNOW. |
36 |
None have any SSE.) |
37 |
Odd: An Opteron. "dd" gives the model number. |
38 |
(Pentium IV compatible. This CPU's got everything, it seems.) |
39 |
PPRO: Values range [0..1]. |
40 |
0: Not compatible with the Intel Pentium Pro processor. |
41 |
1: Compatible with the Intel Pentium Pro processor. |
42 |
MMX: Values range [0..2]. |
43 |
0: No MMX support. |
44 |
1: Standard Intel MMX support. |
45 |
2: Standard MMX support plus AMD MMX extensions. |
46 |
SSE: Values range [0..1]. |
47 |
0: No SSE support. |
48 |
1: Supports SSE (Intel's Streaming SIMD extensions, P3-style). |
49 |
SSE2: Values range [0..1]. |
50 |
0: No SSE2 support. |
51 |
1: Supports SSE2 (Intel's Streaming SIMD extensions 2, P4-style). |
52 |
3DNOW: Values range [0..2]. |
53 |
0: No 3DNOW support. |
54 |
1: Standard AMD 3DNOW support. |
55 |
2: Standard AMD 3DNOW support plus AMD 3DNOW extensions. |
56 |
ARCH: Values range [00..10]. |
57 |
00: 32-bit Intel or compatible |
58 |
01: MIPS (did NT 3.5, apparently) |
59 |
02: DEC Alpha. (Yes, DEC. I can't bring myself to call it COMPAQ.) |
60 |
03: PowerPC |
61 |
04: SHX (?) |
62 |
05: ARM (Acorn Risc Machine, I presume. Running Windows?) |
63 |
06: 64-bit Intel. |
64 |
07: 64-bit Alpha |
65 |
08: MSIL (?) |
66 |
09: 64-bit AMD |
67 |
10: 32-bit Intel doing Win64 (?) |
68 |
LEVEL: "Processor level", like what you see in the main processor environment |
69 |
variable. Sort-of useless for Intel architecture. |
70 |
NCPU: The number of processors available. (Affected by that "Hyper" business |
71 |
that the new XEONs can do, I think.) |
72 |
MHZ: The CPU's internal clock speed in MHz (Approx). |
73 |
RAM: The amount of RAM (physical memory) in megabytes (rounded). |
74 |
|
75 |
|
76 |
SIMPLE EXAMPLE |
77 |
Say you have an application BLOG for which you have two builds of the executable |
78 |
BLOG.EXE: BLOG_GEN.EXE compiled for "Processor = Blend" (a general build) and |
79 |
BLOG_PRO.EXE compiled for "Processor = Pentium Pro" (will only work on a Pentium |
80 |
Pro or compatible or better). Now you want to copy the best one out when a user |
81 |
installs BLOG. You could have something like the following in your Install section: |
82 |
cpudesc::tell |
83 |
Pop $0 ;full identification string in $0 |
84 |
StrCpy $1 $0 1, 22 ;pull out one character after PPRO= |
85 |
IntFmt $2 "%u" $1 ; and turn it into a number |
86 |
IntCmpU $2 1 +1 +3 +3 ;Anything not Pentium II / Pro -compatible gets blog_gen |
87 |
File /oname=blog.exe "blog_source_directory\blog_gen.exe" |
88 |
Goto +2 |
89 |
File /oname=blog.exe "blog_source_directory\blog_pro.exe" |
90 |
... the rest of your Install section |