1CMDLINE_SIZE ?= 0x400 2BOOTSTUB_SIZE ?= 8192 3 4BOOTSTUB_SRC_FILES := bootstub.c sfi.c ssp-uart.c imr_toc.c spi-uart.c 5BOOTSTUB_SRC_FILES_x86 := head.S e820_bios.S 6 7ifeq ($(TARGET_IS_64_BIT),true) 8BOOTSTUB_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX) 9else 10BOOTSTUB_2ND_ARCH_VAR_PREFIX := 11endif 12 13LOCAL_SRC_FILES := $(BOOTSTUB_SRC_FILES) 14LOCAL_SRC_FILES_x86 := $(BOOTSTUB_SRC_FILES_x86) 15ANDROID_TOOLCHAIN_FLAGS := -m32 -ffreestanding 16LOCAL_CFLAGS := $(ANDROID_TOOLCHAIN_FLAGS) -Wall -O1 -DCMDLINE_SIZE=${CMDLINE_SIZE} -DAOSP_HEADER_ADDRESS=$(BOOTSTUB_AOSP_HEADER_ADDRESS) $(BOOTSTUB_CFLAGS) 17LOCAL_CFLAGS += -Werror 18LOCAL_ASFLAGS := -DSTACK_OFFSET=$(BOOTSTUB_STACK_OFFSET) 19LOCAL_HEADER_LIBRARIES = bootimg_headers 20LOCAL_MODULE := $(BOOTSTUB_BINARY).bin 21LOCAL_MODULE_TAGS := optional 22LOCAL_MULTILIB := 32 23LOCAL_MODULE_PATH := $(PRODUCT_OUT) 24LOCAL_MODULE_CLASS := EXECUTABLES 25LOCAL_FORCE_STATIC_EXECUTABLE := true 26LOCAL_2ND_ARCH_VAR_PREFIX := $(BOOTSTUB_2ND_ARCH_VAR_PREFIX) 27 28include $(BUILD_SYSTEM)/binary.mk 29 30$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(LOCAL_CFLAGS) 31$(LOCAL_BUILT_MODULE) : PRIVATE_ELF_FILE := $(intermediates)/$(PRIVATE_MODULE).elf 32$(LOCAL_BUILT_MODULE) : PRIVATE_LINK_SCRIPT := $(LOCAL_PATH)/2ndbootloader.lds 33$(LOCAL_BUILT_MODULE) : BOOTSTUB_OBJS := $(patsubst %.c, %.o , $(LOCAL_SRC_FILES)) 34$(LOCAL_BUILT_MODULE) : BOOTSTUB_OBJS += $(patsubst %.S, %.o , $(LOCAL_SRC_FILES_x86)) 35$(LOCAL_BUILT_MODULE) : BOOTSTUB_OBJS := $(addprefix $(intermediates)/, $(BOOTSTUB_OBJS)) 36$(LOCAL_BUILT_MODULE) : BOOTSTUB_ENTRY := $(BOOTSTUB_ENTRY) 37 38$(LOCAL_BUILT_MODULE): $(all_objects) 39 $(hide) mkdir -p $(dir $@) 40 @echo "Generating bootstub.bin: $@" 41 $(hide) $(TARGET_LD) \ 42 -m elf_i386 \ 43 -T $(PRIVATE_LINK_SCRIPT) --defsym=BOOTSTUB_ENTRY=$(BOOTSTUB_ENTRY) \ 44 $(BOOTSTUB_OBJS) \ 45 -o $(PRIVATE_ELF_FILE) 46 $(hide) $(TARGET_OBJCOPY) -O binary -R .note -R .comment -S $(PRIVATE_ELF_FILE) $@ 47 48$(LOCAL_BUILT_MODULE).size_check: $(LOCAL_BUILT_MODULE) 49 $(hide) ACTUAL_SIZE=`$(call get-file-size,$<)`; \ 50 if [ "$$ACTUAL_SIZE" -gt "$(BOOTSTUB_SIZE)" ]; then \ 51 echo "$<: $$ACTUAL_SIZE exceeds size limit of $(BOOTSTUB_SIZE) bytes, aborting."; \ 52 exit 1; \ 53 fi 54 $(hide) touch $@ 55 56# Then assemble the final bootstub file 57bootstub_full := $(PRODUCT_OUT)/$(BOOTSTUB_BINARY) 58$(bootstub_full) : $(LOCAL_BUILT_MODULE) $(LOCAL_BUILT_MODULE).size_check 59 @echo "Generating bootstub: $@" 60 $(hide) cat $< /dev/zero | dd bs=$(BOOTSTUB_SIZE) count=1 > $@ 61 62