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 | #include <tmacros.h> |
---|
13 | |
---|
14 | volatile bool operation_performed_from_tsr; |
---|
15 | |
---|
16 | void *Pointer1; |
---|
17 | |
---|
18 | rtems_timer_service_routine test_operation_from_isr( |
---|
19 | rtems_id timer, |
---|
20 | void *arg |
---|
21 | ) |
---|
22 | { |
---|
23 | /* free memory from ISR so it is deferred */ |
---|
24 | free( Pointer1 ); |
---|
25 | |
---|
26 | operation_performed_from_tsr = true; |
---|
27 | } |
---|
28 | |
---|
29 | rtems_task Init( |
---|
30 | rtems_task_argument argument |
---|
31 | ) |
---|
32 | { |
---|
33 | rtems_status_code status; |
---|
34 | rtems_id timer; |
---|
35 | void *pointer2; |
---|
36 | |
---|
37 | puts( "\n\n*** TEST MALLOC 02 ***" ); |
---|
38 | |
---|
39 | puts( "malloc memory to free from ISR" ); |
---|
40 | Pointer1 = malloc( 20 ); |
---|
41 | |
---|
42 | /* |
---|
43 | * Timer used in multiple ways |
---|
44 | */ |
---|
45 | status = rtems_timer_create( rtems_build_name('T', 'M', 'R', '0'), &timer ); |
---|
46 | directive_failed( status, "rtems_timer_create" ); |
---|
47 | |
---|
48 | operation_performed_from_tsr = false; |
---|
49 | |
---|
50 | /* |
---|
51 | * Test Operation from ISR |
---|
52 | */ |
---|
53 | status = rtems_timer_fire_after( timer, 10, test_operation_from_isr, NULL ); |
---|
54 | directive_failed( status, "timer_fire_after failed" ); |
---|
55 | |
---|
56 | /* XXX pick a delay method */ |
---|
57 | #if 0 |
---|
58 | status = rtems_task_wake_after( 20 ); |
---|
59 | #else |
---|
60 | { |
---|
61 | rtems_interval start; |
---|
62 | rtems_interval now; |
---|
63 | start = rtems_clock_get_ticks_since_boot(); |
---|
64 | do { |
---|
65 | now = rtems_clock_get_ticks_since_boot(); |
---|
66 | } while ( (now-start) < 100 ); |
---|
67 | } |
---|
68 | #endif |
---|
69 | if ( !operation_performed_from_tsr ) { |
---|
70 | puts( "Operation from ISR did not get processed\n" ); |
---|
71 | rtems_test_exit( 0 ); |
---|
72 | } |
---|
73 | |
---|
74 | puts( "Free from ISR successfully processed" ); |
---|
75 | puts( "Now malloc'ing more memory to process the free" ); |
---|
76 | pointer2 = malloc(20); |
---|
77 | |
---|
78 | puts( "*** END OF TEST MALLOC 02 ***" ); |
---|
79 | rtems_test_exit( 0 ); |
---|
80 | } |
---|
81 | |
---|
82 | /* configuration information */ |
---|
83 | |
---|
84 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
85 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
86 | |
---|
87 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
88 | |
---|
89 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
90 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
91 | |
---|
92 | #define CONFIGURE_INIT |
---|
93 | #include <rtems/confdefs.h> |
---|
94 | /* end of file */ |
---|
95 | |
---|