1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2009. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #ifdef HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <tmacros.h> |
---|
17 | |
---|
18 | volatile bool operation_performed_from_tsr; |
---|
19 | |
---|
20 | void *Pointer1; |
---|
21 | |
---|
22 | rtems_timer_service_routine test_operation_from_isr( |
---|
23 | rtems_id timer, |
---|
24 | void *arg |
---|
25 | ) |
---|
26 | { |
---|
27 | /* free memory from ISR so it is deferred */ |
---|
28 | free( Pointer1 ); |
---|
29 | |
---|
30 | operation_performed_from_tsr = true; |
---|
31 | } |
---|
32 | |
---|
33 | rtems_task Init( |
---|
34 | rtems_task_argument argument |
---|
35 | ) |
---|
36 | { |
---|
37 | rtems_status_code status; |
---|
38 | rtems_id timer; |
---|
39 | void *pointer2; |
---|
40 | |
---|
41 | puts( "\n\n*** TEST MALLOC 02 ***" ); |
---|
42 | |
---|
43 | puts( "malloc memory to free from ISR" ); |
---|
44 | Pointer1 = malloc( 20 ); |
---|
45 | |
---|
46 | /* |
---|
47 | * Timer used in multiple ways |
---|
48 | */ |
---|
49 | status = rtems_timer_create( rtems_build_name('T', 'M', 'R', '0'), &timer ); |
---|
50 | directive_failed( status, "rtems_timer_create" ); |
---|
51 | |
---|
52 | operation_performed_from_tsr = false; |
---|
53 | |
---|
54 | /* |
---|
55 | * Test Operation from ISR |
---|
56 | */ |
---|
57 | status = rtems_timer_fire_after( timer, 10, test_operation_from_isr, NULL ); |
---|
58 | directive_failed( status, "timer_fire_after failed" ); |
---|
59 | |
---|
60 | /* delay to let timer fire */ |
---|
61 | status = rtems_task_wake_after( 20 ); |
---|
62 | directive_failed( status, "timer_wake_after failed" ); |
---|
63 | |
---|
64 | if ( !operation_performed_from_tsr ) { |
---|
65 | puts( "Operation from ISR did not get processed\n" ); |
---|
66 | rtems_test_exit( 0 ); |
---|
67 | } |
---|
68 | |
---|
69 | puts( "Free from ISR successfully processed" ); |
---|
70 | puts( "Now malloc'ing more memory to process the free" ); |
---|
71 | pointer2 = malloc(20); |
---|
72 | rtems_test_assert( pointer2 ); |
---|
73 | |
---|
74 | puts( "*** END OF TEST MALLOC 02 ***" ); |
---|
75 | rtems_test_exit( 0 ); |
---|
76 | } |
---|
77 | |
---|
78 | /* configuration information */ |
---|
79 | |
---|
80 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
81 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
82 | |
---|
83 | #define CONFIGURE_MALLOC_DIRTY |
---|
84 | |
---|
85 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
86 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
87 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
88 | |
---|
89 | #define CONFIGURE_INIT |
---|
90 | #include <rtems/confdefs.h> |
---|
91 | /* end of file */ |
---|
92 | |
---|