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

2019-04-15 14:37发布

关于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位的地址