在Linux设备驱动程序中打印物理地址的数据内容

在设备驱动中打印物理地址的值:

 

static ssize_t address_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned long addr; unsigned long value; unsigned long* pvalue; unsigned long* p; int error; int i; int j; error = strict_strtoul(buf, 16, &addr); if (error) { printk("strict_strtoul addr error/n"); return error; } printk("addr:%lu, addr:0x%lx/n", addr, addr); //pvalue = (unsigned long *)phys_to_virt(addr); pvalue = (unsigned long *)ioremap(addr, 1024); value = *pvalue; for (p=pvalue, i=0; i<1024; ) { printk("0x%08lx/t", addr + i*4); for(j=0; j<8; j++) { printk("0x%08lx,", *p); ++i; ++p; } printk("/n"); } iounmap(pvalue); return count; } 

你可能感兴趣的:(linux,struct)