HV: Avoiding assignment opperation inside macro

To follow the Misra-c standard, the assignment operation inside
function-like macro should be avoided. Replaced the violations
macro using inline function instead.

Signed-off-by: Yang, Yu-chu <yu-chu.yang@intel.com>
This commit is contained in:
Yang, Yu-chu
2018-06-22 15:44:48 -07:00
committed by lijinxia
parent 688b0cdb9c
commit 0419816574
8 changed files with 48 additions and 32 deletions

View File

@@ -273,7 +273,10 @@ struct vcpu {
#define is_vcpu_bsp(vcpu) ((vcpu)->vcpu_id == 0)
/* do not update Guest RIP for next VM Enter */
#define VCPU_RETAIN_RIP(vcpu) ((vcpu)->arch_vcpu.inst_len = 0)
static inline void vcpu_retain_rip(struct vcpu *vcpu)
{
(vcpu)->arch_vcpu.inst_len = 0;
}
/* External Interfaces */
struct vcpu* get_ever_run_vcpu(uint16_t pcpu_id);

View File

@@ -257,19 +257,32 @@ enum _page_table_present {
#define PAGE_SIZE_2M MEM_2M
#define PAGE_SIZE_1G MEM_1G
/* Macros for reading/writing memory */
/* Macros for reading memory */
#define MEM_READ8(addr) (*(volatile uint8_t *)(addr))
#define MEM_WRITE8(addr, data) \
(*(volatile uint8_t *)(addr) = (uint8_t)(data))
#define MEM_READ16(addr) (*(volatile uint16_t *)(addr))
#define MEM_WRITE16(addr, data) \
(*(volatile uint16_t *)(addr) = (uint16_t)(data))
#define MEM_READ32(addr) (*(volatile uint32_t *)(addr))
#define MEM_WRITE32(addr, data) \
(*(volatile uint32_t *)(addr) = (uint32_t)(data))
#define MEM_READ64(addr) (*(volatile uint64_t *)(addr))
#define MEM_WRITE64(addr, data) \
(*(volatile uint64_t *)(addr) = (uint64_t)(data))
/* Inline functions for writing memory */
static inline void mem_write8(void *addr, uint8_t data)
{
*(volatile uint8_t *)(addr) = (uint8_t)(data);
}
static inline void mem_write16(void *addr, uint16_t data)
{
*(volatile uint16_t *)(addr) = (uint16_t)(data);
}
static inline void mem_write32(void *addr, uint32_t data)
{
*(volatile uint32_t *)(addr) = (uint32_t)(data);
}
static inline void mem_write64(void *addr, uint64_t data)
{
*(volatile uint64_t *)(addr) = (uint64_t)(data);
}
/* Typedef for MMIO handler and range check routine */
typedef int(*hv_mem_io_handler_t)(struct vcpu *, struct mem_io *, void *);