当前位置: 技术问答>linux和unix
数据类型的问题
来源: 互联网 发布时间:2016-05-25
本文导语: 大家帮我看看这几行代码,是不是数据类型有错或者是别的原因导致出现这样的错误 unsigned long hpi_vbase; unsigned int *tmp; hpi_vbase = (unsigned long) ioremap_nocache (HPI_PHYSICAL_BASEADDR, HPI_PHYSICAL_size); #define HPIA_LW ...
大家帮我看看这几行代码,是不是数据类型有错或者是别的原因导致出现这样的错误
unsigned long hpi_vbase;
unsigned int *tmp;
hpi_vbase = (unsigned long) ioremap_nocache (HPI_PHYSICAL_BASEADDR, HPI_PHYSICAL_size);
#define HPIA_LW (hpi_vbase+0x04)
#define HPIA_HW (hpi_vbase+0x06)
#define HPIA_LR (hpi_vbase+0x14)
#define HPIA_HR (hpi_vbase+0x16)
HPIA_LW和HPIA_LR的区别实际上就是一个是写使能有效,一个是读使能有效,转换成指针指向的外设空间是一样的
writew (0x1234, HPIA_LW); 写入1234
writew (0x5678, HPIA_HW); 写入5678
*tmp++ = readw (HPIA_LR); 读出1212 , 应该读出1234
*tmp++ = readw (HPIA_HR); 读出5656, 应该读出5678
writel (0x1234, HPIA_LW); 写入1234
writel (0x5678, HPIA_HW); 写入5678
*tmp++ = readw (HPIA_LR); 读出1234
*tmp++ = readw (HPIA_HR); 读出5656
writel (0x1234, HPIA_LW); 写入1234
writel (0x5678, HPIA_HW); 写入5678
*tmp++ = readb (HPIA_LR); 读出12
*tmp++ = readb (HPIA_HR); 读出56
#define readw(c) ({ unsigned int __v = (*(volatile unsigned short *)((unsigned long)(c))); __v; })
#define writew(v,c) (*(volatile unsigned short *)((unsigned long)(c))=v
#define writel(v,c) (*(volatile unsigned int *)((unsigned long)c))=v
#define readl(c) ({ unsigned int __v = (*(volatile unsigned int *)((unsigned long)(c))); __v; })
unsigned long hpi_vbase;
unsigned int *tmp;
hpi_vbase = (unsigned long) ioremap_nocache (HPI_PHYSICAL_BASEADDR, HPI_PHYSICAL_size);
#define HPIA_LW (hpi_vbase+0x04)
#define HPIA_HW (hpi_vbase+0x06)
#define HPIA_LR (hpi_vbase+0x14)
#define HPIA_HR (hpi_vbase+0x16)
HPIA_LW和HPIA_LR的区别实际上就是一个是写使能有效,一个是读使能有效,转换成指针指向的外设空间是一样的
writew (0x1234, HPIA_LW); 写入1234
writew (0x5678, HPIA_HW); 写入5678
*tmp++ = readw (HPIA_LR); 读出1212 , 应该读出1234
*tmp++ = readw (HPIA_HR); 读出5656, 应该读出5678
writel (0x1234, HPIA_LW); 写入1234
writel (0x5678, HPIA_HW); 写入5678
*tmp++ = readw (HPIA_LR); 读出1234
*tmp++ = readw (HPIA_HR); 读出5656
writel (0x1234, HPIA_LW); 写入1234
writel (0x5678, HPIA_HW); 写入5678
*tmp++ = readb (HPIA_LR); 读出12
*tmp++ = readb (HPIA_HR); 读出56
#define readw(c) ({ unsigned int __v = (*(volatile unsigned short *)((unsigned long)(c))); __v; })
#define writew(v,c) (*(volatile unsigned short *)((unsigned long)(c))=v
#define writel(v,c) (*(volatile unsigned int *)((unsigned long)c))=v
#define readl(c) ({ unsigned int __v = (*(volatile unsigned int *)((unsigned long)(c))); __v; })
|
最好把错误信息贴出来
hpi_vbase = (unsigned long) ioremap_nocache (HPI_PHYSICAL_BASEADDR, HPI_PHYSICAL_size);
这代码是在函数体内吗?
hpi_vbase = (unsigned long) ioremap_nocache (HPI_PHYSICAL_BASEADDR, HPI_PHYSICAL_size);
这代码是在函数体内吗?