aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hw/pvscsi.c2
-rw-r--r--src/hw/virtio-ring.h7
-rw-r--r--src/memmap.h7
-rw-r--r--src/x86.h8
4 files changed, 16 insertions, 8 deletions
diff --git a/src/hw/pvscsi.c b/src/hw/pvscsi.c
index a462522..fa20efe 100644
--- a/src/hw/pvscsi.c
+++ b/src/hw/pvscsi.c
@@ -11,6 +11,7 @@
#include "blockcmd.h" // scsi_drive_setup
#include "config.h" // CONFIG_*
#include "malloc.h" // free
+#include "memmap.h" // PAGE_SHIFT, virt_to_phys
#include "output.h" // dprintf
#include "pci.h" // foreachpci
#include "pci_ids.h" // PCI_DEVICE_ID_VMWARE_PVSCSI
@@ -19,7 +20,6 @@
#include "std/disk.h" // DISK_RET_SUCCESS
#include "string.h" // memset
#include "util.h" // usleep
-#include "virtio-ring.h" // PAGE_SHIFT, virt_to_phys
#include "x86.h" // writel
#define MASK(n) ((1 << (n)) - 1)
diff --git a/src/hw/virtio-ring.h b/src/hw/virtio-ring.h
index e8f3b82..7665fd5 100644
--- a/src/hw/virtio-ring.h
+++ b/src/hw/virtio-ring.h
@@ -4,13 +4,6 @@
#include "types.h" // u64
#include "memmap.h" // PAGE_SIZE
-#define PAGE_SHIFT 12
-
-#define virt_to_phys(v) (unsigned long)(v)
-/* Compiler barrier is enough as an x86 CPU does not reorder reads or writes */
-#define smp_rmb() barrier()
-#define smp_wmb() barrier()
-
/* Status byte for guest to report progress, and synchronize features. */
/* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
#define VIRTIO_CONFIG_S_ACKNOWLEDGE 1
diff --git a/src/memmap.h b/src/memmap.h
index c439982..9a59024 100644
--- a/src/memmap.h
+++ b/src/memmap.h
@@ -1,7 +1,14 @@
#ifndef __MEMMAP_H
#define __MEMMAP_H
+#include "types.h" // u32
+
// A typical OS page size
#define PAGE_SIZE 4096
+#define PAGE_SHIFT 12
+
+static inline u32 virt_to_phys(void *v) {
+ return (u32)v;
+}
#endif // memmap.h
diff --git a/src/x86.h b/src/x86.h
index 19d404f..53378e9 100644
--- a/src/x86.h
+++ b/src/x86.h
@@ -190,6 +190,14 @@ static inline void outsl(u16 port, u32 *data, u32 count) {
: "+c"(count), "+S"(data) : "d"(port) : "memory");
}
+/* Compiler barrier is enough as an x86 CPU does not reorder reads or writes */
+static inline void smp_rmb(void) {
+ barrier();
+}
+static inline void smp_wmb(void) {
+ barrier();
+}
+
static inline void writel(void *addr, u32 val) {
barrier();
*(volatile u32 *)addr = val;