1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2007. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be found in |
---|
6 | * the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #include <bsp.h> |
---|
13 | |
---|
14 | #include <assert.h> |
---|
15 | #include <pthread.h> |
---|
16 | #include <stdlib.h> |
---|
17 | |
---|
18 | extern rtems_configuration_table BSP_Configuration; |
---|
19 | |
---|
20 | /* |
---|
21 | * Using GNAT's Distributed Systems Annex support requires |
---|
22 | * each node in the system to have different pid's. In a |
---|
23 | * single CPU RTEMS system, it is always one. This lets the |
---|
24 | * user override the RTEMS default. |
---|
25 | */ |
---|
26 | #ifdef GNAT_PID |
---|
27 | #include <unistd.h> |
---|
28 | |
---|
29 | pid_t getpid() |
---|
30 | { |
---|
31 | return GNAT_PID; |
---|
32 | } |
---|
33 | #endif |
---|
34 | |
---|
35 | /* |
---|
36 | * By having the POSIX_Init thread create a second thread just |
---|
37 | * to invoke gnat_main, we can override all default attributes |
---|
38 | * of the "Ada environment task". Otherwise, we would be |
---|
39 | * stuck with the defaults set by RTEMS. |
---|
40 | */ |
---|
41 | |
---|
42 | void *start_gnat_main( void * argument ) |
---|
43 | { |
---|
44 | extern int gnat_main ( int argc, char **argv, char **envp ); |
---|
45 | |
---|
46 | (void) gnat_main ( 0, 0, 0 ); |
---|
47 | |
---|
48 | exit( 0 ); |
---|
49 | |
---|
50 | return 0; |
---|
51 | } |
---|
52 | |
---|
53 | #ifndef GNAT_MAIN_STACKSPACE |
---|
54 | #define GNAT_MAIN_STACKSPACE 0 |
---|
55 | #endif |
---|
56 | |
---|
57 | void *POSIX_Init( void *argument ) |
---|
58 | { |
---|
59 | pthread_t thread_id; |
---|
60 | pthread_attr_t attr; |
---|
61 | size_t stacksize; |
---|
62 | int status; |
---|
63 | extern size_t _ada_pthread_minimum_stack_size(); |
---|
64 | |
---|
65 | status = pthread_attr_init( &attr ); |
---|
66 | assert( !status ); |
---|
67 | |
---|
68 | stacksize = GNAT_MAIN_STACKSPACE * 1024; |
---|
69 | if ( stacksize < _ada_pthread_minimum_stack_size() ) |
---|
70 | stacksize = _ada_pthread_minimum_stack_size(); |
---|
71 | |
---|
72 | status = pthread_attr_setstacksize( &attr, stacksize ); |
---|
73 | assert( !status ); |
---|
74 | |
---|
75 | status = pthread_create( &thread_id, &attr, start_gnat_main, NULL ); |
---|
76 | assert( !status ); |
---|
77 | |
---|
78 | pthread_exit( 0 ); |
---|
79 | return 0; |
---|
80 | } |
---|
81 | |
---|
82 | /* configuration information */ |
---|
83 | |
---|
84 | /* Standard output and a clock tick so time passes */ |
---|
85 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
86 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
87 | |
---|
88 | /* We want a clock tick every millisecond */ |
---|
89 | #define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(1) |
---|
90 | |
---|
91 | /* The initialization task is a POSIX Initialization thread with default attributes */ |
---|
92 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
93 | |
---|
94 | /* We are using GNAT/RTEMS with a maximum of 20 Ada tasks and no fake Ada tasks. */ |
---|
95 | /* A fake Ada task is a task created outside the Ada run-time that calls into Ada. */ |
---|
96 | #define CONFIGURE_GNAT_RTEMS |
---|
97 | #define CONFIGURE_MAXIMUM_ADA_TASKS 20 |
---|
98 | #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0 |
---|
99 | |
---|
100 | /* Account for any extra task stack size */ |
---|
101 | #define CONFIGURE_MEMORY_OVERHEAD (GNAT_MAIN_STACKSPACE) |
---|
102 | |
---|
103 | #define CONFIGURE_INIT |
---|
104 | |
---|
105 | #include <rtems/confdefs.h> |
---|