[ac7d5ef0] | 1 | /* |
---|
| 2 | * Multiprocessing Manager |
---|
| 3 | * |
---|
| 4 | * |
---|
| 5 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 6 | * On-Line Applications Research Corporation (OAR). |
---|
| 7 | * All rights assigned to U.S. Government, 1994. |
---|
| 8 | * |
---|
| 9 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 10 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 11 | * notice must appear in all copies of this file and its derivatives. |
---|
| 12 | * |
---|
| 13 | * $Id$ |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include <rtems/system.h> |
---|
| 17 | #include <rtems/config.h> |
---|
| 18 | #include <rtems/cpu.h> |
---|
| 19 | #include <rtems/event.h> |
---|
| 20 | #include <rtems/fatal.h> |
---|
| 21 | #include <rtems/intthrd.h> |
---|
| 22 | #include <rtems/message.h> |
---|
| 23 | #include <rtems/mp.h> |
---|
| 24 | #include <rtems/mpci.h> |
---|
| 25 | #include <rtems/mppkt.h> |
---|
| 26 | #include <rtems/part.h> |
---|
| 27 | #include <rtems/sem.h> |
---|
| 28 | #include <rtems/signal.h> |
---|
| 29 | #include <rtems/states.h> |
---|
| 30 | #include <rtems/tasks.h> |
---|
| 31 | #include <rtems/thread.h> |
---|
| 32 | #include <rtems/threadq.h> |
---|
| 33 | #include <rtems/watchdog.h> |
---|
| 34 | |
---|
| 35 | /*PAGE |
---|
| 36 | * |
---|
| 37 | * _Multiprocessing_Manager_initialization |
---|
| 38 | * |
---|
| 39 | */ |
---|
| 40 | |
---|
| 41 | void _Multiprocessing_Manager_initialization ( void ) |
---|
| 42 | { |
---|
| 43 | if ( _Configuration_MP_table->node < 1 || |
---|
| 44 | _Configuration_MP_table->node > _Configuration_MP_table->maximum_nodes ) |
---|
| 45 | rtems_fatal_error_occurred( RTEMS_INVALID_NODE ); |
---|
| 46 | |
---|
| 47 | _Internal_threads_Set_MP_receive_server( _Multiprocessing_Receive_server ); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | /*PAGE |
---|
| 51 | * |
---|
| 52 | * rtems_multiprocessing_announce |
---|
| 53 | * |
---|
| 54 | */ |
---|
| 55 | |
---|
| 56 | void rtems_multiprocessing_announce ( void ) |
---|
| 57 | { |
---|
[3a5dbdc] | 58 | _Thread_Disable_dispatch(); |
---|
| 59 | _Event_sets_Post( |
---|
| 60 | RTEMS_EVENT_0, |
---|
| 61 | &_Internal_threads_System_initialization_thread->pending_events |
---|
| 62 | ); |
---|
| 63 | _Event_Surrender( _Internal_threads_System_initialization_thread ); |
---|
| 64 | _Thread_Enable_dispatch(); |
---|
[ac7d5ef0] | 65 | } |
---|
| 66 | |
---|
| 67 | /*PAGE |
---|
| 68 | * |
---|
| 69 | * _Multiprocessing_Receive_server |
---|
| 70 | * |
---|
| 71 | */ |
---|
| 72 | |
---|
[3a5dbdc] | 73 | typedef void (*packet_processor)( rtems_packet_prefix * ); |
---|
| 74 | |
---|
| 75 | packet_processor _Multiprocessor_Packet_processors[] = { |
---|
| 76 | _Internal_threads_MP_Process_packet, /* RTEMS_MP_PACKET_INTERNAL_THREADS */ |
---|
| 77 | _RTEMS_tasks_MP_Process_packet, /* RTEMS_MP_PACKET_TASKS */ |
---|
| 78 | _Message_queue_MP_Process_packet, /* RTEMS_MP_PACKET_MESSAGE_QUEUE */ |
---|
| 79 | _Semaphore_MP_Process_packet, /* RTEMS_MP_PACKET_SEMAPHORE */ |
---|
| 80 | _Partition_MP_Process_packet, /* RTEMS_MP_PACKET_PARTITION */ |
---|
| 81 | 0, /* RTEMS_MP_PACKET_REGION */ |
---|
| 82 | _Event_MP_Process_packet, /* RTEMS_MP_PACKET_EVENT */ |
---|
| 83 | _Signal_MP_Process_packet /* RTEMS_MP_PACKET_SIGNAL */ |
---|
| 84 | }; |
---|
| 85 | |
---|
[ac7d5ef0] | 86 | Thread _Multiprocessing_Receive_server ( |
---|
| 87 | Thread_Argument ignored |
---|
| 88 | ) |
---|
| 89 | { |
---|
| 90 | |
---|
| 91 | rtems_packet_prefix *the_packet; |
---|
[3a5dbdc] | 92 | packet_processor the_function; |
---|
[ac7d5ef0] | 93 | |
---|
| 94 | for ( ; ; ) { |
---|
| 95 | |
---|
[3a5dbdc] | 96 | _Thread_Disable_dispatch(); |
---|
| 97 | _Event_Seize( RTEMS_EVENT_0, RTEMS_DEFAULT_OPTIONS, RTEMS_NO_TIMEOUT ); |
---|
| 98 | _Thread_Enable_dispatch(); |
---|
[ac7d5ef0] | 99 | |
---|
[3a5dbdc] | 100 | for ( ; ; ) { |
---|
| 101 | the_packet = _MPCI_Receive_packet(); |
---|
[ac7d5ef0] | 102 | |
---|
[3a5dbdc] | 103 | if ( !the_packet ) |
---|
| 104 | break; |
---|
[ac7d5ef0] | 105 | |
---|
| 106 | _Thread_Executing->receive_packet = the_packet; |
---|
| 107 | |
---|
[3a5dbdc] | 108 | if ( !_Mp_packet_Is_valid_packet_class ( the_packet->the_class ) ) |
---|
| 109 | break; |
---|
| 110 | |
---|
| 111 | the_function = _Multiprocessor_Packet_processors[ the_packet->the_class ]; |
---|
| 112 | |
---|
| 113 | if ( !the_function ) |
---|
| 114 | break; |
---|
[ac7d5ef0] | 115 | |
---|
[3a5dbdc] | 116 | (*the_function)( the_packet ); |
---|
[ac7d5ef0] | 117 | } |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | /* end of file */ |
---|