Obtaining System Processor and Memory Information

< BACK  NEXT >
[oR]

The function GetSystemInfo returns information about the system processor and memory characteristics of a device in a SYSTEM_INFO structure. This function takes a single parameter that is a pointer to a SYSTEM_INFO structure. The code in Listing 12.1 shows a call to GetSystemInfo, and then code to display data relevant to Windows CE from the SYSTEM_INFO structure.

Listing 12.1 Displaying system information using GetSystemInfo
 void Listing12_1() {   SYSTEM_INFO si;   GetSystemInfo(&si);   switch (si.wProcessorArchitecture)   {     case PROCESSOR_ARCHITECTURE_INTEL:       cout  _T("Intel Processor");       if(si.wProcessorLevel == 4)         cout  _T(" 486")   endl;       else         cout   _T(" Pentium")   endl;       break;     case PROCESSOR_ARCHITECTURE_MIPS:       cout   _T("Mips Processor");       if(si.wProcessorLevel == 3)         cout   _T(" R3000")   endl;       else         cout   _T(" R4000")   endl;       break;     case PROCESSOR_ARCHITECTURE_ALPHA:       cout   _T("Alpha Processor")   endl;       break;     case PROCESSOR_ARCHITECTURE_PPC:       cout   _T("PPC Processor")   endl;       break;     case PROCESSOR_ARCHITECTURE_SHX:       cout   _T("SHX Processor")   endl;       break;     case PROCESSOR_ARCHITECTURE_ARM:       cout   _T("ARM Processor")   endl;       break;     case PROCESSOR_ARCHITECTURE_IA64:       cout   _T("IA64 Processor")   endl;       break;     case PROCESSOR_ARCHITECTURE_ALPHA64:       cout   _T("Alpha 64 Processor")   endl;       break;     case PROCESSOR_ARCHITECTURE_UNKNOWN:       cout   _T("Unknown Processor")   endl;       break;   }   cout   _T("Processor revision: ")       si.wProcessorRevision   endl;   cout   _T("Page size: ")        si.dwPageSize   endl;   cout   _T("Alloc. Granularity: ")        si.dwAllocationGranularity   endl;   cout   _T("Min. Application Address: ")      (DWORD)si.lpMinimumApplicationAddress   endl;   cout   _T("Max. Application Address: ")      (DWORD)si.lpMaximumApplicationAddress   endl; } 

Typical output for a MIPS-based Windows CE device looks like the following:

 Mips Processor R4000 Processor revision: 3154 Page size: 1024 Alloc. Granularity: 65536 Min. Application Address: 65536 Max. Application Address: 2147483647 

The members wProcessorArchitecture and wProcessorLevel together define the type of processor the device is equipped with. The wProcessorArchitecture member defines the processor's architecture, such as Intel or MIPS, and wProcessorLevel defines the processor's level, such as R3000 or R4000. Some processors have different revisions, and this information is stored in wProcessorRevision. Windows CE only supports a single processor, so the dwNumberOfProcessors member always returns1.

The output above shows that the page size for a MIPS device is 1 KB, and page allocations must always start on a 64-KB boundary (that is the figure returned in the swAllocationGranularity member). The minimum address that can be used is 64 KB, since any address below this is protected. The maximum address space is 2 GB. Remember that all processes share the same address space, so the application that produced the output above can only use up to 32 MB of address space allocated to the process.

The following output is obtained from running Listing 12.1 under emulation on a desktop PC. You can see that the address range is nearly the same but the page size is quite different. The address range is actually the address range for the process running under Windows NT, as each process is allocated a 4-GB address space; however, the upper 2 GB are protected and are reserved for the operating system. The maximum address range is actually 2 GB less the 64 KB reserved by Windows NT.

 Intel Processor Pentium Processor Revision 1537 Page Size: 4096 Min. Application Address: 65536 Max. Application Address: 2147418111 

< BACK  NEXT >


Windows CE 3. 0 Application Programming
Windows CE 3.0: Application Programming (Prentice Hall Series on Microsoft Technologies)
ISBN: 0130255920
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net