Here is an example of how the ARM architecture and the Linux kernel make it possible to perform safe GPIO on the Raspbery Pi.
User and kernel shared memory interface
- user-level GPIO class
- kernel device driver
- kernel
acl_permission
(around line 290)