nuttx/Documentation/reference/user/13_boardctl.rst

231 lines
6.8 KiB
ReStructuredText
Raw Normal View History

doc: Migrating the rest of documentation from cwiki. * This completes task list in https://github.com/apache/nuttx/issues/11127. * This preserves selected content from cwiki and moves it to new docs. * Most pages are simple copy-paste with a simple RST formatting updates, with minor updates. * Content update / reorganization will follow later on when needed. * Files added (or updated title from cwiki -> current docs): * Documentation/implementation: * index. * cancellation_points. * Asynchronous vs. Synchronous Context Switches -> context_switches.rst. * ARMv7-M Hardfaults, SVCALL, and Debuggers -> hardfatuls.rst. * chip.h FAQ -> chip_h.rst. * Debug Output (SYSLOG) Issues -> syslog.rst. * Detaching File Descriptors -> file_descriptors.rst. * device_nodes.rst. * Dynamic Clocking -> power_management.rst. * ENOTTY ioctl() Return Value -> ioctl.rst. * memory_configurations.rst. * kernel_modules_vs_shared_libraries.rst. * NAKing USB OUT/IN Tokens -> usb.rst. * naming_arch_mcu_board_interfaces.rst. * naming_os_internals.rst. * nuttx_tasking.rst. * oneshot_timers_and_cpu_load.rst. * nuttx_initialization_sequence.rst. * short_time_delays.rst. * Signal Handler Tour -> signal_handlers.rst. * smp.rst. * syslog.rst. * Task Exit Sequence -> nuttx_tasking.rst. * tasks_vs_threads.rst. * tls.rst. * tickless_os.rst. * Why Can't Kernel Threads Have pthreads -> kernel_threads_vs_pthreads.rst. * Documentation/components/filesystem: * smartfs.rst. Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
2026-05-16 13:54:41 +02:00
.. _board-ioctl:
2021-03-25 13:16:42 -03:00
===========
Board IOCTL
===========
In a small embedded system, there will typically be a much
greater interaction between application and low-level board features.
The canonically correct to implement such interactions is by
implementing a character driver and performing the interactions
via low level ``ioctl()`` calls. This, however, may not be practical
in many cases and will lead to "correct" but awkward implementations.
:c:func:`boardctl` is non-standard OS interface to alleviate the problem.
It basically circumvents the normal device driver ``ioctl()``
interface and allows the application to perform direct
IOCTL-like calls to the board-specific logic. It is especially
useful for setting up board operational and test configurations.
:c:func:`boardctl` is an application interface to the OS.
There is no point, in fact, of using :c:func:`boardctl` within the OS;
the board interfaces prototyped in :file:`include/nuttx/board.h` may
be called directly from within the OS.
.. c:function:: int boardctl(unsigned int cmd, uintptr_t arg)
:param cmd: Identifies the board command to be executed. See
:file:`include/sys/boardctl.h` for the complete list of common
board commands. Provisions are made to support non-common,
board-specific commands as well.
:param arg: The argument that accompanies the command. The nature
of the argument is determined by the specific command.
:return: On success zero (OK) is returned; -1 (ERROR) is
returned on failure with the errno variable set to indicate the nature of the failure.
Supported commands
==================
The following is the list of supported :c:func:`boardctl` commands.
Besides this list, board logic can implement handling of custom commands by
implementing the :c:func:`board_ioctl` interface.
System state control
--------------------
.. c:macro:: BOARDIOC_POWEROFF
Power off the board
2021-03-25 13:16:42 -03:00
:Argument: Integer value providing power off status information
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_BOARDCTL_POWEROFF
2021-03-25 13:16:42 -03:00
:dependencies: Board logic must provide the :c:func:`board_power_off` interface.
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_RESET
Reset the board
2021-03-25 13:16:42 -03:00
:Argument: Integer value providing power off status information
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_BOARDCTL_RESET
2021-03-25 13:16:42 -03:00
:dependencies: Board logic must provide the :c:func:`board_reset` interface.
2021-03-25 13:16:42 -03:00
Power Management
----------------
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_PM_CONTROL
Manage power state transition and query. The supplied argument
indicates the specific PM operation to perform, which map to
corresponding internal ``pm_<operation>`` functions
(see :doc:`/components/drivers/special/power/pm/index`).
2021-03-25 13:16:42 -03:00
With this interface you can interact with PM handling arch/board logic
(typically done in IDLE loop) or you can directly manage state transitions
from userspace.
2021-03-25 13:16:42 -03:00
:Argument: A pointer to an instance of :c:struct:`boardioc_pm_ctrl_s`.
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_PM
2021-03-25 13:16:42 -03:00
Board information
-----------------
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_UNIQUEID
Return a unique ID associated with the board (such as a
serial number or a MAC address).
2021-03-25 13:16:42 -03:00
:Argument: A writable array of size :c:macro:`CONFIG_BOARDCTL_UNIQUEID_SIZE` in
which to receive the board unique ID.
2021-03-25 13:16:42 -03:00
:dependencies: Board logic must provide the :c:func:`board_uniqueid` interface.
.. c:macro:: BOARDIOC_MACADDR
Get the network driver MAC address.
:Argument: A pointer to an instance of :c:struct:`boardioc_macaddr_s`.
:configuration: CONFIG_BOARDCTL_MACADDR
:dependencies: Board logic must provide the :c:func:`board_macaddr` interface.
2021-03-25 13:16:42 -03:00
Filesystems
-----------
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_MKRD
Create a RAM disk
2021-03-25 13:16:42 -03:00
:Argument: Pointer to read-only instance of :c:struct:`boardioc_mkrd_s`.
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_BOARDCTL_MKRD
.. c:macro:: BOARDIOC_ROMDISK
Register a ROM disk
2021-03-25 13:16:42 -03:00
:Argument: Pointer to read-only instance of :c:struct:`boardioc_romdisk_s`.
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_BOARDCTL_ROMDISK
2021-03-25 13:16:42 -03:00
Symbol Handling
---------------
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_APP_SYMTAB
Select the application symbol table. This symbol table
provides the symbol definitions exported to application
code from application space.
2021-03-25 13:16:42 -03:00
:Argument: A pointer to an instance of :c:struct:`boardioc_symtab_s`.
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_BOARDCTL_APP_SYMTAB
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_OS_SYMTAB
Select the OS symbol table. This symbol table provides
the symbol definitions exported by the OS to kernel
modules.
2021-03-25 13:16:42 -03:00
:Argument: A pointer to an instance of :c:struct:`boardioc_symtab_s`.
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_BOARDCTL_OS_SYMTAB
2021-03-25 13:16:42 -03:00
.. 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).
2021-03-25 13:16:42 -03:00
:Argument: A pointer to an instance of :c:struct:`boardioc_builtin_s`.
2021-03-25 13:16:42 -03:00
:configuration: This command is always available when
CONFIG_BUILTIN is enabled, but does nothing unless
CONFIG_BUILD_PROTECTED is also selected.
2021-03-25 13:16:42 -03:00
USB
---
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_USBDEV_CONTROL
Manage USB device classes
2021-03-25 13:16:42 -03:00
:Argument: A pointer to an instance of :c:struct:`boardioc_usbdev_ctrl_s`.
:configuration: CONFIG_BOARDCTL && CONFIG_BOARDCTL_USBDEVCTRL
:dependencies: Board logic must provide `board_<usbdev>_initialize()`.
2021-03-25 13:16:42 -03:00
Graphics
--------
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_NX_START
Start the NX server
2021-03-25 13:16:42 -03:00
:Argument: Integer display number to be served by this NXMU instance.
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_NX
2021-03-25 13:16:42 -03:00
:dependencies: Base graphics logic provides :c:func:`nxmu_start`.
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_VNC_START
Start the NX server and framebuffer driver.
2021-03-25 13:16:42 -03:00
:Argument: A reference readable instance of :c:struct:`boardioc_vncstart_s`.
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_VNCSERVER
:dependencies: VNC server provides :c:func:`nx_vnc_fbinitialize`.
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_NXTERM
Create an NX terminal device
2021-03-25 13:16:42 -03:00
:Argument: A reference readable/writable instance of
:c:struct:`boardioc_nxterm_create_s`.
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_NXTERM
2021-03-25 13:16:42 -03:00
:dependencies: Base NX terminal logic provides :c:func:`nx_register` and
:c:func:`nxtk_register`.
2021-03-25 13:16:42 -03:00
.. c:macro:: BOARDIOC_NXTERM_IOCTL
Create an NX terminal IOCTL command. Normal IOCTLs
cannot be be performed in most graphics contexts since
the depend on the task holding an open file descriptor
2021-03-25 13:16:42 -03:00
:Argument: A reference readable/writable instance of
:c:struct:`boardioc_nxterm_ioctl_s`.
2021-03-25 13:16:42 -03:00
:configuration: CONFIG_NXTERM
2021-03-25 13:16:42 -03:00
:dependencies: Base NX terminal logic provides :c:func:`nxterm_ioctl_tap`.