Skip to content

Commit

Permalink
Fix nasa#316: Execption/Intterupt API updates
Browse files Browse the repository at this point in the history
- Ensure the FPU functions that are actually not implemented in
  RTEMS/POSIX all return OS_ERR_NOT_IMPLEMENTED, not OS_SUCCESS.
- The RTEMS IntEnable/Disable API should not be a duplicate of
  the IntLock/Unlock API, as the semantics are slightly different.
  The Enable/Disable API should return OS_ERR_NOT_IMPLEMENTED.
- The OS_FPUExcGetMask API should confirm that the output buffer
  is not NULL.
  • Loading branch information
jphickey committed Dec 13, 2019
1 parent 155e9eb commit 49ddbbd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/os/posix/osapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,7 @@ int32 OS_FPUExcSetMask_Impl(uint32 mask)
/*
** Not implemented in linux.
*/
return(OS_SUCCESS);
return(OS_ERR_NOT_IMPLEMENTED);
} /* end OS_FPUExcSetMask_Impl */


Expand All @@ -2400,7 +2400,7 @@ int32 OS_FPUExcGetMask_Impl(uint32 *mask)
** Not implemented in linux.
*/
*mask = 0;
return(OS_SUCCESS);
return(OS_ERR_NOT_IMPLEMENTED);
} /* end OS_FPUExcGetMask_Impl */

/********************************************************************/
Expand Down
35 changes: 23 additions & 12 deletions src/os/rtems/osapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,8 @@ int32 OS_IntAttachHandler_Impl (uint32 InterruptNumber, osal_task_entry Interru
*-----------------------------------------------------------------*/
int32 OS_IntUnlock_Impl (int32 IntLevel)
{
rtems_interrupt_enable ( (rtems_interrupt_level) IntLevel);
rtems_interrupt_level rtems_int_level = IntLevel;
rtems_interrupt_local_enable ( rtems_int_level );
return (OS_SUCCESS);

} /* end OS_IntUnlock_Impl */
Expand All @@ -1487,7 +1488,21 @@ int32 OS_IntLock_Impl (void)
{
rtems_interrupt_level rtems_int_level;

rtems_interrupt_disable(rtems_int_level) ;
/*
* NOTE: rtems_interrupt_local_disable() is a macro
* that sets the rtems_int_level value.
*
* This code assumes that the value is also storable
* in an int32.
*
* This uses the "local" version which operates on
* the current CPU in case of a multi-processor environment.
*
* This should be identical to rtems_interrupt_disable in
* a single-processor config, but that call is not
* implemented in multi-processor configs.
*/
rtems_interrupt_local_disable(rtems_int_level) ;
return ( (int32) rtems_int_level) ;

} /* end OS_IntLock_Impl */
Expand All @@ -1504,8 +1519,7 @@ int32 OS_IntLock_Impl (void)
*-----------------------------------------------------------------*/
int32 OS_IntEnable_Impl (int32 Level)
{
rtems_interrupt_enable ( (rtems_interrupt_level) Level);
return(OS_SUCCESS);
return(OS_ERR_NOT_IMPLEMENTED);
} /* end OS_IntEnable_Impl */


Expand All @@ -1519,10 +1533,7 @@ int32 OS_IntEnable_Impl (int32 Level)
*-----------------------------------------------------------------*/
int32 OS_IntDisable_Impl (int32 Level)
{
rtems_interrupt_level rtems_int_level;

rtems_interrupt_disable(rtems_int_level) ;
return ( (int32) rtems_int_level) ;
return(OS_ERR_NOT_IMPLEMENTED);
} /* end OS_IntDisable_Impl */


Expand Down Expand Up @@ -1612,7 +1623,7 @@ int32 OS_FPUExcEnable_Impl(int32 ExceptionNumber)
/*
** Not implemented in RTEMS.
*/
return(OS_SUCCESS);
return(OS_ERR_NOT_IMPLEMENTED);
} /* end OS_FPUExcEnable_Impl */

/*----------------------------------------------------------------
Expand All @@ -1628,7 +1639,7 @@ int32 OS_FPUExcDisable_Impl(int32 ExceptionNumber)
/*
** Not implemented in RTEMS.
*/
return(OS_SUCCESS);
return(OS_ERR_NOT_IMPLEMENTED);
} /* end OS_FPUExcDisable_Impl */


Expand All @@ -1645,7 +1656,7 @@ int32 OS_FPUExcSetMask_Impl(uint32 mask)
/*
** Not implemented in RTEMS.
*/
return(OS_SUCCESS);
return(OS_ERR_NOT_IMPLEMENTED);
} /* end OS_FPUExcSetMask_Impl */


Expand All @@ -1662,7 +1673,7 @@ int32 OS_FPUExcGetMask_Impl(uint32 *mask)
/*
** Not implemented in RTEMS.
*/
return(OS_SUCCESS);
return(OS_ERR_NOT_IMPLEMENTED);
} /* end OS_FPUExcGetMask_Impl */

/********************************************************************/
Expand Down
5 changes: 5 additions & 0 deletions src/os/shared/osapi-fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ int32 OS_FPUExcSetMask(uint32 mask)
*-----------------------------------------------------------------*/
int32 OS_FPUExcGetMask(uint32 *mask)
{
if (mask == NULL)
{
return OS_INVALID_POINTER;
}

return OS_FPUExcGetMask_Impl(mask);
} /* end OS_FPUExcGetMask */

Expand Down

0 comments on commit 49ddbbd

Please sign in to comment.