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.OARcorp.com/rtems/license.html. |
---|
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 | #ifdef GNAT_PID |
---|
21 | #include <unistd.h> |
---|
22 | pid_t getpid() |
---|
23 | { |
---|
24 | return GNAT_PID; |
---|
25 | } |
---|
26 | #endif |
---|
27 | |
---|
28 | /* |
---|
29 | * By having the POSIX_Init thread create a second thread just |
---|
30 | * to invoke gnat_main, we can override all default attributes |
---|
31 | * of the "Ada environment task". Otherwise, we would be |
---|
32 | * stuck with the defaults set by RTEMS. |
---|
33 | */ |
---|
34 | |
---|
35 | void *start_gnat_main( void * argument ) |
---|
36 | { |
---|
37 | extern int gnat_main ( int argc, char **argv, char **envp ); |
---|
38 | |
---|
39 | printk( "Transferring to Ada\n" ); |
---|
40 | (void) gnat_main ( 0, 0, 0 ); |
---|
41 | |
---|
42 | exit( 0 ); |
---|
43 | |
---|
44 | return 0; |
---|
45 | } |
---|
46 | |
---|
47 | extern size_t _ada_pthread_minimum_stack_size(); |
---|
48 | |
---|
49 | #ifndef GNAT_MAIN_STACKSPACE |
---|
50 | #define GNAT_MAIN_STACKSPACE 0 |
---|
51 | #endif |
---|
52 | void *POSIX_Init( void *argument ) |
---|
53 | { |
---|
54 | pthread_t thread_id; |
---|
55 | pthread_attr_t attr; |
---|
56 | size_t stacksize; |
---|
57 | int status; |
---|
58 | printk( "Starting Posix Init thread\n" ); |
---|
59 | |
---|
60 | status = pthread_attr_init( &attr ); |
---|
61 | assert( !status ); |
---|
62 | |
---|
63 | stacksize = GNAT_MAIN_STACKSPACE * 1024; |
---|
64 | if ( stacksize < _ada_pthread_minimum_stack_size() ) |
---|
65 | stacksize = _ada_pthread_minimum_stack_size(); |
---|
66 | |
---|
67 | status = pthread_attr_setstacksize( &attr, stacksize ); |
---|
68 | assert( !status ); |
---|
69 | |
---|
70 | status = pthread_create( &thread_id, &attr, start_gnat_main, NULL ); |
---|
71 | assert( !status ); |
---|
72 | |
---|
73 | printk( "Exiting Posix Init thread\n" ); |
---|
74 | pthread_exit( 0 ); |
---|
75 | |
---|
76 | return 0; |
---|
77 | } |
---|
78 | |
---|
79 | /* configuration information */ |
---|
80 | |
---|
81 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
82 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
83 | |
---|
84 | #define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(1) |
---|
85 | |
---|
86 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
87 | |
---|
88 | #define CONFIGURE_MAXIMUM_SEMAPHORES 10 |
---|
89 | #define CONFIGURE_GNAT_RTEMS |
---|
90 | #define CONFIGURE_MAXIMUM_ADA_TASKS 20 |
---|
91 | #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0 |
---|
92 | |
---|
93 | #define CONFIGURE_MEMORY_OVERHEAD (GNAT_MAIN_STACKSPACE) |
---|
94 | |
---|
95 | #define CONFIGURE_INIT |
---|
96 | |
---|
97 | #include <rtems/confdefs.h> |
---|
98 | |
---|