|
求救:字附型驱动write函数传入的char×型数据有问题
[复制链接]
//驱动中write函数 对物理地址WR_ADDR写 0x1234abcd
ssize_t regs_op_write( struct file *filp, char *buf, size_t count, loff_t *f_pos) {
char *tmp;
tmp=buf;//+count-1;
//p2v after resetting
regs_op_buffer = ioremap(WR_ADDR, WR_LEN);
copy_from_user((char*)regs_op_buffer,(char*)tmp,count);
return 1;
}
//应用程序中调用write函数 ssize_t regs_op_write( struct file *filp, char *buf, size_t count, loff_t *f_pos)
write(fd,(char*)argv[2],sizeof(int)); 其中argv[2] 来自于main传入参数 1234abcd
但是在驱动中printk
printk("buf from write:%16x\n",*buf);
发现第一个地址(0x1e20000)写入的是 字附 ‘1’ (0x33),本希望是0x12,第二个地址((0x1e20001))'2' (0x34),而不是0x34
各位大侠帮忙啊 ,快郁闷死了
|
|