mmap 通过 PCI 将 VME 总线覆盖到用户空间内存中?

发布于 2024-07-30 18:09:09 字数 986 浏览 15 评论 0原文

我正在尝试通过 PCI 总线将 VME 地址空间映射到用户空间,以便我可以在内存上执行常规读/写操作。 我已经用另一个 PCI 设备做到了这一点,如下所示:-

unsigned long *mapArea(unsigned int barAddr, unsigned int mapSize, int *fd)
{
    unsigned long *mem;

    *fd = open("/dev/mem", O_RDWR);
    if ( *fd<0 ) {
       printf("Cannot open /dev/vme_mem\n");
    exit(-1);
}

unsigned long *mem = (unsigned long*) mmap ( 0, mapSize, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, *fd,  barAddr); 
if ( (mem == NULL) || (mem == (unsigned long*)-1) ) {
    printf ( "Cannot map memory, error is %s\n", strerror(errno) );
    exit(-1);
    }

    return mem;
}

volatile unsigned long *bar = (volatile unsigned long *)mapArea(barAddr, mapSize, &fd);

然后“bar”可以正常用于读/写。

所以对于 VME,并使用 Tundra Universe II PCI-VME 桥芯片:-

我应该打开“/dev/vme_m0” 我从哪里映射我的 BAR? lspci -vv :“区域 1:80020000 处的内存”

此外,VME 总线内的地址偏移了 0x20000000,那么访问/映射它是如何工作的?

(使用 Linux 2.6.18-128.el5 #1 SMP) (需要新标签“vme”!)

I'm trying to map a VME address space through a PCI bus into user space so I can perform regular read/writes on the memory.
I have done this with another PCI device like this :-

unsigned long *mapArea(unsigned int barAddr, unsigned int mapSize, int *fd)
{
    unsigned long *mem;

    *fd = open("/dev/mem", O_RDWR);
    if ( *fd<0 ) {
       printf("Cannot open /dev/vme_mem\n");
    exit(-1);
}

unsigned long *mem = (unsigned long*) mmap ( 0, mapSize, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, *fd,  barAddr); 
if ( (mem == NULL) || (mem == (unsigned long*)-1) ) {
    printf ( "Cannot map memory, error is %s\n", strerror(errno) );
    exit(-1);
    }

    return mem;
}

volatile unsigned long *bar = (volatile unsigned long *)mapArea(barAddr, mapSize, &fd);

And then "bar" can be used normally for read/writes.

So to VME, and with a Tundra Universe II PCI-VME Bridge chip :-

Should I open "/dev/vme_m0"
Where do I map my BAR from? the lspci -vv : "Region 1: Memory at 80020000"

Also the addresses within the VME BUS are offset by 0x20000000, so how does that work wrt accessing/mapping it?!

(Using Linux 2.6.18-128.el5 #1 SMP)
(Need new tag "vme"!)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘虞初梦 2024-08-06 18:09:09

/dev/vme_m0 从哪里来,它代表什么? 在不了解更多信息的情况下,很难判断打开和访问它会做什么。

您需要查看桥接芯片手册以了解对区域 1 的读/写如何转换为 VME 总线上的读/写。 桥接芯片应该有一组定义PCI的寄存器-> VME 地址转换。 通过访问 0x80020000 生成的 VME 地址将取决于这些寄存器之一中指定的 VME 地址。

Where does /dev/vme_m0 come from and what does it represent? It is hard to tell what opening and accessing it will do without knowing more.

You need to look at the bridge chip manual to figure out how a read/write to Region 1 will translate to a read/write on the VME bus. The bridge chip should have a set of registers that define PCI -> VME address translations. The VME address generated by accessing 0x80020000 would depend on the VME address specified in one of those registers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文