如何写信给 &从 x86 程序集中的网卡读取?

发布于 2024-08-12 20:28:06 字数 92 浏览 5 评论 0原文

有谁知道如何访问主板或 PCI 卡上的以太网端口等设备?

有专门的寄存器吗?操作码?我必须调用操作系统吗?如果是这样,怎么办?

提前致谢。

does anyone know how to gain access to devices such as an ethernet port on a mainboard or on a pci card?

Are there special registers? Opcodes? Do I have to make a call to the OS? If so, how?

Thanks in advance.

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

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

发布评论

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

评论(4

宣告ˉ结束 2024-08-19 20:28:06

这取决于您尝试与之通信的特定以太网 MAC 芯片。即使是同一系列的芯片,其运行方式也常常存在细微差别。这就是为什么现代操作系统有“驱动程序”概念:硬件制造商通常编写驱动程序,因为他们了解硬件,而驱动程序提供硬件和操作系统想要看到的内容之间的转换。

您通常可以从 MAC 芯片制造商处获取文档来编写自己的驱动程序。同样,您必须确切地知道您正在尝试与哪个芯片通信才能获得正确的规格。有些芯片没有公开文档,但这通常不是以太网芯片的问题。

It depends on the particular Ethernet MAC chip you're trying to talk to. Even chips in the same family will often have minor differences in how they operate. This is why modern OSes have the "driver" concept: the hardware manufacturer usually writes the driver because they know the hardware, and the driver provides a translation between the hardware and what the OS wants to see.

You can often get documentation from the MAC chip's manufacturer to write your own driver. Again, you have to know exactly which chip you're trying to talk to in order to get the right specs. Some chips have no public documentation, but that's usually not a problem with Ethernet chips.

油焖大侠 2024-08-19 20:28:06

最简单的答案(尽管可能不是您想要的)是编写 C 代码来访问该卡,对其进行编译,然后查看编译器生成的代码。

C 代码很可能直接通过 NIC 驱动程序,或者使用像 winpcap 这样的库。例如,出于安全原因,Windows 上对 原始套接字 的内置支持被禁用。

但这并不是了解 NIC 工作原理的最佳方法。为此,请选择流行的嵌入式 NIC 的数据表,例如 LAN91C111 并阅读如何访问它。 将教会您很多有关以原始方式连接以太网的知识。

恕我直言,这仍然不是一个足够好的沙箱来学习汇编语言。为此,只需在汇编中实现一些小型算法程序 - 例如二叉树搜索。

The simplest answer, although probably not what you're looking for, would be to write the C code to access the card, compile it, and see the code generated by the compiler.

The C code is likely to go through the NIC driver directly, or use a library like winpcap. Built-in support for raw sockets on Windows, for example, was disabled for security reasons.

But this isn't the best way to learn how NICs work. For that, pick a datasheet of a popular embedded NIC like LAN91C111 and read how to access it. That will teach you a lot about interfacing Eterthet in the raw way.

This still isn't a good enough sandbox to study assembly language in, IMHO. For that, just implement a few small algorithmic programs in assembly - like binary tree search.

找回味觉 2024-08-19 20:28:06

您可以使用输入和输出指令或类似的指令来调用卡本身。每个以太网卡都不同,因此您需要制造商提供的文档。

下一个级别是 DOS 函数调用(假设您使用的是 Windows)。这些将允许您使用标准 MSDOS 调用访问以太网卡的有限功能。您可以在旧的 MSDOS 文档中找到这些内容。如果我没记错的话,其中大多数仍然可以在更高版本的 Windows 上运行。

You can use calls to the card itself, using inupt and output instructions or something similar. Each ethernet card is different, so you'll need documentation from the manufacturer.

The next level up is the DOS function calls, assuming you're usuing Windows. These will allow you to access limited features of an ethernet card using standard MSDOS calls. You can find these in old MSDOS documentation. Most of them still work on later versions of Windows, if I'm not mistaken.

温柔女人霸气范 2024-08-19 20:28:06

您需要写入特定的端口地址。此 Wiki 页面可能会帮助您入门。
MemoryMappedIO

You will need to write to specific port addresses. This Wiki page might get you started.
MemoryMappedIO

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