blob: 62ccfcd30d2f2d404dc64040339290d304f6a253 [file] [log] [blame]
Patrick Georgi0588d192009-08-12 15:00:51 +00001#######################################################################
2# Take care of subdirectories
3subdirs-y += boot
Stefan Reinauere3778572010-01-30 09:47:18 +00004# subdirs-y += init
Patrick Georgi0588d192009-08-12 15:00:51 +00005subdirs-y += lib
6subdirs-y += smp
7
Uwe Hermannf8f5b622009-08-25 12:18:05 +00008obj-$(CONFIG_HAVE_OPTION_TABLE) += ../../option_table.o
Patrick Georgi0588d192009-08-12 15:00:51 +00009
Patrick Georgi0588d192009-08-12 15:00:51 +000010#######################################################################
11# Build the final rom image
Patrick Georgi182b09e2010-03-16 16:59:03 +000012COREBOOT_ROM_DEPENDENCIES:=
13ifneq ($(CONFIG_PAYLOAD_NONE),y)
14COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_PAYLOAD_FILE)
Peter Stuge87f95142009-10-23 12:14:15 +000015endif
Cristi Magherusan488c36c2009-08-17 14:46:13 +000016ifeq ($(CONFIG_VGA_BIOS),y)
Patrick Georgi182b09e2010-03-16 16:59:03 +000017COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_VGA_BIOS_FILE)
Cristi Magherusan488c36c2009-08-17 14:46:13 +000018endif
Stefan Reinauer800379f2010-03-01 08:34:19 +000019ifeq ($(CONFIG_INTEL_MBI),y)
Patrick Georgi182b09e2010-03-16 16:59:03 +000020COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_MBI_FILE)
Stefan Reinauer800379f2010-03-01 08:34:19 +000021endif
22ifeq ($(CONFIG_BOOTSPLASH),y)
Patrick Georgi182b09e2010-03-16 16:59:03 +000023COREBOOT_ROM_DEPENDENCIES+=$(CONFIG_FALLBACK_BOOTSPLASH_FILE)
Stefan Reinauer800379f2010-03-01 08:34:19 +000024endif
Stefan Reinauercca62682010-03-30 21:52:05 +000025ifeq ($(CONFIG_AP_CODE_IN_CAR),y)
26COREBOOT_ROM_DEPENDENCIES+=$(obj)/coreboot_ap
27endif
28
Patrick Georgia84e98b2010-03-16 19:01:32 +000029$(obj)/coreboot.rom: $(obj)/coreboot.pre $(obj)/coreboot_ram $(CBFSTOOL) $(call strip_quotes,$(COREBOOT_ROM_DEPENDENCIES))
Stefan Reinauer6bee9512010-03-24 15:51:48 +000030 printf " CBFS $(subst $(obj)/,,$(@))\n"
Patrick Georgi182b09e2010-03-16 16:59:03 +000031 cp $(obj)/coreboot.pre $@.tmp
Stefan Reinauercca62682010-03-30 21:52:05 +000032 if [ -f $(obj)/coreboot_ap ]; \
Patrick Georgi182b09e2010-03-16 16:59:03 +000033 then \
Stefan Reinauercca62682010-03-30 21:52:05 +000034 $(CBFSTOOL) $@.tmp add-stage $(obj)/coreboot_ap $(CONFIG_CBFS_PREFIX)/coreboot_ap $(CBFS_COMPRESS_FLAG); \
Patrick Georgi182b09e2010-03-16 16:59:03 +000035 fi
36 $(CBFSTOOL) $@.tmp add-stage $(obj)/coreboot_ram $(CONFIG_CBFS_PREFIX)/coreboot_ram $(CBFS_COMPRESS_FLAG)
37ifeq ($(CONFIG_PAYLOAD_NONE),y)
Stefan Reinauerf358c0c2010-04-09 13:49:48 +000038 printf " PAYLOAD \e[1;31mnone (as specified by user)\e[0m\n"
Patrick Georgi182b09e2010-03-16 16:59:03 +000039else
Stefan Reinauer314e5512010-04-09 20:36:29 +000040 printf " PAYLOAD $(CONFIG_FALLBACK_PAYLOAD_FILE) (compression: $(CBFS_PAYLOAD_COMPRESS_NAME))\n"
Patrick Georgi182b09e2010-03-16 16:59:03 +000041 $(CBFSTOOL) $@.tmp add-payload $(CONFIG_FALLBACK_PAYLOAD_FILE) $(CONFIG_CBFS_PREFIX)/payload $(CBFS_PAYLOAD_COMPRESS_FLAG)
42endif
43ifeq ($(CONFIG_VGA_BIOS),y)
44 printf " VGABIOS $(CONFIG_FALLBACK_VGA_BIOS_FILE) $(CONFIG_FALLBACK_VGA_BIOS_ID)\n"
45 $(CBFSTOOL) $@.tmp add $(CONFIG_FALLBACK_VGA_BIOS_FILE) "pci$(CONFIG_FALLBACK_VGA_BIOS_ID).rom" optionrom
46endif
47ifeq ($(CONFIG_INTEL_MBI),y)
48 printf " MBI $(CONFIG_FALLBACK_MBI_FILE)\n"
49 $(CBFSTOOL) $@.tmp add $(CONFIG_FALLBACK_MBI_FILE) mbi.bin mbi
50endif
51ifeq ($(CONFIG_BOOTSPLASH),y)
52 printf " BOOTSPLASH $(CONFIG_FALLBACK_BOOTSPLASH_FILE)\n"
53 $(CBFSTOOL) $@.tmp add $(CONFIG_FALLBACK_BOOTSPLASH_FILE) bootsplash.jpg bootsplash
54endif
55 mv $@.tmp $@
56 printf " CBFSPRINT $(subst $(obj)/,,$(@))\n\n"
57 $(CBFSTOOL) $@ print
Patrick Georgi0588d192009-08-12 15:00:51 +000058
Patrick Georgi0588d192009-08-12 15:00:51 +000059#######################################################################
60# i386 specific tools
61
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +000062$(obj)/option_table.h $(obj)/option_table.c: $(obj)/build_opt_tbl $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout
Uwe Hermann6c73b4412009-10-28 17:10:51 +000063 @printf " OPTION $(subst $(obj)/,,$(@))\n"
Patrick Georgi2b7418e2009-08-25 19:38:46 +000064 $(obj)/build_opt_tbl --config $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout --header $(obj)/option_table.h --option $(obj)/option_table.c
Patrick Georgi0588d192009-08-12 15:00:51 +000065
Stefan Reinauerb5828d72010-03-29 17:14:28 +000066$(obj)/build_opt_tbl: $(top)/util/options/build_opt_tbl.c $(top)/src/include/pc80/mc146818rtc.h $(top)/src/include/boot/coreboot_tables.h
Uwe Hermann6c73b4412009-10-28 17:10:51 +000067 @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
Stefan Reinauerb5828d72010-03-29 17:14:28 +000068 $(HOSTCC) $(HOSTCFLAGS) $< -o $@
Patrick Georgi0588d192009-08-12 15:00:51 +000069
70#######################################################################
71# Build the coreboot_ram (stage 2)
72
Stefan Reinauer531704e2010-02-10 11:56:21 +000073$(obj)/coreboot_ram: $(obj)/coreboot_ram.o $(src)/arch/i386/coreboot_ram.ld #ldoptions
Uwe Hermann6c73b4412009-10-28 17:10:51 +000074 @printf " CC $(subst $(obj)/,,$(@))\n"
Stefan Reinauer531704e2010-02-10 11:56:21 +000075 $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/i386/coreboot_ram.ld $(obj)/coreboot_ram.o
Patrick Georgi2b7418e2009-08-25 19:38:46 +000076 $(NM) -n $(obj)/coreboot_ram | sort > $(obj)/coreboot_ram.map
Patrick Georgi0588d192009-08-12 15:00:51 +000077
Patrick Georgi51e142f2010-03-27 17:18:39 +000078$(obj)/coreboot_ram.o: $(obj)/arch/i386/lib/c_start.o $$(drivers) $(obj)/coreboot.a $(LIBGCC_FILE_NAME)
Uwe Hermann6c73b4412009-10-28 17:10:51 +000079 @printf " CC $(subst $(obj)/,,$(@))\n"
Patrick Georgi020f51f2010-03-14 21:25:03 +000080 $(CC) -nostdlib -r -o $@ $(obj)/arch/i386/lib/c_start.o $(drivers) -Wl,--start-group $(obj)/coreboot.a $(LIBGCC_FILE_NAME) -Wl,--end-group
Patrick Georgi0588d192009-08-12 15:00:51 +000081
Patrick Georgi51e142f2010-03-27 17:18:39 +000082$(obj)/coreboot.a: $$(objs)
Uwe Hermann6c73b4412009-10-28 17:10:51 +000083 @printf " AR $(subst $(obj)/,,$(@))\n"
Patrick Georgi2b7418e2009-08-25 19:38:46 +000084 rm -f $(obj)/coreboot.a
Patrick Georgi51e142f2010-03-27 17:18:39 +000085 $(AR) cr $(obj)/coreboot.a $^
Patrick Georgi0588d192009-08-12 15:00:51 +000086
Patrick Georgi0588d192009-08-12 15:00:51 +000087#######################################################################
Stefan Reinauercca62682010-03-30 21:52:05 +000088# coreboot_ap.rom
89
90ifeq ($(CONFIG_AP_CODE_IN_CAR),y)
91
92$(obj)/coreboot_ap: $(obj)/mainboard/$(MAINBOARDDIR)/ap_romstage.o
93 @printf " CC $(subst $(obj)/,,$(@))\n"
94 $(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/i386/init/ldscript_apc.lb $^
95 $(NM) -n $(obj)/coreboot_ap | sort > $(obj)/coreboot_ap.map
96
97
98endif
99
100#######################################################################
Patrick Georgi0588d192009-08-12 15:00:51 +0000101# done
102
Patrick Georgie64b6372010-04-08 21:04:45 +0000103crt0s = $(src)/arch/i386/init/crt0_prologue.inc
Stefan Reinaueracdd52f2010-03-30 20:32:01 +0000104ldscripts =
Patrick Georgi31b0bea2010-02-25 21:50:26 +0000105ldscripts += $(src)/arch/i386/init/ldscript_fallback_cbfs.lb
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000106ifeq ($(CONFIG_BIG_BOOTBLOCK),y)
107crt0s += $(src)/cpu/x86/16bit/entry16.inc
Patrick Georgi31b0bea2010-02-25 21:50:26 +0000108ldscripts += $(src)/cpu/x86/16bit/entry16.lds
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000109endif
110crt0s += $(src)/cpu/x86/32bit/entry32.inc
Patrick Georgi31b0bea2010-02-25 21:50:26 +0000111ldscripts += $(src)/cpu/x86/32bit/entry32.lds
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000112ifeq ($(CONFIG_BIG_BOOTBLOCK),y)
113crt0s += $(src)/cpu/x86/16bit/reset16.inc
Patrick Georgi31b0bea2010-02-25 21:50:26 +0000114ldscripts += $(src)/cpu/x86/16bit/reset16.lds
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000115crt0s += $(src)/arch/i386/lib/id.inc
Patrick Georgi31b0bea2010-02-25 21:50:26 +0000116ldscripts += $(src)/arch/i386/lib/id.lds
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000117endif
118
119crt0s += $(src)/cpu/x86/fpu_enable.inc
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000120ifeq ($(CONFIG_SSE),y)
121crt0s += $(src)/cpu/x86/sse_enable.inc
122endif
123
Patrick Georgi5934b502010-04-12 15:28:34 +0000124crt0s += $(cpu_incs)
125
126#
127# FIXME move to CPU_INTEL_SOCKET_MPGA604
128#
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000129ifeq ($(CONFIG_BOARD_TYAN_S2735),y)
130crt0s += $(src)/cpu/x86/car/cache_as_ram.inc
131endif
132
Stefan Reinauer5c503922010-03-13 22:07:15 +0000133ifeq ($(CONFIG_LLSHELL),y)
134crt0s += $(src)/arch/i386/llshell/llshell.inc
135endif
136
Patrick Georgieb49f9d2010-02-25 17:03:17 +0000137crt0s += $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc
138
139ifeq ($(CONFIG_SSE),y)
140crt0s += $(src)/cpu/x86/sse_disable.inc
141endif
142ifeq ($(CONFIG_MMX),y)
143crt0s += $(src)/cpu/x86/mmx_disable.inc
144endif
145
146ifeq ($(CONFIG_BIG_BOOTBLOCK),y)
Patrick Georgi806a29e2010-02-28 20:56:42 +0000147crt0s += $(chipset_bootblock_inc)
148ldscripts += $(chipset_bootblock_lds)
Patrick Georgia6c337d2010-02-03 17:56:37 +0000149endif
Patrick Georgi2063197a2010-02-09 12:21:10 +0000150
Patrick Georgie64b6372010-04-08 21:04:45 +0000151ifeq ($(CONFIG_ROMCC),y)
152crt0s += $(src)/arch/i386/init/crt0_romcc_epilogue.inc
153endif
154
Patrick Georgi2063197a2010-02-09 12:21:10 +0000155OPTION_TABLE_H:=
156ifeq ($(CONFIG_HAVE_OPTION_TABLE),y)
157OPTION_TABLE_H:=$(obj)/option_table.h
158endif
159
160ifeq ($(CONFIG_ROMCC),y)
161ROMCCFLAGS ?= -mcpu=p2 -O2
162
Stefan Reinauer314e5512010-04-09 20:36:29 +0000163$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(obj)/romcc $(OPTION_TABLE_H) $(obj)/build.h $(obj)/config.h
Patrick Georgi patrick.georgic5f773d2010-03-16 12:01:13 +0000164 printf " ROMCC romstage.inc\n"
Stefan Reinauere9f32582010-03-29 13:04:13 +0000165 $(ROMCC) -c -S $(ROMCCFLAGS) -D__PRE_RAM__ -I. $(INCLUDES) $< -o $@
Patrick Georgi2063197a2010-02-09 12:21:10 +0000166else
Stefan Reinauer18476182010-02-11 08:44:20 +0000167
Stefan Reinauer86554122010-03-29 21:50:53 +0000168$(obj)/mainboard/$(MAINBOARDDIR)/ap_romstage.o: $(src)/mainboard/$(MAINBOARDDIR)/ap_romstage.c $(OPTION_TABLE_H)
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000169 @printf " CC $(subst $(obj)/,,$(@))\n"
Stefan Reinauercca62682010-03-30 21:52:05 +0000170 $(CC) -MMD $(CFLAGS) -I$(src) -I. -c $(src)/mainboard/$(MAINBOARDDIR)/ap_romstage.c -o $@
Stefan Reinauer18476182010-02-11 08:44:20 +0000171
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000172$(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h
Stefan Reinauer53b0ea42010-03-22 11:50:52 +0000173 printf " CC romstage.inc\n"
Stefan Reinauere9f32582010-03-29 13:04:13 +0000174 $(CC) -MMD $(CFLAGS) -D__PRE_RAM__ -I$(src) -I. -c -S $< -o $@
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000175
176$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(obj)/mainboard/$(MAINBOARDDIR)/romstage.pre.inc
Stefan Reinauer53b0ea42010-03-22 11:50:52 +0000177 printf " POST romstage.inc\n"
Stefan Reinauer6bee9512010-03-24 15:51:48 +0000178 sed -e 's/\.rodata/.rom.data/g' -e 's/\.text/.section .rom.text/g' $^ > $@.tmp
Patrick Georgi68882a32010-02-10 18:08:22 +0000179 mv $@.tmp $@
Patrick Georgi2063197a2010-02-09 12:21:10 +0000180endif
Patrick Georgi37bdb872010-02-27 08:39:04 +0000181
Patrick Georgi37bdb872010-02-27 08:39:04 +0000182# Things that appear in every board
183initobjs += $(obj)/mainboard/$(MAINBOARDDIR)/crt0.o
184objs += $(obj)/mainboard/$(MAINBOARDDIR)/mainboard.o
185ifeq ($(CONFIG_GENERATE_MP_TABLE),y)
186objs += $(obj)/mainboard/$(MAINBOARDDIR)/mptable.o
187endif
188ifeq ($(CONFIG_GENERATE_PIRQ_TABLE),y)
189objs += $(obj)/mainboard/$(MAINBOARDDIR)/irq_tables.o
190endif
191ifeq ($(CONFIG_BOARD_HAS_HARD_RESET),y)
192objs += $(obj)/mainboard/$(MAINBOARDDIR)/reset.o
193endif
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000194ifeq ($(CONFIG_GENERATE_ACPI_TABLES),y)
195objs += $(obj)/mainboard/$(MAINBOARDDIR)/acpi_tables.o
196objs += $(obj)/mainboard/$(MAINBOARDDIR)/dsdt.o
Patrick Georgi75bf0532010-03-01 07:42:02 +0000197# make doesn't have arithmetic operators or greater-than comparisons
198ifeq ($(subst 5,4,$(CONFIG_ACPI_SSDTX_NUM)),4)
199objs += $(obj)/mainboard/$(MAINBOARDDIR)/ssdt2.o
200objs += $(obj)/mainboard/$(MAINBOARDDIR)/ssdt3.o
201objs += $(obj)/mainboard/$(MAINBOARDDIR)/ssdt4.o
202endif
203ifeq ($(CONFIG_ACPI_SSDTX_NUM),5)
204objs += $(obj)/mainboard/$(MAINBOARDDIR)/ssdt5.o
205endif
Patrick Georgi9ea7bff2010-02-28 18:23:00 +0000206ifeq ($(CONFIG_BOARD_HAS_FADT),y)
207objs += $(obj)/mainboard/$(MAINBOARDDIR)/fadt.o
208endif
209endif
210
211ifeq ($(CONFIG_HAVE_BUS_CONFIG),y)
212objs += $(obj)/mainboard/$(MAINBOARDDIR)/get_bus_conf.o
213endif
Patrick Georgi37bdb872010-02-27 08:39:04 +0000214
Patrick Georgi9341acd2009-12-23 12:52:56 +0000215ifeq ($(CONFIG_TINY_BOOTBLOCK),y)
Patrick Georgic9fa96d2010-02-24 13:58:23 +0000216include $(src)/arch/i386/Makefile.bootblock.inc
Patrick Georgi9341acd2009-12-23 12:52:56 +0000217else
218include $(src)/arch/i386/Makefile.bigbootblock.inc
219endif