预留内存的设备驱动程序

时间:2017-08-09 05:24:31

标签: memory linux-kernel linux-device-driver embedded-linux reserved

我正在尝试开发一个简单的字符设备驱动程序来访问保留的内存区域,如网站中所述:http://www.wiki.xilinx.com/Linux+Reserved+Memory

/* Get reserved memory region from Device-tree */

np = of_parse_phandle(dev->of_node, "memory-region", 0);

if (!np) {
    dev_err(dev, "No %s specified\n", "memory-region");
    goto error1;
}

rc = of_address_to_resource(np, 0, &r);

if (rc) {
  dev_err(dev, "No memory address assigned to the region\n");  
  goto error1;
}

lp->paddr = r.start;
lp->vaddr = memremap(r.start, resource_size(&r), MEMREMAP_WB);

dev_info(dev, "Allocated reserved memory, vaddr: 0x%0llX, paddr: 0x%0llX\n", (u64)lp->vaddr, lp->paddr);

该网站未提供有关lp->paddrlp->vaddr

的任何信息

lp的数据类型是什么?

1 个答案:

答案 0 :(得分:0)

我认为" lp"不是预定义的变量。 我用vaddr和paddr声明了我自己的struct作为struct元素,并将lp定义为struct变量并且它有效。

private long _lockTicks = 0;

.....

var sw = StopWatch.StartNew();
lock(_locker)
{
   sw.Stop();
   _lockTicks += sw.ElapsedTicks;
   //dostuff
}

......


double seconds = (double)_lockTicks / StopWatch.Frequency;