QA: How can I detect XScale?
Nicholas Tsipanov (nicholas@spbteam.com), October 11, 2002.
Question
I want to add some XScale specific code. How can I determine if my program
is running on XScale processor?
Answer
First you need some definitions that are not included in Pocket PC SDK, but you can find it
in <pkfuncs.h> file from the Platform Builder. Here I presented a small excerpt from
<pkfuncs.h> needed for my code to compile:
#ifdef __cplusplus
extern "C" {
#endif
BOOL KernelIoControl(
DWORD dwIoControlCode,
LPVOID lpInBuf, DWORD nInBufSize,
LPVOID lpOutBuf,
DWORD nOutBufSize,
LPDWORD lpBytesReturned);
#ifdef __cplusplus
}
#endif
#define IOCTL_PROCESSOR_INFORMATION CTL_CODE(FILE_DEVICE_HAL, 25, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Used by IOCTL_PROCESSOR_INFORMATION
typedef struct _PROCESSOR_INFO {
WORD wVersion;
WCHAR szProcessCore[40];
WORD wCoreRevision;
WCHAR szProcessorName[40];
WORD wProcessorRevision;
WCHAR szCatalogNumber[100];
WCHAR szVendor[100];
DWORD dwInstructionSet;
DWORD dwClockSpeed;
} PROCESSOR_INFO;
typedef PROCESSOR_INFO *PPROCESSOR_INFO;
The code itself is simple and straightforward. Please use the following:
{
....
PROCESSOR_INFO pi;
memset(&pi, 0, sizeof(PROCESSOR_INFO));
DWORD dwBytesReturned;
DWORD dwSize = sizeof(PROCESSOR_INFO);
BOOL bResult = KernelIoControl(
IOCTL_PROCESSOR_INFORMATION,
NULL,
0,
&pi,
sizeof(PROCESSOR_INFO),
&dwBytesReturned);
...
}
You will get a string with the processor type description in pi.szProcessorName.
There are two XScale type processors out there used by Pocket PC OEMs (PXA210 and PXA 250) currently,
so you can simply search for a substring "PXA" in the strings pi.szProcessCore and pi.szProcessorName,
because some devices return processor name in the szProcessorName (like Toshiba e740 and iPAQ 39xx),
and others - in the string szProcessCore (like Pocket Loox).
You can download sources of a simple application, which determines
whether you're running on XScale or not (16140b, Zipped).
Related resources:
-
http://www.pocketpcdn.com/sections/deviceinfo.html
Section: Device Information
-
http://www.pocketpcdn.com/articles/serial_number.html
QA: How can I get the serial number of a Pocket PC 2000 device?
-
http://www.pocketpcdn.com/articles/serial_number2002.html
QA: How can I get the serial number of a Pocket PC 2002 device?
- http://www.microsoft.com/mobile/developer/technicalarticles/whichpocket.asp
Article: Which Pocket PC is My Application Running On?