Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hi this is srikanthpilli, i am using arm9-cortex A9 processor. i wanna find arm9 processor cpu id by using linux 'C'. how i will write C code? and how i will check code in arm9-cortex-A9 processor? please help this problem
Thanks for your suggestion, this was done successfully in my console. but i wanna store getting data after type cat /proc/cpuinfu in some other location. so that's why i am asking you how to write code in linux C and how i will store that data in file.
Thanks for your suggestion, this was done successfully in my console. but i wanna store getting data after type cat /proc/cpuinfu in some other location. so that's why i am asking you how to write code in linux C and how i will store that data in file.
thanks
srikanthpilli
I meant you can open /proc/cpuinfo inside your C program to get and store the data.
But if Satyaveer Arya code works, it looks much better.
That page provides the definition for native_cpuid() that should be included as part of the C source file.
In addition, the solution on the page links to a wikipedia article (Wikipedia: CPUID) that describes bit ranges and their meanings for the various processor registers that are read by native_cpuid().
As far as I can tell, the above examples are specific to x86 architecture, and will not work on ARM A9.
Obviously, A9 does have a mechanism for obtaining processor and architecture information; you might be able to use inline assembly to do that. However, it seems to me there are a lot of details to worry about (looking at some of the kernel sources), enough so that it makes more sense to let the kernel people worry about detecting the features, and just read /proc/cpuinfo in userspace programs instead.
If you are worried about memory usage or similar issues, you can use low-level I/O (unistd.h) to read /proc/cpuinfo to a small buffer, splitting each line into name : value pairs for parsing. Parse each pair, perhaps using a helper function for each different name, populating a structure describing the current CPU architecture with the results. This may sound a bit complicated, but it is not at all difficult to do. If you are only interested in specific capabilities (as in whether certain features are available or not), it is even easier.
If you'd like to see some example code, please show the /proc/cpuinfo file from your ARM Cortex A9 first.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.