You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/07/09 08:06:06 UTC

(nuttx) branch master updated (b881868f19 -> 129f751fae)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from b881868f19 arch/arm/sama5: Fix typos in ohci driver comments.
     new bbc31d70f4 drivers: add API for drivers early initialization
     new 129f751fae Documentation: add drivers early initialization

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Documentation/components/drivers/index.rst | 12 ++++++
 drivers/drivers_initialize.c               | 20 ++++++++++
 drivers/note/note_initialize.c             | 60 ++++++++++++++++++++----------
 include/nuttx/drivers/drivers.h            | 11 ++++++
 include/nuttx/note/note_driver.h           | 22 ++++++++++-
 sched/init/nx_start.c                      | 10 +++--
 6 files changed, 110 insertions(+), 25 deletions(-)


(nuttx) 02/02: Documentation: add drivers early initialization

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 129f751faecd36ff8226e98a55ef5da4686ff8be
Author: xuxingliang <xu...@xiaomi.com>
AuthorDate: Tue Jul 9 10:11:50 2024 +0800

    Documentation: add drivers early initialization
    
    Signed-off-by: xuxingliang <xu...@xiaomi.com>
---
 Documentation/components/drivers/index.rst | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Documentation/components/drivers/index.rst b/Documentation/components/drivers/index.rst
index 401f7336ca..26697f597f 100644
--- a/Documentation/components/drivers/index.rst
+++ b/Documentation/components/drivers/index.rst
@@ -283,3 +283,15 @@ The following skeleton files are available:
 * ``drivers/mtd/skeleton.c`` Skeleton memory technology device drivers
 * ``drivers/net/skeleton.c`` Skeleton network/Ethernet drivers
 * ``drivers/usbhost/usbhost_skeleton.c`` Skeleton USB host class driver
+
+Drivers Early Initialization
+============================
+
+To initialize drivers early in the boot process, the :c:func:`drivers_early_initialize`
+function is introduced. This is particularly beneficial for certain drivers,
+such as SEGGER SystemView, or others that require initialization before the
+system is fully operational.
+
+It is important to note that during this early initialization phase,
+system resources are not yet available for use. This includes memory allocation,
+file systems, and any other system resources.


(nuttx) 01/02: drivers: add API for drivers early initialization

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit bbc31d70f4217057ca7a597a58532e5daa240c57
Author: xuxingliang <xu...@xiaomi.com>
AuthorDate: Sat Jul 6 19:04:04 2024 +0800

    drivers: add API for drivers early initialization
    
    Signed-off-by: xuxingliang <xu...@xiaomi.com>
---
 drivers/drivers_initialize.c     | 20 ++++++++++++++
 drivers/note/note_initialize.c   | 60 +++++++++++++++++++++++++++-------------
 include/nuttx/drivers/drivers.h  | 11 ++++++++
 include/nuttx/note/note_driver.h | 22 +++++++++++++--
 sched/init/nx_start.c            | 10 ++++---
 5 files changed, 98 insertions(+), 25 deletions(-)

diff --git a/drivers/drivers_initialize.c b/drivers/drivers_initialize.c
index 70b10f257c..8a52b47c3d 100644
--- a/drivers/drivers_initialize.c
+++ b/drivers/drivers_initialize.c
@@ -53,6 +53,26 @@
  * 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
  *
diff --git a/drivers/note/note_initialize.c b/drivers/note/note_initialize.c
index bcece5019f..5d50728925 100644
--- a/drivers/note/note_initialize.c
+++ b/drivers/note/note_initialize.c
@@ -35,6 +35,46 @@
  * 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
  *
@@ -46,7 +86,7 @@
  *   None.
  *
  * 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
 
-#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;
 }
diff --git a/include/nuttx/drivers/drivers.h b/include/nuttx/drivers/drivers.h
index de025d7d00..3dec180225 100644
--- a/include/nuttx/drivers/drivers.h
+++ b/include/nuttx/drivers/drivers.h
@@ -43,6 +43,17 @@ extern "C"
 #define EXTERN extern
 #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
  *
diff --git a/include/nuttx/note/note_driver.h b/include/nuttx/note/note_driver.h
index 8e1de97037..ddea033743 100644
--- a/include/nuttx/note/note_driver.h
+++ b/include/nuttx/note/note_driver.h
@@ -112,6 +112,25 @@ struct note_driver_s
 
 #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
  *
@@ -123,11 +142,10 @@ struct note_driver_s
  *   None.
  *
  * 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);
 #endif
 
diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c
index a74b5ea22a..997612739c 100644
--- a/sched/init/nx_start.c
+++ b/sched/init/nx_start.c
@@ -518,10 +518,6 @@ void nx_start(void)
 
   g_nx_initstate = OSINIT_BOOT;
 
-  /* Initialize RTOS Data ***************************************************/
-
-  sched_trace_begin();
-
   /* Initialize task list table *********************************************/
 
   tasklist_initialize();
@@ -534,6 +530,12 @@ void nx_start(void)
 
   g_nx_initstate = OSINIT_TASKLISTS;
 
+  /* Initialize RTOS Data ***************************************************/
+
+  drivers_early_initialize();
+
+  sched_trace_begin();
+
   /* Initialize RTOS facilities *********************************************/
 
   /* Initialize the semaphore facility.  This has to be done very early