PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Detecting ARM Revision

Is there a way to detect the ARM revision?

I've tried GetSystemInfo() but I can't see a clear rule how the numbers in the returned struct are to be interpreted.

I would expect an ARM Assembler function for that but I couldn't find one.
I believe "co-processor 15" register 0 has the information you seek.

ie:

Code:

mrc p15, 0, r0, c0, c0, 0


You will find more information here:
http://forums.arm.com/lofiversion/index.php?t502.html

Also check here:
http://infocenter.arm.com/help/index.js ... 50054.html

Bits 19:16 seems to hold the architecture version (ex: 5 = ARM 5TE).

Information is hard to come by, but it's out there. Also check Intel's StrongARM and XScale technical documentation. I remember finding more info about CP15.
Thanks a lot Thierry,

Can it be that your code requires kernel level?

I've written the following short ASM program, which crashes with "Illegal Instruction":

Code:

AREA scale,CODE,READONLY
EXPORT getCoproc15_ASM

getCoproc15_ASM

MRC P15, 0, R0, C0, C0, 0

END
Yes you need kernel mode and surround your call with a __try() / __except() block as some processors won't support the instruction at all.

See here for some useful info:
http://www.drdobbs.com/development-tools/184406115
I'm not really firm with these things: Can I assume that I can switch to kernel mode on any device or will devices with restricted security policy prevent that?

BTW: We already tried kernel mode and it does not crash then, but the values returned still seem rather random (no modern CPU should return "2", right?)
It isn't always possible to switch to kernel mode (ie: certain secure smartphones). The solution I found is to wrap your call to mcr with structured exception handling (ie: __try / __except).

I haven't seen any CPU return 2... Then again I haven't looked at this code in a long time. I use it to detect StrongARM and the different versions of XScale. I don't know what it returns for TI OMAP and other processors (I didn't care at the time).

Regarding your code... Aren't you missing a return statement? ie something like:

Code:

getCoproc15_ASM

MRC P15, 0, R0, C0, C0, 0
MOV PC, LC

END

Yes, the missing return statement was another reason for the crash in the beginning.

If we find out more about the version codes then we'll post our findings here.

Thx!
belveder · 13 Nov 2008, 07:56 UTC — sample return values
Hi,
following your suggestions I enclosed the switch to/from kernel mode by a __try/__except statement. I've checked several mobile phones and here are the return values for the individual fields of the CPUID in decimal format:

Dopod C730
Samsung SC32442, ARM920T (ARMv4T)
vendor = 65
variant = 1
architecture = 2
part = 2336
revision = 0

HTC TyTN P4500
Samsung SC32442, ARM920T (ARMv4T)
vendor = 65
variant = 1
architecture = 2
part = 2336
revision = 0


ASUS M530W
XScale PXA270 (ARMv5TE)
vendor = 105
variant = 0
architecture = 5
part = 1041
revision = 7

Ubiquio 503G
XScale PXA270 (ARMv5TE)
vendor = 105
variant = 0
architecture = 5
part = 1041
revision = 7

O2 XDA Flame
XScale PXA270 (ARMv5TE)
vendor = 105
variant = 0
architecture = 5
part = 1041
revision = 7

HTC Excalibur 100:
OMAP 850, ARM926EJ-S (ARMv5TEJ)
vendor = 65
variant = 0
architecture = 6
part = 2342
revision = 3

Motorola Q9
OMAP 2420, ARM1136 (ARMv6)
vendor = 65
variant = 0
architecture = 7
part = 2870
revision = 2

Regards
Clemens