summaryrefslogtreecommitdiffstats
path: root/src/occ/app.mk
blob: 025b10098b564cc4bb5e4fa742c4fc49e43316ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/occ/app.mk $
#
# OpenPOWER OnChipController Project
#
# Contributors Listed Below - COPYRIGHT 2011,2015
# [+] International Business Machines Corp.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG

#  Description: mk occ application
#
#  This Makefile is included-ed into application Makefiles and
#  encapsulates the steps necessary to create application images.
#
#  The application Makefile (user) must define the following variables:
#
#  APP     - The name of the application
#  SOURCES - The list of local source files that implement the
#            application.
#
#  The application Makefile (user) may optionally define the following
#  variables:
#
#  D    - The value of $(D) is appended to DEFS defined by ssx.mk
#
#  MODE - The following modes are recognized:
#
#         validation - (Default) An application that requires all SSX
#         services.
#
#         firmware - An interrupt only configuration.
#
#  The make process creates the following files:
#
#  $(APP).out  - The PowerPC-ELF version of the application
#  $(APP).bin  - A binary SRAM image of the application
#  $(APP).map  - The linker map of the application
#

OCC = .
SSX = ../ssx
LIB = ../lib
PGP = $(SSX)/pgp
SSXDIR =  $(SSX)/ssx
PPC405 = $(SSX)/ppc405
BOOTLOADER = ../occBootLoader

ifeq "$(MODE)" "firmware"
SSX_TIMER_SUPPORT = 0
SSX_THREAD_SUPPORT = 0
endif

export SSX_TIMER_SUPPORT
export SSX_THREAD_SUPPORT
export PPC405_MMU_SUPPORT
export PGP_ASYNC_SUPPORT

INCLUDES += -I$(OCC) -I$(LIB)

include $(PGP)/ssx.mk
include $(PGP)/ssxpgpfiles.mk
include $(SSXDIR)/ssxssxfiles.mk
include $(PPC405)/ssxppc405files.mk
include $(LIB)/libgpefiles.mk

all_gpefiles += ${addprefix ../lib/,${LIB_PSOBJECTS}}

GPE_OBJECTS = ${all_gpefiles}
OCC_OBJECTS = ${occ_cfiles} ${occ_Sfiles}
OBJECTS = ${GPE_OBJECTS} ${OCC_OBJECTS}

# Need full paths to all .o files for commands that follow
LDFLAGS = \
		  -L $(SSX)/ssx \
		  -L $(SSX)/ppc32 \
		  -L $(SSX)/ppc405 \
		  -L $(SSX)/pgp \
		  -L $(OCC) \
		  -L $(LIB) \
		  -L $(OCC)/amec \
		  -L $(OCC)/aplt \
		  -L $(OCC)/cent \
		  -L $(OCC)/cmdh \
		  -L $(OCC)/dcom \
		  -L $(OCC)/errl \
		  -L $(OCC)/gpe \
		  -L $(OCC)/proc \
		  -L $(OCC)/pss \
		  -L $(OCC)/rtls \
		  -L $(OCC)/sensor \
		  -L $(OCC)/thread \
		  -L $(OCC)/timer \
		  -L $(OCC)/trac \
		  -L $(OCC)/firdata \
		  -lssx -lppc32 --oformat=elf32-powerpc -melf32ppc

# Added for linking files compiled using gnu assembler
LDARGS = --no-warn-mismatch --accept-unknown-input-arch
# Changed to use GCC-DEFS instead of DEFS so that different defines
# can be used for compiling .S and .pS files
GCC-DEFS += $(D)

#*******************************************************************************
# compilation
#*******************************************************************************

# Use complex method for linking pore and PPC objects
all: $(OBJECTS) libssx.a
# add -w to inhibit all warnings
	$(MAKE) -w -C $(PGP) DEFS="$(DEFS)" -e
	$(CPP) -P $(DEFS) < $(OCC)/linkocc.cmd > linkscript

# Create gpe binary with symbols undefined
#   First stage link, no ppc syms yet.  Link with -noinhibit-exec to prevent
#   undefined syms killing output.  This binary won't be located at the
#   correct base address, but can reasonably be assumed to be the correct
#   size.  (If it isn't the right size, then iterate over another link stage.)
	$(PORE-LD) -o gpe_1.out $(GPE_OBJECTS) -noinhibit-exec -Map gpe_1.map -e 0
	$(PORE-OBJCOPY) -O binary gpe_1.out gpe_1.bin

# Insert gpe binary to occ
#   Don't link with -zmuldefs here so we get an error if PORE symbols
#   clash with PowerPC ones.
	$(LD) -o occ_1.out -R gpe_1.out \
	  -Tlinkscript $(LDFLAGS) $(LDARGS) -Map occ_1.map -Bstatic -b binary gpe_1.bin
        # Find the address of gpe binary and create gpe binary with symbols relocated
        #   Find where pore binary was placed.  The symbol we look for
        #   incorporates the name of the binary we linked above.
        #   Second stage link of pore object at the correct address (from symbols above)
        #   now gets ppc syms added from occ_1.out, -z muldefs stops multiple def
        #   errors when we get pore symbols from occ_1.out too
	pore_base=`nm occ_1.out | grep _binary_gpe_1_bin_start | sed -e s', .*,,'`;$(PORE-LD) -o gpe.out \
	  $(GPE_OBJECTS) -Ttext $$pore_base --no-warn-mismatch --accept-unknown-input-arch -R occ_1.out -z muldefs -Map gpe.map -e 0
	$(PORE-OBJCOPY) -O binary gpe.out gpe.bin

        # Insert the gpe binary to occ and relocate the symbols in occ
        #   Create gep_2.out that is used by OCC_OBJECTS to relocate the symboles in occ
        #   so we have all symboles relocated in both OCC_OBJECTS and gpe.bin
	pore_base=`nm occ_1.out | grep _binary_gpe_1_bin_start | sed -e s', .*,,'`;$(PORE-LD) -o gpe_2.out \
	  $(GPE_OBJECTS) -Ttext $$pore_base --no-warn-mismatch --accept-unknown-input-arch -noinhibit-exec -Map gpe_2.map -e 0

	$(LD) -o occ.out -R gpe_2.out \
	  -Tlinkscript $(LDFLAGS) $(LDARGS)  -Map occ.map -Bstatic -b binary gpe.bin

# Specify source object format as elf32-powerpc
	$(OBJCOPY) -I elf32-powerpc -O binary $(APP).out $(APP).bin
	$(OBJDUMP) -D $(APP).out > $(APP).dis
	$(BOOTLOADER)/imageHdrScript $(APP).bin `md5sum $(APP).out | cut -c 1-4`

libssx.a:
	$(MAKE) -C $(LIB) DEFS="$(DEFS)" -e

.PHONY : combineImage
combineImage:
	 	$(BOOTLOADER)/imageHdrScript $(APP).bin combineImage
	 	$(BOOTLOADER)/imageHdrScript $(APP).out displaySize

.PHONY : clean
clean:
	rm -f *.o *.d *.d.* *.out *.bin *.srec *.dis *.map *.hash linkscript
	rm -f ./*/*.o ./*/*.d ./*/*.d.* ./*/*.hash

.PHONY : clean_all
clean_all:
	$(MAKE) clean
	$(MAKE) -C $(PGP) clean

ifneq ($(MAKECMDGOALS),clean)
-include $(OBJECTS:.o=.d)
endif
OpenPOWER on IntegriCloud