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?