linux内核里面writel是如何实现的?
189 {
190 __raw_writel(b, addr);
191 mb();
192 }
130 {
131 IO_CONCAT(__IO_PREFIX,writel)(
132 }
134 #define IO_CONCAT(a,b) _IO_CONCAT(a,b)
135 #define _IO_CONCAT(a,b) a ## _ ## b
跟踪__IO_PREFIX 定义如下
502 #define __IO_PREFIX apecs
{
apecs_writel(b, addr);
}
you should refer to the file "arch\alpha\kernle\Machvec_
"~\Machve.h" "~\io.c" "~\io.h" "~\core_**.h".
as you have analysized before, in the file Machvec_impl.h and Machve.h,
DO_CIA_IO,IO,IO_LITE, these three macros implement the symbole
connection between ** arch and writel function, and the function
pointer initializations.
so, the details implementation to writel is to init the
alpha_machine_vector structure and the definition to the relevant
function pointer invoked to complete the low-level write operation.
.mv_writel =CAT(low,_writel),<---IO(CIA,
|
writel(b, addr)-->__raw_writel(b, addr);--->cia_writel(b,addr)--
For the second quesiton,
mb()--->__asm__ __volatile__("mb": : :"memory");
so, it is a memory barrier for alpha architecture to ensure some
operations before some actions could be occured.
and, it is similiar with the barrier() in x86 platform/arm platform.
件里面寻找答案。对于你的apsec,看看以下代码段(
------------------------------
#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 <asm/io_trivial.h>
------------------------------
arch/alpha/include/asm/io_
------------------------------
__EXTERN_INLINE void
IO_CONCAT(__IO_PREFIX,writel)(
{
*(volatile u32 __force *)a = b;
}
来写入数据的。