mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
drivers: add API for drivers early initialization
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
@@ -53,6 +53,26 @@
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: drivers_early_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* drivers_early_initialize will be called once before OS initialization
|
||||||
|
* when no system resource is ready to use.
|
||||||
|
*
|
||||||
|
* drivers_early_initialize serves the purpose of bringing up drivers as
|
||||||
|
* early as possible, so they can be used even during OS initialization.
|
||||||
|
* It must not rely on any system resources, such as heap memory.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void drivers_early_initialize(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_DRIVERS_NOTE
|
||||||
|
note_early_initialize();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: drivers_initialize
|
* Name: drivers_initialize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -35,6 +35,46 @@
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: note_early_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Registers note drivers early, without depending on system features
|
||||||
|
* such as heap memory.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero on success. A negated errno value is returned on a failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int note_early_initialize(void)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
#ifdef CONFIG_SEGGER_SYSVIEW
|
||||||
|
ret = note_sysview_initialize();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
serr("note_sysview_initialize failed %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_DRIVERS_NOTESNAP
|
||||||
|
ret = notesnap_register();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
serr("notesnap_register failed %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: note_initialize
|
* Name: note_initialize
|
||||||
*
|
*
|
||||||
@@ -46,7 +86,7 @@
|
|||||||
* None.
|
* None.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero on succress. A negated errno value is returned on a failure.
|
* Zero on success. A negated errno value is returned on a failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -81,23 +121,5 @@ int note_initialize(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SEGGER_SYSVIEW
|
|
||||||
ret = note_sysview_initialize();
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
serr("note_sysview_initialize failed %d\n", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_DRIVERS_NOTESNAP
|
|
||||||
ret = notesnap_register();
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
serr("notesnap_register failed %d\n", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,17 @@ extern "C"
|
|||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: drivers_early_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Performs one-time, early driver initialization that doesn't rely on OS
|
||||||
|
* resources being ready.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void drivers_early_initialize(void);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: drivers_initialize
|
* Name: drivers_initialize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -112,6 +112,25 @@ struct note_driver_s
|
|||||||
|
|
||||||
#if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)
|
#if defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT)
|
||||||
|
|
||||||
|
#ifdef CONFIG_DRIVERS_NOTE
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: note_early_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Early register sched note related drivers that do not rely on system
|
||||||
|
* features like mm.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero on success. A negative errno value is returned on a failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int note_early_initialize(void);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: note_initialize
|
* Name: note_initialize
|
||||||
*
|
*
|
||||||
@@ -123,11 +142,10 @@ struct note_driver_s
|
|||||||
* None.
|
* None.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero on succress. A negated errno value is returned on a failure.
|
* Zero on success. A negative errno value is returned on a failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_DRIVERS_NOTE
|
|
||||||
int note_initialize(void);
|
int note_initialize(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -518,10 +518,6 @@ void nx_start(void)
|
|||||||
|
|
||||||
g_nx_initstate = OSINIT_BOOT;
|
g_nx_initstate = OSINIT_BOOT;
|
||||||
|
|
||||||
/* Initialize RTOS Data ***************************************************/
|
|
||||||
|
|
||||||
sched_trace_begin();
|
|
||||||
|
|
||||||
/* Initialize task list table *********************************************/
|
/* Initialize task list table *********************************************/
|
||||||
|
|
||||||
tasklist_initialize();
|
tasklist_initialize();
|
||||||
@@ -534,6 +530,12 @@ void nx_start(void)
|
|||||||
|
|
||||||
g_nx_initstate = OSINIT_TASKLISTS;
|
g_nx_initstate = OSINIT_TASKLISTS;
|
||||||
|
|
||||||
|
/* Initialize RTOS Data ***************************************************/
|
||||||
|
|
||||||
|
drivers_early_initialize();
|
||||||
|
|
||||||
|
sched_trace_begin();
|
||||||
|
|
||||||
/* Initialize RTOS facilities *********************************************/
|
/* Initialize RTOS facilities *********************************************/
|
||||||
|
|
||||||
/* Initialize the semaphore facility. This has to be done very early
|
/* Initialize the semaphore facility. This has to be done very early
|
||||||
|
|||||||
Reference in New Issue
Block a user