Hi, 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.
Hi, 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.
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.
You will need to write to specific port addresses. This Wiki page might get you started.
MemoryMappedIO
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.
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.