################################################################################
#
#                    (C) Copyright 2006, Cortus S.A.
#                          ALL RIGHTS RESERVED
#                         http://www.cortus.com
#
# $CortusRelease$
# $FileName$
#
################################################################################

# GDB Initialization file when using debugger in command line mode via jtag server
#

target aps :38000

# Limit backtrace
set backtrace limit 20

################################################################################
# Dump out gmon data structure.
# This is used for profiling.
################################################################################
# 
# NB the format here has to correspond to that used by the gmon_conv program
define dump_gmon
    dump   binary value  gmon.raw gmonparam
    append binary memory gmon.raw gmonparam.arcs   &gmonparam.arcs[gmonparam.narcs]
    append binary memory gmon.raw gmonparam.counts &gmonparam.counts[gmonparam.ncounts]
    printf "Number of arcs %d/%d\n", gmonparam.narcs, gmonparam.maxarcs
    printf "Memory used %dK bytes\n", (sizeof(gmonparam) + gmonparam.ncounts * sizeof(unsigned short) + gmonparam.maxarcs * sizeof(struct rawarc))/1024
end
document dump_gmon
    Dump out the profiling data to gmon.raw for further processing.
    Convert this to gmon.out with gmon_conv (no parameters).
    This function will only works if profiling was enabled!
end

#################################################################################
# Reset various bits of HW
################################################################################

# Reset interrupt controller interrupts [0..7] inclusive
set *(unsigned*)0x40000000=0
set *(unsigned*)0x40000004=0
set *(unsigned*)0x40000008=0
set *(unsigned*)0x4000000c=0
set *(unsigned*)0x40000010=0
set *(unsigned*)0x40000014=0
set *(unsigned*)0x40000018=0
set *(unsigned*)0x4000001c=0

# Reset counter: value, reload, expired, mask
set *(unsigned*)0x40002000=0xffffffff
set *(unsigned*)0x40002004=0xffffffff
set *(unsigned*)0x40002008=0
set *(unsigned*)0x4000200c=0

load
break exit
break __stack_overflowed

