C/Direct memory access
From Attie's Wiki
(Difference between revisions)
m (Created page with 'This example shows how to access memory locations directly (in this case a 16-bit register) <source lang="c"> unsigned short *p; unsigned short mask = 0x400; p = 0xFFFE3A02; if …') |
m (Attie moved page Direct memory access to C/Direct memory access) |
||
(One intermediate revision by one user not shown) | |||
Line 11: | Line 11: | ||
} | } | ||
</source> | </source> | ||
+ | |||
+ | From within the kernel, use <code>ptr = ioremap(addr,len)</code> and <code>iounmap(ptr)</code> |
Latest revision as of 17:07, 14 February 2013
This example shows how to access memory locations directly (in this case a 16-bit register)
unsigned short *p; unsigned short mask = 0x400; p = 0xFFFE3A02; if (*p & mask) { *p &= ~mask; } else { *p |= mask; }
From within the kernel, use ptr = ioremap(addr,len)
and iounmap(ptr)