Add a state variable that provides the current level of OS initialization. This is needed by some logic that may attempt to run early in the start-up sequence, but cannot run if a sufficient level of initializaitn has not not yet occurred
This commit is contained in:
parent
0554de6c50
commit
2dc258986d
@ -11451,4 +11451,8 @@
|
||||
We can get better timing accuracy without it (2016-02-03).
|
||||
* drivers/ioexpander/pca555.c: Add logic to make the PCA555 driver
|
||||
thread safe (2016-02-03).
|
||||
|
||||
* sched/init/os_start.c and include/nuttx/init.h: Add a state variable
|
||||
that provides the current level of OS initialization. This is needed by
|
||||
some logic that may attempt to run early in the start-up sequence but
|
||||
cannot run if a sufficient level of initialization has not yet occurred
|
||||
(2016-02-05).
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/init.h
|
||||
*
|
||||
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008, 2011, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -43,10 +43,40 @@
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define OSINIT_MM_READY() (g_os_initstate >= OSINIT_MEMORY)
|
||||
#define OSINIT_HW_READY() (g_os_initstate >= OSINIT_HARDWARE)
|
||||
#define OSINIT_OS_READY() (g_os_initstate >= OSINIT_OSREADY)
|
||||
#define OSINIT_OS_INITIALIZING() (g_os_initstate < OSINIT_OSREADY)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Initialization state. OS bring-up occurs in several phases: */
|
||||
|
||||
enum os_initstate_e
|
||||
{
|
||||
OSINIT_POWERUP = 0, /* 1. Power-up. No initialization yet performed */
|
||||
OSINIT_BOOT, /* 2. Basic boot up initialization is complete. OS
|
||||
* services and hardware resources are not yet
|
||||
* available. */
|
||||
OSINIT_MEMORY, /* 3. The memory manager has been initialized */
|
||||
OSINIT_HARDWARE, /* 4. MCU-specific hardware is complete. Hardware
|
||||
* resources such as timers and device drivers
|
||||
* are now avaiable. Low-level OS services
|
||||
* sufficient to support the hardware are
|
||||
* also avaialable but the OS has not yet
|
||||
* completed its full initialization. */
|
||||
OSINIT_OSREADY /* 5. The OS is fully initialized and multi-tasking
|
||||
* is active. */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@ -59,6 +89,13 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* This is the current initialization state. The level of initialization
|
||||
* is only important early in the start-up sequence when certain OS or
|
||||
* hardware resources may not yet be available to the kernel logic.
|
||||
*/
|
||||
|
||||
EXTERN uint8_t g_os_initstate; /* See enum os_initstate_e */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* sched/init/os_start.c
|
||||
*
|
||||
* Copyright (C) 2007-2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -72,14 +72,6 @@
|
||||
#endif
|
||||
#include "init/init.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Declarations
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@ -215,6 +207,13 @@ const struct tasklist_s g_tasklisttable[NUM_TASK_STATES] =
|
||||
#endif
|
||||
};
|
||||
|
||||
/* This is the current initialization state. The level of initialization
|
||||
* is only important early in the start-up sequence when certain OS or
|
||||
* hardware resources may not yet be available to the kernel logic.
|
||||
*/
|
||||
|
||||
uint8_t g_os_initstate; /* See enum os_initstate_e */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
@ -264,6 +263,10 @@ void os_start(void)
|
||||
|
||||
slldbg("Entry\n");
|
||||
|
||||
/* Boot up is complete */
|
||||
|
||||
g_os_initstate = OSINIT_BOOT;
|
||||
|
||||
/* Initialize RTOS Data ***************************************************/
|
||||
/* Initialize all task lists */
|
||||
|
||||
@ -391,6 +394,10 @@ void os_start(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The memory manager is available */
|
||||
|
||||
g_os_initstate = OSINIT_MEMORY;
|
||||
|
||||
#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
|
||||
/* Initialize tasking data structures */
|
||||
|
||||
@ -497,6 +504,10 @@ void os_start(void)
|
||||
|
||||
up_initialize();
|
||||
|
||||
/* Hardware resources are available */
|
||||
|
||||
g_os_initstate = OSINIT_HARDWARE;
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
/* Complete initialization the networking system now that interrupts
|
||||
* and timers have been configured by up_initialize().
|
||||
@ -542,6 +553,10 @@ void os_start(void)
|
||||
#endif
|
||||
|
||||
/* Bring Up the System ****************************************************/
|
||||
/* The OS is fully initialized and we are beginning multi-tasking */
|
||||
|
||||
g_os_initstate = OSINIT_OSREADY;
|
||||
|
||||
/* Create initial tasks and bring-up the system */
|
||||
|
||||
DEBUGVERIFY(os_bringup());
|
||||
|
Loading…
x
Reference in New Issue
Block a user