Is it possible to have a piece of code like this in user space?
I mean is it possible to read/write co-processor register in user space in Netbsd / Linux?
XYZ]# cat pmc.c
static inline int
arm11_pmc_ctrl_read(void)
{
unsigned int val;
__asm volatile ("mrc p15, 0, %0, c15, c12, 0" : "=r" (val));
return val;
}
int main(){
unsigned int ctrl;
ctrl = arm11_pmc_ctrl_read();
}
You may have to change the permissions of the binary executable by applying a suid bit on it and it will run as root, I know, it may sound like a security hole, but unfortunately, root would have that privilege to run it, and not the normal user.
Or you could create a device i.e. a
/dev/mydevusingmknodand write a device driver in which the normal user can then interact with the device driver, which in turn is running in kernel space and do the assembly magic and return it back to the userland space, this method is preferable.Hope this helps,
Best regards,
Tom.