mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-25 23:13:26 +00:00
hv: code style fix for partition mode specific code
There are still some misra-c violations when CONFIG_PARTITION_MODE is defined. arch/x86/configs: - remove the unused macro: PRE_LAUNCH_VM_NUM - pt_dev.c: VMx_CONFIG_PCI_PTDEV_NUM has been defined in partition_config.h, should not hard code them again in pt_dev.c. - ve820.c: use "UL" suffix instead of "U" for 64 bits variables. vmid is uint16_t in ACRN, so vuart_vmid should be uint16_t as well. Fix another few other miscellaneous misra-c violations. Tracked-On: #861 Signed-off-by: Zide Chen <zide.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
8478a328a3
commit
94e1227559
@ -7,8 +7,6 @@
|
|||||||
#ifndef PARTITION_CONFIG_H
|
#ifndef PARTITION_CONFIG_H
|
||||||
#define PARTITION_CONFIG_H
|
#define PARTITION_CONFIG_H
|
||||||
|
|
||||||
#define PRE_LAUNCH_VM_NUM 2
|
|
||||||
|
|
||||||
#define VM0_CONFIGURED
|
#define VM0_CONFIGURED
|
||||||
|
|
||||||
#define VM0_CONFIG_NAME "PRE-LAUNCHED VM1 for APL-MRB"
|
#define VM0_CONFIG_NAME "PRE-LAUNCHED VM1 for APL-MRB"
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
|
#include <partition_config.h>
|
||||||
|
|
||||||
struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[2] = {
|
struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM] = {
|
||||||
{
|
{
|
||||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
@ -17,7 +18,7 @@ struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[2] = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[3] = {
|
struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM] = {
|
||||||
{
|
{
|
||||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
|
@ -8,32 +8,32 @@
|
|||||||
|
|
||||||
const struct e820_entry ve820_entry[E820_MAX_ENTRIES] = {
|
const struct e820_entry ve820_entry[E820_MAX_ENTRIES] = {
|
||||||
{ /* 0 to mptable */
|
{ /* 0 to mptable */
|
||||||
.baseaddr = 0x0U,
|
.baseaddr = 0x0UL,
|
||||||
.length = 0xEFFFFU,
|
.length = 0xEFFFFUL,
|
||||||
.type = E820_TYPE_RAM
|
.type = E820_TYPE_RAM
|
||||||
},
|
},
|
||||||
|
|
||||||
{ /* mptable 65536U */
|
{ /* mptable 65536U */
|
||||||
.baseaddr = 0xF0000U,
|
.baseaddr = 0xF0000UL,
|
||||||
.length = 0x10000U,
|
.length = 0x10000UL,
|
||||||
.type = E820_TYPE_RESERVED
|
.type = E820_TYPE_RESERVED
|
||||||
},
|
},
|
||||||
|
|
||||||
{ /* mptable to lowmem */
|
{ /* mptable to lowmem */
|
||||||
.baseaddr = 0x100000U,
|
.baseaddr = 0x100000UL,
|
||||||
.length = 0x1FF00000U,
|
.length = 0x1FF00000UL,
|
||||||
.type = E820_TYPE_RAM
|
.type = E820_TYPE_RAM
|
||||||
},
|
},
|
||||||
|
|
||||||
{ /* lowmem to PCI hole */
|
{ /* lowmem to PCI hole */
|
||||||
.baseaddr = 0x20000000U,
|
.baseaddr = 0x20000000UL,
|
||||||
.length = 0xa0000000U,
|
.length = 0xa0000000UL,
|
||||||
.type = E820_TYPE_RESERVED
|
.type = E820_TYPE_RESERVED
|
||||||
},
|
},
|
||||||
|
|
||||||
{ /* PCI hole to 4G */
|
{ /* PCI hole to 4G */
|
||||||
.baseaddr = 0xe0000000U,
|
.baseaddr = 0xe0000000UL,
|
||||||
.length = 0x20000000U,
|
.length = 0x20000000UL,
|
||||||
.type = E820_TYPE_RESERVED
|
.type = E820_TYPE_RESERVED
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
#ifndef PARTITION_CONFIG_H
|
#ifndef PARTITION_CONFIG_H
|
||||||
#define PARTITION_CONFIG_H
|
#define PARTITION_CONFIG_H
|
||||||
|
|
||||||
#define PRE_LAUNCH_VM_NUM 2
|
|
||||||
|
|
||||||
#define VM0_CONFIGURED
|
#define VM0_CONFIGURED
|
||||||
|
|
||||||
#define VM0_CONFIG_NAME "PRE-LAUNCHED VM1 for DNV-CB2"
|
#define VM0_CONFIG_NAME "PRE-LAUNCHED VM1 for DNV-CB2"
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
|
#include <partition_config.h>
|
||||||
|
|
||||||
struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[3] = {
|
struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM] = {
|
||||||
{
|
{
|
||||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
@ -21,7 +22,7 @@ struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[3] = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[3] = {
|
struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM] = {
|
||||||
{
|
{
|
||||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
|
@ -8,32 +8,32 @@
|
|||||||
|
|
||||||
const struct e820_entry ve820_entry[E820_MAX_ENTRIES] = {
|
const struct e820_entry ve820_entry[E820_MAX_ENTRIES] = {
|
||||||
{ /* 0 to mptable */
|
{ /* 0 to mptable */
|
||||||
.baseaddr = 0x0U,
|
.baseaddr = 0x0UL,
|
||||||
.length = 0xEFFFFU,
|
.length = 0xEFFFFUL,
|
||||||
.type = E820_TYPE_RAM
|
.type = E820_TYPE_RAM
|
||||||
},
|
},
|
||||||
|
|
||||||
{ /* mptable 65536U */
|
{ /* mptable 65536U */
|
||||||
.baseaddr = 0xF0000U,
|
.baseaddr = 0xF0000UL,
|
||||||
.length = 0x10000U,
|
.length = 0x10000UL,
|
||||||
.type = E820_TYPE_RESERVED
|
.type = E820_TYPE_RESERVED
|
||||||
},
|
},
|
||||||
|
|
||||||
{ /* mptable to lowmem */
|
{ /* mptable to lowmem */
|
||||||
.baseaddr = 0x100000U,
|
.baseaddr = 0x100000UL,
|
||||||
.length = 0x7FF00000U,
|
.length = 0x7FF00000UL,
|
||||||
.type = E820_TYPE_RAM
|
.type = E820_TYPE_RAM
|
||||||
},
|
},
|
||||||
|
|
||||||
{ /* lowmem to PCI hole */
|
{ /* lowmem to PCI hole */
|
||||||
.baseaddr = 0x80000000U,
|
.baseaddr = 0x80000000UL,
|
||||||
.length = 0x40000000U,
|
.length = 0x40000000UL,
|
||||||
.type = E820_TYPE_RESERVED
|
.type = E820_TYPE_RESERVED
|
||||||
},
|
},
|
||||||
|
|
||||||
{ /* PCI hole to 4G */
|
{ /* PCI hole to 4G */
|
||||||
.baseaddr = 0xe0000000U,
|
.baseaddr = 0xe0000000UL,
|
||||||
.length = 0x20000000U,
|
.length = 0x20000000UL,
|
||||||
.type = E820_TYPE_RESERVED
|
.type = E820_TYPE_RESERVED
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -106,7 +106,7 @@ static inline uint16_t get_vm_bsp_pcpu_id(const struct acrn_vm_config *vm_config
|
|||||||
/**
|
/**
|
||||||
* @pre vm_config != NULL
|
* @pre vm_config != NULL
|
||||||
*/
|
*/
|
||||||
uint16_t get_vm_pcpu_nums(struct acrn_vm_config *vm_config)
|
uint16_t get_vm_pcpu_nums(const struct acrn_vm_config *vm_config)
|
||||||
{
|
{
|
||||||
uint16_t i, host_pcpu_num, pcpu_num = 0U;
|
uint16_t i, host_pcpu_num, pcpu_num = 0U;
|
||||||
uint64_t cpu_bitmap = vm_config->pcpu_bitmap;
|
uint64_t cpu_bitmap = vm_config->pcpu_bitmap;
|
||||||
@ -315,7 +315,7 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
|
|||||||
ept_mr_add(vm, (uint64_t *)vm->arch_vm.nworld_eptp,
|
ept_mr_add(vm, (uint64_t *)vm->arch_vm.nworld_eptp,
|
||||||
vm_config->memory.start_hpa, 0UL, vm_config->memory.size,
|
vm_config->memory.start_hpa, 0UL, vm_config->memory.size,
|
||||||
EPT_RWX|EPT_WB);
|
EPT_RWX|EPT_WB);
|
||||||
init_vm_boot_info(vm);
|
(void)init_vm_boot_info(vm);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,7 +549,7 @@ void prepare_vm(uint16_t vm_id, struct acrn_vm_config *vm_config)
|
|||||||
|
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
mptable_build(vm);
|
(void)mptable_build(vm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0U; i < get_pcpu_nums(); i++) {
|
for (i = 0U; i < get_pcpu_nums(); i++) {
|
||||||
|
@ -46,7 +46,7 @@ static char vuart_tx_buf[TX_BUF_SIZE];
|
|||||||
#define vuart_unlock(vu) spinlock_release(&((vu)->lock))
|
#define vuart_unlock(vu) spinlock_release(&((vu)->lock))
|
||||||
|
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
int8_t vuart_vmid = - 1;
|
uint16_t vuart_vmid = 0xFFFFU;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void fifo_reset(struct fifo *fifo)
|
static inline void fifo_reset(struct fifo *fifo)
|
||||||
@ -372,16 +372,14 @@ void vuart_console_rx_chars(struct acrn_vuart *vu)
|
|||||||
|
|
||||||
struct acrn_vuart *vuart_console_active(void)
|
struct acrn_vuart *vuart_console_active(void)
|
||||||
{
|
{
|
||||||
|
struct acrn_vm *vm = NULL;
|
||||||
|
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
struct acrn_vm *vm;
|
if (vuart_vmid < CONFIG_MAX_VM_NUM) {
|
||||||
|
|
||||||
if (vuart_vmid == -1) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
vm = get_vm_from_vmid(vuart_vmid);
|
vm = get_vm_from_vmid(vuart_vmid);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
struct acrn_vm *vm = get_sos_vm();
|
vm = get_sos_vm();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vm != NULL) {
|
if (vm != NULL) {
|
||||||
|
@ -298,7 +298,7 @@ typedef int32_t (*vm_sw_loader_t)(struct acrn_vm *vm);
|
|||||||
extern vm_sw_loader_t vm_sw_loader;
|
extern vm_sw_loader_t vm_sw_loader;
|
||||||
|
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
uint16_t get_vm_pcpu_nums(struct acrn_vm_config *vm_config);
|
uint16_t get_vm_pcpu_nums(const struct acrn_vm_config *vm_config);
|
||||||
void vrtc_init(struct acrn_vm *vm);
|
void vrtc_init(struct acrn_vm *vm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ struct acrn_vuart {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
extern int8_t vuart_vmid;
|
extern uint16_t vuart_vmid;
|
||||||
#endif /* CONFIG_PARTITION_MODE */
|
#endif /* CONFIG_PARTITION_MODE */
|
||||||
|
|
||||||
struct acrn_vuart *vm_vuart(struct acrn_vm *vm);
|
struct acrn_vuart *vm_vuart(struct acrn_vm *vm);
|
||||||
|
Loading…
Reference in New Issue
Block a user