23,120
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <asm/io.h>
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef unsigned long DWORD;
int main()
{
BYTE bReg = 0x00;
DWORD dwAddr = ioremap(0x400,256); //0x400是串口的内存地址
printf(" 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n");
printf(" --------------------------------------------\n");
for(int y=0;y<0x10;y++)
{
printf("%02X: ",y<<4);
for(int i=0;i<0x10;i++)
{
bReg = y*0x10+i;
printf("%02X ",readb(dwAddr+bReg));
}
printf("\n");
}
iounmap(dwAddr);
}
include\asm-mips\io.h
/*
* ioremap - map bus memory into CPU space
* @offset: bus address of the memory
* @size: size of the resource to map
*
* ioremap performs a platform specific sequence of operations to
* make bus memory CPU accessible via the readb/readw/readl/writeb/
* writew/writel functions and the other mmio helpers. The returned
* address is not guaranteed to be usable directly as a virtual
* address.
*/
#define ioremap(offset, size) \
__ioremap_mode((offset), (size), _CACHE_UNCACHED)