ioremap 函数映射操作已知的物理地址(寄存器、端口、IO)
2015-07-23 22:10
369 查看
NAME
ioremap - map bus memory into CPU space
SYNOPSIS
ARGUMENTS
offset
bus address of the memory
size
size of the resource to map
DESCRIPTION
ioremap 函数来映射到内核地址空间,然后修改虚拟地址空间达到控制寄存器的状态。
我用如下方法操作一个地址为0x56000020的端口
第一种:
编译时候出现警告warning,左值有问题,建议使用第二种。
第二种:
ioremap - map bus memory into CPU space
SYNOPSIS
void __iomem * ioremap (unsigned long offset, unsigned long size);
ARGUMENTS
offset
bus address of the memory
size
size of the resource to map
DESCRIPTION
ioremap performs a platform specific sequence of operations to make bus memory CPU accessible via the readb/readw/readl/writeb/ writew/writel functions and the other mmio helpers. The returned address is not guaranteed to be usable directly as a virtual address.
ioremap 函数来映射到内核地址空间,然后修改虚拟地址空间达到控制寄存器的状态。
我用如下方法操作一个地址为0x56000020的端口
第一种:
unsigned long port_addr; (void *)(port_addr) = ioremap(0x56000020,0x8); *(volatile unsigned int *)(port_addr) |= 0x00008000;
编译时候出现警告warning,左值有问题,建议使用第二种。
第二种:
volatile unsigned int *port_addr = ioremap(0x56000020,0x8); *port_addr |= 0x00008000;
#define rGPACON (*(volatile unsigned *)(ioremap(GPACON,0x8)))
相关文章推荐
- 关于hibernate插入mysql数据库中文数据乱码处理
- eclipse中SVN分支合并到主干
- OX01: Web Speder 入门
- 原生 or 混合 ? 关于应用永不停息的争论
- Buildings
- spring[2]
- oc010---protocol
- 阅读《C陷阱与缺陷》的知识增量
- c++ 实现数据库连接池
- 应用启动选择
- EasyUI获取DataGrid中某一列的所有值
- EasyUI获取DataGrid中某一列的所有值
- Heartbeat
- EasyUI获取DataGrid中某一列的所有值
- 多校第一场 1003
- Linux kernel 分析之十九:阅读源代码技巧-变量命名规则
- hdu 5308 I Wanna Become A 24-Point Master 2015 Multi-University Training Contest 2
- 为何高于四次的方程没有根式解?
- TextView支持的XML属性及相关方法
- 关于使用二分思想算法的时间复杂度的计算