HV: config: adapt to the generated config.h

This patch drops "#include <bsp_cfg.h>" and include the generated config.h in
CFLAGS for the configuration data.

Also make sure that all configuration data have the 'CONFIG_' prefix.

v4 -> v5:

    * No changes.

v3 -> v4:

    * Add '-include config.h' to hypervisor/bsp/uefi/efi/Makefile.
    * Update comments mentioning bsp_cfg.h.

v2 -> v3:

    * Include config.h on the command line instead of in any header or source to
      avoid including config.h multiple times.
    * Add config.h as an additional dependency for source compilation.

v1 -> v2:

    * No changes.

Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
This commit is contained in:
Junjie Mao 2018-05-22 23:24:07 +08:00 committed by lijinxia
parent f9bb2024cc
commit c849bff850
17 changed files with 46 additions and 48 deletions

View File

@ -77,6 +77,7 @@ INCLUDE_PATH += include/common
INCLUDE_PATH += bsp/include
INCLUDE_PATH += bsp/$(PLATFORM)/include/bsp
INCLUDE_PATH += boot/include
INCLUDE_PATH += $(HV_OBJDIR)/include
CC ?= gcc
AS ?= as
@ -180,7 +181,7 @@ DISTCLEAN_OBJS := $(shell find $(BASEDIR) -name '*.o')
VERSION := bsp/$(PLATFORM)/include/bsp/version.h
.PHONY: all
all: $(BUILD_DEPS) $(VERSION) $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin
all: $(BUILD_DEPS) $(VERSION) oldconfig $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin
rm -f $(VERSION)
ifeq ($(PLATFORM), uefi)
@ -247,11 +248,10 @@ $(VERSION):
echo "#define HV_BUILD_TIME "\""$$TIME"\""" >> $(VERSION);\
echo "#define HV_BUILD_USER "\""$(USER)"\""" >> $(VERSION)
$(HV_OBJDIR)/%.o: %.c
$(HV_OBJDIR)/%.o: %.c $(HV_OBJDIR)/$(HV_CONFIG_H)
[ ! -e $@ ] && mkdir -p $(dir $@); \
$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -c $(CFLAGS) $(ARCH_CFLAGS) $< -o $@
$(HV_OBJDIR)/%.o: %.S
$(HV_OBJDIR)/%.o: %.S $(HV_OBJDIR)/$(HV_CONFIG_H)
[ ! -e $@ ] && mkdir -p $(dir $@); \
$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. $(ASFLAGS) $(ARCH_ASFLAGS) -c $< -o $@

View File

