summaryrefslogtreecommitdiffstats
path: root/src/occ_405/Makefile
blob: f64a31964435a85f908940aeca749ee56daaaacd (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
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/occ_405/Makefile $
#
# OpenPOWER OnChipController Project
#
# Contributors Listed Below - COPYRIGHT 2015,2016
# [+] 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
# This Makefile compiles all of the SSX code required for the P9 port
# of SSX.  See the "img_defs.mk" file in this directory.

#Pull in the definitions that affect all makefiles for this image
include img_defs.mk

#Use tracepp instead of ppetracepp for 405 code
include occ_defs.mk

#Pull in object file names for the top directory
include topfiles.mk

SSX_MAKE_DIR := $(SSX_SRCDIR)/occhw
OBJS := $(addprefix $(OBJDIR)/, $(TOP_OBJECTS))
OBJDIRS = $(sort $(dir ${OBJS}))
SSXLIB := $(OBJDIR)/ssx/libssx.a
COMMONLIB := $(OBJDIR)/common/libcommon.a
OCCLIB := $(OBJDIR)/occlib/libocc.a
PPC405LIB := $(OBJDIR)/ppc405lib/libppc405.a
LINK_OBJS = $(OBJS) $(SSXLIB) $(COMMONLIB) $(OCCLIB) $(PPC405LIB)
LINK_SCRIPT = $(addprefix $(OBJDIR)/, linkscript)
LINK_CMD_SCRIPT = linkocc.cmd
LDFLAGS += --oformat=elf32-powerpc -melf32ppc
LIB_DIRS =  -L$(OBJDIR) \
            -L$(OBJDIR)/ssx \
            -L$(OBJDIR)/ssx/ppc405 \
            -L$(OBJDIR)/ssx/ppc32 \
            -L$(OBJDIR)/commonlib \
            -L$(OBJDIR)/occlib \
            -L$(OBJDIR)/ppc405lib \
            -L$(OBJDIR)/cmdh \
            -L$(OBJDIR)/dcom \
            -L$(OBJDIR)/dimm \
            -L$(OBJDIR)/errl \
            -L$(OBJDIR)/lock \
            -L$(OBJDIR)/pss \
            -L$(OBJDIR)/rtls \
            -L$(OBJDIR)/sensor \
            -L$(OBJDIR)/thread \
            -L$(OBJDIR)/timer \
            -L$(OBJDIR)/trac \
            -L$(OBJDIR)/amec \
            -L$(OBJDIR)/dcom \
            -L$(OBJDIR)/proc \
            -L$(OBJDIR)/firdata \
            -L$(OBJDIR)/cent \
            -L$(OBJDIR)/mem \
            -L$(OBJDIR)/wof \
            -L$(OBJDIR)/pgpe

#default target is to make a binary application image
.PHONY : all
all: $(PPETOOLS_OBJDIR)/ppetracepp $(OBJDIR)/$(IMAGE_NAME).bin $(OBJDIR)/$(IMAGE_NAME).dis

#This removes all unecessary headers from the ELF executable
$(OBJDIR)/$(IMAGE_NAME).bin $(OBJDIR)/$(IMAGE_NAME).dis: $(OBJDIR)/$(IMAGE_NAME).out
	$(OBJCOPY) -O binary  $< $(OBJDIR)/$(IMAGE_NAME).bin
	$(OBJDUMP) -S $< > $(OBJDIR)/$(IMAGE_NAME).dis

# Create a linked ELF executable and verify we aren't missing sensors
$(OBJDIR)/$(IMAGE_NAME).out: $(PPETOOLS_OBJDIR)/tracepp $(LINK_OBJS) $(LINK_SCRIPT)
	$(LD) -e __ssx_boot -T$(LINK_SCRIPT) $(LDFLAGS) -Map $(OBJDIR)/$(IMAGE_NAME).map -Bstatic -o $(OBJDIR)/$(IMAGE_NAME).out $(LIB_DIRS) -lssx -locc -lppc405 -lcommon
	$(OCCTOOLS)/check-sensors.sh $(OBJDUMP) $(OBJDIR)

$(PPETOOLS_OBJDIR)/ppetracepp: $(PPETOOLS_OBJDIR)
	g++ -O3 -w -g -I$(PPETRACEPP_DIR)/ $(PPETRACEPP_DIR)/ppetracepp.C -o $(PPETOOLS_OBJDIR)/ppetracepp

$(PPETOOLS_OBJDIR):
	mkdir -p $(PPETOOLS_OBJDIR)

#pass the link command file through the C preprocessor to evaluate macros and remove comments
$(LINK_SCRIPT): $(LINK_CMD_SCRIPT)
	$(CPP) -E -x c -P $(DEFS) $(LINK_CMD_SCRIPT) -o $(LINK_SCRIPT)

#Create an obj directory if needed
$(LINK_OBJS) $(OBJS) $(OBJS:.o=.d): | $(OBJDIRS)

$(OBJDIRS):
	mkdir -p $@

#Build the SSX kernel library
$(SSXLIB):
	$(MAKE) -I $(IMAGE_SRCDIR) -C $(SSX_MAKE_DIR)

#Build the code that is common for all processors (PPE's and 405)
$(COMMONLIB):
	$(MAKE) -I $(IMAGE_SRCDIR) -C $(COMMONLIB_SRCDIR)

#Build the code that is common for all OCC processors (GPEs and 405)
$(OCCLIB):
	$(MAKE) -I $(IMAGE_SRCDIR) -C $(OCCLIB_SRCDIR)

#Build the library code that only works on the ppc405
$(PPC405LIB):
	$(MAKE) -I $(IMAGE_SRCDIR) -C $(PPC405LIB_SRCDIR)

$(PPETOOLS_OBJDIR)/tracepp:
	(cd $(TRACEPP_DIR) && make)

# collect all of the trace hash files for this image into a single trexStringFile
.PHONY : tracehash
tracehash:
	mkdir -p $(OBJDIR)
	$(THASH) -c -d $(OBJDIR) -s $(OBJDIR)/trexStringFile

# load and run the 405 image in simics
run: $(OBJDIR)/$(IMAGE_NAME).out
	$(SIMICS_WS)/simics \
		-e '$$occ_405_binary_to_load=$(OBJDIR)/$(IMAGE_NAME).out' modelsetup.simics

#clean out all generated files
.PHONY : clean
clean:
	rm -fr $(OBJDIR)

#Add dependencies to header files
ifneq ($(MAKECMDGOALS),clean)
-include $(OBJS:.o=.d)
endif
OpenPOWER on IntegriCloud