[SeaBIOS] [PATCH 1/3] virtio: uninline _vp_{read,write}
Gerd Hoffmann
kraxel at redhat.com
Fri Jul 3 11:37:36 CEST 2015
Next patch makes it larger, and I don't think it makes sense to
continue inlining it. Uninline and move from header to c file.
Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
---
src/hw/virtio-pci.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/hw/virtio-pci.h | 79 ++---------------------------------------------------
2 files changed, 80 insertions(+), 77 deletions(-)
diff --git a/src/hw/virtio-pci.c b/src/hw/virtio-pci.c
index 6df5194..769710a 100644
--- a/src/hw/virtio-pci.c
+++ b/src/hw/virtio-pci.c
@@ -24,6 +24,84 @@
#include "virtio-pci.h"
#include "virtio-ring.h"
+u64 _vp_read(struct vp_cap *cap, u32 offset, u8 size)
+{
+ u32 addr = cap->addr + offset;
+ u64 var;
+
+ if (cap->is_io) {
+ switch (size) {
+ case 8:
+ var = inl(addr);
+ var |= (u64)inl(addr+4) << 32;
+ break;
+ case 4:
+ var = inl(addr);
+ break;
+ case 2:
+ var = inw(addr);
+ break;
+ case 1:
+ var = inb(addr);
+ break;
+ default:
+ var = 0;
+ }
+ } else {
+ switch (size) {
+ case 8:
+ var = readl((void*)addr);
+ var |= (u64)readl((void*)(addr+4)) << 32;
+ break;
+ case 4:
+ var = readl((void*)addr);
+ break;
+ case 2:
+ var = readw((void*)addr);
+ break;
+ case 1:
+ var = readb((void*)addr);
+ break;
+ default:
+ var = 0;
+ }
+ }
+ dprintf(9, "vp read %x (%d) -> 0x%llx\n", addr, size, var);
+ return var;
+}
+
+void _vp_write(struct vp_cap *cap, u32 offset, u8 size, u64 var)
+{
+ u32 addr = cap->addr + offset;
+
+ dprintf(9, "vp write %x (%d) <- 0x%llx\n", addr, size, var);
+ if (cap->is_io) {
+ switch (size) {
+ case 4:
+ outl(var, addr);
+ break;
+ case 2:
+ outw(var, addr);
+ break;
+ case 1:
+ outb(var, addr);
+ break;
+ }
+ } else {
+ switch (size) {
+ case 4:
+ writel((void*)addr, var);
+ break;
+ case 2:
+ writew((void*)addr, var);
+ break;
+ case 1:
+ writeb((void*)addr, var);
+ break;
+ }
+ }
+}
+
u64 vp_get_features(struct vp_device *vp)
{
u32 f0, f1;
diff --git a/src/hw/virtio-pci.h b/src/hw/virtio-pci.h
index b11c355..8d4ebe3 100644
--- a/src/hw/virtio-pci.h
+++ b/src/hw/virtio-pci.h
@@ -98,83 +98,8 @@ struct vp_device {
u8 use_modern;
};
-static inline u64 _vp_read(struct vp_cap *cap, u32 offset, u8 size)
-{
- u32 addr = cap->addr + offset;
- u64 var;
-
- if (cap->is_io) {
- switch (size) {
- case 8:
- var = inl(addr);
- var |= (u64)inl(addr+4) << 32;
- break;
- case 4:
- var = inl(addr);
- break;
- case 2:
- var = inw(addr);
- break;
- case 1:
- var = inb(addr);
- break;
- default:
- var = 0;
- }
- } else {
- switch (size) {
- case 8:
- var = readl((void*)addr);
- var |= (u64)readl((void*)(addr+4)) << 32;
- break;
- case 4:
- var = readl((void*)addr);
- break;
- case 2:
- var = readw((void*)addr);
- break;
- case 1:
- var = readb((void*)addr);
- break;
- default:
- var = 0;
- }
- }
- dprintf(9, "vp read %x (%d) -> 0x%llx\n", addr, size, var);
- return var;
-}
-
-static inline void _vp_write(struct vp_cap *cap, u32 offset, u8 size, u64 var)
-{
- u32 addr = cap->addr + offset;
-
- dprintf(9, "vp write %x (%d) <- 0x%llx\n", addr, size, var);
- if (cap->is_io) {
- switch (size) {
- case 4:
- outl(var, addr);
- break;
- case 2:
- outw(var, addr);
- break;
- case 1:
- outb(var, addr);
- break;
- }
- } else {
- switch (size) {
- case 4:
- writel((void*)addr, var);
- break;
- case 2:
- writew((void*)addr, var);
- break;
- case 1:
- writeb((void*)addr, var);
- break;
- }
- }
-}
+u64 _vp_read(struct vp_cap *cap, u32 offset, u8 size);
+void _vp_write(struct vp_cap *cap, u32 offset, u8 size, u64 var);
#define vp_read(_cap, _struct, _field) \
_vp_read(_cap, offsetof(_struct, _field), \
--
1.8.3.1
More information about the SeaBIOS
mailing list