# HG changeset patch # User gthomas # Date 1067523175 0 # Node ID 2a68919a1b99305c47d1a9c9a484f338a0171fc7 # Parent 1ded88da2dd4308bfefcea56d7ccf3ff06508f4d Enable profiling using timer #1 diff --git a/packages/hal/arm/sa11x0/var/current/ChangeLog b/packages/hal/arm/sa11x0/var/current/ChangeLog --- a/packages/hal/arm/sa11x0/var/current/ChangeLog +++ b/packages/hal/arm/sa11x0/var/current/ChangeLog @@ -1,3 +1,8 @@ +2003-10-30 Gary Thomas + + * cdl/hal_arm_sa11x0.cdl: + * src/sa11x0_misc.c: Add support for profiling, using timer #1 + 2003-07-18 Nick Garnett * cdl/hal_arm_sa11x0.cdl: diff --git a/packages/hal/arm/sa11x0/var/current/cdl/hal_arm_sa11x0.cdl b/packages/hal/arm/sa11x0/var/current/cdl/hal_arm_sa11x0.cdl --- a/packages/hal/arm/sa11x0/var/current/cdl/hal_arm_sa11x0.cdl +++ b/packages/hal/arm/sa11x0/var/current/cdl/hal_arm_sa11x0.cdl @@ -62,6 +62,7 @@ cdl_package CYGPKG_HAL_ARM_SA11X0 { implements CYGINT_HAL_ARM_ARCH_STRONGARM implements CYGINT_HAL_VIRTUAL_VECTOR_COMM_BAUD_SUPPORT + implements CYGINT_PROFILE_HAL_TIMER # Let the architectural HAL see this variant's interrupts file - # the SA11x0 has no variation between targets here. diff --git a/packages/hal/arm/sa11x0/var/current/src/sa11x0_misc.c b/packages/hal/arm/sa11x0/var/current/src/sa11x0_misc.c --- a/packages/hal/arm/sa11x0/var/current/src/sa11x0_misc.c +++ b/packages/hal/arm/sa11x0/var/current/src/sa11x0_misc.c @@ -9,6 +9,7 @@ // ------------------------------------------- // This file is part of eCos, the Embedded Configurable Operating System. // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. +// Copyright (C) 2003 Gary Thomas // // eCos is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -207,6 +208,44 @@ void hal_delay_us(cyg_int32 usecs) val -= 1000000; } } +#ifdef CYGPKG_PROFILE_GPROF +//-------------------------------------------------------------------------- +// +// Profiling support - uses a separate high-speed timer +// + +#include +#include +#include + +// Can't rely on Cyg_Interrupt class being defined. +#define Cyg_InterruptHANDLED 1 + +// Profiling timer ISR +static cyg_uint32 +profile_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data, HAL_SavedRegisters *regs) +{ + HAL_INTERRUPT_ACKNOWLEDGE(CYGNUM_HAL_INTERRUPT_TIMER1); + __profile_hit(regs->pc); + return Cyg_InterruptHANDLED; +} + +void +hal_enable_profile_timer(int resolution) +{ + // Run periodic timer interrupt for profile + // The resolution is specified in us, the hardware generates 3.6864 + // ticks/us + int period = (resolution*36864) / 10000; + + // Attach ISR. + HAL_INTERRUPT_ATTACH(CYGNUM_HAL_INTERRUPT_TIMER1, &profile_isr, 0x1111, 0); + HAL_INTERRUPT_UNMASK(CYGNUM_HAL_INTERRUPT_TIMER1); + + // Set period. + *SA11X0_OSMR1 = period; +} +#endif // -------------------------------------------------------------------------