-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
297 lines (292 loc) · 9.64 KB
/
CMakeLists.txt
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
cmake_minimum_required(VERSION 3.10)
project(hitagimon VERSION 0.2)
enable_language(CXX C ASM-ATT)
set(CMAKE_CXX_STANDARD 17)
set(tools /home/jwscoggins/dev/i960/i960-elf-gcc-3.4.6_v4_to_11.3.0)
set(CMAKE_C_COMPILER ${tools}/bin/i960-elf-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/i960-elf-g++)
set(CMAKE_ASM-ATT_COMPILER ${tools}/bin/i960-elf-as)
set(CMAKE_LINKER ${tools}/bin/i960-elf-ld)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBARE_METAL -DUSE_STRLWR=0 -DUSE_DL=0 -DUSH_CONFIG_PLATFORM_POSIX -fno-exceptions")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBARE_METAL -DUSE_STRLWR=0 -DUSE_DL=0 -DCONFIG_PLATFORM_POSIX --std=gnu99")
set(CMAKE_OBJCOPY_COMPILER ${tools}/bin/i960-elf-objcopy)
set(CMAKE_OBJDUMP_COMPILER ${tools}/bin/i960-elf-objdump)
# gcc 3.4.6 doesn't support colorizing output
unset(CMAKE_COLOR_DIAGNOSTICS CACHE)
add_compile_options(-Wall)
# for some reason, the compiler generated multiple copies of the same entries
#add_link_options(-Wl,--as-needed -nostdlib -static -T ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT} -ffreestanding -Wl,--allow-multiple-definition)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msc -mnumerics")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msc -mnumerics")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mka -msoft-float")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mka -msoft-float")
set(CMAKE_ASM-ATT_FLAGS "${CMAKE_ASM_FLAGS} -AMC -I${CMAKE_SOURCE_DIR}/boot")
#set(CMAKE_ASM-ATT_FLAGS "${CMAKE_ASM_FLAGS} -AKA -I${CMAKE_SOURCE_DIR}/boot")
#add_link_options(-mmc -mnumerics)
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -nostdlib -static -T ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT} -msb -mnumerics -ffreestanding")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
add_library(hitagisys
# disabled entries are because mon960 provides the implementations for them
#sys/brk.cc
#sys/fstat.cc
#sys/isatty.cc
sys/lseek.cc
sys/write.cc
sys/read.cc
sys/open.cc
#sys/kill.cc
sys/setitimer.cc
sys/close.cc
sys/gettimeofday.cc
sys/access.cc
#sys/getpid.cc
sys/_exit.cc
sys/link.cc
sys/unlink.cc sys/linkage.cc sys/getrusage.cc)
add_library(hitagicortex
cortex/Faults.def
cortex/IODevice.cc
cortex/IODevice.h
cortex/ChipsetInteract.h
cortex/Faults.cc
cortex/Faults.h
cortex/IAC.h
cortex/IAC.cc
cortex/IACImplementation.s
cortex/ModernCpp.h
cortex/SystemCounter.h cortex/SystemCounter.cc cortex/builtins.h cortex/builtins.c cortex/IndirectInterrupts.cc
cortex/ext2.h
cortex/SoftwareDMA.h
cortex/SoftwareDMA.cc
cortex/SysExamine.cc
cortex/builtins.s
)
add_library(wasm3
wasm3/wasm3.h
wasm3/wasm3_defs.h
wasm3/m3_api_libc.c
wasm3/m3_api_libc.h
wasm3/m3_api_meta_wasi.c
wasm3/m3_api_tracer.c
wasm3/m3_api_tracer.h
wasm3/m3_api_uvwasi.c
wasm3/m3_api_wasi.c
wasm3/m3_api_wasi.h
wasm3/m3_bind.c
wasm3/m3_bind.h
wasm3/m3_code.c
wasm3/m3_compile.c
wasm3/m3_core.c
wasm3/m3_env.c
wasm3/m3_exec.c
wasm3/m3_exec.h
wasm3/m3_function.c
wasm3/m3_info.c
wasm3/m3_info.h
wasm3/m3_math_utils.h
wasm3/m3_module.c
wasm3/m3_parse.c
)
add_executable(hitagimon
boot/sx_init.s # this must ALWAYS be first!
boot/f_table.s
boot/i_handle.s
boot/i_table.s
boot/f_handle.cc
boot/macros.s
hitagimain.cc
start.ld
)
# add the microshell library directly since I get an infinite loop otherwise
#add_library(microshell
# microshell/src/inc/ush.h
# microshell/src/inc/ush_commands.h
# microshell/src/inc/ush_const.h
# microshell/src/inc/ush_file.h
# microshell/src/inc/ush_internal.h
# microshell/src/inc/ush_node.h
# microshell/src/inc/ush_preconfig.h
# microshell/src/inc/ush_shell.h
# microshell/src/inc/ush_types.h
# microshell/src/inc/ush_utils.h
# microshell/src/config/ush_config_platform.h
# microshell/src/config/posix/ush_config.h
# microshell/src/src/commands/ush_cmd.c
# microshell/src/src/commands/ush_cmd_cat.c
# microshell/src/src/commands/ush_cmd_cd.c
# microshell/src/src/commands/ush_cmd_echo.c
# microshell/src/src/commands/ush_cmd_help.c
# microshell/src/src/commands/ush_cmd_ls.c
# microshell/src/src/commands/ush_cmd_pwd.c
# microshell/src/src/commands/ush_cmd_xxd.c
# microshell/src/src/ush.c
# microshell/src/src/ush_autocomp.c
# microshell/src/src/ush_autocomp_state.c
# microshell/src/src/ush_autocomp_utils.c
# microshell/src/src/ush_commands.c
# microshell/src/src/ush_file.c
# microshell/src/src/ush_node.c
# microshell/src/src/ush_node_mount.c
# microshell/src/src/ush_node_utils.c
# microshell/src/src/ush_parse.c
# microshell/src/src/ush_parse_char.c
# microshell/src/src/ush_parse_utils.c
# microshell/src/src/ush_process.c
# microshell/src/src/ush_prompt.c
# microshell/src/src/ush_read.c
# microshell/src/src/ush_read_char.c
# microshell/src/src/ush_read_utils.c
# microshell/src/src/ush_reset.c
# microshell/src/src/ush_utils.c
# microshell/src/src/ush_write.c
# microshell/src/src/ush_write_utils.c
#
#)
add_subdirectory(microshell/src)
build_ush(microshell)
target_compile_definitions(
microshell
PUBLIC
USH_CONFIG_PLATFORM_POSIX
)
set_target_properties(hitagimon PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/start.ld)
add_library(hitagiemul
emulation/Segment.cc emulation/Segment.h emulation/Domain.cc emulation/Domain.h)
target_include_directories(hitagiemul PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(hitagicortex PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(hitagisys PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(hitagimon PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(wasm3 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(hitagimon
hitagicortex
hitagisys
hitagiemul
wasm3
microshell
mon960
)
#add_link_options(-Wl,--as-needed -nostdlib -static -T ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT} -ffreestanding -Wl,--allow-multiple-definition)
target_link_options(hitagimon
PRIVATE -Wl,--as-needed
PRIVATE -static
PRIVATE -T ${CMAKE_SOURCE_DIR}/start.ld
PRIVATE -ffreestanding
PRIVATE -Wl,--allow-multiple-definition
)
add_custom_command(
OUTPUT prog.bin
COMMAND ${CMAKE_OBJCOPY_COMPILER} --pad-to=0x00100000 --only-section=.boot --only-section=.text --only-section=.bss --only-section=.data --gap-fill=0x00 --set-section-flags .bss=alloc,load,contents --set-section-flags .boot=alloc,load,contents -O binary hitagimon prog.bin
DEPENDS hitagimon
#MAIN_DEPENDENCY hitagimon
)
add_custom_target(hitagimon_sd_image
DEPENDS prog.bin
)
#add_custom_command(
# OUTPUT data.bin
# COMMAND ${CMAKE_OBJCOPY_COMPILER} --pad-to=0xFE900000 --only-section=.bss --only-section=.data --gap-fill=0x00 --set-section-flags .bss=alloc,load,contents -O binary hitagimon data.bin
# MAIN_DEPENDENCY
# hitagimon
#)
#
#add_custom_command(
# OUTPUT code.bin
# COMMAND ${CMAKE_OBJCOPY_COMPILER} --pad-to=0x00200000 --only-section=.text -O binary hitagimon code.bin
# MAIN_DEPENDENCY
# hitagimon
#)
#
#
#
#add_custom_target(hitagimon_firmware
# DEPENDS
# code.bin
# data.bin
#)
#
#
#add_custom_command(
# OUTPUT flash_firmware_p0.bin
# COMMAND ${CMAKE_OBJCOPY_COMPILER} --interleave-width=1 -b 0 -i 4 -I binary -O binary code.bin flash_firmware_p0.bin
# DEPENDS hitagimon_firmware
# MAIN_DEPENDENCY code.bin
#)
#
#add_custom_command(
# OUTPUT flash_firmware_p1.bin
# COMMAND ${CMAKE_OBJCOPY_COMPILER} --interleave-width=1 -b 1 -i 4 -I binary -O binary code.bin flash_firmware_p1.bin
# DEPENDS hitagimon_firmware
# MAIN_DEPENDENCY code.bin
#)
#
#add_custom_command(
# OUTPUT flash_firmware_p2.bin
# COMMAND ${CMAKE_OBJCOPY_COMPILER} --interleave-width=1 -b 2 -i 4 -I binary -O binary code.bin flash_firmware_p2.bin
# DEPENDS hitagimon_firmware
# MAIN_DEPENDENCY code.bin
#)
#
#add_custom_command(
# OUTPUT flash_firmware_p3.bin
# COMMAND ${CMAKE_OBJCOPY_COMPILER} --interleave-width=1 -b 3 -i 4 -I binary -O binary code.bin flash_firmware_p3.bin
# DEPENDS hitagimon_firmware
# MAIN_DEPENDENCY code.bin
#)
#
#add_custom_target(hitagimon_wide_mode_parts
# DEPENDS
# flash_firmware_p0.bin
# flash_firmware_p1.bin
# flash_firmware_p2.bin
# flash_firmware_p3.bin
#)
#
#set(TARGET_FLASH_CHIP SST39SF040@PLCC32)
#add_custom_command(
# OUTPUT uploaded_flash_firmware0
# COMMAND minipro -p ${TARGET_FLASH_CHIP} --write flash_firmware_p0.bin
# DEPENDS hitagimon_wide_mode_parts
# MAIN_DEPENDENCY flash_firmware_p0.bin
#)
#
#add_custom_target(install_wide_flash0
# DEPENDS
# uploaded_flash_firmware0
#)
#
#add_custom_command(
# OUTPUT uploaded_flash_firmware1
# COMMAND minipro -p ${TARGET_FLASH_CHIP} --write flash_firmware_p1.bin
# DEPENDS hitagimon_wide_mode_parts
# MAIN_DEPENDENCY flash_firmware_p1.bin
#)
#
#add_custom_target(install_wide_flash1
# DEPENDS
# uploaded_flash_firmware1
#)
#add_custom_command(
# OUTPUT uploaded_flash_firmware2
# COMMAND minipro -p ${TARGET_FLASH_CHIP} --write flash_firmware_p2.bin
# DEPENDS hitagimon_wide_mode_parts
# MAIN_DEPENDENCY flash_firmware_p2.bin
#)
#
#add_custom_target(install_wide_flash2
# DEPENDS
# uploaded_flash_firmware2
#)
#add_custom_command(
# OUTPUT uploaded_flash_firmware3
# COMMAND minipro -p ${TARGET_FLASH_CHIP} --write flash_firmware_p3.bin
# DEPENDS hitagimon_wide_mode_parts
# MAIN_DEPENDENCY flash_firmware_p3.bin
#)
#
#add_custom_target(install_wide_flash3
# DEPENDS
# uploaded_flash_firmware3
#)