@ -424,7 +424,7 @@ void bsp_boot_init(void)
load_gdtr_and_tr();
/* Switch to run-time stack */
CPU_SP_WRITE(&get_cpu_var(stack)[STACK_SIZE - 1]);
CPU_SP_WRITE(&get_cpu_var(stack)[CONFIG_STACK_SIZE - 1]);
#ifdef STACK_PROTECTOR
set_fs_base();
@ -456,8 +456,8 @@ void bsp_boot_init(void)
calibrate_tsc();
/* Enable logging */
init_logmsg(LOG_BUF_SIZE,
LOG_DESTINATION);
init_logmsg(CONFIG_LOG_BUF_SIZE,
CONFIG_LOG_DESTINATION);
if (HV_RC_VERSION)
pr_acrnlog("HV version %d.%d-rc%d-%s-%s %s build by %s, start time %lluus",
@ -556,7 +556,7 @@ void cpu_secondary_init(void)
__bitmap_set(get_cpu_id(), &pcpu_active_bitmap);
/* Switch to run-time stack */
CPU_SP_WRITE(&get_cpu_var(stack)[STACK_SIZE - 1]);
CPU_SP_WRITE(&get_cpu_var(stack)[CONFIG_STACK_SIZE - 1]);
#ifdef STACK_PROTECTOR
set_fs_base();
@ -654,7 +654,7 @@ void start_cpus()
/* Wait until global count is equal to expected CPU up count or
* configured time-out has expired
*/
timeout = CPU_UP_TIMEOUT * 1000;
timeout = CONFIG_CPU_UP_TIMEOUT * 1000;
while ((up_count != expected_up) && (timeout != 0)) {
/* Delay 10us */
udelay(10);
@ -679,7 +679,7 @@ void stop_cpus()
int i;
uint32_t timeout, expected_up;
timeout = CPU_UP_TIMEOUT * 1000;
timeout = CONFIG_CPU_UP_TIMEOUT * 1000;
for (i = 0; i < phy_cpu_num; i++) {
if (get_cpu_id() == i) /* avoid offline itself */
continue;

View File

@ -34,9 +34,9 @@ void load_gdtr_and_tr(void)
/* ring 0 data sel descriptor */
gdt->host_gdt_data_descriptor.value = 0x00cf93000000ffff;
tss->ist1 = (uint64_t)get_cpu_var(mc_stack) + STACK_SIZE;
tss->ist2 = (uint64_t)get_cpu_var(df_stack) + STACK_SIZE;
tss->ist3 = (uint64_t)get_cpu_var(sf_stack) + STACK_SIZE;
tss->ist1 = (uint64_t)get_cpu_var(mc_stack) + CONFIG_STACK_SIZE;
tss->ist2 = (uint64_t)get_cpu_var(df_stack) + CONFIG_STACK_SIZE;
tss->ist3 = (uint64_t)get_cpu_var(sf_stack) + CONFIG_STACK_SIZE;
tss->ist4 = 0L;
/* tss descriptor */

View File

@ -304,7 +304,7 @@ void setup_ioapic_irq(void)
spinlock_init(&ioapic_lock);
for (ioapic_id = 0, gsi = 0; ioapic_id < NR_IOAPICS; ioapic_id++) {
for (ioapic_id = 0, gsi = 0; ioapic_id < CONFIG_NR_IOAPICS; ioapic_id++) {
int pin;
int max_pins;
int version;

View File

@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "bsp_cfg.h"
#ifdef CONFIG_DMAR_PARSE_ENABLED
#include <hypervisor.h>
#include "vtd.h"

View File

@ -1,4 +1,4 @@
#include "bsp_cfg.h"
#include "config.h"
ENTRY(cpu_primary_start_32)
@ -83,4 +83,3 @@ SECTIONS
_ld_ram_size = LENGTH(ram) ;
_ld_ram_end = _ld_ram_size + _ld_ram_start ;
}

View File

@ -36,7 +36,7 @@ HV_FILE:=acrn
EFI_OBJDIR:=$(HV_OBJDIR)/bsp/uefi/efi
C_SRCS = boot.c pe.c malloc.c
ACRN_OBJS := $(patsubst %.c,$(EFI_OBJDIR)/%.o,$(C_SRCS))
INCLUDE_PATH += ../include/bsp/
INCLUDE_PATH += $(HV_OBJDIR)/include
OBJCOPY=objcopy
@ -68,7 +68,8 @@ endif
CFLAGS=-I. -I.. -I$(INCDIR)/efi -I$(INCDIR)/efi/$(ARCH) \
-DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \
-Wall -I../fs/ -D$(ARCH) -O2
-Wall -I../fs/ -D$(ARCH) -O2 \
-include config.h
CFLAGS += -mno-mmx -mno-sse -mno-sse2 -mno-80387 -mno-fp-ret-in-387
@ -107,11 +108,11 @@ install-conf: $(CONF_FILE)
clean:
rm -f $(BOOT) $(HV_OBJDIR)/$(HV_FILE).efi $(EFI_OBJDIR)/boot.so $(ACRN_OBJS) $(FS)
$(EFI_OBJDIR)/%.o:%.S
$(EFI_OBJDIR)/%.o:%.S $(HV_OBJDIR)/$(HV_CONFIG_H)
[ ! -e $@ ] && mkdir -p $(dir $@); \
$(CC) $(CFLAGS) -c -o $@ $<
$(EFI_OBJDIR)/%.o: %.c
$(EFI_OBJDIR)/%.o: %.c $(HV_OBJDIR)/$(HV_CONFIG_H)
[ ! -e $@ ] && mkdir -p $(dir $@); \
$(CC) $(patsubst %, -I%, $(INCLUDE_PATH)) -I. -c $(CFLAGS) $(ARCH_CFLAGS) $< -o $@

View File

@ -380,7 +380,7 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *_table)
/*
* If we reach this point, it means we did not receive a specific
* bootloader name to be used. Fall back to the default bootloader
* as specified in bsp_cfg.h
* as specified in config.h
*/
bootloader_name = ch8_2_ch16(CONFIG_UEFI_OS_LOADER_NAME);
}
@ -454,4 +454,3 @@ failed:
return exit(image, err, ERROR_STRING_LENGTH, error_buf);
}

View File

@ -34,7 +34,6 @@
#ifndef __ACRNBOOT_H__
#define __ACRNBOOT_H__
#include <bsp_cfg.h>
#include "multiboot.h"
#define E820_RAM 1
@ -182,4 +181,3 @@ msr_read(uint32_t reg_num)
}
#endif

