; --------------------------------------------------------------------------------
; @Title: NetBSD Demo for TRACE32 OS Awareness
; @Description: 
;   
;   This batchfile demonstrates the use of the OS Awareness for NetBSD
;   
;   The example is generated for an MPC8548CDS board using an ICD.
;   It will NOT run on any other board, but may be used as a template
;   for others.
;   
;   NetBSD will be downloaded via ICD.
;   
; @Keywords: awareness, mpc8548cds, netbsd, RTOS
; @Author: DIE
; @Board: MPC8548CDS
; @Chip: MPC8548E
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: netbsd.cmm 13125 2018-09-11 14:03:01Z rdienstbeck $


; Starting NetBSD example with TRACE32 and Terminal:
; - Connect NULL modem cable to processor card
; - Start TRACE32
; - Open Terminal: 115200 baud, 8/N/1, no(!) handshake
; - TRACE32: do netbsd
; - Terminal: open a Shell and start "/usr/sbin/hello"


 SCREEN.ON

; Debugger Reset

 WinPAGE.RESet
 AREA.RESet
 WinPOS 0. 21. 70. 9. 0. 0. W000
 AREA.view
 
 PRINT "resetting..."

 SYStem.Down
 TASK.RESet
 Break.RESet
 MAP.RESet
 sYmbol.RESet
 TRANSlation.RESet

 
; Initializing Debugger

 PRINT "initializing..."
 SYStem.CPU MPC8548
 ;SYStem.BdmClock 10.0MHz
 SYStem.Option MMUSPACES ON     ; enable space ids to virtual addresses
 SYStem.Up
 SETUP.IMASKASM ON
 Register.RESet
 

; Target Setup

 PRINT "target setup..."

; if you want to load the image via ICD

 IF !SIMULATOR()
 ( 
   ; let the boot monitor setup the board
   Go.direct
   WAIT 5.s
   Break.direct
 )


; Load the NetBSD image
   
 ; Use the next lines only to load the NetBSD image into
 ; RAM using the debugger.
   
 PRINT "loading NetBSD image..."
 Register.RESet
 Data.LOAD.Elf netbsd-MPC8548CDS-hello
 ;Data.LOAD.Elf netbsd


; Load the NetBSD kernel symbols into the debugger

 PRINT "loading NetBSD kernel symbols..."
 Data.LOAD.Elf netbsd.gdb /NoCODE
   

; Initializing Debugger MMU

 TRANSlation.RESet
 TRANSlation.Create 0x0:0x0--0x00FFFFFF 0x0     // map kernel pages manually
 TRANSlation.Create 0x0:0x0b000000--0x0bffffff 0x0b000000  // kernel's heap
 TRANSlation.COMMON 0x0--0x00FFFFFF         // valid for all space ids
 TRANSlation.ON
   
 WinPOS 0. 0. 75. 18.
 List.auto


; Initialize RTOS Support

 ; Note that the NetBSD awareness needs the kernel symbols to work
 
 PRINT "initializing NetBSD support..."
 TASK.CONFIG ../netbsd       ; loads NetBSD awareness (netbsd.t32)
 MENU.ReProgram ../netbsd    ; loads NetBSD menu (netbsd.men)
 HELP.FILTER.Add rtosnetbsd  ; add NetBSD awareness manual to help filter

 ; switch on autoloader
 
 sYmbol.AutoLOAD.CHECKLINUX "do "+OS.PPD()+"/../autoload "

; Group kernel area to be displayed with red bar

 GROUP.Create "kernel" 0x0--0x00FFFFFF /RED


; Let's boot NetBSD
 Go.direct
 PRINT "booting NetBSD..."
 WAIT 5.s
 
 PRINT "done."     ; done with loading and starting NetBSD
 

; --------------------------------------------------------------------------------
; Application Debugging
; e.g. "hello"

 DO ../app_debug hello

 ENDDO
 
