Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 1 | # |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame] | 2 | # Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 3 | # Copyright (c) 2020, Renesas Electronics Corporation. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 8 | toolchains := aarch64 |
| 9 | |
Chris Kay | 1559f64 | 2024-06-04 00:04:48 +0000 | [diff] [blame] | 10 | include ../../../make_helpers/build-rules.mk |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 11 | include ../../../make_helpers/common.mk |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 12 | include ../../../make_helpers/toolchain.mk |
| 13 | |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 14 | ################################################### |
| 15 | # makefile |
| 16 | ################################################### |
| 17 | |
| 18 | #output file name |
| 19 | FILE_NAME_SA0 = bootparam_sa0 |
| 20 | FILE_NAME_SA6 = cert_header_sa6 |
| 21 | |
| 22 | OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf |
| 23 | OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf |
| 24 | |
| 25 | #object file name |
| 26 | OBJ_FILE_SA0 = sa0.o |
| 27 | OBJ_FILE_SA6 = sa6.o |
| 28 | |
| 29 | #linker script name |
| 30 | MEMORY_DEF_SA0 = sa0.ld.S |
| 31 | MEMORY_DEF_SA6 = sa6.ld.S |
| 32 | |
| 33 | ################################################### |
| 34 | # Convenience function for adding build definitions |
| 35 | # $(eval $(call add_define,FOO)) will have: |
| 36 | # -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise |
| 37 | define add_define |
| 38 | DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),) |
| 39 | endef |
| 40 | |
| 41 | # Process RCAR_SA0_SIZE flag |
| 42 | ifndef RCAR_SA0_SIZE |
| 43 | RCAR_SA0_SIZE := 1 |
| 44 | else |
| 45 | ifeq (${RCAR_SA0_SIZE},0) |
| 46 | RCAR_SA0_SIZE := 0 |
| 47 | else |
| 48 | RCAR_SA0_SIZE := 1 |
| 49 | endif |
| 50 | endif |
| 51 | $(eval $(call add_define,RCAR_SA0_SIZE)) |
| 52 | |
| 53 | # Process RCAR_SA6_TYPE flag |
| 54 | ifndef RCAR_SA6_TYPE |
| 55 | RCAR_SA6_TYPE := 0 |
| 56 | else |
| 57 | ifeq (${RCAR_SA6_TYPE},0) |
| 58 | RCAR_SA6_TYPE := 0 |
| 59 | else |
| 60 | RCAR_SA6_TYPE := 1 |
| 61 | endif |
| 62 | endif |
| 63 | $(eval $(call add_define,RCAR_SA6_TYPE)) |
| 64 | |
| 65 | RCAR_VMA_ADJUST_ADDR := 0xE6320000 |
| 66 | $(eval $(call add_define,RCAR_VMA_ADJUST_ADDR)) |
| 67 | |
| 68 | |
| 69 | ################################################### |
| 70 | |
| 71 | #c compiler |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 72 | CFLAGS += ${DEFINES} |
| 73 | CFLAGS += -nostdinc \ |
| 74 | -I../../../include/lib/libc \ |
| 75 | -I../../../include/lib/libc/aarch64 |
| 76 | |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 77 | #clean |
| 78 | CL = rm -f |
| 79 | |
| 80 | ################################################### |
| 81 | .SUFFIXES : .s .c .o |
| 82 | |
| 83 | ################################################### |
| 84 | # command |
| 85 | |
| 86 | .PHONY: all |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame] | 87 | |
| 88 | all: $(FILE_NAME_SA0).srec $(FILE_NAME_SA0).bin |
| 89 | all: $(FILE_NAME_SA6).srec $(FILE_NAME_SA6).bin |
| 90 | |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 91 | ################################################### |
| 92 | # Linker |
| 93 | ################################################### |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame] | 94 | |
Chris Kay | 1559f64 | 2024-06-04 00:04:48 +0000 | [diff] [blame] | 95 | $(FILE_NAME_SA0).srec: $(OUTPUT_FILE_SA0) | $$(@D)/ |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame] | 96 | $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 97 | |
Chris Kay | 1559f64 | 2024-06-04 00:04:48 +0000 | [diff] [blame] | 98 | $(FILE_NAME_SA0).bin: $(OUTPUT_FILE_SA0) | $$(@D)/ |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame] | 99 | $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 100 | |
Chris Kay | 1559f64 | 2024-06-04 00:04:48 +0000 | [diff] [blame] | 101 | $(OUTPUT_FILE_SA0): $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0) | $$(@D)/ |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame] | 102 | $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib -T $(MEMORY_DEF_SA0) -o $(OUTPUT_FILE_SA0) -Wl,-Map $(FILE_NAME_SA0).map |
| 103 | |
Chris Kay | 1559f64 | 2024-06-04 00:04:48 +0000 | [diff] [blame] | 104 | $(FILE_NAME_SA6).srec: $(OUTPUT_FILE_SA6) | $$(@D)/ |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame] | 105 | $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec |
| 106 | |
Chris Kay | 1559f64 | 2024-06-04 00:04:48 +0000 | [diff] [blame] | 107 | $(FILE_NAME_SA6).bin: $(OUTPUT_FILE_SA6) | $$(@D)/ |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame] | 108 | $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 109 | |
Chris Kay | 1559f64 | 2024-06-04 00:04:48 +0000 | [diff] [blame] | 110 | $(OUTPUT_FILE_SA6): $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6) | $$(@D)/ |
Chris Kay | 51a20b7 | 2024-06-04 11:31:06 +0000 | [diff] [blame] | 111 | $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib -T $(MEMORY_DEF_SA6) -o $(OUTPUT_FILE_SA6) -Wl,-Map $(FILE_NAME_SA6).map |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 112 | |
| 113 | ################################################### |
| 114 | # Compile |
| 115 | ################################################### |
| 116 | |
Chris Kay | 1559f64 | 2024-06-04 00:04:48 +0000 | [diff] [blame] | 117 | %.o: %.c | $$(@D)/ |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 118 | $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< |
Biju Das | fb0e550 | 2020-12-07 13:25:07 +0000 | [diff] [blame] | 119 | |
| 120 | .PHONY: clean |
| 121 | clean: |
| 122 | $(CL) *.bin *.map *.srec *.elf *.o |