Commit 3fdf659d authored by Sasha Levin's avatar Sasha Levin Committed by Will Deacon
Browse files

kvm tools: Abolishment of uint*_t types



Clean uint*_t type from the code.

Signed-off-by: default avatarSasha Levin <levinsasha928@gmail.com>
Signed-off-by: default avatarPekka Enberg <penberg@kernel.org>
parent 3c8d07a7
......@@ -7,6 +7,7 @@
#include "kvm/term.h"
#include "kvm/kvm.h"
#include <linux/types.h>
#include <linux/serial_reg.h>
#include <pthread.h>
......@@ -14,20 +15,20 @@
struct serial8250_device {
pthread_mutex_t mutex;
uint16_t iobase;
uint8_t irq;
uint8_t rbr; /* receive buffer */
uint8_t dll;
uint8_t dlm;
uint8_t iir;
uint8_t ier;
uint8_t fcr;
uint8_t lcr;
uint8_t mcr;
uint8_t lsr;
uint8_t msr;
uint8_t scr;
u16 iobase;
u8 irq;
u8 rbr; /* receive buffer */
u8 dll;
u8 dlm;
u8 iir;
u8 ier;
u8 fcr;
u8 lcr;
u8 mcr;
u8 lsr;
u8 msr;
u8 scr;
};
static struct serial8250_device devices[] = {
......@@ -141,7 +142,7 @@ void serial8250__inject_sysrq(struct kvm *self)
sysrq_pending = SYSRQ_PENDING_BREAK;
}
static struct serial8250_device *find_device(uint16_t port)
static struct serial8250_device *find_device(u16 port)
{
unsigned int i;
......@@ -154,10 +155,10 @@ static struct serial8250_device *find_device(uint16_t port)
return NULL;
}
static bool serial8250_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
static bool serial8250_out(struct kvm *self, u16 port, void *data, int size, u32 count)
{
struct serial8250_device *dev;
uint16_t offset;
u16 offset;
bool ret = true;
dev = find_device(port);
......@@ -242,10 +243,10 @@ out_unlock:
return ret;
}
static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
static bool serial8250_in(struct kvm *self, u16 port, void *data, int size, u32 count)
{
struct serial8250_device *dev;
uint16_t offset;
u16 offset;
bool ret = true;
dev = find_device(port);
......@@ -288,7 +289,7 @@ static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size,
switch (offset) {
case UART_IIR: {
uint8_t iir = dev->iir;
u8 iir = dev->iir;
if (dev->fcr & UART_FCR_ENABLE_FIFO)
iir |= 0xc0;
......
......@@ -4,25 +4,25 @@
#include "kvm/bios.h"
#include "kvm/util.h"
static inline void set_fs(uint16_t seg)
static inline void set_fs(u16 seg)
{
asm volatile("movw %0,%%fs" : : "rm" (seg));
}
static inline uint8_t rdfs8(unsigned long addr)
static inline u8 rdfs8(unsigned long addr)
{
uint8_t v;
u8 v;
asm volatile("addr32 movb %%fs:%1,%0" : "=q" (v) : "m" (*(uint8_t *)addr));
asm volatile("addr32 movb %%fs:%1,%0" : "=q" (v) : "m" (*(u8 *)addr));
return v;
}
bioscall void e820_query_map(struct e820_query *query)
{
uint8_t map_size;
uint16_t fs_seg;
uint32_t ndx;
u8 map_size;
u16 fs_seg;
u32 ndx;
fs_seg = flat_to_seg16(E820_MAP_SIZE);
set_fs(fs_seg);
......@@ -34,7 +34,7 @@ bioscall void e820_query_map(struct e820_query *query)
if (ndx < map_size) {
unsigned long start;
unsigned int i;
uint8_t *p;
u8 *p;
fs_seg = flat_to_seg16(E820_MAP_START);
set_fs(fs_seg);
......
......@@ -8,7 +8,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <inttypes.h>
#include <linux/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <stdbool.h>
......@@ -17,7 +17,7 @@
#include <unistd.h>
#include <fcntl.h>
struct disk_image *disk_image__new(int fd, uint64_t size, struct disk_image_operations *ops)
struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops)
{
struct disk_image *self;
......@@ -31,7 +31,7 @@ struct disk_image *disk_image__new(int fd, uint64_t size, struct disk_image_oper
return self;
}
struct disk_image *disk_image__new_readonly(int fd, uint64_t size, struct disk_image_operations *ops)
struct disk_image *disk_image__new_readonly(int fd, u64 size, struct disk_image_operations *ops)
{
struct disk_image *self;
......@@ -45,23 +45,23 @@ struct disk_image *disk_image__new_readonly(int fd, uint64_t size, struct disk_i
return self;
}
static ssize_t raw_image__read_sector_iov(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount)
static ssize_t raw_image__read_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
{
uint64_t offset = sector << SECTOR_SHIFT;
u64 offset = sector << SECTOR_SHIFT;
return preadv_in_full(self->fd, iov, iovcount, offset);
}
static ssize_t raw_image__write_sector_iov(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount)
static ssize_t raw_image__write_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
{
uint64_t offset = sector << SECTOR_SHIFT;
u64 offset = sector << SECTOR_SHIFT;
return pwritev_in_full(self->fd, iov, iovcount, offset);
}
static int raw_image__read_sector_ro_mmap(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len)
static int raw_image__read_sector_ro_mmap(struct disk_image *self, u64 sector, void *dst, u32 dst_len)
{
uint64_t offset = sector << SECTOR_SHIFT;
u64 offset = sector << SECTOR_SHIFT;
if (offset + dst_len > self->size)
return -1;
......@@ -71,9 +71,9 @@ static int raw_image__read_sector_ro_mmap(struct disk_image *self, uint64_t sect
return 0;
}
static int raw_image__write_sector_ro_mmap(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len)
static int raw_image__write_sector_ro_mmap(struct disk_image *self, u64 sector, void *src, u32 src_len)
{
uint64_t offset = sector << SECTOR_SHIFT;
u64 offset = sector << SECTOR_SHIFT;
if (offset + src_len > self->size)
return -1;
......@@ -110,7 +110,7 @@ static struct disk_image *raw_image__probe(int fd, struct stat *st, bool readonl
static struct disk_image *blkdev__probe(const char *filename, struct stat *st)
{
uint64_t size;
u64 size;
int fd;
if (!S_ISBLK(st->st_mode))
......
......@@ -22,10 +22,10 @@
((reg) | (1 << (feature)))
struct cpuid_regs {
uint32_t eax;
uint32_t ebx;
uint32_t ecx;
uint32_t edx;
u32 eax;
u32 ebx;
u32 ecx;
u32 edx;
};
static inline void host_cpuid(struct cpuid_regs *regs)
......
#ifndef KVM__DISK_IMAGE_H
#define KVM__DISK_IMAGE_H
#include <stdint.h>
#include <linux/types.h>
#include <stdbool.h>
#include <sys/uio.h>
......@@ -11,36 +11,36 @@
struct disk_image;
struct disk_image_operations {
int (*read_sector)(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len);
int (*write_sector)(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len);
ssize_t (*read_sector_iov)(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount);
ssize_t (*write_sector_iov)(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount);
int (*read_sector)(struct disk_image *self, u64 sector, void *dst, u32 dst_len);
int (*write_sector)(struct disk_image *self, u64 sector, void *src, u32 src_len);
ssize_t (*read_sector_iov)(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount);
ssize_t (*write_sector_iov)(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount);
void (*close)(struct disk_image *self);
};
struct disk_image {
int fd;
uint64_t size;
u64 size;
struct disk_image_operations *ops;
void *priv;
};
struct disk_image *disk_image__open(const char *filename, bool readonly);
struct disk_image *disk_image__new(int fd, uint64_t size, struct disk_image_operations *ops);
struct disk_image *disk_image__new_readonly(int fd, uint64_t size, struct disk_image_operations *ops);
struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops);
struct disk_image *disk_image__new_readonly(int fd, u64 size, struct disk_image_operations *ops);
void disk_image__close(struct disk_image *self);
static inline int disk_image__read_sector(struct disk_image *self, uint64_t sector, void *dst, uint32_t dst_len)
static inline int disk_image__read_sector(struct disk_image *self, u64 sector, void *dst, u32 dst_len)
{
return self->ops->read_sector(self, sector, dst, dst_len);
}
static inline int disk_image__write_sector(struct disk_image *self, uint64_t sector, void *src, uint32_t src_len)
static inline int disk_image__write_sector(struct disk_image *self, u64 sector, void *src, u32 src_len)
{
return self->ops->write_sector(self, sector, src, src_len);
}
static inline ssize_t disk_image__read_sector_iov(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount)
static inline ssize_t disk_image__read_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
{
if (self->ops->read_sector_iov)
return self->ops->read_sector_iov(self, sector, iov, iovcount);
......@@ -54,7 +54,7 @@ static inline ssize_t disk_image__read_sector_iov(struct disk_image *self, uint6
return sector << SECTOR_SHIFT;
}
static inline ssize_t disk_image__write_sector_iov(struct disk_image *self, uint64_t sector, const struct iovec *iov, int iovcount)
static inline ssize_t disk_image__write_sector_iov(struct disk_image *self, u64 sector, const struct iovec *iov, int iovcount)
{
if (self->ops->write_sector_iov)
return self->ops->write_sector_iov(self, sector, iov, iovcount);
......
#ifndef KVM_E820_H
#define KVM_E820_H
#include <stdint.h>
#include <linux/types.h>
#define SMAP 0x534d4150 /* ASCII "SMAP" */
......@@ -11,17 +11,17 @@
#define E820_MEM_AREAS 4
struct e820_entry {
uint64_t addr; /* start of memory segment */
uint64_t size; /* size of memory segment */
uint32_t type; /* type of memory segment */
u64 addr; /* start of memory segment */
u64 size; /* size of memory segment */
u32 type; /* type of memory segment */
} __attribute__((packed));
struct e820_query {
uint32_t eax;
uint32_t ebx;
uint32_t edi;
uint32_t ecx;
uint32_t edx;
u32 eax;
u32 ebx;
u32 edi;
u32 ecx;
u32 edx;
};
void e820_query_map(struct e820_query *query);
......
#ifndef KVM__INTERRUPT_H
#define KVM__INTERRUPT_H
#include <inttypes.h>
#include <linux/types.h>
#include "kvm/bios.h"
#include "kvm/bios-export.h"
struct real_intr_desc {
uint16_t offset;
uint16_t segment;
u16 offset;
u16 segment;
} __attribute__((packed));
#define REAL_SEGMENT_SHIFT 4
......
......@@ -2,7 +2,8 @@
#define KVM__IOPORT_H
#include <stdbool.h>
#include <stdint.h>
#include <asm/types.h>
#include <linux/types.h>
/* some ports we reserve for own use */
#define IOPORT_DBG 0xe0
......@@ -18,40 +19,40 @@
struct kvm;
struct ioport_operations {
bool (*io_in)(struct kvm *self, uint16_t port, void *data, int size, uint32_t count);
bool (*io_out)(struct kvm *self, uint16_t port, void *data, int size, uint32_t count);
bool (*io_in)(struct kvm *self, u16 port, void *data, int size, u32 count);
bool (*io_out)(struct kvm *self, u16 port, void *data, int size, u32 count);
};
void ioport__setup_legacy(void);
void ioport__register(uint16_t port, struct ioport_operations *ops, int count);
void ioport__register(u16 port, struct ioport_operations *ops, int count);
static inline uint8_t ioport__read8(uint8_t *data)
static inline u8 ioport__read8(u8 *data)
{
return *data;
}
static inline uint16_t ioport__read16(uint16_t *data)
static inline u16 ioport__read16(u16 *data)
{
return *data;
}
static inline uint32_t ioport__read32(uint32_t *data)
static inline u32 ioport__read32(u32 *data)
{
return *data;
}
static inline void ioport__write8(uint8_t *data, uint8_t value)
static inline void ioport__write8(u8 *data, u8 value)
{
*data = value;
}
static inline void ioport__write16(uint16_t *data, uint16_t value)
static inline void ioport__write16(u16 *data, u16 value)
{
*data = value;
}
static inline void ioport__write32(uint32_t *data, uint32_t value)
static inline void ioport__write32(u32 *data, u32 value)
{
*data = value;
}
......
......@@ -4,7 +4,6 @@
#include <linux/kvm.h> /* for struct kvm_regs */
#include <pthread.h>
#include <stdint.h>
struct kvm;
......
......@@ -4,7 +4,7 @@
#include "kvm/interrupt.h"
#include <stdbool.h>
#include <stdint.h>
#include <linux/types.h>
#include <time.h>
#define KVM_NR_CPUS (255)
......@@ -16,14 +16,14 @@ struct kvm {
int nrcpus; /* Number of cpus to run */
uint64_t ram_size;
u64 ram_size;
void *ram_start;
bool nmi_disabled;
uint16_t boot_selector;
uint16_t boot_ip;
uint16_t boot_sp;
u16 boot_selector;
u16 boot_ip;
u16 boot_sp;
struct interrupt_table interrupt_table;
};
......@@ -37,8 +37,8 @@ void kvm__setup_bios(struct kvm *self);
void kvm__start_timer(struct kvm *self);
void kvm__stop_timer(struct kvm *self);
void kvm__irq_line(struct kvm *self, int irq, int level);
bool kvm__emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count);
bool kvm__emulate_mmio(struct kvm *self, uint64_t phys_addr, uint8_t *data, uint32_t len, uint8_t is_write);
bool kvm__emulate_io(struct kvm *self, u16 port, void *data, int direction, int size, u32 count);
bool kvm__emulate_mmio(struct kvm *self, u64 phys_addr, u8 *data, u32 len, u8 is_write);
/*
* Debugging
......@@ -52,9 +52,9 @@ static inline bool host_ptr_in_ram(struct kvm *self, void *p)
return self->ram_start <= p && p < (self->ram_start + self->ram_size);
}
static inline uint32_t segment_to_flat(uint16_t selector, uint16_t offset)
static inline u32 segment_to_flat(u16 selector, u16 offset)
{
return ((uint32_t)selector << 4) + (uint32_t) offset;
return ((u32)selector << 4) + (u32) offset;
}
static inline void *guest_flat_to_host(struct kvm *self, unsigned long offset)
......@@ -62,7 +62,7 @@ static inline void *guest_flat_to_host(struct kvm *self, unsigned long offset)
return self->ram_start + offset;
}
static inline void *guest_real_to_host(struct kvm *self, uint16_t selector, uint16_t offset)
static inline void *guest_real_to_host(struct kvm *self, u16 selector, u16 offset)
{
unsigned long flat = segment_to_flat(selector, offset);
......
#ifndef KVM__PCI_H
#define KVM__PCI_H
#include <inttypes.h>
#include <linux/types.h>
#include <linux/pci_regs.h>
......@@ -15,41 +15,41 @@
#define PCI_CONFIG_BUS_FORWARD 0xcfa
struct pci_config_address {
unsigned zeros : 2; /* 1 .. 0 */
unsigned register_number : 6; /* 7 .. 2 */
unsigned function_number : 3; /* 10 .. 8 */
unsigned device_number : 5; /* 15 .. 11 */
unsigned bus_number : 8; /* 23 .. 16 */
unsigned reserved : 7; /* 30 .. 24 */
unsigned enable_bit : 1; /* 31 */
unsigned zeros : 2; /* 1 .. 0 */
unsigned register_number : 6; /* 7 .. 2 */
unsigned function_number : 3; /* 10 .. 8 */
unsigned device_number : 5; /* 15 .. 11 */
unsigned bus_number : 8; /* 23 .. 16 */
unsigned reserved : 7; /* 30 .. 24 */
unsigned enable_bit : 1; /* 31 */
};
struct pci_device_header {
uint16_t vendor_id;
uint16_t device_id;
uint16_t command;
uint16_t status;
uint16_t revision_id : 8;
uint32_t class : 24;
uint8_t cacheline_size;
uint8_t latency_timer;
uint8_t header_type;
uint8_t bist;
uint32_t bar[6];
uint32_t card_bus;
uint16_t subsys_vendor_id;
uint16_t subsys_id;
uint32_t exp_rom_bar;
uint32_t capabilities : 8;
uint32_t reserved1 : 24;
uint32_t reserved2;
uint8_t irq_line;
uint8_t irq_pin;
uint8_t min_gnt;
uint8_t max_lat;
u16 vendor_id;
u16 device_id;
u16 command;
u16 status;
u16 revision_id : 8;
u32 class : 24;
u8 cacheline_size;
u8 latency_timer;
u8 header_type;
u8 bist;
u32 bar[6];
u32 card_bus;
u16 subsys_vendor_id;
u16 subsys_id;
u32 exp_rom_bar;
u32 capabilities : 8;
u32 reserved1 : 24;
u32 reserved2;
u8 irq_line;
u8 irq_pin;
u8 min_gnt;
u8 max_lat;
};
void pci__init(void);
void pci__register(struct pci_device_header *dev, uint8_t dev_num);
void pci__register(struct pci_device_header *dev, u8 dev_num);
#endif /* KVM__PCI_H */
......@@ -33,7 +33,7 @@ struct qcow_header {
u32 l1_size;
u8 cluster_bits;
u8 l2_bits;
uint64_t oflag_mask;
u64 oflag_mask;
};
struct qcow1_header_disk {
......
#ifndef KVM_SEGMENT_H
#define KVM_SEGMENT_H
#include <stdint.h>
#include <linux/types.h>
static inline uint16_t flat_to_seg16(uint32_t address)
static inline u16 flat_to_seg16(u32 address)
{
return address >> 4;
}
static inline uint16_t flat_to_off16(uint32_t address, uint32_t segment)
static inline u16 flat_to_off16(u32 address, u32 segment)
{
return address - (segment << 4);
}
......
#ifndef KVM__THREADPOOL_H
#define KVM__THREADPOOL_H
#include <stdint.h>
struct kvm;
typedef void (*kvm_thread_callback_fn_t)(struct kvm *kvm, void *data);
......
......@@ -3,25 +3,25 @@
#include <linux/virtio_ring.h>
#include <stdint.h>
#include <linux/types.h>
#include <sys/uio.h>
#include "kvm/kvm.h"
struct virt_queue {
struct vring vring;
uint32_t pfn;
struct vring vring;
u32 pfn;
/* The last_avail_idx field is an index to ->ring of struct vring_avail.
It's where we assume the next request index is at. */
uint16_t last_avail_idx;
u16 last_avail_idx;
};
static inline uint16_t virt_queue__pop(struct virt_queue *queue)
static inline u16 virt_queue__pop(struct virt_queue *queue)
{
return queue->vring.avail->ring[queue->last_avail_idx++ % queue->vring.num];
}
static inline struct vring_desc *virt_queue__get_desc(struct virt_queue *queue, uint16_t desc_ndx)
static inline struct vring_desc *virt_queue__get_desc(struct virt_queue *queue, u16 desc_ndx)
{
return &queue->vring.desc[desc_ndx];
}
......@@ -33,8 +33,8 @@ static inline bool virt_queue__available(struct virt_queue *vq)
return vq->vring.avail->idx != vq->last_avail_idx;