1 # 2 # Makefile - build a UEFI boot image for booting from different exception levels. 3 # 4 # Copyright (C) 2011-2013 ARM Limited. 5 # All rights reserved. 6 # 7 # Redistribution and use in source and binary forms, with or without 8 # modification, are permitted provided that the following conditions are 9 # met: 10 # 11 # * Redistributions of source code must retain the above copyright 12 # notice, this list of conditions and the following disclaimer. 13 # * Redistributions in binary form must reproduce the above copyright 14 # notice, this list of conditions and the following disclaimer in 15 # the documentation and/or other materials provided with the 16 # distribution. 17 # * Neither the name of ARM nor the names of its contributors may be 18 # used to endorse or promote products derived from this software 19 # without specific prior written permission. 20 # 21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 24 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 27 # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 # 33 # This license can also be found in the LICENSE.TXT file. 34 35 36 # VE 37 PHYS_OFFSET := 0x80000000 38 UART_BASE := 0x1c090000 39 GIC_DIST_BASE := 0x2c001000 40 GIC_CPU_BASE := 0x2c002000 41 CNTFRQ := 0x01800000 # 24Mhz 42 43 BOOTLOADER := boot.S 44 LD_SCRIPT := model.lds.S 45 IMAGE_1 := uefi-bootstrap-el1.axf 46 IMAGE_2 := uefi-bootstrap-el2.axf 47 IMAGE_3 := uefi-bootstrap-el3.axf 48 IMAGE_3F := uefi-bootstrap-el3-foundation.axf 49 50 51 CROSS_COMPILE ?= aarch64-none-elf- 52 CC := $(CROSS_COMPILE)gcc 53 LD := $(CROSS_COMPILE)ld 54 55 all: $(IMAGE_1) $(IMAGE_2) $(IMAGE_3) $(IMAGE_3F) 56 57 clean: 58 rm -f *.axf *.o *.lds 59 60 $(IMAGE_1): boot1.o model1.lds 61 $(LD) -o $@ --script=model1.lds 62 63 $(IMAGE_2): boot2.o model2.lds 64 $(LD) -o $@ --script=model2.lds 65 66 $(IMAGE_3): boot3.o model3.lds 67 $(LD) -o $@ --script=model3.lds 68 69 $(IMAGE_3F): boot3f.o model3f.lds 70 $(LD) -o $@ --script=model3f.lds 71 72 boot1.o: $(BOOTLOADER) Makefile 73 $(CC) $(CPPFLAGS) -DUART_BASE=$(UART_BASE) -DCNTFRQ=$(CNTFRQ) -DGIC_DIST_BASE=$(GIC_DIST_BASE) -DGIC_CPU_BASE=$(GIC_CPU_BASE) -DSTART_EL2=1 -DSTART_EL1=1 -c -o $@ $(BOOTLOADER) 74 75 boot2.o: $(BOOTLOADER) Makefile 76 $(CC) $(CPPFLAGS) -DUART_BASE=$(UART_BASE) -DCNTFRQ=$(CNTFRQ) -DGIC_DIST_BASE=$(GIC_DIST_BASE) -DGIC_CPU_BASE=$(GIC_CPU_BASE) -DSTART_EL2=1 -c -o $@ $(BOOTLOADER) 77 78 boot3.o: $(BOOTLOADER) Makefile 79 $(CC) $(CPPFLAGS) -DUART_BASE=$(UART_BASE) -DCNTFRQ=$(CNTFRQ) -DGIC_DIST_BASE=$(GIC_DIST_BASE) -DGIC_CPU_BASE=$(GIC_CPU_BASE) -c -o $@ $(BOOTLOADER) 80 81 boot3f.o: $(BOOTLOADER) Makefile 82 $(CC) $(CPPFLAGS) -DUART_BASE=$(UART_BASE) -DCNTFRQ=$(CNTFRQ) -DGIC_DIST_BASE=$(GIC_DIST_BASE) -DGIC_CPU_BASE=$(GIC_CPU_BASE) -DFOUNDATION_MODEL=1 -c -o $@ $(BOOTLOADER) 83 84 model1.lds: $(LD_SCRIPT) Makefile boot1.o 85 $(CC) $(CPPFLAGS) -DPHYS_OFFSET=$(PHYS_OFFSET) -DBOOT1 -E -P -C -o $@ $< 86 87 model2.lds: $(LD_SCRIPT) Makefile boot2.o 88 $(CC) $(CPPFLAGS) -DPHYS_OFFSET=$(PHYS_OFFSET) -DBOOT2 -E -P -C -o $@ $< 89 90 model3.lds: $(LD_SCRIPT) Makefile boot3.o 91 $(CC) $(CPPFLAGS) -DPHYS_OFFSET=$(PHYS_OFFSET) -DBOOT3 -E -P -C -o $@ $< 92 93 model3f.lds: $(LD_SCRIPT) Makefile boot3f.o 94 $(CC) $(CPPFLAGS) -DPHYS_OFFSET=$(PHYS_OFFSET) -DBOOT3F -E -P -C -o $@ $< 95 96 .PHONY: all clean 97