#include <idt/idtirq.h>
#include <io/kio.h>
#include <mem/kmem.h>
#include <net/virtnet.h>
#include <pci/pci.h>
#include <types/nums.h>
Go to the source code of this file.
|
void | VirtnetNegotiate (u32 iob) |
| Performs device negotiation with the VirtIO network device.
|
void | VirtnetInit (u32 iob) |
| Initializes the VirtIO network queue and allocates RX buffers.
|
void | NetStq (u32 iob) |
| Processes received packets from the VirtIO queue.
|
void | VirtnetSetup () |
| Performs full setup of the VirtIO network device.
|
◆ NetStq()
Processes received packets from the VirtIO queue.
Iterates over the used ring to find received packets, prints their contents in hex, and recycles the RX buffers by re-adding the descriptors to the avail ring.
- Parameters
-
iob | The I/O base address for the VirtIO device. |
Definition at line 138 of file virtio.c.
◆ VirtnetInit()
void VirtnetInit |
( |
u32 | iob | ) |
|
Initializes the VirtIO network queue and allocates RX buffers.
- Selects RX queue 0 via PCI register.
- Allocates a 4 KiB block for the VirtIO queue and zeroes it.
- Determines the queue size from the device, clamping if needed.
- Initializes descriptor structures:
- desc: descriptors for received packets
- avail: list of available descriptors
- used: list of used descriptors from the device
- Allocates individual 2 KiB RX buffers for each descriptor.
- Notifies the device that the queue is ready and available.
- Parameters
-
iob | The I/O base address for the VirtIO device. |
Definition at line 78 of file virtio.c.
◆ VirtnetNegotiate()
void VirtnetNegotiate |
( |
u32 | iob | ) |
|
Performs device negotiation with the VirtIO network device.
Resets the VirtIO network device and negotiates feature support by writing appropriate status flags to the I/O port.
- Parameters
-
iob | The I/O base address for the VirtIO device. |
Definition at line 41 of file virtio.c.
◆ VirtnetSetup()
Performs full setup of the VirtIO network device.
Finds the VirtIO network device on the PCI bus, reads its IRQ, sets the interrupt handler, unmasks the IRQ, and performs negotiation and initialization.
Definition at line 176 of file virtio.c.