132 }
IO_CONCAT定义在include/asm-$(arch)目录下的IO.H中
#define IO_CONCAT(a,b)_IO_CONCAT(a,b)
#define _IO_CONCAT(a,b)a ## _ ## b
这段代码前几天看过了,是标示将两边的字符串连接起来的意思,即ab。
include/asm-$(arch)/core_apecs.h
/*
* APECS is the internal name for the 2107x chipset which provides
* memory controller and PCI access for the 21064 chip based systems.
*
* This file is based on:
*
* DECchip 21071-AA and DECchip 21072-AA Core Logic Chipsets
* Data Sheet
*
* EC-N0648-72
*
* david.rusling@reo. Initial Version.
*/
继续阅读代码,看看定义__IO_PREFIX之后紧接着包含了哪个头文件。在哪个头文
件里面寻找答案。对于你的apsec,看看以下代码段(linux-2.6.28-rc4)
#undef __IO_PREFIX
#define __IO_PREFIX apecs
#define apecs_trivial_io_bw 0
#define apecs_trivial_io_lq 0
#define apecs_trivial_rw_bw 2
#define apecs_trivial_rw_lq 1
#define apecs_trivial_iounmap 1
#include
前往include/asm-$(arch)/io_trivial.h
__EXTERN_INLINE void
IO_CONCAT(__IO_PREFIX,writel)(u32 b, volatile void __iomem *a)
{
*(volatile u32 __force *)a = b;
}
就是最终通过*(volatile u32 __force *)a = b;
来写入数据的。
同样的readl读取数据也和writel类似,这里就不重复了。
# define __force __attribute__((force))
表示所定义的变量类型是可以做强制类型转换的,在进行Sparse分析的时候,是不用报告警信息的。
(如果在没有os,没有mmu的情况下,当开发板裸跑的时候,我们只需要一句话就一切ok:
*(unsigned long *)addr = value)
如果觉得《linux内存映射边读边写 内存映射IO空间的读写函数writeb() writew() writel()》对你有帮助,请点赞、收藏,并留下你的观点哦!