Subrata Banik has uploaded this change for review.

View Change

Rampayload: Attempt to boot coreboot without ramstage

This patch makes below code changes to boot platform with
CONFIG_RAMPAYLOAD enable(without ramstage).

A. Able to compile ASL code in postcar.
B. Also add option to create smm.manual/smmstub.manual based on
$(TARGET_STAGE) variable.

$(TARGET_STAGE)=ramstage if user selects CONFIG_HAVE_RAMSTAGE
$(TARGET_STAGE)=postcar if user selects CONFIG_RAMPAYLOAD

C. Avoid compilation of ramstage specific files from x86/Makefile.inc
when !CONFIG_HAVE_RAMSTAGE.

D. Replace ENV_RAMSTAGE with ENV_PAYLOAD_LOADER to include required
functions incase CONFIG_RAMPAYLOAD is enable.

Change-Id: I22994c11317cf6936828c07fcac2cf14fca8a74b
Signed-off-by: Subrata Banik <subrata.banik@intel.com>
---
M Makefile.inc
M src/arch/x86/Makefile.inc
M src/cpu/x86/smm/Makefile.inc
M src/lib/program.ld
M src/mainboard/google/dragonegg/chromeos.c
M src/mainboard/intel/icelake_rvp/chromeos.c
6 files changed, 28 insertions(+), 28 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/76/34476/1
diff --git a/Makefile.inc b/Makefile.inc
index 2cad230..399dccc 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -252,6 +252,12 @@
# possibly true in many cases. In other cases it seems that an empty
# ResourceTemplate is the correct code.
# As it's valid ASL, disable the warning.
+ifeq ($(CONFIG_RAMPAYLOAD),y)
+TARGET_ASL_STAGE=postcar
+else
+TARGET_ASL_STAGE=ramstage
+endif
+
EMPTY_RESOURCE_TEMPLATE_WARNING = 3150
IGNORED_IASL_WARNINGS = -vw $(EMPTY_RESOURCE_TEMPLATE_WARNING)

@@ -263,7 +269,7 @@
-include $(obj)/$(1).d
$(obj)/$(1).aml: $(src)/mainboard/$(MAINBOARDDIR)/$(1).asl $(obj)/config.h
@printf " IASL $$(subst $(top)/,,$$(@))\n"
- $(CC_ramstage) -x assembler-with-cpp -E -MMD -MT $$(@) $$(CPPFLAGS_ramstage) -D__ACPI__ -P -include $(src)/include/kconfig.h -I$(obj) -I$(src) -I$(src)/include -I$(src)/arch/$(ARCHDIR-$(ARCH-ramstage-y))/include -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $(obj)/$(1).asl
+ $(CC_$(TARGET_ASL_STAGE)) -x assembler-with-cpp -E -MMD -MT $$(@) $$(CPPFLAGS_$(TARGET_ASL_STAGE)) -D__ACPI__ -P -include $(src)/include/kconfig.h -I$(obj) -I$(src) -I$(src)/include -I$(src)/arch/$(ARCHDIR-$(ARCH-$(TARGET_ASL_STAGE)-y))/include -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $(obj)/$(1).asl
cd $$(dir $$@); $(IASL) $(IGNORED_IASL_WARNINGS) -we -p $$(notdir $$@) $(1).asl
if ! $(IASL) -d $$@ 2>&1 | grep -Eq 'ACPI (Warning|Error)'; then \
echo " IASL $$@ disassembled correctly."; \
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 32e0173..c2ca697 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -302,7 +302,7 @@
# ramstage
###############################################################################

-ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
+ifeq ($(CONFIG_HAVE_RAMSTAGE),y)

ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpigen.c
diff --git a/src/cpu/x86/smm/Makefile.inc b/src/cpu/x86/smm/Makefile.inc
index 5c7aab3..4b227f5 100644
--- a/src/cpu/x86/smm/Makefile.inc
+++ b/src/cpu/x86/smm/Makefile.inc
@@ -13,15 +13,17 @@
## GNU General Public License for more details.
##

-ramstage-y += smm_module_loader.c
-
-ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
-$(eval $(call create_class_compiler,smm,x86_32))
-$(eval $(call create_class_compiler,smmstub,x86_32))
+ifeq ($(CONFIG_HAVE_RAMSTAGE),y)
+TARGET_STAGE=ramstage
+else ifeq ($(CONFIG_RAMPAYLOAD),y)
+TARGET_STAGE=postcar
else
-$(eval $(call create_class_compiler,smm,x86_64))
-$(eval $(call create_class_compiler,smmstub,x86_64))
+$(error Halting the build due to unknown TARGET_STAGE select)
endif
+$(TARGET_STAGE)-y += smm_module_loader.c
+
+$(eval $(call create_class_compiler,smm,$(ARCH-$(TARGET_STAGE)-y)))
+$(eval $(call create_class_compiler,smmstub,$(ARCH-$(TARGET_STAGE)-y)))

smmstub-generic-ccopts += -D__SMM__
smm-generic-ccopts += -D__SMM__
@@ -32,12 +34,12 @@

