#define __VIRTIO_CONFIG_H__
#include <uk/arch/types.h>
+#include <uk/config.h>
#include <uk/plat/common/cpu.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus __ */
-#define MAX_TRY_COUNT (10)
+#define MAX_TRY_COUNT 10
-#define VIRTIO_CONFIG_STATUS_RESET 0x0 /* Reset the device */
-#define VIRTIO_CONFIG_STATUS_ACK 0x1 /* recognize device as virtio */
-#define VIRTIO_CONFIG_STATUS_DRIVER 0x2 /* driver for the device found*/
-#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x4 /* initialization is complete */
-#define VIRTIO_CONFIG_STATUS_NEEDS_RESET 0x40 /* device needs reset */
-#define VIRTIO_CONFIG_STATUS_FAIL 0x80 /* device something's wrong*/
+#define VIRTIO_CONFIG_STATUS_RESET 0x0 /* device reset */
+#define VIRTIO_CONFIG_STATUS_ACK 0x1 /* device is virtio */
+#define VIRTIO_CONFIG_STATUS_DRIVER 0x2 /* driver found */
+#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x4 /* init complete */
+#define VIRTIO_CONFIG_STATUS_NEEDS_RESET 0x40 /* device needs reset */
+#define VIRTIO_CONFIG_STATUS_FAIL 0x80 /* device failure */
-#define VIRTIO_TRANSPORT_F_START 28
-#define VIRTIO_TRANSPORT_F_END 32
+#define VIRTIO_TRANSPORT_F_START 28
+#define VIRTIO_TRANSPORT_F_END 32
/* v1.0 compliant. */
-#define VIRTIO_F_VERSION_1 32
+#define VIRTIO_F_VERSION_1 32
-#ifdef __X86_64__
-static inline void _virtio_cwrite_bytes(const void *addr, const __u8 offset,
- const void *buf, int len, int type_len)
+#if CONFIG_ARCH_X86_64
+static inline void virtio_cwrite_bytes(const void *addr, const __u8 offset,
+ const void *buf, int len, int type_len)
{
int i = 0;
__u16 io_addr;
}
}
-static inline void _virtio_cread_bytes(const void *addr, const __u8 offset,
- void *buf, int len, int type_len)
+static inline void virtio_cread_bytes(const void *addr, const __u8 offset,
+ void *buf, int len, int type_len)
{
int i = 0;
__u16 io_addr;
}
}
}
-#else /* __X86_64__ */
+#else /* !CONFIG_ARCH_X86_64 */
/* IO barriers */
#define __iormb() rmb()
#define __iowmb() wmb()
-static inline void _virtio_cwrite_bytes(const void *addr, const __u8 offset,
- const void *buf, int len, int type_len)
+static inline void virtio_cwrite_bytes(const void *addr, const __u8 offset,
+ const void *buf, int len, int type_len)
{
int i = 0;
void *io_addr;
}
}
-static inline void _virtio_cread_bytes(const void *addr, const __u8 offset,
- void *buf, int len, int type_len)
+static inline void virtio_cread_bytes(const void *addr, const __u8 offset,
+ void *buf, int len, int type_len)
{
int i = 0;
void *io_addr;
}
}
-#endif /* __X86_64__ */
+#endif /* !CONFIG_ARCH_X86_64 */
/**
* Read the virtio device configuration of specified length.
do {
check = len;
- _virtio_cread_bytes(addr, offset, &old_buf[0], len, 1);
- _virtio_cread_bytes(addr, offset, buf, len, 1);
+ virtio_cread_bytes(addr, offset, &old_buf[0], len, 1);
+ virtio_cread_bytes(addr, offset, buf, len, 1);
for (i = 0; i < len; i++) {
if (unlikely(buf[i] != old_buf[i])) {
{
__u8 buf = 0;
- _virtio_cread_bytes(addr, offset, &buf, sizeof(buf), sizeof(buf));
+ virtio_cread_bytes(addr, offset, &buf, sizeof(buf), sizeof(buf));
return buf;
}
{
__u16 buf = 0;
- _virtio_cread_bytes(addr, offset, &buf, sizeof(buf), sizeof(buf));
+ virtio_cread_bytes(addr, offset, &buf, sizeof(buf), sizeof(buf));
return buf;
}
{
__u32 buf = 0;
- _virtio_cread_bytes(addr, offset, &buf, sizeof(buf), sizeof(buf));
+ virtio_cread_bytes(addr, offset, &buf, sizeof(buf), sizeof(buf));
return buf;
}
static inline void virtio_cwrite8(const void *addr, const __u8 offset,
const __u8 data)
{
- _virtio_cwrite_bytes(addr, offset, &data, sizeof(data), sizeof(data));
+ virtio_cwrite_bytes(addr, offset, &data, sizeof(data), sizeof(data));
}
/**
static inline void virtio_cwrite16(const void *addr, const __u8 offset,
const __u16 data)
{
- _virtio_cwrite_bytes(addr, offset, &data, sizeof(data), sizeof(data));
+ virtio_cwrite_bytes(addr, offset, &data, sizeof(data), sizeof(data));
}
/**
static inline void virtio_cwrite32(const void *addr, const __u8 offset,
const __u32 data)
{
- _virtio_cwrite_bytes(addr, offset, &data, sizeof(data), sizeof(data));
+ virtio_cwrite_bytes(addr, offset, &data, sizeof(data), sizeof(data));
}
#ifdef __cplusplus