mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
further. It is only tested with my Kconfig build dir fixes applied. Not sure how pretty this is. All the mkdirs increase build time by 0.2s, so it looks a lot more nasty than it actually is. If wishes, we can create the whole directory structure below build in the "prepare" target. It's not faster, but more limited to one place. The next step could be to spread out *_LIB_OBJ to lib/Makefile. in which case it is nice that you can just write object.o instead of $(obj)/object.o or $(obj)/lib/object.o ... The top level modules (initram, stage0, stage2, ..) are still in $(obj). So are the northbridge and southbridge object files - These require some more cleanup anyways, as they're defined in the mainboard Makefile. Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@242 f3766cd6-281f-0410-b1cd-43a5c92072e9
159 lines
5.3 KiB
Makefile
159 lines
5.3 KiB
Makefile
##
|
|
## This file is part of the LinuxBIOS project.
|
|
##
|
|
## Copyright (C) 2006-2007 coresystems GmbH
|
|
## Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH.
|
|
##
|
|
## This program is free software; you can redistribute it and/or modify
|
|
## it under the terms of the GNU General Public License as published by
|
|
## the Free Software Foundation; either version 2 of the License, or
|
|
## (at your option) any later version.
|
|
##
|
|
## This program is distributed in the hope that it will be useful,
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
## GNU General Public License for more details.
|
|
##
|
|
## You should have received a copy of the GNU General Public License
|
|
## along with this program; if not, write to the Free Software
|
|
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
##
|
|
|
|
ifeq ($(CONFIG_ARCH_X86),y)
|
|
|
|
INITCFLAGS := $(CFLAGS) -I$(src)/include/cpu/generic/x86 -I$(src)/include \
|
|
-fno-builtin
|
|
|
|
SILENT := &> /dev/null
|
|
|
|
#
|
|
# Build the ROM Image / LAR archive
|
|
#
|
|
# LinuxBIOS v3 is completely modular. One module, the bootblock (stage0),
|
|
# is mandatory. All modules are packed together in a LAR archive.
|
|
# The LAR archive may contain any number of stages, payloads and option ROMs.
|
|
#
|
|
|
|
ROM_SIZE := $(shell expr $(CONFIG_LINUXBIOS_ROMSIZE_KB) \* 1024 )
|
|
|
|
$(obj)/linuxbios.rom: $(obj)/linuxbios.bootblock $(obj)/util/lar/lar lzma $(obj)/linuxbios.initram $(obj)/linuxbios.stage2 payload
|
|
$(Q)printf "Building LinuxBIOS image... \n"
|
|
$(Q)rm -rf $(obj)/lar.tmp
|
|
$(Q)mkdir $(obj)/lar.tmp
|
|
$(Q)mkdir $(obj)/lar.tmp/normal
|
|
$(Q)cp $(obj)/linuxbios.initram $(obj)/lar.tmp/normal/initram
|
|
$(Q)cp $(obj)/linuxbios.stage2 $(obj)/lar.tmp/normal/stage2
|
|
$(Q)cp $(CONFIG_PAYLOAD) $(obj)/lar.tmp/normal/payload
|
|
$(Q)printf " "
|
|
$(Q)cd $(obj)/lar.tmp && ../util/lar/lar -cv ../linuxbios.rom . \
|
|
-s $(ROM_SIZE) -b $(obj)/linuxbios.bootblock
|
|
$(Q)# QEMU wants bios.bin:
|
|
$(Q)# Run "qemu -L build/ -nographic -hda /dev/zero".
|
|
$(Q)cp $@ $(obj)/bios.bin
|
|
|
|
$(obj)/linuxbios.bootblock: $(obj)/linuxbios.vpd $(obj)/stage0.init
|
|
$(Q)cat $^ > $@
|
|
|
|
#
|
|
# LinuxBIOS stage0. This is the LinuxBIOS "boot block code".
|
|
# It enables Cache-as-RAM and parses the LAR archive for an
|
|
# initram module and the various stages and payload files.
|
|
#
|
|
|
|
STAGE0_CONSOLE_OBJ = vtxprintf.o vsprintf.o console.o
|
|
STAGE0_LIB_OBJ = uart8250.o mem.o elfboot.o lar.o
|
|
STAGE0_ARCH_X86_OBJ = cachemain.o serial.o archelfboot.o
|
|
|
|
ifeq ($(CONFIG_CAR_TYPE_I586),y)
|
|
STAGE0_CAR_OBJ = stage0_i586.o
|
|
else
|
|
STAGE0_CAR_OBJ = stage0_i586.o
|
|
endif
|
|
|
|
|
|
STAGE0_OBJ := $(patsubst %,$(obj)/console/%,$(STAGE0_CONSOLE_OBJ)) \
|
|
$(patsubst %,$(obj)/lib/%,$(STAGE0_LIB_OBJ)) \
|
|
$(patsubst %,$(obj)/arch/x86/%,$(STAGE0_ARCH_X86_OBJ)) \
|
|
$(patsubst %,$(obj)/arch/x86/%,$(STAGE0_CAR_OBJ))
|
|
|
|
$(obj)/stage0.init: $(STAGE0_OBJ)
|
|
$(Q)printf "Building stage0.init... "
|
|
|
|
$(Q)# We need to be careful. If stage0.o gets bigger than
|
|
$(Q)# 0x4000 - 0x100, we will end up with a 4 gig file.
|
|
$(Q)# I wonder if that behavior is on purpose.
|
|
|
|
$(Q)$(CC) -nostdlib -static -T $(src)/arch/x86/ldscript.ld \
|
|
$(STAGE0_OBJ) -o $(obj)/stage0.o
|
|
|
|
$(Q)objcopy -O binary $(obj)/stage0.o $(obj)/stage0.init
|
|
|
|
$(Q)test `wc -c < $(obj)/stage0.init` -gt 16128 && \
|
|
printf "Error. Bootblock got too big.\n" || true
|
|
$(Q)printf "done\n"
|
|
|
|
|
|
#
|
|
# This is the rest of LinuxBIOS (v2: linuxbios_ram.rom).
|
|
# Is this maybe platform independent, except for the "drivers"?
|
|
# Where should it be built, maybe in device/?
|
|
#
|
|
# TODO: This should be compressed with the default compressor.
|
|
#
|
|
|
|
STAGE2_LIB_OBJ = stage2.o clog2.o mem.o malloc.o tables.o delay.o compute_ip_checksum.o
|
|
|
|
STAGE2_ARCH_X86_OBJ = archtables.o linuxbios_table.o udelay_io.o
|
|
STAGE2_ARCH_X86_OBJ += pci_ops_auto.o pci_ops_conf1.o pci_ops_conf2.o
|
|
|
|
STAGE2_DYNAMIC_OBJ = statictree.o
|
|
|
|
STAGE2_OBJ := $(patsubst %,$(obj)/lib/%,$(STAGE2_LIB_OBJ)) \
|
|
$(patsubst %,$(obj)/arch/x86/%,$(STAGE2_ARCH_X86_OBJ)) \
|
|
$(patsubst %,$(obj)/device/%,$(STAGE2_DEVICE_OBJ)) \
|
|
$(patsubst %,$(obj)/mainboard/$(MAINBOARDDIR)/%,$(STAGE2_MAINBOARD_OBJ)) \
|
|
$(patsubst %,$(obj)/mainboard/$(MAINBOARDDIR)/%,$(STAGE2_DYNAMIC_OBJ)) \
|
|
|
|
STAGE2_OBJ += $(STAGE2_CHIPSET_OBJ)
|
|
|
|
$(obj)/linuxbios.stage2: $(obj)/stage0.init $(STAGE2_OBJ)
|
|
$(Q)printf "Building linuxbios.stage2... "
|
|
$(Q)# leave a .o with full symbols in it for debugging.
|
|
$(Q)$(LD) -R $(obj)/stage0.o -Ttext 0x1000 --entry=stage2 \
|
|
-o $(obj)/linuxbios.stage2.o $(STAGE2_OBJ)
|
|
$(Q)objcopy -O binary $(obj)/linuxbios.stage2.o $(obj)/linuxbios.stage2
|
|
$(Q)printf "done\n"
|
|
|
|
|
|
#
|
|
# The payload as we love it. Get it from somewhere.
|
|
# Is this a place to incorporate buildrom?
|
|
#
|
|
# TODO: This is not implemented yet.
|
|
# TODO: This needs to be compressed with the default compressor.
|
|
#
|
|
|
|
payload:
|
|
$(Q)printf "Building payload... skipped\n"
|
|
|
|
|
|
#
|
|
# Build rules.
|
|
#
|
|
|
|
$(obj)/arch/x86/%.o: $(src)/arch/x86/%.c
|
|
$(Q)mkdir -p $(obj)/arch/x86
|
|
$(Q)$(CC) $(INITCFLAGS) -c $< -o $@
|
|
|
|
$(obj)/mainboard/$(MAINBOARDDIR)/%.o: $(src)/mainboard/$(MAINBOARDDIR)/%.c
|
|
$(Q)mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
|
|
$(Q)$(CC) $(INITCFLAGS) -c $< -o $@
|
|
|
|
# Building asm stub.
|
|
$(obj)/arch/x86/stage0%.o: $(src)/arch/x86/stage0%.S
|
|
$(Q)$(CC) -E $(LINUXBIOSINCLUDE) $< \
|
|
-o $(obj)/arch/x86/stage0_asm.s -DBOOTBLK=0x1f00 -DRESRVED=0xf0 \
|
|
-DDATE=\"`date +%Y/%m/%d`\"
|
|
$(Q)$(AS) $(obj)/arch/x86/stage0_asm.s -o $@
|
|
|
|
endif
|