如何通过网络代理 mmap 读取和写入?

发布于 2024-09-24 15:04:57 字数 409 浏览 10 评论 0原文

我正在开发用于控制嵌入式 ARM 系统上的 mmap 设备的软件,但遇到了一些可用的调试和开发工具不足的情况。即 valgrind 和高端螺纹分析仪等仪表工具不可用。

我想做的是在 x86 机器上编译我的代码,使用相同大小映射一个“虚拟”内存段,然后通过网络将这些读/写代理到嵌入式机器,然后嵌入式机器可以做出相应的响应。

我意识到这可能需要客户端/服务器机制,并且速度会非常慢,但是使用此选项的好处将使 mmap 接口本身之外的机制(异步事件处理、线程管理)可用于使用 x86 开发工具进行检测非常有用。

我在一些用于模拟的 ASIC 开发中听说过这种技术,但从未使用过任何提供此功能的技术。这里的关键点是,我想在两个平台上使用相同的代码,而不必重写一堆东西,或者必须编写一个包含任何硬件处理逻辑的内核模块。我想通过mmap将所有设备控制逻辑保留在用户态

I'm working on software to control a mmap'd device on an embedded ARM system, but have run into a few situations where the debugging and development tools available haven't been sufficient. i.e. Instrumentation tools like valgrind and higher end thread profilers are unavailable.

What I'd like to do is compile my code on an x86 machine, mmap a 'dummy' segment of memory using the same size and then proxy those reads/writes across the network to the embedded machine which could then respond accordingly.

I realize this would likely require a client/server mechanism and would be excruciatingly slow but the benefits of having this option would make the mechanics outside of the mmap interface itself (async event handling, thread management) available to instrument using x86 development tools would be very useful.

I've heard of this technique in some ASIC development for simulation but never used anything that provided this functionality. The key point here is that I want to use the same code on both platforms without having to rewrite a bunch of stuff, or have to write a kernel module that has any hardware handling logic in it. I want to keep all the device control logic in userland through mmap

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

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

发布评论

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

评论(2

慕烟庭风 2024-10-01 15:04:57

如果您仔细考虑一下,基本上可以归结为实现远程文件系统。

  • “最简单”可能是如果你
    嵌入式设备可以实现
    NFS客户端的简单版本
    侧,并在您的 mmap 上创建一个文件
    台式机
  • 相反也应该是可能的,
    即有nfs服务器模块
    在您的嵌入式系统上运行并
    /dev/shm 之类的内容作为 nfs 挂载点导出到桌面。

对于这两种方法(任何其他使用 mmap),您必须非常小心数据同步。但只要您有一个典型的调试设置,基本上只有一名编写者和一名读者,这就是可行的。如果这变得更复杂,可以使用 nfs 扩展来使用远程文件锁定。

If you think this through, basically this boils down to implement a remote file system.

  • the "easiest" would probably if your
    embedded device could realize a
    simple version of the NFS client
    side, and mmap a file on your
    desktop machine
  • the inverse should also be possible,
    namely to have nfs server modules
    running on you embedded system and to
    export something like /dev/shm as an nfs mount point to your desktop.

For both approaches (any any other using mmap) you must be really careful on data synchronization. But as long as you have a typical debug setting with basically one writer and one reader this could be doable. If this gets more complicated, there is remote file locking available as an nfs extension.

白况 2024-10-01 15:04:57

我过去一直想要类似的东西,但从未真正抽出时间来实现它。不过,您可能想看看像 memcached 这样的东西,我知道它通常用于基于 web/db 的东西,但可能会出于此目的而滥用它,特别是因为它用于调试。

I have wanted something similar in the past but never really got around to implementing it. However you might want to give something like memcached a look, I know its normally used for web/db based stuff, but it might be possible to abuse it for this purpose, especially since it is for debug.

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