Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - CPUID: (4 Items)
   
CPUID  
Is there a way to get CPUID with QNX 4.25, as it can be done under many other Unix-like OSes by using the /proc/cpuinfo?


What other options I could used to get the CPU information (vendor, brand, model, etc)?

Thanks
Omer
RE: CPUID  
I wrote a short function using inline assembly language to read the 64-bit
CPU timestamp counter using the 'rdtsc' instruction:

    extern void rdtsc(unsigned long *hi, unsigned long *lo);
    #pragma aux rdtsc = \
        ".586p" \
        "rdtsc" \
        "mov    [esi],edx" \
        "mov    [edi],eax" \
        parm [esi] [edi] \
        modify [eax edx];


It should be possible to do something similar for reading the CPUID
information directly from the processor.



Walt Wimer
TCSA, Inc.


-----Original Message-----
From: Omer Gagne [mailto:community-noreply@qnx.com] 
Sent: Monday, December 07, 2009 11:47 AM
To: qnx4-community
Subject: CPUID

Is there a way to get CPUID with QNX 4.25, as it can be done under many
other Unix-like OSes by using the /proc/cpuinfo?

What other options I could used to get the CPU information (vendor, brand,
model, etc)?

Thanks
Omer



_______________________________________________

QNX4 Community Support
http://community.qnx.com/sf/go/post43311

Re: RE: CPUID  
some simple examples:

typedef struct {
 unsigned int eax;
 unsigned int ebx;
 unsigned int ecx;
 unsigned int edx;
} regs_abcd_t;

void CPUID (unsigned int arg_eax, unsigned int arg_ecx, regs_abcd_t *out);
#pragma aux CPUID = \
	".586" \
	"cpuid" \
	"mov [edi],eax" \
	"mov [edi+4],ebx" \
	"mov [edi+8],ecx" \
	"mov [edi+12],edx" \
	parm [eax] [ecx] [edi] \
	modify exact [eax ebx ecx edx];

void processor_brand_string (char *str);															/* str must point to a buffer which is at least 48 B long */
#pragma aux processor_brand_string = \
	".586 " \
	"mov eax,80000002h " \
	"cpuid " \
	"mov [esi],eax " \
	"mov [esi+4],ebx " \
	"mov [esi+8],ecx " \
	"mov [esi+12],edx " \
	"mov eax,80000003h " \
	"cpuid " \
	"mov [esi+16],eax " \
	"mov [esi+20],ebx " \
	"mov [esi+24],ecx " \
	"mov [esi+28],edx " \
	"mov eax,80000004h " \
	"cpuid " \
	"mov [esi+32],eax " \
	"mov [esi+36],ebx " \
	"mov [esi+40],ecx " \
	"mov [esi+44],edx " \
	parm [esi] \
	modify exact [eax ebx ecx edx];

See Watcom 10.6 documentation on "Auxiliary pragmas" in helpviewer.
And Intel Software Developer's Manual - Instruction Set Reference - http://www.intel.com/products/processor/manuals/

stepan hejny
aveco
Re: RE: CPUID  
Stephan,

Thanks, I wrote code to be able to know if the CPUID was present, but was not able to get CPU Information.  Now, with 
this, I'll be having the CPU information.

Thank you,

Omer