diff options
author | Michael Gielda <mgielda@antmicro.com> | 2014-04-03 14:53:04 +0200 |
---|---|---|
committer | Michael Gielda <mgielda@antmicro.com> | 2014-04-03 14:53:04 +0200 |
commit | ae1e4e08a1005a0c487f03ba189d7536e7fdcba6 (patch) | |
tree | f1c296f8a966a9a39876b0e98e16d9c5da1776dd /ecos/packages/hal/common/current/tests | |
parent | f157da5337118d3c5cd464266796de4262ac9dbd (diff) |
Added the OS files
Diffstat (limited to 'ecos/packages/hal/common/current/tests')
-rw-r--r-- | ecos/packages/hal/common/current/tests/basic.c | 109 | ||||
-rw-r--r-- | ecos/packages/hal/common/current/tests/cache.c | 240 | ||||
-rw-r--r-- | ecos/packages/hal/common/current/tests/context.c | 120 | ||||
-rw-r--r-- | ecos/packages/hal/common/current/tests/cpp1.c | 108 | ||||
-rw-r--r-- | ecos/packages/hal/common/current/tests/intr.c | 156 | ||||
-rw-r--r-- | ecos/packages/hal/common/current/tests/vaargs.c | 156 |
6 files changed, 889 insertions, 0 deletions
diff --git a/ecos/packages/hal/common/current/tests/basic.c b/ecos/packages/hal/common/current/tests/basic.c new file mode 100644 index 0000000..a229a0f --- /dev/null +++ b/ecos/packages/hal/common/current/tests/basic.c @@ -0,0 +1,109 @@ +//================================================================= +// +// basic.c +// +// HAL basic functions test +// +//========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// +// 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 +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas +// Date: 2001-10-24 +//####DESCRIPTIONEND#### +//========================================================================== + +#include <cyg/infra/testcase.h> // test case macros +#include <cyg/infra/diag.h> // diag_printf +#include <cyg/infra/cyg_ass.h> // assertions + +#include <cyg/hal/hal_arch.h> // context macros + +// ------------------------------------------------------------------------- + +#define BITS(t) (sizeof(t)*8) + +void +entry(void) +{ + int res; + int i, mask, ndx; + hal_jmp_buf jmpbuf; + + res = 1; + + // Check HAL_MSBIT_NDEX() functions + mask = 1; // One bits set + for (i = 0; i < BITS(int); i++) { + HAL_MSBIT_INDEX(ndx, mask); + res &= (ndx == i); + HAL_LSBIT_INDEX(ndx, mask); + res &= (ndx == i); + mask <<= 1; + } + + mask = 3; // Two bits set + for (i = 0; i < BITS(int)-1; i++) { + HAL_MSBIT_INDEX(ndx, mask); + res &= (ndx == (i+1)); + HAL_LSBIT_INDEX(ndx, mask); + res &= (ndx == i); + mask <<= 1; + } + CYG_TEST_PASS_FAIL(res, "HAL_xSBIT_INDEX() basic functions"); + + res = 0; + if (hal_setjmp(jmpbuf)) { + res = 1; + } else { + hal_longjmp(jmpbuf, 1); + } + CYG_TEST_PASS_FAIL(res, "hal_setjmp()/hal_longjmp() basic functions"); + + CYG_TEST_FINISH("HAL basic functions test"); +} + +// ------------------------------------------------------------------------- + +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + + entry(); +} + +// ------------------------------------------------------------------------- +// EOF basic.c diff --git a/ecos/packages/hal/common/current/tests/cache.c b/ecos/packages/hal/common/current/tests/cache.c new file mode 100644 index 0000000..1fd4b66 --- /dev/null +++ b/ecos/packages/hal/common/current/tests/cache.c @@ -0,0 +1,240 @@ +/*================================================================= +// +// cache.c +// +// HAL Cache timing test +// +//========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// +// 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 +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): dsm +// Contributors: dsm, nickg +// Date: 1998-06-18 +//####DESCRIPTIONEND#### +*/ + +#include <pkgconf/hal.h> + +#include <cyg/infra/testcase.h> + +#include <cyg/hal/hal_cache.h> +#include <cyg/hal/hal_intr.h> +#include <cyg/infra/diag.h> + +#if defined(HAL_DCACHE_SIZE) && HAL_DCACHE_SIZE != 0 + +// ------------------------------------------------------------------------- +// If the HAL does not supply this, we supply our own version + +#ifndef HAL_DCACHE_PURGE_ALL + +#ifdef HAL_DCACHE_SYNC + +# define HAL_DCACHE_PURGE_ALL() HAL_DCACHE_SYNC() + +#else + +static cyg_uint8 dca[HAL_DCACHE_SIZE + HAL_DCACHE_LINE_SIZE*2]; + +#define HAL_DCACHE_PURGE_ALL() \ +CYG_MACRO_START \ + volatile cyg_uint8 *addr = &dca[HAL_DCACHE_LINE_SIZE]; \ + volatile cyg_uint8 tmp = 0; \ + int i; \ + for( i = 0; i < HAL_DCACHE_SIZE; i += HAL_DCACHE_LINE_SIZE ) \ + { \ + tmp = addr[i]; \ + } \ +CYG_MACRO_END + +#endif // HAL_DCACHE_SYNC + +#endif // HAL_DCACHE_PURGE_ALL + +// ------------------------------------------------------------------------- + +#ifndef MAX_STRIDE +#define MAX_STRIDE 64 +#endif + +volatile char m[(HAL_DCACHE_SIZE/HAL_DCACHE_LINE_SIZE)*MAX_STRIDE]; + +// ------------------------------------------------------------------------- + +static void time0(register cyg_uint32 stride) +{ + register cyg_uint32 j,k; + register char c CYGBLD_ATTRIB_UNUSED; + + diag_printf("stride=%d\n", stride); + + k = 0; + if ( cyg_test_is_simulator ) + k = 3960; + + for(; k<4000;k++) { + for(j=0; j<(HAL_DCACHE_SIZE/HAL_DCACHE_LINE_SIZE); j++) { + c=m[stride*j]; + } + } +} + +// ------------------------------------------------------------------------- + +void time1(void) +{ + cyg_uint32 i; + + for(i=1; i<=MAX_STRIDE; i+=i) { + time0(i); + } +} + +// ------------------------------------------------------------------------- +// This test could be improved by counting number of passes possible +// in a given number of ticks. + +static void entry0( void ) +{ + register CYG_INTERRUPT_STATE oldints; + +#ifdef HAL_CACHE_UNIFIED + + HAL_DISABLE_INTERRUPTS(oldints); + HAL_DCACHE_PURGE_ALL(); // rely on above definition + HAL_UCACHE_INVALIDATE_ALL(); + HAL_UCACHE_DISABLE(); + HAL_RESTORE_INTERRUPTS(oldints); + CYG_TEST_INFO("Cache off"); + time1(); + + HAL_DISABLE_INTERRUPTS(oldints); + HAL_DCACHE_PURGE_ALL(); // rely on above definition + HAL_UCACHE_INVALIDATE_ALL(); + HAL_UCACHE_ENABLE(); + HAL_RESTORE_INTERRUPTS(oldints); + CYG_TEST_INFO("Cache on"); + time1(); + +#else // HAL_CACHE_UNIFIED + + HAL_DISABLE_INTERRUPTS(oldints); + HAL_DCACHE_PURGE_ALL(); + HAL_ICACHE_INVALIDATE_ALL(); + HAL_DCACHE_INVALIDATE_ALL(); + HAL_ICACHE_DISABLE(); + HAL_DCACHE_DISABLE(); + HAL_RESTORE_INTERRUPTS(oldints); + CYG_TEST_INFO("Dcache off Icache off"); + time1(); + + HAL_DISABLE_INTERRUPTS(oldints); + HAL_DCACHE_PURGE_ALL(); + HAL_ICACHE_INVALIDATE_ALL(); + HAL_DCACHE_INVALIDATE_ALL(); + HAL_ICACHE_DISABLE(); + HAL_DCACHE_ENABLE(); + HAL_RESTORE_INTERRUPTS(oldints); + CYG_TEST_INFO("Dcache on Icache off"); + time1(); + + HAL_DISABLE_INTERRUPTS(oldints); + HAL_DCACHE_PURGE_ALL(); + HAL_ICACHE_INVALIDATE_ALL(); + HAL_DCACHE_INVALIDATE_ALL(); + HAL_ICACHE_ENABLE(); + HAL_DCACHE_DISABLE(); + HAL_RESTORE_INTERRUPTS(oldints); + CYG_TEST_INFO("Dcache off Icache on"); + time1(); + + HAL_DISABLE_INTERRUPTS(oldints); + HAL_DCACHE_PURGE_ALL(); + HAL_ICACHE_INVALIDATE_ALL(); + HAL_DCACHE_INVALIDATE_ALL(); + HAL_ICACHE_ENABLE(); + HAL_DCACHE_ENABLE(); + HAL_RESTORE_INTERRUPTS(oldints); + CYG_TEST_INFO("Dcache on Icache on"); + time1(); + + HAL_DISABLE_INTERRUPTS(oldints); + HAL_DCACHE_PURGE_ALL(); + HAL_ICACHE_INVALIDATE_ALL(); + HAL_DCACHE_INVALIDATE_ALL(); + HAL_ICACHE_DISABLE(); + HAL_DCACHE_DISABLE(); + HAL_RESTORE_INTERRUPTS(oldints); + CYG_TEST_INFO("Dcache off Icache off"); + time1(); + +#endif // HAL_CACHE_UNIFIED + + CYG_TEST_PASS_FINISH("End of test"); +} + +// ------------------------------------------------------------------------- + +void cache_main( void ) +{ + CYG_TEST_INIT(); + + entry0(); + +} + +// ------------------------------------------------------------------------- + +externC void +cyg_start( void ) +{ + cache_main(); +} + +#else // HAL_DCACHE_SIZE +#define N_A_MSG "No cache" +#endif // HAL_DCACHE_SIZE + +#ifdef N_A_MSG +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + CYG_TEST_NA( N_A_MSG ); +} +#endif // N_A_MSG + +// ------------------------------------------------------------------------- +/* EOF cache.c */ diff --git a/ecos/packages/hal/common/current/tests/context.c b/ecos/packages/hal/common/current/tests/context.c new file mode 100644 index 0000000..4e96dd0 --- /dev/null +++ b/ecos/packages/hal/common/current/tests/context.c @@ -0,0 +1,120 @@ +/*================================================================= +// +// context.c +// +// HAL Thread context handling test +// +//========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// +// 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 +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 1998-10-07 +//####DESCRIPTIONEND#### +*/ + +#include <pkgconf/hal.h> + +#include <pkgconf/infra.h> + +#include <cyg/infra/testcase.h> + +#include <cyg/infra/cyg_trac.h> +#include <cyg/hal/hal_arch.h> + +#define CYG_TRACE_USER_BOOL 1 + +// ------------------------------------------------------------------------- + +#define THREADS 4 +#define STACKSIZE (2*1024) + +char stack[THREADS][STACKSIZE]; + +CYG_ADDRWORD sp[THREADS]; + +cyg_count32 switches = 0; + +// ------------------------------------------------------------------------- + +void entry0( CYG_ADDRWORD arg ) +{ + CYG_TRACE1B("Thread %d started\n", arg ); + + while( switches < 1000 ) + { + HAL_THREAD_SWITCH_CONTEXT( &sp[arg], &sp[(arg+1) % THREADS] ); + + CYG_TRACE1B("Thread %d resumed\n", arg ); + + switches++; + } + + CYG_TEST_PASS_FINISH("HAL Context test"); + +} + +// ------------------------------------------------------------------------- + +void context_main(void) +{ + int i; + + CYG_TEST_INIT(); + + // Init all thread contexts: + + for( i = 0 ; i < THREADS; i++ ) + { + sp[i] = (CYG_ADDRWORD)stack[i]+STACKSIZE; + + HAL_THREAD_INIT_CONTEXT( sp[i], i, entry0, i*0x01010000 ); + } + + // Load the first thread. + + HAL_THREAD_LOAD_CONTEXT( &sp[0] ); +} + +// ------------------------------------------------------------------------- + +externC void +cyg_start( void ) +{ + context_main(); +} + +// ------------------------------------------------------------------------- +/* EOF context.c */ diff --git a/ecos/packages/hal/common/current/tests/cpp1.c b/ecos/packages/hal/common/current/tests/cpp1.c new file mode 100644 index 0000000..9c5eaa3 --- /dev/null +++ b/ecos/packages/hal/common/current/tests/cpp1.c @@ -0,0 +1,108 @@ +/*================================================================= +// +// cpp1.c +// +// cpp arithmetic bug regression test +// +//========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// +// 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 +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): hmt +// Contributors: hmt +// Date: 2001-04-30 +//####DESCRIPTIONEND#### +*/ + +#include <pkgconf/hal.h> + +#include <pkgconf/infra.h> + +#include <cyg/infra/testcase.h> + +// ----------------------------------------------------------------- +// This is smaller than 2048. +// Unless the parser binds '+' too strongly because it is after a ket, so +// it is mistaken for unary plus, when (4 * 20 + 2) * 4 * 20 is larger. +#define CYGNUM_HAL_STACK_SIZE_MINIMUM ((4 * 20) + 2 * 4 * 20) + +#define CYGNUM_UITRON_STACK_SIZE (2048) + +#ifdef CYGNUM_HAL_STACK_SIZE_MINIMUM +# ifdef CYGNUM_UITRON_STACK_SIZE +# if CYGNUM_UITRON_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_MINIMUM + +// then override the configured stack size +# undef CYGNUM_UITRON_STACK_SIZE +# define CYGNUM_UITRON_STACK_SIZE CYGNUM_HAL_STACK_SIZE_MINIMUM + +# endif // CYGNUM_UITRON_STACK_SIZE < CYGNUM_HAL_STACK_SIZE_MINIMUM +# endif // CYGNUM_UITRON_STACK_SIZE +#endif // CYGNUM_HAL_STACK_SIZE_MINIMUM + + +// This tests for the bug per se: +int i = CYGNUM_UITRON_STACK_SIZE; + +// This tests the workaround independently of more complex context: +#define MAX(_x_,_y_) ((_x_) > (_y_) ? (_x_) : (_y_)) + +static char stack1[ + MAX( + CYGNUM_HAL_STACK_SIZE_MINIMUM, + 2048) + ]; + +// Better to report a fully-fledged failure and test the workaround than +// fail early. +#if 0 +# if CYGNUM_UITRON_STACK_SIZE != 2048 +# error FAIL: CPP '+' binding bug detected +# endif +#endif + +// ------------------------------------------------------------------------- +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + CYG_TEST_PASS("CPP '+' binding test compiled OK"); + CYG_TEST_PASS_FAIL( 2048 == i, "initialized i should be 2048" ); + CYG_TEST_PASS_FAIL( 2048 == sizeof( stack1 ), + "workaround: sizeof( stack1 ) should be 2048" ); + CYG_TEST_EXIT("All done"); +} + +// ------------------------------------------------------------------------- +/* EOF cpp1.c */ diff --git a/ecos/packages/hal/common/current/tests/intr.c b/ecos/packages/hal/common/current/tests/intr.c new file mode 100644 index 0000000..9cf695c --- /dev/null +++ b/ecos/packages/hal/common/current/tests/intr.c @@ -0,0 +1,156 @@ +/*================================================================= +// +// intr.c +// +// HAL Interrupt API test +// +//========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// +// 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 +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): nickg +// Contributors: nickg +// Date: 1998-10-08 +//####DESCRIPTIONEND#### +*/ + +#include <pkgconf/hal.h> + +#include <cyg/infra/testcase.h> + +#include <cyg/hal/hal_intr.h> +#include <cyg/hal/drv_api.h> + +// Include HAL/Platform specifics +#include CYGBLD_HAL_PLATFORM_H + +#ifdef CYGPKG_KERNEL +#include <pkgconf/kernel.h> // Need to look for the RTC config. +#endif + +// Fallback defaults (in case HAL didn't define these) +#ifndef CYGNUM_HAL_RTC_NUMERATOR +#define CYGNUM_HAL_RTC_NUMERATOR 1000000000 +#define CYGNUM_HAL_RTC_DENOMINATOR 100 +#define CYGNUM_HAL_RTC_PERIOD 9999 +#endif + +// ------------------------------------------------------------------------- + +#define ISR_DATA 0xAAAA1234 + +// ------------------------------------------------------------------------- + +volatile cyg_count32 ticks = 0; +volatile cyg_count32 dsr_ticks = 0; +static cyg_interrupt intr; +static cyg_handle_t intr_handle; + +// ------------------------------------------------------------------------- + +cyg_uint32 isr( cyg_uint32 vector, CYG_ADDRWORD data ) +{ + CYG_TEST_CHECK( ISR_DATA == data , "Bad data passed to ISR"); + CYG_TEST_CHECK( CYGNUM_HAL_INTERRUPT_RTC == vector , + "Bad vector passed to ISR"); + + HAL_CLOCK_RESET( vector, CYGNUM_HAL_RTC_PERIOD ); + + HAL_INTERRUPT_ACKNOWLEDGE( vector ); + + ticks++; + + return CYG_ISR_CALL_DSR; +} + +// ------------------------------------------------------------------------- + +void dsr( cyg_uint32 vector, cyg_ucount32 count, CYG_ADDRWORD data ) +{ + CYG_TEST_CHECK( ISR_DATA == data , "Bad data passed to DSR"); + CYG_TEST_CHECK( CYGNUM_HAL_INTERRUPT_RTC == vector , + "Bad vector passed to DSR"); + + dsr_ticks += count; +} + +void intr_main( void ) +{ + CYG_INTERRUPT_STATE oldints; + + cyg_drv_interrupt_create(CYGNUM_HAL_INTERRUPT_RTC, 1, + ISR_DATA, isr, dsr, &intr_handle, &intr); + cyg_drv_interrupt_attach(intr_handle); + HAL_CLOCK_INITIALIZE( CYGNUM_HAL_RTC_PERIOD ); + cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_RTC); + + HAL_ENABLE_INTERRUPTS(); + + while( ticks < 10 ) + { + + } + + + CYG_TEST_CHECK( dsr_ticks == 10, "DSR not called sufficient times"); + + HAL_DISABLE_INTERRUPTS(oldints); + + CYG_TEST_PASS_FINISH("HAL interrupt test"); +} + + +// ------------------------------------------------------------------------- + +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + + // Attaching the ISR will not succeed if the kernel real-time + // clock has been configured in. +#ifndef CYGVAR_KERNEL_COUNTERS_CLOCK + + intr_main(); + +#else + + CYG_TEST_NA("Cannot override kernel real-time clock."); + +#endif +} + + +// ------------------------------------------------------------------------- +// EOF intr.c diff --git a/ecos/packages/hal/common/current/tests/vaargs.c b/ecos/packages/hal/common/current/tests/vaargs.c new file mode 100644 index 0000000..9bb621d --- /dev/null +++ b/ecos/packages/hal/common/current/tests/vaargs.c @@ -0,0 +1,156 @@ +//================================================================= +// +// vaargs.c +// +// HAL variable argument calls test +// +//========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// +// 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 +// Software Foundation; either version 2 or (at your option) any later +// version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License +// along with eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors: jskov +// Date: 2001-08-03 +//####DESCRIPTIONEND#### +//========================================================================== + +#include <cyg/infra/testcase.h> // test case macros +#include <cyg/infra/diag.h> // diag_printf +#include <cyg/infra/cyg_ass.h> // assertions + +#include <cyg/hal/hal_arch.h> // context macros + +#include <stdarg.h> // vaargs magic + +// ------------------------------------------------------------------------- + +int +function(int n, ...) +{ + va_list args; + int c = 11 * n; + int i = 1; + int res = 1; + + CYG_ASSERT(n >= 0 && n < 8, "Invalid count argument"); + + va_start(args, n); + + for (i = 1; i <= n; c++, i++) { + int v = va_arg(args, int); + if (v != c) { + diag_printf("FAIL:<Bad argument: index %d expected %d got %d>\n", i, c, v); + res = 0; + } + } + + va_end(args); + + return res; +} + +int +function_proxy(int n, va_list args) +{ + int c = 11 * n; + int i = 1; + int res = 1; + + CYG_ASSERT(n >= 0 && n < 8, "Invalid count argument"); + + for (i = 1; i <= n; c++, i++) { + int v = va_arg(args, int); + if (v != c) { + diag_printf("FAIL:<Bad argument: index %d expected %d got %d>\n", i, c, v); + res = 0; + } + } + + return res; +} + +int +proxy(int n, ...) +{ + int res; + va_list args; + + va_start(args, n); + res = function_proxy(n, args); + va_end(args); + + return res; +} + + +void +entry(void) +{ + int res; + + res = function(0); + res &= function(1, 11); + res &= function(2, 22, 23); + res &= function(3, 33, 34, 35); + res &= function(4, 44, 45, 46, 47); + res &= function(5, 55, 56, 57, 58, 59); + res &= function(6, 66, 67, 68, 69, 70, 71); + res &= function(7, 77, 78, 79, 80, 81, 82, 83); + CYG_TEST_PASS_FAIL(res, "Direct vaargs calls"); + + res = proxy(0); + res &= proxy(1, 11); + res &= proxy(2, 22, 23); + res &= proxy(3, 33, 34, 35); + res &= proxy(4, 44, 45, 46, 47); + res &= proxy(5, 55, 56, 57, 58, 59); + res &= proxy(6, 66, 67, 68, 69, 70, 71); + res &= proxy(7, 77, 78, 79, 80, 81, 82, 83); + CYG_TEST_PASS_FAIL(res, "Proxy vaargs calls"); + + CYG_TEST_FINISH("HAL vaargs test"); +} + +// ------------------------------------------------------------------------- + +externC void +cyg_start( void ) +{ + CYG_TEST_INIT(); + + entry(); +} + +// ------------------------------------------------------------------------- +// EOF vaargs.c |