1#!/usr/bin/env omake 2#---------------------------------------------------------------------------- 3# Project: Horizon 4# File: debuggerdefs.partner.om 5# 6# Copyright 2007-2009 Nintendo. All rights reserved. 7# 8# These coded instructions, statements, and computer programs contain 9# proprietary information of Nintendo of America Inc. and/or Nintendo 10# Company Ltd., and are protected by Federal copyright law. They may 11# not be disclosed to third parties or copied or duplicated in any form, 12# in whole or in part, without the prior written consent of Nintendo. 13# 14# $Date:: 2010-12-09#$ 15# $Rev: 32502 $ 16# $Author: takiguchi_shinichi $ 17#---------------------------------------------------------------------------- 18 19PYTHON = python 20RUBY = ruby 21PARTNER_PARTNER = $(absname $(ROOT_TOOLS)$(DIRSEP)CommandLineTools$(DIRSEP)partner_partner.rb) 22private.RUNNER_CORE_0_2 = $(file $(ROOT_BUILD)/runner/run-core_0_2.py) 23LOADRUN = $(absname $(ROOT_TOOLS)$(DIRSEP)CommandLineTools$(DIRSEP)ctr_loadrunf32.exe) 24LOADRUN_SPI = $(absname $(ROOT_TOOLS)$(DIRSEP)CommandLineTools$(DIRSEP)ctr_loadrun32.exe) 25 26public.PartnerMCR(axf, process) = 27 export depend_files 28 depend_files = 29 if $(not $(SKIP_BUILD)) 30 depend_files += $(axf) $(process) 31 32 export basefile 33 export axf_symbol 34 if $(not $(equal $(process), $(EMPTY))) 35 basefile = $(process) 36 axf_symbol = $(removesuffix $(process)).axf 37 else 38 basefile = $(axf) 39 40 mcr = $(addsuffix .mcr,$(removesuffix $(basefile))) 41 log = $(removesuffix $(absname $(basefile))).log 42 basedir = $(dirname $(absname $(basefile))) 43 44 $(mcr): $(dirname $(mcr)) $(ROOT_OMAKE)/debuggerdefs.partner.om $(depend_files) 45 section 46 f = $(fopen $(@), w) 47 fprintln($(f),ESC) 48 fprintln($(f),INITA) 49 fprintln($(f),CORE 0) 50 fprintln($(f),L "$(absname $(axf))") 51 if $(axf_symbol) 52 fprintln($(f),LSA "$(absname $(axf_symbol))") 53 54 fprintln($(f),CD "$(basedir)") 55 if $(not $(equal $(log),$(EMPTY))) 56 fprintln($(f),$">" "$(absname $(log))") 57 fprintln($(f),G) 58 close($(f)) 59 60 if $(and $(defined TEST_ENVIRONMENT_PROCESSLIST), $(TEST_ENVIRONMENT_PROCESSLIST)) 61 $(log): $(mcr) $(depend_files) $(RUNNER) :effects: $(RUNNER_LOCK) 62 bash $(RUNNER) $(mcr) 63 64 return $(mcr) 65 66private.IsEmpty(seq) = 67 return $(eq 0, $(length $(seq))) 68 69public.FilterTestAttributes(process) = 70 71 if $(not $(defined TEST_ATTRIBUTES)) 72 TEST_ATTRIBUTES = 73 export 74 75 if $(not $(defined TEST_INCLUDE)) 76 TEST_INCLUDE = BASIC 77 export 78 else 79 TEST_INCLUDE = $(split $",",$(TEST_INCLUDE)) 80 export 81 82 if $(not $(defined TEST_EXCLUDE)) 83 TEST_EXCLUDE = 84 export 85 else 86 TEST_EXCLUDE = $(split $",",$(TEST_EXCLUDE)) 87 export 88 89 attributes = $(ParseDependProcess null, $(rootname $(process)), $(TEST_ATTRIBUTES)) 90 91 if $(IsEmpty $(attributes)) 92 attributes = BASIC 93 export 94 95 has_includes = $(filter $(TEST_INCLUDE), $(attributes)) 96 has_excludes = $(filter $(TEST_EXCLUDE), $(attributes)) 97 98 if $(and $(IsEmpty $(has_excludes)), $(not $(IsEmpty $(has_includes)))) 99 return $(process) 100 101 return 102 103public.FilterTest(sources) = 104 105 filtered_sources = $(sources) 106 107 if $(defined TEST_FILTER) 108 regex = $"^\("$(compileToRegex $(TEST_FILTER))$"\)"\$ 109 filtered_sources = 110 111 foreach( source, $(sources) ) 112 if $(isFilterMatch $(regex), $(rootname $(basename $(source)))) 113 filtered_sources += $(source) 114 export filtered_sources 115 export filtered_sources 116 export filtered_sources 117 118 return $(filtered_sources) 119 120private.RunProgramBeforeTest(options, logfile) = 121 if $(defined BEFORE_TEST) 122 foreach(runner, $(BEFORE_TEST)) 123 runner.run($(options), logfile) 124 125private.GetDependsBeforeTest() = 126 ret = 127 if $(defined BEFORE_TEST) 128 foreach(runner, $(BEFORE_TEST)) 129 value $(runner.GetDepends) 130 return $(ret) 131 132private.RunProgramAfterTest(options, logfile) = 133 if $(defined AFTER_TEST) 134 foreach(runner, $(AFTER_TEST)) 135 runner.run($(options), logfile) 136 137private.GetDependsAfterTest() = 138 ret = 139 if $(defined AFTER_TEST) 140 foreach(runner, $(AFTER_TEST)) 141 value $(runner.GetDepends) 142 return $(ret) 143 144private.ParseDependProcesses(process, processlist) = 145 processes = 146 basedir = $(dirname $(absname $(process))) 147 148 foreach(proc, $(DEPEND_PROCESSES)) 149 if $(not $(proc)) 150 continue 151 152 if $(findstring $(proc),$"^@") 153 processes += $(file $(removeprefix $"@", $(proc))) 154 export 155 156 elseif $(findstring $(proc),$"^\.") 157 processes += $(file $(absname $(proc))) 158 export 159 160 else 161 tmp_image_dir = $(dirname $(proc)) 162 tmp_image_dir = $(absname $(addprefix $(basedir)$(DIRSEP)..$(DIRSEP)..$(DIRSEP),$(tmp_image_dir))) 163 tmp_image = $(addsuffix $(EXT_CDI),$(basename $(proc))) 164 tmp_image = $(addprefix $(config.getTargetSubDirectory false)$(DIRSEP),$(tmp_image)) 165 processes += $(file $(addprefix $(tmp_image_dir)$(DIRSEP),$(tmp_image))) 166 export 167 export 168 169 return $(processes) 170 171public.GetLoadrunOptions() = 172 options = 173 174 if $(and $(not $(defined RUN_TIMEOUT)), $(not $(IsEmpty $(filter dotests-%, $(TARGETS))))) 175 RUN_TIMEOUT = 60 176 export RUN_TIMEOUT 177 178 if $(and $(not $(defined EXIT_PATTERN)), $(not $(IsEmpty $(filter dotests-%, $(TARGETS))))) 179 EXIT_PATTERN=$"CU_TEST_EXIT|KernelPanic|nn::svc::Break\(" 180 export EXIT_PATTERN 181 182 if $(and $(defined RUN_NOWAIT), $(RUN_NOWAIT)) 183 options += --no-wait 184 export options 185 186 if $(defined EXIT_PATTERN) 187 options += --exit-pattern $(string $(EXIT_PATTERN)) 188 export options 189 190 if $(defined RUN_TIMEOUT) 191 options += --timeout $(RUN_TIMEOUT) 192 export options 193 194 if $(defined RUN_DEVICE) 195 options += -d $(RUN_DEVICE) 196 export options 197 198 if $(and $(defined RUN_VARBOSE), $(RUN_VARBOSE)) 199 options += --varbose 200 export options 201 202 return $(options) 203 204public.GetLoadrunOptionsForTool() = 205 options = 206 207 if $(and $(defined RUN_NOWAIT), $(RUN_NOWAIT)) 208 options += --no-wait 209 export options 210 211 return $(options) 212 213public.FilesToRunProcessList(config, process) = 214 process = $(filter %.cdi,$(process)) 215 if $(eq 0,$(length $(process))) 216 return 217 process = $(nth 0,$(process)) 218 219 export depend_files 220 depend_files = 221 222 export processes 223 processes = 224 225 kernel = $(config.getSuitableKernelFilename) 226 kernel_core0 = $(gsub $(kernel),Kernel\.ARM946ES\.,Kernel.MPCore.) 227 kernel_core2 = $(gsub $(kernel),Kernel\.MPCore\.,Kernel.ARM946ES.) 228 229 if $(not $(and $(defined TEST_DEBUG_ARM9), $(TEST_DEBUG_ARM9))) 230 kernel_core2 = $(gsub $(kernel_core2),Development,Release) 231 kernel_core2 = $(gsub $(kernel_core2),Debug,Release) 232 export 233 234 log = $(addsuffix .proclist.log,$(removesuffix $(process))) 235 setuplog = $(addsuffix .proclist.setup.log,$(removesuffix $(process))) 236 teardownlog = $(addsuffix .proclist.teardown.log,$(removesuffix $(process))) 237 basedir = $(dirname $(absname $(process))) 238 239 if $(defined DEPEND_PROCESSES) 240 DEPEND_PROCESSES = $(ParseDependProcess $(config), $(removesuffix $(basename $(process))), $(DEPEND_PROCESSES)) 241 processes += $(ParseDependProcesses $(process), $(DEPEND_PROCESSES)) 242 export 243 processes += $(absname $(process)) 244 245 if $(not $(SKIP_BUILD)) 246 depend_files += $(kernel_core0) $(kernel_core2) 247 depend_files += $(processes) 248 249 processes = $(addprefix @,$(processes)) 250 251 process_list = $(dirname $(kernel_core0))$(DIRSEP)process.list 252 253 tooloptions = -c0 esc -c0 init -k11 $(kernel_core0) -k9 $(kernel_core2) -pl $(process_list) $(GetLoadrunOptionsForTool) 254 255 if $(not $(and $(defined SKIP_RUN), $(SKIP_RUN))) 256 if $(and $(defined TEST_ENVIRONMENT_PROCESSLIST), $(TEST_ENVIRONMENT_PROCESSLIST)) 257 $(log): $(LOADRUN) $(depend_files) $(GetDependsBeforeTest) $(GetDependsAfterTest) :effects: $(LOADRUN) :value: $(random) 258 if $(and $(defined LOGLIST), $(LOGLIST)) 259 echo $(log) >> $(LOGLIST) 260 if $(defined RUN_HOSTPROGRAM) 261 RUN_HOSTPROGRAM.run() 262 RunProgramBeforeTest($(tooloptions), $(setuplog)) 263 section 264 f = $(fopen $(process_list), w) 265 foreach(filename, $(processes)) 266 fprintln($(f), $(filename)) 267 close($(f)) 268 269 $(LOADRUN) -c0 esc -c0 init -k11 $(kernel_core0) -k9 $(kernel_core2) $(GetLoadrunOptions) | tee $(absname $(log)) 270 RunProgramAfterTest($(tooloptions), $(teardownlog)) 271 depend_files += $(log) 272 273 if $(filter run-proclist, $(TARGETS)) 274 $(log): $(LOADRUN) $(depend_files) $(GetDependsBeforeTest) $(GetDependsAfterTest) :effects: $(LOADRUN) :value: $(random) 275 section 276 f = $(fopen $(process_list), w) 277 foreach(filename, $(processes)) 278 fprintln($(f), $(filename)) 279 close($(f)) 280 $(LOADRUN) -c0 esc -c0 init -k11 $(kernel_core0) -k9 $(kernel_core2) $(GetLoadrunOptions) | tee $(absname $(log)) 281 depend_files += $(log) 282 export 283 export 284 return $(depend_files) 285 286public.FilesToRunEmulationMemory(config, process) = 287 288 process = $(filter %.cci %.csu,$(process)) 289 if $(eq 0,$(length $(process))) 290 return 291 process = $(nth 0,$(process)) 292 293 kernel = $(config.getSuitableKernelFilename) 294 kernel_core0 = $(gsub $(kernel),Kernel\.ARM946ES\.,Kernel.MPCore.) 295 kernel_core2 = $(gsub $(kernel),Kernel\.MPCore\.,Kernel.ARM946ES.) 296 297 if $(not $(and $(defined TEST_DEBUG_ARM9), $(TEST_DEBUG_ARM9))) 298 kernel_core2 = $(gsub $(kernel_core2),Development,Release) 299 kernel_core2 = $(gsub $(kernel_core2),Debug,Release) 300 export 301 302 if $(and $(defined RUN_FAST_KERNEL), $(RUN_FAST_KERNEL)) 303 kernel_core0 = $(gsub $(kernel_core0),.small,.fast) 304 kernel_core2 = $(gsub $(kernel_core2),.small,.fast) 305 export 306 307 export processes 308 processes = 309 310 export options 311 options = 312 313 export depend_files 314 depend_files = 315 316 if $(defined DEPEND_PROCESSES) 317 DEPEND_PROCESSES = $(ParseDependProcess $(config), $(removesuffix $(basename $(process))), $(DEPEND_PROCESSES)) 318 processes += $(ParseDependProcesses $(process), $(DEPEND_PROCESSES)) 319 export 320 321 if $(not $(SKIP_BUILD)) 322 depend_files += $(process) $(kernel_core0) $(kernel_core2) 323 depend_files += $(processes) 324 325 foreach(proc, $(processes)) 326 options += -rp $(proc) 327 328 if $(and $(defined RUN_FROMTESTMENU), $(RUN_FROMTESTMENU)) 329 options += -c0 "rdc $(process),0" 330 options += -c0 "zn ID2_2=0x20" 331 options += -rid 0004013000008002 332 export 333 else 334 options += -re $(process) 335 export 336 337 log = $(addsuffix .emumem.log,$(removesuffix $(process))) 338 setuplog = $(addsuffix .proclist.setup.log,$(removesuffix $(process))) 339 teardownlog = $(addsuffix .proclist.teardown.log,$(removesuffix $(process))) 340 basedir = $(dirname $(absname $(process))) 341 342 process_list = $(dirname $(kernel_core0))$(DIRSEP)process.list 343 344 tooloptions = -c0 esc -c0 init -k11 $(kernel_core0) -k9 $(kernel_core2) -pl $(process_list) $(GetLoadrunOptionsForTool) 345 346 if $(not $(and $(defined SKIP_RUN), $(SKIP_RUN))) 347 if $(or $(and $(defined TEST_ENVIRONMENT_EMUMEM), $(TEST_ENVIRONMENT_EMUMEM))\ 348 $(and $(defined TEST_ENVIRONMENT_IMPORT), $(TEST_ENVIRONMENT_IMPORT))) 349 $(log): $(LOADRUN) $(depend_files) $(GetDependsBeforeTest) $(GetDependsAfterTest) :effects: $(LOADRUN) :value: $(random) 350 if $(and $(defined LOGLIST), $(LOGLIST)) 351 echo $(log) >> $(LOGLIST) 352 if $(defined RUN_HOSTPROGRAM) 353 RUN_HOSTPROGRAM.run() 354 RunProgramBeforeTest($(tooloptions), $(setuplog)) 355 echo $(LOADRUN) -c0 esc -c0 init -k11 $(kernel_core0) -k9 $(kernel_core2) -pl $(process_list) $(options) $(GetLoadrunOptions) 356 $(LOADRUN) -c0 esc -c0 init -k11 $(kernel_core0) -k9 $(kernel_core2) -pl $(process_list) $(options) $(GetLoadrunOptions) | tee $(absname $(log)) 357 RunProgramAfterTest($(tooloptions), $(teardownlog)) 358 depend_files += $(log) 359 export 360 export 361 362 if $(filter run-emumem, $(TARGETS)) 363 $(log): $(LOADRUN) $(depend_files) $(GetDependsBeforeTest) $(GetDependsAfterTest) :effects: $(LOADRUN) :value: $(random) 364 $(LOADRUN) -c0 esc -c0 init -k11 $(kernel_core0) -k9 $(kernel_core2) -pl $(process_list) $(options) $(GetLoadrunOptions) | tee $(absname $(log)) 365 depend_files += $(log) 366 export 367 export 368 369 return $(depend_files) 370 371public.FilesToRunSPI(config, process) = 372 process = $(filter %.cci,$(process)) 373 if $(eq 0,$(length $(process))) 374 return 375 process = $(nth 0,$(process)) 376 377 export depend_files 378 depend_files = 379 if $(not $(SKIP_BUILD)) 380 depend_files += $(process) 381 382 log = $(addsuffix .spi.log,$(removesuffix $(process))) 383 384 commands = -c esc -c reset 385 commands += -c "RDC \"$(process)\",0" 386 commands += -c NEWP 387 388 if $(and $(defined TEST_ENVIRONMENT_SPI), $(TEST_ENVIRONMENT_SPI)) 389 $(log): $(LOADRUN_SPI) $(depend_files) :effects: $(LOADRUN_SPI) :value: $(random) 390 $(LOADRUN_SPI) $(commands) $(GetLoadrunOptions) | tee $(absname $(log)) 391 depend_files += $(log) 392 393 if $(filter run-spi, $(TARGETS)) 394 $(log): $(LOADRUN_SPI) $(depend_files) :effects: $(LOADRUN_SPI) :value: $(random) 395 $(LOADRUN_SPI) $(commands) $(GetLoadrunOptions) | tee $(absname $(log)) 396 depend_files += $(log) 397 398 return $(depend_files) 399 400public.UserRunProcess(config, name, files) = 401 TARGET_FILE = $(UserProcess $(config), $(name), $(files)) 402 LIST_PREFIX = $(removesuffix $(basename $(TARGET_FILE))) 403 CCIFile = $(replacesuffixes $(EXT_ELF), $(EXT_CCI), $(TARGET_FILE)) 404 CIPFile = $(replacesuffixes $(EXT_ELF), $(EXT_CIP), $(TARGET_FILE)) 405 406 RUN_PROCLIST_FILES = $(FilesToRunProcessList $(config),$(absname $(TARGET_FILE))) 407 RUN_EMUMEM_FILES = $(FilesToRunEmulationMemory $(config),$(absname $(TARGET_FILE))) 408 RUN_SPI_FILES = $(FilesToRunSPI $(config),$(absname $(TARGET_FILE))) 409 410 if $(not $(defined RUN_FILTER)) 411 RUN_FILTER= * 412 export 413 414 if $(isFilterMatch $(compileToRegex $(RUN_FILTER)), $(config.getScannerName)) 415 run-proclist: $(RUN_PROCLIST_FILES) 416 run-scripts: $(RUN_PROCLIST_FILES) 417 run-emumem: $(RUN_EMUMEM_FILES) 418 run-spi: $(RUN_SPI_FILES) 419 420 return $(TARGET_FILE) 421