nios II 高2G地址与低2G的关系

IO programming in user space.

Note, you are doing in user space, with uclibc and included from /opt/nios2/include. It is not kernel space. You can not use interrupt. You can not use nios2 HAL, either.

You should know about the cache in Nios II. (BadOman:?) The first 2GB of address space is cached. The second 2GB is non-cached. These are not two seperate memory spaces or anything so there is a total of 2GB of address space (mirrored memory). This only applies for Nios II Full version with Data Cache. Nios II Standard version is uncached, so there should be no problems.

In other words address 0x00000000 (cachable) maps to address 0x8000000 (non-cachable)
" " " " " " 0x00000001 " " " " " " " " 0x8000001 (and so on .....)

So use the first 2GB for non-peripheral access (local memory), and the second 2GB for peripherals
You can define memory pointer access, and you can make it uncached by setting address bit 31.
eg, 0x00004000 -> 0x80004000

Or use port address defined in nios2_system.h, eg na_button_pio.
#include

#define inw(port) (*(volatile unsigned *)(port)) # for io read,
#define outw(d,port) (*(volatile unsigned *)(port))=(d) # for io write,

As an alternative, you can use these two defines (which are always uncached), they are similar to the Nios2-IDE functions :
#define IORD(address,offset) (*(volatile unsigned *)(((address)|0x80000000)+4*(offset)))
#define IOWR(address,offset,value) (*(volatile unsigned *)(((address)|0x80000000)+4*(offset)))=(value)

本文转自
file:///E:/g/linuxnios/pages/CompileHello%20-%20JotSpot%20Wiki%20(nioswiki).htm
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值