vxWorks 6.8将物理内存映射到虚拟内存 [英] vxWorks 6.8 mapping physical to virtual memory

查看:289
本文介绍了vxWorks 6.8将物理内存映射到虚拟内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在这里的第一个问题:).

This is my first question here :).

我一直在尝试将物理内存映射到vxWorks 6.8中的虚拟内存,但没有成功, 我正在尝试使用"vmMap"功能,但它总是以以下方式返回:

I been trying for while now to map physical memory to virtual memory in vxWorks 6.8 with no success, I'm trying to use "vmMap" function but somehow it keeps return with:

errno = 0x30065 S_taskLib_NAME_NOT_FOUND.

errno = 0x30065 S_taskLib_NAME_NOT_FOUND.

我的代码是:

int page_size=0;
PHYS_ADDR GPIO_BASE_VIRTUAL_ADDR = 0x40E00000;
VIRT_ADDR VIRTUAL_ADDR=0;

page_size =vmPageSizeGet();
if((VIRTUAL_ADDR = (VIRT_ADDR)memalign(page_size,page_size*2))==NULL)// allocate 2 pages 
{
    printf("error in memalign() errno = 0x%x\n",errnoGet());
}

if(vmMap(NULL,VIRTUAL_ADDR,GPIO_BASE_VIRTUAL_ADDR,(page_size*2))== ERROR )
{
    printf("Error mapping memory errno = 0x%x%\n",errnoGet());
}

任何帮助将不胜感激, 谢谢,

Any help will be very appreciate, thanks,

摩西.

推荐答案

很久以前,您就已经解决了这个问题,但是我想我会留下一些面包屑,以便其他人可能会在昏暗的&遥远的未来..

I see you already solved this long ago, but thought I'd leave some bread crumbs for whoever else might stumble this way in the dim & distant future..

除非您正在执行RTP,否则您的MMU很有可能甚至不会翻译地址.也就是说,如果在物理地址空间中出现0x7fc00400的字样,则可以将该值强制转换为指针并使用它.

Unless you're doing RTPs there's a good chance your MMU isn't even translating addresses. I.e., if something appears at say, 0x7fc00400 in the physical address space, you could simply cast that value to a pointer and use it.

*((short *) 0x7fc00400) = foo; // write 16 bits!

是的,如今,建议以这种方式使用指针几乎是一种讽刺,但是我要指出的是,如果您正在执行vxworks内核空间代码,那么实际上您还是在裸机上,所以为什么不是吗?

And Yes, these days it is almost sacrilege to suggest (ab)using pointers this way, but I would point out that if you're doing vxworks kernel space code, you're practically on the bare metal anyway, so why not?

这篇关于vxWorks 6.8将物理内存映射到虚拟内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