; --------------------------------------------------------------------------------
; @Title: Nucleus Plus Demo for TRACE32 OS Awareness
; @Description: 
;   
;   This batchfile loads all necessary files to demonstrate
;   the OS Awareness for Nucleus PLUS.
;   
; @Keywords: nucleus, RTOS
; @Author: DIE
; @Chip: MPC821
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: nucleus.cmm 13125 2018-09-11 14:03:01Z rdienstbeck $

;   Created by Rudolf Dienstbeck / Lauterbach GmbH at 10.01.2002

; NOTE:
; currently the demo runs with Simulator or ICD on ADS821

 SCREEN.ON

; Emulator reset
 PRINT "resetting..."
 SYStem.RESet
 MAP.RESet
 WinPAGE.RESet
 WinPOS 0 20. 70. 8. 0. 0. W000
 AREA.view

; initialize system
 PRINT "initializing..."

 IF SIMULATOR()
 (
   SYStem.CPU MPC821
   SYStem.Up
 )

 IF ICD()
 (
   SYStem.BdmClock 5000000.
   SYStem.CPU MPC821
   SYStem.Up

   ; adapt it to your path
   DO ../../hardware/ads821/ads821.cmm
 )
 IF ICE()
 (
   SYStem.Option premapmod ON
   SYStem.Option base 0x2200000
   SYStem.Mode AloneInt

   ; System settings for PPC860 probe
   Data.Set spr:638. %Long 0x2200000
   Data.Set 0x2200100--0x220013f %Long 0x0
   Data.Set 0x2200100 %Long 0x01
   Data.Set 0x2200104 %Long 0x0ff009A4

   Register.Set MSR 0x1002
   Register.Set dec 0x0ffff
   ; TBSCR
   Data.Set 0x2200200 %Long 0x0966b0002
 )

; Default mapping
 IF ICE()
 (
   MAP.PRE 0x0--0x0fffff 0.
   MAP.DEFault 0x0--0x0fffff
 )
 IF FIRE()
 (
   MAP.Intern 0x0--0x0fffff
 )

; load sample application
 PRINT "loading sample application..."
 Data.LOAD.Elf history/demo.elf     // contains History Component
 ;Data.LOAD.Elf dbug+/demo.cof       // contains DBUG+
 
; skip UART Init function for simulator usage
 IF SIMULATOR()&&sYmbol.EXIST(UART_Init_Port)
   Data.Assemble P:UART_Init_Port blr

; initialize mutitasking support
 PRINT "initializing RTOS support..."
 TASK.CONFIG nucleus 
 MENU.ReProgram nucleus
 HELP.FILTER.Add rtosnucleus

 PRINT "load complete."
 
; open some windows
 WinPOS 0 0 74. 9. 0. 1. W001
 TASK.TaskStat 
 WinPOS 0 12. 80. 3. 0. 1. W003
 TASK.QueueStat
 WinPOS 50. 6. 70. 21.
 List.auto
 
; open DBUG+ terminal, if available
 IF sYmbol.EXIST(T32OUT)
   TERM.view T32OUT T32IN

 Go.direct task_1
 
 ENDDO
