; --------------------------------------------------------------------------------
; @Title: KGDB based Linux Aware Debugging
; @Description:
;  This script configures the TRACE32 GDB Front End to debug the Linux kernel using
;  KGDB over RS232. The Linux kernel must be compiled with KGDB enabled.
;  To stop execution, you need to use the kgdb-break.cmm script
; @Author: KJM
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: kgdb_serial.cmm 7697 2014-09-30 11:07:01Z kjmal $


  IF !INTERFACE.GDB()
  (
      DIALOG.OK "Please start a TRACE32 GDB Front End (PBI=GDB) for this demo."
      ENDDO
  )
  
  RESet
  WinCLEAR
  
  ; Select the CPU
  SYStem.CPU *
  
  ; Enable address extension
  SYStem.Option MMUSPACES ON
  
  ; Set the communcation parameter (serial port)
  SYStem.PORT COM1 baud=115200 KGDB
  
  ; Attach to the KGDB stub in the Linux kernel
  SYStem.Mode Attach
  
  ; Load the kernel symbols 
  Data.LOAD.Elf vmlinux /GNU /NoCODE 

  ; Load the Linux Awareness (e.g Linux-3.x. for ARM)
  TASK.CONFIG ~~/demo/arm/kernel/linux/linux-3.x/linux3.t32
  MENU.ReProgram ~~/demo/arm/kernel/linux/linux-3.x/linux.men
  
  ; Tell the Linux Awareness to only acces the memory using virtual addresses:
  TASK.Option NOPHYS

  ; Open a List window
  WinPOS 0% 0% 49% 48%
  List.auto
  
  ENDDO