How read coprocessor registers in ARM architecture

后端 未结 1 1246
悲哀的现实
悲哀的现实 2021-01-18 21:56

I\'m trying to read CP15 coprocessor in the following System-on-chip

Cortex A7 - ARMv7-A

Below my snippet

void main (void)
{
    unsigned int         


        
相关标签:
1条回答
  • 2021-01-18 22:25

    It seems that you are trying to access MIDR: Main ID Register (from the ARMARMv7 B4.1.105) using the instruction

    MRC p15, 0, <Rt>, c0, c0, 0    ; Read MIDR into Rt
    

    However, as you are in Linux and executing an application, you are in usermode (PL0) and ARMARMv7 specifies in the usage constraints of MIDR that

    Only accessible from PL1 or higher.

    So only accessible at PL1, PL2, PL3. To access it you need to create a driver running at PL1 which will do the read of MIDR. Then, in your application, open this driver to get the data using IOCTL for example.

    You can also try to access the kernel mode (PL1) using a SVC call from PL0, but this would imply modifying your kernel SVC handler.

    0 讨论(0)
提交回复
热议问题