2

I am trying to build an unikernel in Rust,which will boot and start a web server. I am using Qemu for testing purposes.

So far, I have managed to write an OS with segmentation, paging and interrupts enabled by following various blogs online and projects on github. The kernel is up and running and is able to detect software interrupts and also hardware interrupts if an interrupt of kind int 32 is explicitly called. After this I enabled IO Ports and implemented all the Port I/O functions like inb,outb,inl,outl,inw,outw that helps me to read and write to the port. I read somewhere that this is how the driver and the device communicate with each other. Using these I used the probe method to detect the peripheral devices. In qemu, 3 devices were detected.

One of those devices is Intel 82540EM Ethernet Controller with device id 0x100e and vendor id 0x8086. I am trying to communicate with this driver to implement the transmission and reception of the packets that will complete my project. I understood that all the communication that happens between the network card and the driver happens through the device's IO ports.

But, I couldn't clearly understand what happens in the background. So, can someone explain me- How do we detect that some new packet has arrived to the Network card?

natcomp256
  • 706
  • 7
  • 13
  • *and the driver needs to generate an interrupt on receiving a packet.* — I've never written a kernel, but I'm pretty sure you've got this backwards. The network card will raise an interrupt when data is available to read. The kernel will do some bookkeeping in the interrupt and then later on (outside of the interrupt) read the data from the card. – Shepmaster Apr 20 '17 at 12:54
  • Yeah. that is correct. I am editing it. – natcomp256 Apr 20 '17 at 15:06

0 Answers0