Friday, October 31, 2008

CPUID (Intel)

1. Reference:

Intel® Processor Identification and the CPUID Instruction
http://www.intel.com/assets/pdf/appnote/241618.pdf

Intel Architecture Software Developer¡¯s Manual -- Volume 2: Instruction Set Reference
http://download.intel.com/design/pentium/MANUALS/24319101.PDF

2. Detecting the CPUID Instruction

The Intel486 family and subsequent Intel processors provide a straightforward method for determining whether the processor's internal architecture is able to execute the CPUID instruction. This method uses the ID flag in bit 21 of the EFLAGS register. If software can change the value of this flag, the CPUID instruction is executable. The POPF, POPFD, PUSHF, and PUSHFD instructions are used to access the Flags in Eflags register

3. Output of the CPUID Instruction

4. Processor Serial Number
4.1 Presence of Processor Serial Number

MOV EAX, 01H
CPUID

After execution of the CPUID instruction, the ECX and EDX register contains the Feature Flags. If the PSN Feature Flags, (EDX register, bit 18) equals “1”, the processor serial number feature is supported, and enabled. Otherwise, the processor serial number feature is either not supported, or disabled in a Pentium III processor.

Processor serial number (PSN) is available in Pentium III processor only. The value in this register is reserved in the Pentium 4 processor or later. On all models, use the PSN flag (returned using CPUID) to check for PSN support before accessing the feature.

4.2 Forming the 96-bit Processor Serial Number

MOV EAX, 01H
CPUID

After execution of the CPUID instruction, the EAX register contains the Processor Signature. The Processor Signature comprises the most significant 32-bits of the processor serial number.

MOV EAX, 03H
CPUID

After execution of the CPUID instruction, the EDX register contains the middle 32-bits, and the ECX register contains the least significant 32-bits of the processor serial number. Software may then concatenate the saved Processor Signature, EDX, and ECX before returning the complete 96-bit processor serial number.



Tuesday, October 7, 2008

Build Boost1.36 with MinGW

1. Download and install the 7-zip ;

2. Uncompress the boost archive to BUILD_DIR, then change directory to it;

3. Run "./configure --with-toolset=mingw --with-libraries=thread,signals", where the "Makefile" and "user-config.jam" should be generated in current directory.

4. Modify the "Makefile" according to your requirements. A sample command line show as below:

BJAM=./tools/jam/src/bin.ntx86/bjam
prefix=../install/boost_1_36_0_mingw3.4.5
builddir =bin-mingw3.4.5
LIBS= --with-thread --with-signals

install: .dummy
@echo "$(BJAM) --user-config=user-config.jam --prefix=$(prefix) --exec-prefix=$(exec_prefix) --libdir=$(libdir) --includedir=$(includedir) $(LIBS) install"
@$(BJAM) --toolset=gcc --build-dir=$(builddir) --prefix=$(prefix) --layout=system\
threading=multi link=static runtime-link=static release debug $(LIBS) install\
|| echo "Not all Boost libraries built properly."

clean: .dummy
rm -rf $(builddir)

distclean: clean
rm -rf Makefile config.log

check: .dummy
@cd status && ../$(BJAM) --user-config=../user-config.jam || echo "Some Boost regression tests failed. This is normal for many compilers."

.dummy:

5. Run "Make install", than boost is installed to your $(EPREFIX) directory.