File indexing completed on 2025-05-11 08:24:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #include <bsp/irq-generic.h>
0038
0039 #include <rtems/score/smpimpl.h>
0040
0041 rtems_status_code rtems_interrupt_set_affinity(
0042 rtems_vector_number vector,
0043 size_t affinity_size,
0044 const cpu_set_t *affinity
0045 )
0046 {
0047 Processor_mask set;
0048 Processor_mask_Copy_status status;
0049
0050 if ( affinity == NULL ) {
0051 return RTEMS_INVALID_ADDRESS;
0052 }
0053
0054 if ( !bsp_interrupt_is_valid_vector( vector ) ) {
0055 return RTEMS_INVALID_ID;
0056 }
0057
0058 status = _Processor_mask_From_cpu_set_t( &set, affinity_size, affinity );
0059 if ( !_Processor_mask_Is_at_most_partial_loss( status ) ) {
0060 return RTEMS_INVALID_NUMBER;
0061 }
0062
0063 _Processor_mask_And( &set, _SMP_Get_online_processors(), &set );
0064 if ( _Processor_mask_Is_zero( &set ) ) {
0065 return RTEMS_INVALID_NUMBER;
0066 }
0067
0068 #if defined(BSP_IRQ_HAVE_GET_SET_AFFINITY)
0069 return bsp_interrupt_set_affinity( vector, &set );
0070 #else
0071 return RTEMS_SUCCESSFUL;
0072 #endif
0073 }
0074
0075 rtems_status_code rtems_interrupt_get_affinity(
0076 rtems_vector_number vector,
0077 size_t affinity_size,
0078 cpu_set_t *affinity
0079 )
0080 {
0081 rtems_status_code sc;
0082 Processor_mask set;
0083 Processor_mask_Copy_status status;
0084
0085 if ( affinity == NULL ) {
0086 return RTEMS_INVALID_ADDRESS;
0087 }
0088
0089 _Processor_mask_Zero( &set );
0090
0091 if ( bsp_interrupt_is_valid_vector( vector ) ) {
0092 #if defined(BSP_IRQ_HAVE_GET_SET_AFFINITY)
0093 sc = bsp_interrupt_get_affinity( vector, &set );
0094 #else
0095 _Processor_mask_From_index( &set, 0 );
0096 sc = RTEMS_SUCCESSFUL;
0097 #endif
0098 } else {
0099 sc = RTEMS_INVALID_ID;
0100 }
0101
0102 status = _Processor_mask_To_cpu_set_t( &set, affinity_size, affinity );
0103 if ( sc == RTEMS_SUCCESSFUL && status != PROCESSOR_MASK_COPY_LOSSLESS ) {
0104 return RTEMS_INVALID_SIZE;
0105 }
0106
0107 return sc;
0108 }