View File

@ -169,7 +169,7 @@ static void switch_to(struct vcpu *curr)
* reset stack pointer here. Otherwise, schedule
* is recursive call and stack will overflow finally.
*/
uint64_t cur_sp = (uint64_t)&get_cpu_var(stack)[STACK_SIZE];
uint64_t cur_sp = (uint64_t)&get_cpu_var(stack)[CONFIG_STACK_SIZE];
if (curr == NULL) {
asm volatile ("movq %1, %%rsp\n"

View File

@ -238,7 +238,7 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp, uint32_t cpu_id)
printf("Host Call Trace:\r\n");
if (rsp >
(uint64_t)&per_cpu(stack, cpu_id)[STACK_SIZE - 1]
(uint64_t)&per_cpu(stack, cpu_id)[CONFIG_STACK_SIZE - 1]
|| rsp < (uint64_t)&per_cpu(stack, cpu_id)[0]) {
return;
}
@ -257,7 +257,7 @@ static void show_host_call_trace(uint64_t rsp, uint64_t rbp, uint32_t cpu_id)
* if the address is invalid, it will cause hv page fault
* then halt system */
while ((rbp <=
(uint64_t)&per_cpu(stack, cpu_id)[STACK_SIZE - 1])
(uint64_t)&per_cpu(stack, cpu_id)[CONFIG_STACK_SIZE - 1])
&& (rbp >= (uint64_t)&per_cpu(stack, cpu_id)[0])
&& (cb_hierarchy++ < CALL_TRACE_HIERARCHY_MAX)) {
printf("----> 0x%016llx\r\n",

View File

@ -30,11 +30,11 @@
/* The initial log level*/
uint32_t console_loglevel;
uint32_t mem_loglevel;
#ifdef CONSOLE_LOGLEVEL_DEFAULT
uint32_t console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
#ifdef CONFIG_CONSOLE_LOGLEVEL_DEFAULT
uint32_t console_loglevel = CONFIG_CONSOLE_LOGLEVEL_DEFAULT;
#endif
#ifdef MEM_LOGLEVEL_DEFAULT
uint32_t mem_loglevel = MEM_LOGLEVEL_DEFAULT;
#ifdef CONFIG_MEM_LOGLEVEL_DEFAULT
uint32_t mem_loglevel = CONFIG_MEM_LOGLEVEL_DEFAULT;
#endif
static int string_to_argv(char *argv_str, void *p_argv_mem,

View File

@ -13,7 +13,7 @@
#define IOAPIC_MAX_LINES 120
#define NR_LEGACY_IRQ 16
#define NR_LEGACY_PIN NR_LEGACY_IRQ
#define NR_MAX_GSI (NR_IOAPICS*IOAPIC_MAX_LINES)
#define NR_MAX_GSI (CONFIG_NR_IOAPICS*IOAPIC_MAX_LINES)
#define GSI_MASK_IRQ(irq) irq_gsi_mask_unmask((irq), true)
#define GSI_UNMASK_IRQ(irq) irq_gsi_mask_unmask((irq), false)

View File

@ -32,10 +32,10 @@ struct per_cpu_region {
struct host_gdt gdt;
struct tss_64 tss;
int state;
uint8_t mc_stack[STACK_SIZE] __aligned(16);
uint8_t df_stack[STACK_SIZE] __aligned(16);
uint8_t sf_stack[STACK_SIZE] __aligned(16);
uint8_t stack[STACK_SIZE] __aligned(16);
uint8_t mc_stack[CONFIG_STACK_SIZE] __aligned(16);
uint8_t df_stack[CONFIG_STACK_SIZE] __aligned(16);
uint8_t sf_stack[CONFIG_STACK_SIZE] __aligned(16);
uint8_t stack[CONFIG_STACK_SIZE] __aligned(16);
char logbuf[LOG_MESSAGE_MAX_SIZE];
uint8_t lapic_id;
} __aligned(CPU_PAGE_SIZE); //per_cpu_region size aligned with CPU_PAGE_SIZE

View File

@ -12,8 +12,7 @@
*
* DESCRIPTION
*
* This file includes config header file "bsp_cfg.h" and other
* hypervisor used header files.
* This file includes hypervisor used header files.
* It should be included in all the source files.
*
*
@ -23,7 +22,6 @@
/* Include config header file containing config options */
#include <types.h>
#include "bsp_cfg.h"
#include "acrn_common.h"
#include <acrn_hv_defs.h>
#include <hv_lib.h>

View File

@ -6,14 +6,15 @@
#include <hypervisor.h>
/************************************************************************/
/* Memory pool declaration (block size = MALLOC_ALIGN) */
/* Memory pool declaration (block size = CONFIG_MALLOC_ALIGN) */
/************************************************************************/
#define __bss_noinit __attribute__((__section__(".bss_noinit")))
static uint8_t __bss_noinit Malloc_Heap[HEAP_SIZE] __aligned(MALLOC_ALIGN);
static uint8_t __bss_noinit
Malloc_Heap[CONFIG_HEAP_SIZE] __aligned(CONFIG_MALLOC_ALIGN);
#define MALLOC_HEAP_BUFF_SIZE MALLOC_ALIGN
#define MALLOC_HEAP_TOTAL_BUFF (HEAP_SIZE/MALLOC_HEAP_BUFF_SIZE)
#define MALLOC_HEAP_BUFF_SIZE CONFIG_MALLOC_ALIGN
#define MALLOC_HEAP_TOTAL_BUFF (CONFIG_HEAP_SIZE/MALLOC_HEAP_BUFF_SIZE)
#define MALLOC_HEAP_BITMAP_SIZE \
INT_DIV_ROUNDUP(MALLOC_HEAP_TOTAL_BUFF, BITMAP_WORD_SIZE)
static uint32_t Malloc_Heap_Bitmap[MALLOC_HEAP_BITMAP_SIZE];
@ -22,7 +23,7 @@ static uint32_t Malloc_Heap_Contiguity_Bitmap[MALLOC_HEAP_BITMAP_SIZE];
struct mem_pool Memory_Pool = {
.start_addr = Malloc_Heap,
.spinlock = {.head = 0, .tail = 0},
.size = HEAP_SIZE,
.size = CONFIG_HEAP_SIZE,
.buff_size = MALLOC_HEAP_BUFF_SIZE,
.total_buffs = MALLOC_HEAP_TOTAL_BUFF,
.bmp_size = MALLOC_HEAP_BITMAP_SIZE,
@ -34,10 +35,10 @@ struct mem_pool Memory_Pool = {
/* Memory pool declaration (block size = CPU_PAGE_SIZE) */
/************************************************************************/
static uint8_t __bss_noinit
Paging_Heap[NUM_ALLOC_PAGES][CPU_PAGE_SIZE] __aligned(CPU_PAGE_SIZE);
Paging_Heap[CONFIG_NUM_ALLOC_PAGES][CPU_PAGE_SIZE] __aligned(CPU_PAGE_SIZE);
#define PAGING_HEAP_BUFF_SIZE CPU_PAGE_SIZE
#define PAGING_HEAP_TOTAL_BUFF NUM_ALLOC_PAGES
#define PAGING_HEAP_TOTAL_BUFF CONFIG_NUM_ALLOC_PAGES
#define PAGING_HEAP_BITMAP_SIZE \
INT_DIV_ROUNDUP(PAGING_HEAP_TOTAL_BUFF, BITMAP_WORD_SIZE)
static uint32_t Paging_Heap_Bitmap[PAGING_HEAP_BITMAP_SIZE];
@ -46,7 +47,7 @@ static uint32_t Paging_Heap_Contiguity_Bitmap[MALLOC_HEAP_BITMAP_SIZE];
struct mem_pool Paging_Memory_Pool = {
.start_addr = Paging_Heap,
.spinlock = {.head = 0, .tail = 0},
.size = NUM_ALLOC_PAGES * CPU_PAGE_SIZE,
.size = CONFIG_NUM_ALLOC_PAGES * CPU_PAGE_SIZE,
.buff_size = PAGING_HEAP_BUFF_SIZE,
.total_buffs = PAGING_HEAP_TOTAL_BUFF,
.bmp_size = PAGING_HEAP_BITMAP_SIZE,

View File

@ -46,3 +46,5 @@ minimalconfig: $(HV_OBJDIR)/$(HV_CONFIG)
@python $(KCONFIG_DIR)/minimalconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) $(HV_OBJDIR)/$(HV_DEFCONFIG)
-include $(HV_OBJDIR)/$(HV_CONFIG_MK)
CFLAGS += -include $(HV_OBJDIR)/$(HV_CONFIG_H)