Linux内核中IO地址空间映射实例

关于IO地址映射,如中断外设的地址和映射后的地址访问

下面是P1020 手册中关于PIC中断控制器的描述

PIC Memory Map/Register Definition

The PIC programmable register map occupies 256 Kbytes of memory-mapped space.

Reading undefined portions of the memory map returns all zeros; writing has no effect.
All PIC registers are 32 bits wide and, although located on 128-bit address boundaries,
should be accessed only as 32-bit quantities.
The PIC address offset map is divided into three areas:
• 0xnn4_0000-0xnn4_FFF0-Global registers
• 0xnn5_0000-0xnn5_FFF0-Interrupt source configuration registers

• 0xnn6_0000-0xnn7_FFF0-Per-CPU registers


由图看到,假如我想访问PIC_EIVPR4,程序如下

int16->pic_vaddr =(unsigned int *)ioremap(get_immrbase() + 0x50080, 128); 
映射之后就可以访问了

如果我想访问PIC_EIDR4

out_be32((int16->pic_vaddr+4), regdata);
为什么这个地方是+4呢,而不是+0x10 ???
注意PIC控制器的描述:
All PIC registers are 32 bits wide and, although located on 128-bit address boundaries,
should be accessed only as 32-bit quantities.

实际上PIC寄存器是32位宽,但占用了128bit(16个int)地址范围

但访问还是要按照32位的地址







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值