# change to the target path because objcopy will use the path name in its
# ELF symbol names.
-$(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smm.manual): $(obj)/smm/smm
+$(call src-to-obj,$(TARGET_STAGE),$(obj)/cpu/x86/smm/smm.manual): $(obj)/smm/smm
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
cd $(dir $<); $(OBJCOPY_smm) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)

ifeq ($(CONFIG_HAVE_SMI_HANDLER),y)
-ramstage-srcs += $(obj)/cpu/x86/smm/smm.manual
+$(TARGET_STAGE)-srcs += $(obj)/cpu/x86/smm/smm.manual
endif

ifeq ($(CONFIG_SMM_TSEG),y)
@@ -46,7 +48,7 @@

smm-y += smm_module_handler.c

-ramstage-srcs += $(obj)/cpu/x86/smm/smmstub.manual
+$(TARGET_STAGE)-srcs += $(obj)/cpu/x86/smm/smmstub.manual

# SMM Stub Module. The stub is used as a trampoline for relocation and normal
# SMM handling.
@@ -54,26 +56,18 @@
$(LD_smmstub) -nostdlib -r -o $@ $(COMPILER_RT_FLAGS_smmstub) --whole-archive --start-group $(smmstub-objs) --no-whole-archive $(COMPILER_RT_smmstub) --end-group

# Link the SMM stub module with a 0-byte heap.
-ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
-$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o, 0,x86_32))
-else
-$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o, 0,x86_64))
-endif
+$(eval $(call rmodule_link,$(obj)/smmstub/smmstub.elf, $(obj)/smmstub/smmstub.o, 0,$(ARCH-$(TARGET_STAGE)-y)))

$(obj)/smmstub/smmstub: $(obj)/smmstub/smmstub.elf.rmod
$(OBJCOPY_smmstub) -O binary $< $@

-$(call src-to-obj,ramstage,$(obj)/cpu/x86/smm/smmstub.manual): $(obj)/smmstub/smmstub
+$(call src-to-obj,$(TARGET_STAGE),$(obj)/cpu/x86/smm/smmstub.manual): $(obj)/smmstub/smmstub
@printf " OBJCOPY $(subst $(obj)/,,$(@))\n"
cd $(dir $<); $(OBJCOPY_smmstub) -I binary $(notdir $<) $(target-objcopy) $(abspath $@)

# C-based SMM handler.

-ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
-$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_32))
-else
-$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),x86_64))
-endif
+$(eval $(call rmodule_link,$(obj)/smm/smm.elf, $(obj)/smm/smm.o, $(CONFIG_SMM_MODULE_HEAP_SIZE),$(ARCH-$(TARGET_STAGE)-y)))

$(obj)/smm/smm: $(obj)/smm/smm.elf.rmod
$(OBJCOPY_smm) -O binary $< $@
diff --git a/src/lib/program.ld b/src/lib/program.ld
index 851aa75..66421d1 100644
--- a/src/lib/program.ld
+++ b/src/lib/program.ld
@@ -55,7 +55,7 @@
KEEP(*(.rsbe_init));
_ersbe_init_begin = .;

-#if ENV_RAMSTAGE
+#if ENV_PAYLOAD_LOADER
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_pci_drivers = .;
KEEP(*(.rodata.pci_driver));
diff --git a/src/mainboard/google/dragonegg/chromeos.c b/src/mainboard/google/dragonegg/chromeos.c
index 7132b04..7ef8070 100644
--- a/src/mainboard/google/dragonegg/chromeos.c
+++ b/src/mainboard/google/dragonegg/chromeos.c
@@ -21,7 +21,7 @@

#include <variant/gpio.h>

-#if ENV_RAMSTAGE
+#if ENV_PAYLOAD_LOADER
#include <boot/coreboot_tables.h>

void fill_lb_gpios(struct lb_gpios *gpios)
@@ -36,7 +36,7 @@
};
lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
}
-#endif /* ENV_RAMSTAGE */
+#endif /* ENV_PAYLOAD_LOADER */

int get_write_protect_state(void)
{
diff --git a/src/mainboard/intel/icelake_rvp/chromeos.c b/src/mainboard/intel/icelake_rvp/chromeos.c
index ce8e548..127903b 100644
--- a/src/mainboard/intel/icelake_rvp/chromeos.c
+++ b/src/mainboard/intel/icelake_rvp/chromeos.c
@@ -20,7 +20,7 @@
#include <variant/gpio.h>
#include <vendorcode/google/chromeos/chromeos.h>

-#if ENV_RAMSTAGE
+#if ENV_PAYLOAD_LOADER
#include <boot/coreboot_tables.h>

void fill_lb_gpios(struct lb_gpios *gpios)
@@ -33,7 +33,7 @@
};
lb_add_gpios(gpios, chromeos_gpios, ARRAY_SIZE(chromeos_gpios));
}
-#endif /* ENV_RAMSTAGE */
+#endif /* ENV_PAYLOAD_LOADER */

int get_lid_switch(void)
{

To view, visit change 34476. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I22994c11317cf6936828c07fcac2cf14fca8a74b
Gerrit-Change-Number: 34476
Gerrit-PatchSet: 1
Gerrit-Owner: Subrata Banik <subrata.banik@intel.com>
Gerrit-MessageType: newchange