专栏中心

EEPW首页 > 专栏 > linux中readl()和writel()函数

linux中readl()和writel()函数

发布人:电子禅石 时间:2021-08-30 来源:工程师 发布文章

readX/writeX() are used to access memory mapped devices. On some

 * architectures the memory mapped IO stuff needs to be accessed

 * differently. On the simple architectures, we just read/write the

 * memory location directly.

writel() 往内存映射的 I/O 空间上写数据,wirtel()  I/O 上写入 32 位数据 (4字节)。

 

 原型:

#include  

void writel (unsigned char data , unsigned short addr )

 

 

readl() 从内存映射的 I/O 空间读取数据,readl 从 I/O 读取 32 位数据 ( 4 字节 )

 

原型:

#include  

unsigned char readl (unsigned int addr )

 

变量    addr  是 I/O 地址。

返回值 : 从 I/O 空间读取的数值。

 

定义

#define readb __raw_readb

#define readw(addr) __le16_to_cpu(__raw_readw(addr))

#define readl(addr) __le32_to_cpu(__raw_readl(addr))

#ifndef __raw_readb

static inline u8 __raw_readb(const volatile void __iomem *addr)

{

    return *(const volatile u8 __force *) addr;

}

#endif

 

#ifndef __raw_readw

static inline u16 __raw_readw(const volatile void __iomem *addr)

{

    return *(const volatile u16 __force *) addr;

}

#endif

 

#ifndef __raw_readl

static inline u32 __raw_readl(const volatile void __iomem *addr)

{

    return *(const volatile u32 __force *) addr;

}

#endif

 

#define writeb __raw_writeb

#define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr)

#define writel(b,addr) __raw_writel(__cpu_to_le32(b),addr)


专栏文章内容及配图由作者撰写发布,仅供工程师学习之用,如有侵权或者其他违规问题,请联系本站处理。 联系我们

关键词: linux

相关推荐

彻底告别486:Linux内核维护者正式移除英特尔486处理器支持

由于英特尔裁员和公司重组,主要的英特尔 Linux 驱动项目正在消亡

linux入门精华

GeForce 590 驱动分支是首个不支持 GTX 9 和 10 系列 GPU 的分支——Linux 版本标志着定义时代显卡的终结

实时Linux技术:如何在嵌入式LINUX中应用实时特性

视频 2009-10-22

Linux中的fork与exec系列函数分析

嵌入式系统 2025-08-06

53年后,惠普于1972年推出的总线标准获得了稳定的Linux驱动——通用接口总线拥有惊人的8 MB/s带宽

Linus Torvalds 称谷歌工程师提交的 RISC-V 代码为“垃圾”,并表示它“让世界变得更糟糕”

嵌入式系统 2025-08-11

ARM 开发板使用手册 在三星 S3C2410开发板上烧写linux

Linux 今天 34 岁了

基于ARM的嵌入式Linux系统开发 下

视频 2009-10-22

基于ARM的嵌入式Linux系统开发 中

视频 2009-10-22

Linux就AI生成代码定下规则:允许Copilot类工具、拒绝劣质AI代码,错误由人类负责

Kontron与Congatec合作开发安全的嵌入式Linux平台

U-BOOT 与 MontaVista Linux 的移植

嵌入式Linux优化:加快系统起动和应用起动的过程

视频 2009-10-22

FFT公司9200的板子的资料

基于ARM的嵌入式Linux系统开发 上

视频 2009-10-22

RK3506核心板SDK重磅升级,解锁三核A7实时控制新架构

2025-12-18
更多 培训课堂
更多 焦点
更多 视频

技术专区