Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #457, provide BSP shutdown handler #465

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/bsp/mcp750-vxworks/src/bsp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@

#include "mcp750_bsp_internal.h"

/* ---------------------------------------------------------
OS_BSP_Shutdown_Impl()

Helper function to abort the running task
--------------------------------------------------------- */
void OS_BSP_Shutdown_Impl(void)
{
abort();
}


/******************************************************************************
** Function: OS_BSPMain()
**
Expand Down
11 changes: 11 additions & 0 deletions src/bsp/pc-linux/src/bsp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ int OS_BSP_GetReturnStatus(void)
return retcode;
}

/* ---------------------------------------------------------
OS_BSP_Shutdown_Impl()

Helper function to abort the running task
--------------------------------------------------------- */
void OS_BSP_Shutdown_Impl(void)
{
abort();
}


/******************************************************************************
** Function: main()
**
Expand Down
41 changes: 28 additions & 13 deletions src/bsp/pc-rtems/src/bsp_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,30 @@ rtems_status_code OS_BSP_GetReturnStatus(void)
return retcode;
}

/* ---------------------------------------------------------
OS_BSP_Shutdown_Impl()

Helper function to abort the running task
--------------------------------------------------------- */
void OS_BSP_Shutdown_Impl(void)
{
/*
* Not calling exit() under RTEMS, this simply shuts down the executive,
* forcing the user to reboot the system.
*
* Calling suspend causes execution to get stuck here, but the RTEMS
* shell thread will still be active so the user can poke around, read results,
* then use a shell command to reboot when ready.
*/
while (!OS_BSP_PcRtemsGlobal.BatchMode)
{
printf("\n\nInit thread idle.\nPress <enter> for shell or reset machine...\n\n");
rtems_task_suspend(rtems_task_self());
}

rtems_shutdown_executive(OS_BSP_GetReturnStatus());
}

/*
** A simple entry point to start from the loader
*/
Expand Down Expand Up @@ -355,20 +379,11 @@ rtems_task Init(rtems_task_argument ignored)
OS_Application_Run();

/*
* Not calling exit() under RTEMS, this simply shuts down the executive,
* forcing the user to reboot the system.
*
* Calling suspend causes execution to get stuck here, but the RTEMS
* shell thread will still be active so the user can poke around, read results,
* then use a shell command to reboot when ready.
* Enter the BSP default shutdown mode
* depending on config, this may reset/reboot or suspend
* so the operator can use the shell.
*/
while (!OS_BSP_PcRtemsGlobal.BatchMode)
{
printf("\n\nInit thread idle.\nPress <enter> for shell or reset machine...\n\n");
rtems_task_suspend(rtems_task_self());
}

rtems_shutdown_executive(OS_BSP_GetReturnStatus());
OS_BSP_Shutdown_Impl();
}

/* configuration information */
Expand Down
10 changes: 10 additions & 0 deletions src/bsp/shared/inc/bsp-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ void OS_BSP_ConsoleOutput_Impl(const char *Str, uint32 DataLen);
------------------------------------------------------------------*/
void OS_BSP_ConsoleSetMode_Impl(uint32 ModeBits);

/*----------------------------------------------------------------
Function: OS_BSP_Shutdown_Impl

Purpose: Causes the calling task to abort in a BSP-safe way.
This may map to the abort() system call, but on some systems
that causes a reboot or undesirable side effect. The
BSP may implement this call in a different manner.
------------------------------------------------------------------*/
void OS_BSP_Shutdown_Impl(void);

/*********************
END bsp-impl.h
*********************/
Expand Down
4 changes: 2 additions & 2 deletions ut_assert/src/utbsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage)

/*
* If any ABORT (major failure) message is thrown,
* then actually call abort() to stop the test and dump a core
* then call a BSP-provided routine to stop the test and possibly dump a core
*/
if (MessageType == UTASSERT_CASETYPE_ABORT)
{
abort();
OS_BSP_Shutdown_Impl();
}
}

Expand Down