; --------------------------------------------------------------------------------
; @Title: Startup Script for Debugging Windows EC2013 Kernel Startup on PandaBoard
; @Description: -
; @Keywords: awareness
; @Author: DIE
; @Board: PandaBoard
; @Chip: OMAP4430
; @Copyright: (C) 1989-2019 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: nk.cmm 15210 2019-11-04 10:51:00Z bschroefel $


 LOCAL &winceroot &reldir &term

 &winceroot="C:\WINCE800"    ; typically C:\WINCE800
 &reldir="&winceroot\OSDesigns\PandaBSPuart\PandaBSPuart\RelDir\PANDABOARD_ARMV7_Debug"

 &term="COM3"

 SCREEN.ALways      ; permanent update for internal terminal window
 ; screen.on        ; if you use external terminal

 ; reset debugger

 WinCLEAR
 RESet

 ; setup debugger

 SYStem.CPU OMAP4430
 SYStem.Option ResBreak OFF     ; hardware dependent (see manual)
 SYStem.Option WaitReset ON     ; hardware dependent (see manual)
 SYStem.JtagClock CTCK 30MHz    ; hardware dependent (see manual)
 SYStem.Option DACR ON          ; give Debugger global write permissions
 TrOnchip.Set DABORT OFF        ; used by Windows CE for page miss!
 TrOnchip.Set PABORT OFF        ; used by Windows CE for page miss!
 TrOnchip.Set UNDEF OFF         ; my be used by Windows CE for FPU detection

 ; open serial terminal window for u-boot

 WinPOS 35. 0. ,,,,, comterm
 TERM.METHOD COM &term 115200.
 TERM.SIZE 80. 1000.
 TERM.Mode VT100
 TERM.SCROLL ON
 TERM.view

 ; connect to target

 SYStem.Up

 SETUP.IMASKASM ON             ; lock interrupts while single stepping

 MAP.DenyAccess 0xC0000000--0xDFFFFFFF  ; disable access to non-existent memory

 ; start on-board bootloader to initialize the board

 Go
 WAIT 1.s
 Break

 ; disable caches and MMU

 Data.Set C15:1 Data.Long(c15:1)&~0x1005    ; SCTLR: I/C/M; L1 cache and MMU
 Data.Set C15:0x201 %Long 0x00F00000	    ; CPACR InitFPU

 ; load image to physical memory

 ; see config.bib

 ; RAMIMAGE entry specifies virtual load address, here 0x80100000
 ; physical is usually RAM start plus the offset;
 ; RAM starts at 0x80000000, so physical load address is 0x80100000

 ; ROMSTART entry specifies the start address, here 0x80100000
 ; IMPORTANT: do *not* add 4k page to ROMSTART - we need the TOC!

 ; ROMOFFSET adds an offset to RAMIMAGE for flash load addresses,
 ; here 0x1F470400
 ; then load nk.bin to <phys. addr.> - (RAMIMAGE+ROMOFFSET)

 Register.RESet
 Data.LOAD.eXe "&reldir\nk.bin" 0x80100000-0x80100000               ; Debug
 ;Data.LOAD.EXE "&reldir\nk.bin" 0x80100000-(0x80100000+0x1F470400)  ; Shipbuild

 ; set PC to physical start address for each core
 ; see config.bib NK RAMIMAGE

 CORE.select 0
 Register.Set PC 0x80100000
 CORE.select 1
 Register.Set PC 0x80100000
 CORE.select 0

 ; We'd like to see something, open a code window.

 WinPOS 0. 0. 77. 22.
 List.auto

 ; load WinEC awareness (wince.t32) for section detection

 TASK.CONFIG ~~\demo\arm\kernel\wince\ec2013\wince8.t32
 MENU.ReProgram ~~\demo\arm\kernel\wince\ec2013\wince8.men
 sYmbol.AutoLoad.CHECKWINCE "do ~~\demo\arm\kernel\wince\ec2013\autoload "
 sYmbol.SourcePATH.Set &reldir

 ; specify physical address of image

 TASK.ROM.PA 0x80100000

 ; and load OAL symbols (nk.exe)

 TASK.sYmbol.Option AutoLoad NoProcess  ; no processes yet to handle
 TASK.sYmbol.LOADRM "nk.exe"

 ; adapt source paths if necessary (case sensitive!)
 ;sYmbol.SourcePATH.Translate "c:\wince800" "&winceroot"
 ;sYmbol.SourcePATH.Translate "d:\bt\1318" "&winceroot"
 sYmbol.SourcePATH.Set .    ; add current directory to search path

 ; start kernel

 ; open DCC terminal window for debug output

 WinPOS 35. 0. ,,,,, comterm
 TERM.RESet
 TERM.METHOD DCC3
 TERM.Mode ASCII
 TERM.SIZE 140. 1000.
 TERM.SCROLL ON
 TERM.view

 ; if you want to debug the tiny startup sequence, that is running
 ; in physical address mode, you have to relocate code symbols to physical:

 ;sYmbol.RELOC P:(0x80200000-0x80200000)
 ;Go KernelStart /Onchip   ; onchip because of cache switches

 ; after switching to virtual address; re-relocate symbols

 ;sYmbol.RELOC P:0x00000000

 ; use onchip because we switch on MMU
 ;Go ARMInit /Onchip
 Go OEMInit /Onchip

ENDDO
