mirror of
https://github.com/ipxe/ipxe
synced 2025-12-25 09:01:24 +03:00
[virtio] Remove dependency on nic for virtio PCI functions
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
This commit is contained in:
committed by
Michael Brown
parent
fc49421c7e
commit
d3d8f20626
@@ -37,58 +37,58 @@
|
||||
/* Virtio ABI version, this must match exactly */
|
||||
#define VIRTIO_PCI_ABI_VERSION 0
|
||||
|
||||
static inline u32 vp_get_features(struct nic *nic)
|
||||
static inline u32 vp_get_features(unsigned int ioaddr)
|
||||
{
|
||||
return inl(nic->ioaddr + VIRTIO_PCI_HOST_FEATURES);
|
||||
return inl(ioaddr + VIRTIO_PCI_HOST_FEATURES);
|
||||
}
|
||||
|
||||
static inline void vp_set_features(struct nic *nic, u32 features)
|
||||
static inline void vp_set_features(unsigned int ioaddr, u32 features)
|
||||
{
|
||||
outl(features, nic->ioaddr + VIRTIO_PCI_GUEST_FEATURES);
|
||||
outl(features, ioaddr + VIRTIO_PCI_GUEST_FEATURES);
|
||||
}
|
||||
|
||||
static inline void vp_get(struct nic *nic, unsigned offset,
|
||||
static inline void vp_get(unsigned int ioaddr, unsigned offset,
|
||||
void *buf, unsigned len)
|
||||
{
|
||||
u8 *ptr = buf;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
ptr[i] = inb(nic->ioaddr + VIRTIO_PCI_CONFIG + offset + i);
|
||||
ptr[i] = inb(ioaddr + VIRTIO_PCI_CONFIG + offset + i);
|
||||
}
|
||||
|
||||
static inline u8 vp_get_status(struct nic *nic)
|
||||
static inline u8 vp_get_status(unsigned int ioaddr)
|
||||
{
|
||||
return inb(nic->ioaddr + VIRTIO_PCI_STATUS);
|
||||
return inb(ioaddr + VIRTIO_PCI_STATUS);
|
||||
}
|
||||
|
||||
static inline void vp_set_status(struct nic *nic, u8 status)
|
||||
static inline void vp_set_status(unsigned int ioaddr, u8 status)
|
||||
{
|
||||
if (status == 0) /* reset */
|
||||
return;
|
||||
outb(status, nic->ioaddr + VIRTIO_PCI_STATUS);
|
||||
outb(status, ioaddr + VIRTIO_PCI_STATUS);
|
||||
}
|
||||
|
||||
|
||||
static inline void vp_reset(struct nic *nic)
|
||||
static inline void vp_reset(unsigned int ioaddr)
|
||||
{
|
||||
outb(0, nic->ioaddr + VIRTIO_PCI_STATUS);
|
||||
(void)inb(nic->ioaddr + VIRTIO_PCI_ISR);
|
||||
outb(0, ioaddr + VIRTIO_PCI_STATUS);
|
||||
(void)inb(ioaddr + VIRTIO_PCI_ISR);
|
||||
}
|
||||
|
||||
static inline void vp_notify(struct nic *nic, int queue_index)
|
||||
static inline void vp_notify(unsigned int ioaddr, int queue_index)
|
||||
{
|
||||
outw(queue_index, nic->ioaddr + VIRTIO_PCI_QUEUE_NOTIFY);
|
||||
outw(queue_index, ioaddr + VIRTIO_PCI_QUEUE_NOTIFY);
|
||||
}
|
||||
|
||||
static inline void vp_del_vq(struct nic *nic, int queue_index)
|
||||
static inline void vp_del_vq(unsigned int ioaddr, int queue_index)
|
||||
{
|
||||
/* select the queue */
|
||||
|
||||
outw(queue_index, nic->ioaddr + VIRTIO_PCI_QUEUE_SEL);
|
||||
outw(queue_index, ioaddr + VIRTIO_PCI_QUEUE_SEL);
|
||||
|
||||
/* deactivate the queue */
|
||||
|
||||
outl(0, nic->ioaddr + VIRTIO_PCI_QUEUE_PFN);
|
||||
outl(0, ioaddr + VIRTIO_PCI_QUEUE_PFN);
|
||||
}
|
||||
#endif /* _VIRTIO_PCI_H_ */
|
||||
|
||||
Reference in New Issue
Block a user