将PCI地址映射更改为固定地址

时间:2017-05-16 11:07:13

标签: linux driver linux-device-driver pci-e

由于我的硬件(地址解码器)中的错误,我在访问Linux中枚举的BAR地址时遇到了问题。

如果我们从Linux主机访问我的设备寄存器,则枚举的Linux条形地址将导致垃圾值,这是由于硬件地址多路复用器解码问题(设备只有在最高5位应为零时才能访问)。条形码地址应在以下范围内。

0x04000000 0x08000000 0x0c000000

有没有办法改变内核。

我尝试了以下更改,但没有解决,所以请帮助我如何更改为我的设备的固定地址

 Tried below things today in kernel.

            In e820_reserve_resources() API tried to reserve memory range between 0x08000000 and 0x08ffffff. Below is the code snippet.
          res->name = e820_type_to_string(e820->map[i].type);
                res->start = e820->map[i].addr;
                res->end = end;
                res->flags = e820_type_to_iomem_type(e820->map[i].type);
                res->desc = e820_type_to_iores_desc(e820->map[i].type);
#if 1
                printk(KERN_INFO "TESTCHIP e820_reserve_resources name= %s - start_addr = 0x%x - end = 0x%x flasg = %x desc = %x\n", res->name, res->start, res->end, res->flags, res->desc);

                if(res->start == 0x100000) { // Address range check Silambarasan
                        res->end = 0x07FFFFFF;
                        printk(KERN_INFO "TESTCHIP end = 0x%x\n",res->end);
                        res->flags |= IORESOURCE_BUSY;
                        insert_resource(&iomem_resource, res);
                        res++;

                res->name = "reserved";
                res->start = 0x08000000;
                res->end = 0x08FFFFFF;
                res->flags = 0x200;
                res->desc = 0;
                }

#endif
#######################################

                With the above changes able to see the memory reserved in cat /proc/iomem section as below.

00000000-00000fff : reserved
00001000-0009d7ff : System RAM
0009d800-0009ffff : reserved
000a0000-000bffff : PCI Bus 0000:00
000c0000-000cfdff : Video ROM
000d0000-000d3fff : PCI Bus 0000:00
000d4000-000d7fff : PCI Bus 0000:00
000d8000-000dbfff : PCI Bus 0000:00
000dc000-000dffff : PCI Bus 0000:00
000e0000-000fffff : reserved
  000e0000-000e3fff : PCI Bus 0000:00
  000e4000-000e7fff : PCI Bus 0000:00
  000f0000-000fffff : System ROM
00100000-07ffffff : System RAM
  01000000-016768e9 : Kernel code
  016768ea-01d3677f : Kernel data
  01f4e000-0214cfff : Kernel bss
08000000-08ffffff : reserved
2f000000-36ffffff : Crash kernel
b609d000-b60a3fff : ACPI Non-volatile Storage
b60a4000-b6506fff : System RAM

现在尝试在pdev_assign_fixed_resource()函数中将上面的保留内存分配给PCI桥。 在此,当我尝试分配保留内存时,它将其分配为设备的虚拟内存。

0 个答案:

没有答案