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

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

commit 00879c0c2b9d25a93745c08195fdcb9c6230233a
Author: anjiahao <[email protected]>
AuthorDate: Sun Sep 28 11:43:54 2025 +0800

    Protect:use userspace inside of BOARDIOC_BUILTINS to get built-in 
information
    
    Get the builtin list from USERSPACE instead of BOARDIOC_BUILTINS.
    
    Signed-off-by: anjiahao <[email protected]>
    Signed-off-by: wangjianyu3 <[email protected]>
---
 .github/CODEOWNERS                                 |  1 -
 Documentation/reference/user/13_boardctl.rst       | 20 ------
 .../arm/at32/at32f437-mini/kernel/at32_userspace.c |  7 ++
 .../arcx-socket-grid/kernel/imxrt_userspace.c      |  7 ++
 .../imxrt/imxrt1050-evk/kernel/imxrt_userspace.c   |  7 ++
 .../imxrt/imxrt1060-evk/kernel/imxrt_userspace.c   |  7 ++
 .../imxrt/imxrt1064-evk/kernel/imxrt_userspace.c   |  7 ++
 .../imxrt/imxrt1170-evk/kernel/imxrt_userspace.c   |  7 ++
 .../arm/imxrt/teensy-4.x/kernel/imxrt_userspace.c  |  7 ++
 .../lc823450-xgevk/kernel/lc823450_userspace.c     |  7 ++
 .../lpc4088-devkit/kernel/lpc17_40_userspace.c     |  7 ++
 .../lpc4088-quickstart/kernel/lpc17_40_userspace.c |  7 ++
 .../open1788/kernel/lpc17_40_userspace.c           |  7 ++
 .../pnev5180b/kernel/lpc17_40_userspace.c          |  7 ++
 .../lpc43xx/bambino-200e/kernel/lpc43_userspace.c  |  7 ++
 boards/arm/mps/mps2-an500/kernel/mps_userspace.c   |  7 ++
 boards/arm/mps/mps3-an547/kernel/mps_userspace.c   |  7 ++
 .../arm/qemu/qemu-armv7r/kernel/qemu_userspace.c   |  7 ++
 .../s32k3xx/mr-canhubk3/kernel/s32k3xx_userspace.c |  7 ++
 boards/arm/sam34/sam3u-ek/kernel/sam_userspace.c   |  7 ++
 .../pic32czca70-curiosity/kernel/sam_userspace.c   |  7 ++
 .../arm/samv7/same70-qmtech/kernel/sam_userspace.c |  7 ++
 .../samv7/same70-xplained/kernel/sam_userspace.c   |  7 ++
 .../arm/samv7/samv71-xult/kernel/sam_userspace.c   |  7 ++
 .../clicker2-stm32/kernel/stm32_userspace.c        |  7 ++
 .../mikroe-stm32f4/kernel/stm32_userspace.c        |  7 ++
 .../olimex-stm32-p407/kernel/stm32_userspace.c     |  7 ++
 .../arm/stm32f4/omnibusf4/kernel/stm32_userspace.c |  7 ++
 .../stm32f4/stm3240g-eval/kernel/stm32_userspace.c |  7 ++
 .../stm32f4discovery/kernel/stm32_userspace.c      |  7 ++
 .../stm32f746g-disco/kernel/stm32_userspace.c      |  7 ++
 .../stm32f769i-disco/kernel/stm32_userspace.c      |  7 ++
 .../stm32f777zit6-meadow/kernel/stm32_userspace.c  |  7 ++
 .../stm32h7/nucleo-h723zg/kernel/stm32_userspace.c |  7 ++
 .../stm32h7/nucleo-h743zi/kernel/stm32_userspace.c |  7 ++
 .../stm32h747i-disco/kernel/stm32_userspace.c      |  7 ++
 .../stm32l476vg-disco/kernel/stm32l4_userspace.c   |  7 ++
 .../stm32l4r9ai-disco/kernel/stm32l4_userspace.c   |  7 ++
 boards/arm/tiva/lm3s6965-ek/kernel/lm_userspace.c  |  7 ++
 .../fvp-v8r/fvp-armv8r/kernel/fvp_userspace.c      |  7 ++
 boards/boardctl.c                                  | 34 ----------
 .../c906/smartl-c906/kernel/c906_userspace.c       |  7 ++
 .../common/kernel/esp32c3_userspace.c              |  7 ++
 .../risc-v/k210/maix-bit/kernel/k210_userspace.c   |  7 ++
 .../risc-v/k230/canmv230/kernel/k230_userspace.c   |  7 ++
 boards/risc-v/mpfs/common/kernel/mpfs_userspace.c  |  7 ++
 .../qemu-rv/rv-virt/kernel/rv_virt_userspace.c     |  7 ++
 .../xtensa/esp32/common/kernel/esp32_userspace.c   |  7 ++
 .../esp32s3/common/kernel/esp32s3_userspace.c      |  7 ++
 include/nuttx/lib/builtin.h                        | 44 ++-----------
 include/nuttx/userspace.h                          |  9 +++
 include/sys/boardctl.h                             | 56 ++++------------
 libs/libc/builtin/CMakeLists.txt                   |  4 --
 libs/libc/builtin/Make.defs                        |  4 --
 libs/libc/builtin/lib_builtin_setlist.c            | 75 ----------------------
 55 files changed, 348 insertions(+), 221 deletions(-)

diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 4d503bb92c8..bf2d0aa1033 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -14979,7 +14979,6 @@ libs/libc/builtin/lib_builtin_getmode.c 
[email protected] alin.jerpelea@son
 libs/libc/builtin/lib_builtin_getname.c [email protected] 
[email protected] [email protected]
 libs/libc/builtin/lib_builtin_getuid.c [email protected] 
[email protected]
 libs/libc/builtin/lib_builtin_isavail.c [email protected] 
[email protected] [email protected]
-libs/libc/builtin/lib_builtin_setlist.c [email protected] 
[email protected] [email protected]
 libs/libc/ctype/* [email protected] [email protected] 
[email protected]
 libs/libc/dirent/lib_alphasort.c [email protected] [email protected]
 libs/libc/dirent/lib_closedir.c [email protected] [email protected] 
[email protected]
diff --git a/Documentation/reference/user/13_boardctl.rst 
b/Documentation/reference/user/13_boardctl.rst
index f8742bcb05f..3e3c39a7b9f 100644
--- a/Documentation/reference/user/13_boardctl.rst
+++ b/Documentation/reference/user/13_boardctl.rst
@@ -147,26 +147,6 @@ Symbol Handling
 
    :configuration: CONFIG_BOARDCTL_OS_SYMTAB
 
-.. c:macro:: BOARDIOC_BUILTINS
-
-   Provide the user-space list of built-in applications for
-   use by BINFS in protected mode.  Normally this is small
-   set of globals provided by user-space logic.  It provides
-   name-value pairs for associating built-in application
-   names with user-space entry point addresses.  These
-   globals are only needed for use by BINFS which executes
-   built-in applications from kernel-space in PROTECTED mode.
-   In the FLAT build, the user space globals are readily
-   available.  (BINFS is not supportable in KERNEL mode since
-   user-space address have no general meaning that
-   configuration).
-
-   :Argument: A pointer to an instance of :c:struct:`boardioc_builtin_s`.
-
-   :configuration: This command is always available when
-     CONFIG_BUILTIN is enabled, but does nothing unless
-     CONFIG_BUILD_PROTECTED is also selected.
-
 USB
 ---
 
diff --git a/boards/arm/at32/at32f437-mini/kernel/at32_userspace.c 
b/boards/arm/at32/at32f437-mini/kernel/at32_userspace.c
index 38ccfa6c51e..042b39d16de 100644
--- a/boards/arm/at32/at32f437-mini/kernel/at32_userspace.c
+++ b/boards/arm/at32/at32f437-mini/kernel/at32_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/imxrt/arcx-socket-grid/kernel/imxrt_userspace.c 
b/boards/arm/imxrt/arcx-socket-grid/kernel/imxrt_userspace.c
index d23be6c46f7..d9a4b02a1fe 100644
--- a/boards/arm/imxrt/arcx-socket-grid/kernel/imxrt_userspace.c
+++ b/boards/arm/imxrt/arcx-socket-grid/kernel/imxrt_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/imxrt/imxrt1050-evk/kernel/imxrt_userspace.c 
b/boards/arm/imxrt/imxrt1050-evk/kernel/imxrt_userspace.c
index c8a29cd123e..17191fff3ac 100644
--- a/boards/arm/imxrt/imxrt1050-evk/kernel/imxrt_userspace.c
+++ b/boards/arm/imxrt/imxrt1050-evk/kernel/imxrt_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/imxrt/imxrt1060-evk/kernel/imxrt_userspace.c 
b/boards/arm/imxrt/imxrt1060-evk/kernel/imxrt_userspace.c
index ab45742ddca..ea445e4885f 100644
--- a/boards/arm/imxrt/imxrt1060-evk/kernel/imxrt_userspace.c
+++ b/boards/arm/imxrt/imxrt1060-evk/kernel/imxrt_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/imxrt/imxrt1064-evk/kernel/imxrt_userspace.c 
b/boards/arm/imxrt/imxrt1064-evk/kernel/imxrt_userspace.c
index c793802e1dd..296e543bfc5 100644
--- a/boards/arm/imxrt/imxrt1064-evk/kernel/imxrt_userspace.c
+++ b/boards/arm/imxrt/imxrt1064-evk/kernel/imxrt_userspace.c
@@ -104,6 +104,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/imxrt/imxrt1170-evk/kernel/imxrt_userspace.c 
b/boards/arm/imxrt/imxrt1170-evk/kernel/imxrt_userspace.c
index 3f9332c4112..8c32cbe8e7d 100644
--- a/boards/arm/imxrt/imxrt1170-evk/kernel/imxrt_userspace.c
+++ b/boards/arm/imxrt/imxrt1170-evk/kernel/imxrt_userspace.c
@@ -115,6 +115,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/imxrt/teensy-4.x/kernel/imxrt_userspace.c 
b/boards/arm/imxrt/teensy-4.x/kernel/imxrt_userspace.c
index c0dfcded61b..5618f1e5dae 100644
--- a/boards/arm/imxrt/teensy-4.x/kernel/imxrt_userspace.c
+++ b/boards/arm/imxrt/teensy-4.x/kernel/imxrt_userspace.c
@@ -104,6 +104,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/lc823450/lc823450-xgevk/kernel/lc823450_userspace.c 
b/boards/arm/lc823450/lc823450-xgevk/kernel/lc823450_userspace.c
index edc11fa73f4..640178a2682 100644
--- a/boards/arm/lc823450/lc823450-xgevk/kernel/lc823450_userspace.c
+++ b/boards/arm/lc823450/lc823450-xgevk/kernel/lc823450_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/lpc17xx_40xx/lpc4088-devkit/kernel/lpc17_40_userspace.c 
b/boards/arm/lpc17xx_40xx/lpc4088-devkit/kernel/lpc17_40_userspace.c
index 04c606fd4da..40987ee79db 100644
--- a/boards/arm/lpc17xx_40xx/lpc4088-devkit/kernel/lpc17_40_userspace.c
+++ b/boards/arm/lpc17xx_40xx/lpc4088-devkit/kernel/lpc17_40_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git 
a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/kernel/lpc17_40_userspace.c 
b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/kernel/lpc17_40_userspace.c
index 9b37a304533..9776d663c61 100644
--- a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/kernel/lpc17_40_userspace.c
+++ b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/kernel/lpc17_40_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/lpc17xx_40xx/open1788/kernel/lpc17_40_userspace.c 
b/boards/arm/lpc17xx_40xx/open1788/kernel/lpc17_40_userspace.c
index 054faef3b33..47ad96084bf 100644
--- a/boards/arm/lpc17xx_40xx/open1788/kernel/lpc17_40_userspace.c
+++ b/boards/arm/lpc17xx_40xx/open1788/kernel/lpc17_40_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/kernel/lpc17_40_userspace.c 
b/boards/arm/lpc17xx_40xx/pnev5180b/kernel/lpc17_40_userspace.c
index 6df2807a7b3..22ca3832662 100644
--- a/boards/arm/lpc17xx_40xx/pnev5180b/kernel/lpc17_40_userspace.c
+++ b/boards/arm/lpc17xx_40xx/pnev5180b/kernel/lpc17_40_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/lpc43xx/bambino-200e/kernel/lpc43_userspace.c 
b/boards/arm/lpc43xx/bambino-200e/kernel/lpc43_userspace.c
index c2f13cf6c42..90785f4754c 100644
--- a/boards/arm/lpc43xx/bambino-200e/kernel/lpc43_userspace.c
+++ b/boards/arm/lpc43xx/bambino-200e/kernel/lpc43_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/mps/mps2-an500/kernel/mps_userspace.c 
b/boards/arm/mps/mps2-an500/kernel/mps_userspace.c
index 9a56745fba1..b3379bf7cd8 100644
--- a/boards/arm/mps/mps2-an500/kernel/mps_userspace.c
+++ b/boards/arm/mps/mps2-an500/kernel/mps_userspace.c
@@ -117,6 +117,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/mps/mps3-an547/kernel/mps_userspace.c 
b/boards/arm/mps/mps3-an547/kernel/mps_userspace.c
index fa22607eb97..b14ce04c935 100644
--- a/boards/arm/mps/mps3-an547/kernel/mps_userspace.c
+++ b/boards/arm/mps/mps3-an547/kernel/mps_userspace.c
@@ -117,6 +117,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/qemu/qemu-armv7r/kernel/qemu_userspace.c 
b/boards/arm/qemu/qemu-armv7r/kernel/qemu_userspace.c
index bda9bf8a94d..7d9a50ae0e0 100644
--- a/boards/arm/qemu/qemu-armv7r/kernel/qemu_userspace.c
+++ b/boards/arm/qemu/qemu-armv7r/kernel/qemu_userspace.c
@@ -98,6 +98,13 @@ const struct userspace_s userspace locate_data(".userspace") 
=
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/s32k3xx/mr-canhubk3/kernel/s32k3xx_userspace.c 
b/boards/arm/s32k3xx/mr-canhubk3/kernel/s32k3xx_userspace.c
index 275102bbfc1..9555d3e84c9 100644
--- a/boards/arm/s32k3xx/mr-canhubk3/kernel/s32k3xx_userspace.c
+++ b/boards/arm/s32k3xx/mr-canhubk3/kernel/s32k3xx_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/sam34/sam3u-ek/kernel/sam_userspace.c 
b/boards/arm/sam34/sam3u-ek/kernel/sam_userspace.c
index c9e537e5182..e5674b291ef 100644
--- a/boards/arm/sam34/sam3u-ek/kernel/sam_userspace.c
+++ b/boards/arm/sam34/sam3u-ek/kernel/sam_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/samv7/pic32czca70-curiosity/kernel/sam_userspace.c 
b/boards/arm/samv7/pic32czca70-curiosity/kernel/sam_userspace.c
index c27705fc0e9..66bf511a1d6 100644
--- a/boards/arm/samv7/pic32czca70-curiosity/kernel/sam_userspace.c
+++ b/boards/arm/samv7/pic32czca70-curiosity/kernel/sam_userspace.c
@@ -92,6 +92,13 @@ const struct userspace_s userspace locate_data(".userspace") 
=
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/samv7/same70-qmtech/kernel/sam_userspace.c 
b/boards/arm/samv7/same70-qmtech/kernel/sam_userspace.c
index 9f19fb66f12..748ca2cfe03 100644
--- a/boards/arm/samv7/same70-qmtech/kernel/sam_userspace.c
+++ b/boards/arm/samv7/same70-qmtech/kernel/sam_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/samv7/same70-xplained/kernel/sam_userspace.c 
b/boards/arm/samv7/same70-xplained/kernel/sam_userspace.c
index 83b5611f051..71f769adca3 100644
--- a/boards/arm/samv7/same70-xplained/kernel/sam_userspace.c
+++ b/boards/arm/samv7/same70-xplained/kernel/sam_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/samv7/samv71-xult/kernel/sam_userspace.c 
b/boards/arm/samv7/samv71-xult/kernel/sam_userspace.c
index 6bbac20ef3d..74167762433 100644
--- a/boards/arm/samv7/samv71-xult/kernel/sam_userspace.c
+++ b/boards/arm/samv7/samv71-xult/kernel/sam_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32f4/clicker2-stm32/kernel/stm32_userspace.c 
b/boards/arm/stm32f4/clicker2-stm32/kernel/stm32_userspace.c
index fcaa153b670..9f3ce122826 100644
--- a/boards/arm/stm32f4/clicker2-stm32/kernel/stm32_userspace.c
+++ b/boards/arm/stm32f4/clicker2-stm32/kernel/stm32_userspace.c
@@ -104,6 +104,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32f4/mikroe-stm32f4/kernel/stm32_userspace.c 
b/boards/arm/stm32f4/mikroe-stm32f4/kernel/stm32_userspace.c
index 75c04f0ea07..b030e8ac9ac 100644
--- a/boards/arm/stm32f4/mikroe-stm32f4/kernel/stm32_userspace.c
+++ b/boards/arm/stm32f4/mikroe-stm32f4/kernel/stm32_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32f4/olimex-stm32-p407/kernel/stm32_userspace.c 
b/boards/arm/stm32f4/olimex-stm32-p407/kernel/stm32_userspace.c
index db4079eff62..557f30511e6 100644
--- a/boards/arm/stm32f4/olimex-stm32-p407/kernel/stm32_userspace.c
+++ b/boards/arm/stm32f4/olimex-stm32-p407/kernel/stm32_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32f4/omnibusf4/kernel/stm32_userspace.c 
b/boards/arm/stm32f4/omnibusf4/kernel/stm32_userspace.c
index 77bf45552f2..731faf79df6 100644
--- a/boards/arm/stm32f4/omnibusf4/kernel/stm32_userspace.c
+++ b/boards/arm/stm32f4/omnibusf4/kernel/stm32_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32f4/stm3240g-eval/kernel/stm32_userspace.c 
b/boards/arm/stm32f4/stm3240g-eval/kernel/stm32_userspace.c
index ca655d1ada4..353f8e96bd0 100644
--- a/boards/arm/stm32f4/stm3240g-eval/kernel/stm32_userspace.c
+++ b/boards/arm/stm32f4/stm3240g-eval/kernel/stm32_userspace.c
@@ -101,6 +101,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32f4/stm32f4discovery/kernel/stm32_userspace.c 
b/boards/arm/stm32f4/stm32f4discovery/kernel/stm32_userspace.c
index 6bcb1ee9edf..804ede617f8 100644
--- a/boards/arm/stm32f4/stm32f4discovery/kernel/stm32_userspace.c
+++ b/boards/arm/stm32f4/stm32f4discovery/kernel/stm32_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32f7/stm32f746g-disco/kernel/stm32_userspace.c 
b/boards/arm/stm32f7/stm32f746g-disco/kernel/stm32_userspace.c
index d81d6dbc653..a46e2e203f1 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/kernel/stm32_userspace.c
+++ b/boards/arm/stm32f7/stm32f746g-disco/kernel/stm32_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32f7/stm32f769i-disco/kernel/stm32_userspace.c 
b/boards/arm/stm32f7/stm32f769i-disco/kernel/stm32_userspace.c
index 0e5928da47f..69a7a944f83 100644
--- a/boards/arm/stm32f7/stm32f769i-disco/kernel/stm32_userspace.c
+++ b/boards/arm/stm32f7/stm32f769i-disco/kernel/stm32_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/kernel/stm32_userspace.c 
b/boards/arm/stm32f7/stm32f777zit6-meadow/kernel/stm32_userspace.c
index bf2e7d446b5..ed23eea44ab 100644
--- a/boards/arm/stm32f7/stm32f777zit6-meadow/kernel/stm32_userspace.c
+++ b/boards/arm/stm32f7/stm32f777zit6-meadow/kernel/stm32_userspace.c
@@ -112,6 +112,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32h7/nucleo-h723zg/kernel/stm32_userspace.c 
b/boards/arm/stm32h7/nucleo-h723zg/kernel/stm32_userspace.c
index efeccb94388..8e61dbf7336 100644
--- a/boards/arm/stm32h7/nucleo-h723zg/kernel/stm32_userspace.c
+++ b/boards/arm/stm32h7/nucleo-h723zg/kernel/stm32_userspace.c
@@ -93,6 +93,13 @@ const struct userspace_s userspace locate_data(".userspace") 
=
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32h7/nucleo-h743zi/kernel/stm32_userspace.c 
b/boards/arm/stm32h7/nucleo-h743zi/kernel/stm32_userspace.c
index e08a2a3e793..4d9c4139ac7 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/kernel/stm32_userspace.c
+++ b/boards/arm/stm32h7/nucleo-h743zi/kernel/stm32_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32h7/stm32h747i-disco/kernel/stm32_userspace.c 
b/boards/arm/stm32h7/stm32h747i-disco/kernel/stm32_userspace.c
index add2b26b43d..46638ac67d7 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/kernel/stm32_userspace.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/kernel/stm32_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32l4/stm32l476vg-disco/kernel/stm32l4_userspace.c 
b/boards/arm/stm32l4/stm32l476vg-disco/kernel/stm32l4_userspace.c
index dbc82d5be38..517fbd1c8e1 100644
--- a/boards/arm/stm32l4/stm32l476vg-disco/kernel/stm32l4_userspace.c
+++ b/boards/arm/stm32l4/stm32l476vg-disco/kernel/stm32l4_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/kernel/stm32l4_userspace.c 
b/boards/arm/stm32l4/stm32l4r9ai-disco/kernel/stm32l4_userspace.c
index d2622ef46f0..045896eeb89 100644
--- a/boards/arm/stm32l4/stm32l4r9ai-disco/kernel/stm32l4_userspace.c
+++ b/boards/arm/stm32l4/stm32l4r9ai-disco/kernel/stm32l4_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm/tiva/lm3s6965-ek/kernel/lm_userspace.c 
b/boards/arm/tiva/lm3s6965-ek/kernel/lm_userspace.c
index 84cec6ba6b9..c7bd35bd605 100644
--- a/boards/arm/tiva/lm3s6965-ek/kernel/lm_userspace.c
+++ b/boards/arm/tiva/lm3s6965-ek/kernel/lm_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/arm64/fvp-v8r/fvp-armv8r/kernel/fvp_userspace.c 
b/boards/arm64/fvp-v8r/fvp-armv8r/kernel/fvp_userspace.c
index ef17dab38db..6ee2c5fb503 100644
--- a/boards/arm64/fvp-v8r/fvp-armv8r/kernel/fvp_userspace.c
+++ b/boards/arm64/fvp-v8r/fvp-armv8r/kernel/fvp_userspace.c
@@ -124,6 +124,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/boardctl.c b/boards/boardctl.c
index df128042a14..2bfcb87f70d 100644
--- a/boards/boardctl.c
+++ b/boards/boardctl.c
@@ -644,40 +644,6 @@ int boardctl(unsigned int cmd, uintptr_t arg)
         break;
 #endif
 
-#ifdef CONFIG_BUILTIN
-      /* CMD:           BOARDIOC_BUILTINS
-       * DESCRIPTION:   Provide the user-space list of built-in applications
-       *                for use by BINFS in protected mode.  Normally this
-       *                is small set of globals provided by user-space
-       *                logic.  It provides name-value pairs for associating
-       *                built-in application names with user-space entry
-       *                point addresses.  These globals are only needed for
-       *                use by BINFS which executes built-in applications
-       *                from kernel-space in PROTECTED mode. In the FLAT
-       *                build, the user space globals are readily
-       *                available.  (BINFS is not supportable in KERNEL mode
-       *                since user-space address have no general meaning
-       *                that configuration).
-       * ARG:           A pointer to an instance of struct boardioc_builtin_s
-       * CONFIGURATION: This BOARDIOC command is always available when
-       *                CONFIG_BUILTIN is enabled, but does nothing unless
-       *                CONFIG_BUILD_KERNEL is selected.
-       * DEPENDENCIES:  None
-       */
-
-      case BOARDIOC_BUILTINS:
-        {
-#if defined(CONFIG_BUILD_PROTECTED)
-          FAR const struct boardioc_builtin_s *builtin =
-            (FAR const struct boardioc_builtin_s *)arg;
-
-          DEBUGASSERT(builtin != NULL);
-          builtin_setlist(builtin->builtins, builtin->count);
-#endif
-        }
-        break;
-#endif
-
 #ifdef CONFIG_BOARDCTL_USBDEVCTRL
       /* CMD:           BOARDIOC_USBDEV_CONTROL
        * DESCRIPTION:   Manage USB device classes
diff --git a/boards/risc-v/c906/smartl-c906/kernel/c906_userspace.c 
b/boards/risc-v/c906/smartl-c906/kernel/c906_userspace.c
index f084e79736a..395037d0127 100644
--- a/boards/risc-v/c906/smartl-c906/kernel/c906_userspace.c
+++ b/boards/risc-v/c906/smartl-c906/kernel/c906_userspace.c
@@ -106,6 +106,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/risc-v/esp32c3-legacy/common/kernel/esp32c3_userspace.c 
b/boards/risc-v/esp32c3-legacy/common/kernel/esp32c3_userspace.c
index e7aa28d6d4f..986f32609e3 100644
--- a/boards/risc-v/esp32c3-legacy/common/kernel/esp32c3_userspace.c
+++ b/boards/risc-v/esp32c3-legacy/common/kernel/esp32c3_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/risc-v/k210/maix-bit/kernel/k210_userspace.c 
b/boards/risc-v/k210/maix-bit/kernel/k210_userspace.c
index 88383e49d89..62c57a41b1a 100644
--- a/boards/risc-v/k210/maix-bit/kernel/k210_userspace.c
+++ b/boards/risc-v/k210/maix-bit/kernel/k210_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/risc-v/k230/canmv230/kernel/k230_userspace.c 
b/boards/risc-v/k230/canmv230/kernel/k230_userspace.c
index b40588eda2d..2c560527231 100644
--- a/boards/risc-v/k230/canmv230/kernel/k230_userspace.c
+++ b/boards/risc-v/k230/canmv230/kernel/k230_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/risc-v/mpfs/common/kernel/mpfs_userspace.c 
b/boards/risc-v/mpfs/common/kernel/mpfs_userspace.c
index ca0b1e0f7f3..3783b51e647 100644
--- a/boards/risc-v/mpfs/common/kernel/mpfs_userspace.c
+++ b/boards/risc-v/mpfs/common/kernel/mpfs_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/risc-v/qemu-rv/rv-virt/kernel/rv_virt_userspace.c 
b/boards/risc-v/qemu-rv/rv-virt/kernel/rv_virt_userspace.c
index 18a67106822..dc984b4d3fe 100644
--- a/boards/risc-v/qemu-rv/rv-virt/kernel/rv_virt_userspace.c
+++ b/boards/risc-v/qemu-rv/rv-virt/kernel/rv_virt_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/xtensa/esp32/common/kernel/esp32_userspace.c 
b/boards/xtensa/esp32/common/kernel/esp32_userspace.c
index 1a78133376f..0d82719c88c 100644
--- a/boards/xtensa/esp32/common/kernel/esp32_userspace.c
+++ b/boards/xtensa/esp32/common/kernel/esp32_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/boards/xtensa/esp32s3/common/kernel/esp32s3_userspace.c 
b/boards/xtensa/esp32s3/common/kernel/esp32s3_userspace.c
index 5c12945939c..acd82f2ae54 100644
--- a/boards/xtensa/esp32s3/common/kernel/esp32s3_userspace.c
+++ b/boards/xtensa/esp32s3/common/kernel/esp32s3_userspace.c
@@ -102,6 +102,13 @@ const struct userspace_s userspace 
locate_data(".userspace") =
 #ifdef CONFIG_LIBC_USRWORK
   .work_usrstart    = work_usrstart,
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  .builtin_count    = &g_builtin_count,
+  .builtins         = &g_builtins[0],
+#endif
 };
 
 /****************************************************************************
diff --git a/include/nuttx/lib/builtin.h b/include/nuttx/lib/builtin.h
index 51d32d75a19..a8392cfddf7 100644
--- a/include/nuttx/lib/builtin.h
+++ b/include/nuttx/lib/builtin.h
@@ -29,6 +29,7 @@
 
 #include <nuttx/config.h>
 #include <sys/types.h>
+#include <nuttx/userspace.h>
 
 #ifdef CONFIG_APP_REGISTRY
 
@@ -66,18 +67,10 @@ extern "C"
 #endif
 
 #if defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)
-/* In the PROTECTED build, the builtin arrays are only needed by BINFS.
- * in this case, the user-space globals are not accessible and must be
- * provided to the OS via the boardctl(BOARDIOC_BUILTINS) call.  In this
- * case, the PROTECTED kernel will keep its own copy of the user-space
- * array.
- *
- * The call to boardctl(BOARDIOC_BUILTINS) must be provided by the
- * application layer.
- */
+/* In the PROTECTED build, We use USERSPACE to get builtin information. */
 
