Clean up MISRA C violation

clean up a few MISRA C violations that can be fixed by code change in vboot files

Tracked-On: #861
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Jason Chen CJ 2019-05-08 20:20:54 +08:00 committed by Eddie Dong
parent d364d352f8
commit 7494ed2775
4 changed files with 23 additions and 18 deletions

View File

@ -271,7 +271,7 @@ switch_to_guest_mode(EFI_HANDLE image, EFI_PHYSICAL_ADDRESS hv_hpa)
if (addr < 4096) if (addr < 4096)
Print(L"Warning: CPU trampoline code buf occupied zero-page\n"); Print(L"Warning: CPU trampoline code buf occupied zero-page\n");
efi_ctx->ap_trampoline_buf = (void *)addr; efi_ctx->ap_trampoline_buf = addr;
config_table = sys_table->ConfigurationTable; config_table = sys_table->ConfigurationTable;

View File

@ -26,13 +26,13 @@ static void init_depri_boot(void)
struct multiboot_info *mbi = NULL; struct multiboot_info *mbi = NULL;
if (!depri_initialized) { if (!depri_initialized) {
parse_hv_cmdline(); (void)parse_hv_cmdline();
mbi = (struct multiboot_info *) hpa2hva(((uint64_t)(uint32_t)boot_regs[1])); mbi = (struct multiboot_info *) hpa2hva(((uint64_t)(uint32_t)boot_regs[1]));
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES) == 0U) { if ((mbi == NULL) || ((mbi->mi_flags & MULTIBOOT_INFO_HAS_DRIVES) == 0U)) {
pr_err("no multiboot drivers for depri_boot found"); pr_err("no multiboot drivers for depri_boot found");
} else { } else {
memcpy_s(&depri_boot_ctx, sizeof(struct depri_boot_context), (void)memcpy_s(&depri_boot_ctx, sizeof(struct depri_boot_context),
hpa2hva((uint64_t)mbi->mi_drives_addr), hpa2hva((uint64_t)mbi->mi_drives_addr),
sizeof(struct depri_boot_context)); sizeof(struct depri_boot_context));
save_lapic(&depri_boot_lapic_regs); save_lapic(&depri_boot_lapic_regs);
@ -55,7 +55,7 @@ const struct lapic_regs *get_depri_boot_lapic_regs(void)
static uint64_t get_depri_boot_ap_trampoline(void) static uint64_t get_depri_boot_ap_trampoline(void)
{ {
return (uint64_t)(depri_boot_ctx.ap_trampoline_buf); return depri_boot_ctx.ap_trampoline_buf;
} }
static void* get_depri_boot_rsdp(void) static void* get_depri_boot_rsdp(void)
@ -63,7 +63,7 @@ static void* get_depri_boot_rsdp(void)
return hpa2hva((uint64_t)(depri_boot_ctx.rsdp)); return hpa2hva((uint64_t)(depri_boot_ctx.rsdp));
} }
static void depri_boot_spurious_handler(int32_t vector) static void depri_boot_spurious_handler(uint32_t vector)
{ {
if (get_pcpu_id() == BOOT_CPU_ID) { if (get_pcpu_id() == BOOT_CPU_ID) {
struct acrn_vcpu *vcpu = per_cpu(vcpu, BOOT_CPU_ID); struct acrn_vcpu *vcpu = per_cpu(vcpu, BOOT_CPU_ID);

View File

@ -12,6 +12,7 @@
#include <vboot.h> #include <vboot.h>
#include <direct_boot.h> #include <direct_boot.h>
#include <deprivilege_boot.h> #include <deprivilege_boot.h>
#include <logmsg.h>
#define BOOTLOADER_NUM 4U #define BOOTLOADER_NUM 4U
#define BOOTLOADER_NAME_SIZE 20U #define BOOTLOADER_NAME_SIZE 20U
@ -42,18 +43,22 @@ void init_vboot_operations(void)
}; };
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1]); mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1]);
for (i = 0U; i < BOOTLOADER_NUM; i++) { if (mbi == NULL) {
if (strncmp(hpa2hva(mbi->mi_loader_name), vboot_bootloader_maps[i].bootloader_name, panic("No multiboot info");
strnlen_s(vboot_bootloader_maps[i].bootloader_name, BOOTLOADER_NAME_SIZE)) == 0) { } else {
/* Only support two vboot mode */ for (i = 0U; i < BOOTLOADER_NUM; i++) {
if (vboot_bootloader_maps[i].mode == DEPRI_BOOT_MODE) { if (strncmp(hpa2hva(mbi->mi_loader_name), vboot_bootloader_maps[i].bootloader_name,
vboot_ops = get_deprivilege_boot_ops(); strnlen_s(vboot_bootloader_maps[i].bootloader_name, BOOTLOADER_NAME_SIZE)) == 0) {
sos_boot_mode = DEPRI_BOOT_MODE; /* Only support two vboot mode */
} else { if (vboot_bootloader_maps[i].mode == DEPRI_BOOT_MODE) {
vboot_ops = get_direct_boot_ops(); vboot_ops = get_deprivilege_boot_ops();
sos_boot_mode = DIRECT_BOOT_MODE; sos_boot_mode = DEPRI_BOOT_MODE;
} else {
vboot_ops = get_direct_boot_ops();
sos_boot_mode = DIRECT_BOOT_MODE;
}
break;
} }
break;
} }
} }
} }

View File

@ -12,7 +12,7 @@
struct depri_boot_context { struct depri_boot_context {
struct acrn_vcpu_regs vcpu_regs; struct acrn_vcpu_regs vcpu_regs;
void *rsdp; void *rsdp;
void *ap_trampoline_buf; uint64_t ap_trampoline_buf;
} __packed; } __packed;
const struct depri_boot_context *get_depri_boot_ctx(void); const struct depri_boot_context *get_depri_boot_ctx(void);