;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; QNX awareness on AM62 Cortex-A53
; 11 Jan 22 - Richard Woodruff - Create from AM64 for AM62
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ; Add Linux or Windows paths to component symbols
 &opath="d:"
;&opath="/opt"
 &SYMS="&opath/syms/am62"

 IF VERSION.BUILD()>13839.
   &demo=OS.PDD()
 ELSE
   &demo="~~/demo/arm64"

 RESet
 SYStem.RESet

 IF COMBIPROBE()||UTRACE()
 (
   IF (ID.WHISKER(0.)==0x12)
     SYStem.CONFIG.CONNECTOR MIPI20T
   ELSE
     SYStem.CONFIG.CONNECTOR MIPI34 ; because of converter LA-3782
 )

 SYStem.CPU AM625X
 CORE.ASSIGN 1. 2. 3. 4.
 SYStem.jtagclock ctck 20MHz

 SYStem.Option RESBREAK OFF
 SYStem.Option EnReset OFF
 ;SYStem.MemAccess.DAP  ; chance of coherency issue with awareness
 SYStem.MemAccess.Denied
 SYStem.Option.MemStatusCheck.on ; work around v8 timeout aborts

 &GTCSPEED="200MHz"  ; 250MHz Default, SDK now sets down to 200MHz

 stm.off
 stm.TimeStampCLOCK  &GTCSPEED
 systemtrace.off

 CTS.UseConst OFF
 CTS.UseMemory OFF
 CTS.UseRegister OFF

 ; system for QNX awareness
 SYStem.Option MMUSPACES ON     ; enable space ids to virtual addresses
 SETUP.IMASKASM ON              ; lock interrupts while single stepping
 setup.IMASKHLL.on

 SYStem.Mode Attach

; to debug the startup
 ;Data.LOAD.Elf "&SYMS/startup-armv8_fm.sym" /nocode
 ;TRANSlation.COMMON 0x0--0xffffffffffffffff
 ;stop

; Load the symbols of procnto for kernel debug
; add [+keeplinked] to build script to keep symbol files
 Data.LOAD.Elf "&SYMS/procnto-smp-instr.sym" /nocode /plusvm
;Data.LOAD.Elf "&SYMS/procnto-smp-instr-safety.sym" /nocode /plusvm

 PRINT "initializing debugger MMU..."
 MMU.FORMAT STD
 TRANSlation.COMMON 0xffffff8000000000--0xffffffffffffffff  ; kernel area is common for all MMU space ids
 TRANSlation.TableWalk ON    ; debugger uses a table walk to decode virtual addresses
 TRANSlation.ON              ; switch on debugger(!) address translation

; Initialize QNX Support
 PRINT "initializing QNX support..."
 TASK.CONFIG "&demo/kernel/qnx/qnx.t32"    ; loads QNX awareness
 MENU.ReProgram "&demo/kernel/qnx/qnx.men"

; Group kernel area to be displayed with red bar
 GROUP.Create "kernel" 0xffffff8000000000--0xffffffffffffffff /RED

 ; activate autoloader for processes:
 TASK.sYmbol.Option AutoLoad Process

 break

; -----------------------------------------------------------------------------
; Trace
(
  ETM.ContextID 32
  ETM.Trace ON
  ETM.ON
  ETM.TimeStampCLOCK &GTCSPEED
  ;ETM.TImeMode.AsyncTimeStamps
  ETM.TIMEMODE EXTERNAL
  Trace.clock 1200MHz
  &ppd=OS.PPD()
  DO "&ppd/../../../x_gel_to_cmm/am62_offchip_trace.cmm"
)

; Open up trace Analysis windows
 trace.STATistic.TASK                ; display per thread stats
 trace.stat.Y /t /SORT RATIO         ; display per symbol stats (kernel)
 trace.chart.Y /t /SORT RATIO        ; show timeline
 trace.chart.task
; trace.profilechart.task

 trace
 register /sl
 list

ENDDO