-EXTERN FAR const struct builtin_s *g_builtins;
-EXTERN int g_builtin_count;
+#define g_builtins (USERSPACE->builtins)
+#define g_builtin_count (*USERSPACE->builtin_count)
 
 #else
 /* In the FLAT build, the builtin list is just a global global array and
@@ -93,35 +86,6 @@ EXTERN const int g_builtin_count;
  * Public Function Prototypes
  ****************************************************************************/
 
-/****************************************************************************
- * Name: builtin_setlist
- *
- * Description:
- *   Saves the user-space list of built-in applications for use by BINFS in
- *   protected mode.  Normally this is small set of globals provided by
- *   user-space logic.  It provides name-value pairs for associating
- *   built-in application names with user-space entry point addresses.
- *   These globals are only needed for use by BINFS which executes built-in
- *   applications from kernel-space in PROTECTED mode.  In the FLAT build,
- *   the user space globals are readily available.  (BINFS is not
- *   supportable in KERNEL mode since user-space address have no general
- *   meaning that configuration).
- *
- * Input Parameters:
- *   builtins - The list of built-in functions.  Each entry is a name-value
- *              pair that maps a built-in function name to its user-space
- *              entry point address.
- *   count    - The number of name-value pairs in the built-in list.
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-#if defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)
-void builtin_setlist(FAR const struct builtin_s *builtins, int count);
-#endif
-
 /****************************************************************************
  * Name: builtin_isavail
  *
diff --git a/include/nuttx/userspace.h b/include/nuttx/userspace.h
index e85a2a5e752..af3d027ec4e 100644
--- a/include/nuttx/userspace.h
+++ b/include/nuttx/userspace.h
@@ -34,6 +34,8 @@
 #include <signal.h>
 #include <pthread.h>
 
+#include <nuttx/lib/builtin.h>
+
 #ifdef CONFIG_BUILD_PROTECTED
 
 /****************************************************************************
@@ -121,6 +123,13 @@ struct userspace_s
 #ifdef CONFIG_LIBC_USRWORK
   CODE int (*work_usrstart)(void);
 #endif
+
+  /* Builtin support */
+
+#ifdef CONFIG_BUILTIN
+  FAR const int *builtin_count;
+  FAR const struct builtin_s *builtins;
+#endif
 };
 
 /****************************************************************************
diff --git a/include/sys/boardctl.h b/include/sys/boardctl.h
index 7ef05eb31c7..59e0e73504b 100644
--- a/include/sys/boardctl.h
+++ b/include/sys/boardctl.h
@@ -113,24 +113,6 @@
  * CONFIGURATION: CONFIG_BOARDCTL_OS_SYMTAB
  * DEPENDENCIES:  None
  *
- * CMD:           BOARDIOC_BUILTINS
- * DESCRIPTION:   Provide the user-space list of built-in applications for
- *                use by BINFS in protected mode.  Normally this is small
- *                set of globals provided by user-space logic.  It provides
- *                name-value pairs for associating built-in application
- *                names with user-space entry point addresses.  These
- *                globals are only needed for use by BINFS which executes
- *                built-in applications from kernel-space in PROTECTED mode.
- *                In the FLAT build, the user space globals are readily
- *                available.  (BINFS is not supportable in KERNEL mode since
- *                user-space address have no general meaning that
- *                configuration).
- * ARG:           A pointer to an instance of struct boardioc_builtin_s
- * CONFIGURATION: This BOARDIOC command is always available when
- *                CONFIG_BUILTIN is enabled, but does nothing unless
- *                CONFIG_BUILD_PROTECTED is also selected.
- * DEPENDENCIES:  None
- *
  * CMD:           BOARDIOC_USBDEV_CONTROL
  * DESCRIPTION:   Manage USB device classes
  * ARG:           A pointer to an instance of struct boardioc_usbdev_ctrl_s
@@ -190,20 +172,19 @@
 #define BOARDIOC_ROMDISK           _BOARDIOC(0x0007)
 #define BOARDIOC_APP_SYMTAB        _BOARDIOC(0x0008)
 #define BOARDIOC_OS_SYMTAB         _BOARDIOC(0x0009)
-#define BOARDIOC_BUILTINS          _BOARDIOC(0x000a)
-#define BOARDIOC_USBDEV_CONTROL    _BOARDIOC(0x000b)
-#define BOARDIOC_NX_START          _BOARDIOC(0x000c)
-#define BOARDIOC_VNC_START         _BOARDIOC(0x000d)
-#define BOARDIOC_NXTERM            _BOARDIOC(0x000e)
-#define BOARDIOC_NXTERM_IOCTL      _BOARDIOC(0x000f)
-#define BOARDIOC_SPINLOCK          _BOARDIOC(0x0010)
-#define BOARDIOC_UNIQUEKEY         _BOARDIOC(0x0011)
-#define BOARDIOC_SWITCH_BOOT       _BOARDIOC(0x0012)
-#define BOARDIOC_BOOT_IMAGE        _BOARDIOC(0x0013)
-#define BOARDIOC_RESET_CAUSE       _BOARDIOC(0x0014)
-#define BOARDIOC_IRQ_AFFINITY      _BOARDIOC(0x0015)
-#define BOARDIOC_START_CPU         _BOARDIOC(0x0016)
-#define BOARDIOC_MACADDR           _BOARDIOC(0x0017)
+#define BOARDIOC_USBDEV_CONTROL    _BOARDIOC(0x000a)
+#define BOARDIOC_NX_START          _BOARDIOC(0x000b)
+#define BOARDIOC_VNC_START         _BOARDIOC(0x000c)
+#define BOARDIOC_NXTERM            _BOARDIOC(0x000d)
+#define BOARDIOC_NXTERM_IOCTL      _BOARDIOC(0x000e)
+#define BOARDIOC_SPINLOCK          _BOARDIOC(0x000f)
+#define BOARDIOC_UNIQUEKEY         _BOARDIOC(0x0010)
+#define BOARDIOC_SWITCH_BOOT       _BOARDIOC(0x0011)
+#define BOARDIOC_BOOT_IMAGE        _BOARDIOC(0x0012)
+#define BOARDIOC_RESET_CAUSE       _BOARDIOC(0x0013)
+#define BOARDIOC_IRQ_AFFINITY      _BOARDIOC(0x0014)
+#define BOARDIOC_START_CPU         _BOARDIOC(0x0015)
+#define BOARDIOC_MACADDR           _BOARDIOC(0x0016)
 
 /* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support.
  * In this case, all commands not recognized by boardctl() will be forwarded
@@ -302,17 +283,6 @@ struct boardioc_symtab_s
   int nsymbols;
 };
 
-#ifdef CONFIG_BUILTIN
-/* Arguments passed with the BOARDIOC_BUILTIN command */
-
-struct builtin_s;  /* Forward reference */
-struct boardioc_builtin_s
-{
-  FAR const struct builtin_s *builtins;
-  int count;
-};
-#endif
-
 #ifdef CONFIG_BOARDCTL_USBDEVCTRL
 /* This structure provides the argument BOARDIOC_USBDEV_CONTROL and
  * describes which device should be controlled and what should be
diff --git a/libs/libc/builtin/CMakeLists.txt b/libs/libc/builtin/CMakeLists.txt
index f7587c3a465..ee45861174e 100644
--- a/libs/libc/builtin/CMakeLists.txt
+++ b/libs/libc/builtin/CMakeLists.txt
@@ -23,10 +23,6 @@
 if(CONFIG_APP_REGISTRY)
   set(SRCS lib_builtin_getname.c lib_builtin_isavail.c lib_builtin_forindex.c)
 
-  if(CONFIG_BUILD_PROTECTED)
-    list(APPEND SRCS lib_builtin_setlist.c)
-  endif()
-
   if(CONFIG_SCHED_USER_IDENTITY)
     list(APPEND SRCS lib_builtin_getuid.c lib_builtin_getgid.c
          lib_builtin_getmode.c)
diff --git a/libs/libc/builtin/Make.defs b/libs/libc/builtin/Make.defs
index 268ee4f20d3..4239260d026 100644
--- a/libs/libc/builtin/Make.defs
+++ b/libs/libc/builtin/Make.defs
@@ -26,10 +26,6 @@ ifneq ($(CONFIG_APP_REGISTRY),)
 
 CSRCS += lib_builtin_getname.c lib_builtin_isavail.c lib_builtin_forindex.c
 
-ifeq ($(CONFIG_BUILD_PROTECTED),y)
-CSRCS += lib_builtin_setlist.c
-endif
-
 ifeq ($(CONFIG_SCHED_USER_IDENTITY),y)
 CSRCS += lib_builtin_getuid.c lib_builtin_getgid.c lib_builtin_getmode.c
 endif
diff --git a/libs/libc/builtin/lib_builtin_setlist.c 
b/libs/libc/builtin/lib_builtin_setlist.c
deleted file mode 100644
index 0fd352e9dad..00000000000
--- a/libs/libc/builtin/lib_builtin_setlist.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
- * libs/libc/builtin/lib_builtin_setlist.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <nuttx/lib/builtin.h>
-
-#if defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-FAR const struct builtin_s *g_builtins;
-int g_builtin_count;
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: builtin_setlist
- *
- * Description:
- *   Saves the user-space list of built-in applications for use by BINFS in
- *   protected mode.  Normally this is small set of globals provided by
- *   user-space logic.  It provides name-value pairs for associating
- *   built-in application names with user-space entry point addresses.
- *   These globals are only needed for use by BINFS which executes built-in
- *   applications from kernel-space in PROTECTED mode.  In the FLAT build,
- *   the user space globals are readily available.  (BINFS is not
- *   supportable in KERNEL mode since user-space address have no general
- *   meaning that configuration).
- *
- * Input Parameters:
- *   builtins - The list of built-in functions.  Each entry is a name-value
- *              pair that maps a built-in function name to its user-space
- *              entry point address.
- *   count    - The number of name-value pairs in the built-in list.
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-void builtin_setlist(FAR const struct builtin_s *builtins, int count)
-{
-  g_builtins      = builtins;
-  g_builtin_count = count;
-}
-
-#endif /* CONFIG_BUILD_PROTECTED && __KERNEL__ */

Reply via email to