如何从linux内核空间访问物理地址? [英] How to acess the physical address from linux kernel space?

查看:62
本文介绍了如何从linux内核空间访问物理地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在rasberry pi板上工作.是否可以直接访问GPIO物理地址从Linux内核空间使用inb(),outb()...?.如果是,怎么办?.

I am working on rasberry pi board. Is it possible to directly access the GPIO physical address from linux kernel space using inb(), outb()... ?. If yes how ?.

GPIO寄存器地址链接第90章一更 http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

GPIO register address link Page 90 http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

谢谢

推荐答案

是.

  1. 使用 ioremap
  2. 获取到相关寄存器的虚拟地址映射设置
  3. 使用 readl/writel 操纵物理内存.
  1. Get a virtual address mapping setup to the registers in question using ioremap
  2. Use readl/writel to manipulate the physical memory.

请注意,ARM处理器将在未对齐访问时发生故障.Linux可以很好地处理此问题,但是会降低性能.

Beware that ARM processors will fault on unaligned accesses. Linux handles this gracefully, but with a performance penalty.

小例子:

void __iomem *regs = ioremap(0xdead0000, 4);

pr_info("0xdead0000: %#x\n", readl(regs));

iounmap(regs);

这篇关于如何从linux内核空间访问物理地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