[7efcefa] | 1 | /* |
---|
[4ad07d0] | 2 | * COPYRIGHT (c) 1989-2007. |
---|
[7efcefa] | 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> |
---|
[8b09de0] | 16 | #include <stdlib.h> |
---|
[7efcefa] | 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 | |
---|
[8b09de0] | 39 | printk( "Transferring to Ada\n" ); |
---|
[7efcefa] | 40 | (void) gnat_main ( 0, 0, 0 ); |
---|
| 41 | |
---|
| 42 | exit( 0 ); |
---|
| 43 | |
---|
| 44 | return 0; |
---|
| 45 | } |
---|
| 46 | |
---|
[8b09de0] | 47 | extern size_t _ada_pthread_minimum_stack_size(); |
---|
| 48 | |
---|
[4ad07d0] | 49 | #ifndef GNAT_MAIN_STACKSPACE |
---|
| 50 | #define GNAT_MAIN_STACKSPACE 0 |
---|
| 51 | #endif |
---|
[7efcefa] | 52 | void *POSIX_Init( void *argument ) |
---|
| 53 | { |
---|
| 54 | pthread_t thread_id; |
---|
| 55 | pthread_attr_t attr; |
---|
[4ad07d0] | 56 | size_t stacksize; |
---|
[7efcefa] | 57 | int status; |
---|
[8b09de0] | 58 | printk( "Starting Posix Init thread\n" ); |
---|
[7efcefa] | 59 | |
---|
| 60 | status = pthread_attr_init( &attr ); |
---|
| 61 | assert( !status ); |
---|
| 62 | |
---|
| 63 | stacksize = GNAT_MAIN_STACKSPACE * 1024; |
---|
[4ad07d0] | 64 | if ( stacksize < _ada_pthread_minimum_stack_size() ) |
---|
| 65 | stacksize = _ada_pthread_minimum_stack_size(); |
---|
[7efcefa] | 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 | |
---|
[8b09de0] | 73 | printk( "Exiting Posix Init thread\n" ); |
---|
[7efcefa] | 74 | pthread_exit( 0 ); |
---|
| 75 | |
---|
| 76 | return 0; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | /* configuration information */ |
---|
| 80 | |
---|
[8b09de0] | 81 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 82 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
[7efcefa] | 83 | |
---|
| 84 | #define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(1) |
---|
| 85 | |
---|
| 86 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
| 87 | |
---|
[a1affab] | 88 | #define CONFIGURE_MAXIMUM_SEMAPHORES 10 |
---|
[7efcefa] | 89 | #define CONFIGURE_GNAT_RTEMS |
---|
| 90 | #define CONFIGURE_MAXIMUM_ADA_TASKS 20 |
---|
| 91 | #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0 |
---|
| 92 | |
---|
[8b09de0] | 93 | #define CONFIGURE_MEMORY_OVERHEAD (GNAT_MAIN_STACKSPACE) |
---|
[7efcefa] | 94 | |
---|
| 95 | #define CONFIGURE_INIT |
---|
| 96 | |
---|
[8b09de0] | 97 | #include <rtems/confdefs.h> |
---|
[7efcefa] | 98 | |
---|