Skip to content

Commit

Permalink
posix: create kconfig options for pse51, pse52, pse53
Browse files Browse the repository at this point in the history
Create Kconfig "shortcuts" for PSE51, PSE52, and PSE53.

Signed-off-by: Chris Friedt <[email protected]>
  • Loading branch information
Chris Friedt committed May 27, 2024
1 parent c237a88 commit 432df23
Show file tree
Hide file tree
Showing 32 changed files with 245 additions and 65 deletions.
6 changes: 3 additions & 3 deletions doc/services/portability/posix/aep/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The *Minimal Realtime System Profile* (PSE51) includes all of the
:header: Symbol, Support, Remarks
:widths: 50, 10, 50

_POSIX_AEP_REALTIME_MINIMAL, -1,
_POSIX_AEP_REALTIME_MINIMAL, -1, :kconfig:option:`CONFIG_POSIX_AEP_REALTIME_MINIMAL`

.. csv-table:: PSE51 Option Groups
:header: Symbol, Support, Remarks
Expand Down Expand Up @@ -94,7 +94,7 @@ The *Realtime Controller System Profile* (PSE52) includes all features from PSE5
:header: Symbol, Support, Remarks
:widths: 50, 10, 50

_POSIX_AEP_REALTIME_CONTROLLER, -1,
_POSIX_AEP_REALTIME_CONTROLLER, -1, :kconfig:option:`CONFIG_POSIX_AEP_REALTIME_CONTROLLER`

.. csv-table:: PSE52 Option Groups
:header: Symbol, Support, Remarks
Expand Down Expand Up @@ -134,7 +134,7 @@ The *Dedicated Realtime System Profile* (PSE53) includes all features from PSE52
:header: Symbol, Support, Remarks
:widths: 50, 10, 50

_POSIX_AEP_REALTIME_DEDICATED, -1,
_POSIX_AEP_REALTIME_DEDICATED, -1, :kconfig:option:`CONFIG_POSIX_AEP_REALTIME_DEDICATED`

.. csv-table:: PSE53 Option Groups
:header: Symbol, Support, Remarks
Expand Down
45 changes: 33 additions & 12 deletions doc/services/portability/posix/overview/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,43 @@ Configuration

Like most features in Zephyr, POSIX features are
:ref:`highly configurable<zephyr_intro_configurability>` but disabled by default. Users must
explicitly choose to enable POSIX options via :ref:`Kconfig<kconfig>` selection. Indeed, there are
:ref:`many Kconfig options in Zephyr<posix_kconfig_options>` for the POSIX API to allow for
feature selection at various levels of granularity.
explicitly choose to enable POSIX options via :ref:`Kconfig<kconfig>` selection.

Alternatively, users may enable one of the Kconfig options below as a shortcut to enable multiple
:ref:`Option Groups<posix_option_groups>`.
Subprofiles
+++++++++++

* :kconfig:option:`CONFIG_POSIX_API` - Enables all implemented POSIX API Options and Option Groups
Enable one of the Kconfig options below to quickly configure a pre-defined
:ref:`POSIX subprofile <posix_subprofiles>`.

.. note::
Since the POSIX environment in Zephyr is fully configurable via :ref:`Kconfig<kconfig>`,
configurations that require modifying features should not be made if strict compliance is
required (POSIX-1.2017, section 2.1.3.1).
* :kconfig:option:`CONFIG_POSIX_AEP_CHOICE_BASE` (:ref:`Base <posix_system_interfaces_required>`)
* :kconfig:option:`CONFIG_POSIX_AEP_CHOICE_PSE51` (:ref:`PSE51 <posix_aep_pse51>`)
* :kconfig:option:`CONFIG_POSIX_AEP_CHOICE_PSE52` (:ref:`PSE52 <posix_aep_pse52>`)
* :kconfig:option:`CONFIG_POSIX_AEP_CHOICE_PSE53` (:ref:`PSE53 <posix_aep_pse53>`)

Additional POSIX :ref:`Options and Option Groups <posix_option_groups>` may be enabled as needed
via Kconfig (e.g. ``CONFIG_POSIX_C_LIB_EXT=y``). Further fine-tuning may be accomplished via
:ref:`additional POSIX-related Kconfig options <posix_kconfig_options>`.

Subprofiles, Options, and Option Groups should be considered the preferred way to configure POSIX
in Zephyr going forward.

Legacy
++++++

Historically, Zephyr used :kconfig:option:`CONFIG_POSIX_API` to configure a set of POSIX features
that was overloaded and always increasing in size.

* :kconfig:option:`CONFIG_POSIX_API`

The option is now frozen, and can be considered equivalent to the following:

* :kconfig:option:`CONFIG_POSIX_AEP_CHOICE_PSE51`
* :kconfig:option:`CONFIG_POSIX_FD_MGMT`
* :kconfig:option:`CONFIG_POSIX_MESSAGE_PASSING`
* :kconfig:option:`CONFIG_POSIX_NETWORKING`

..
TODO: create Kconfig shortcuts for PSE51, PSE52, and PSE53
However, :kconfig:option:`CONFIG_POSIX_API` should be considered legacy and should not be used for
new Zephyr applications.

.. _IEEE: https://www.ieee.org/
.. _IEEE Computer Society: https://www.computer.org/
Expand Down
1 change: 1 addition & 0 deletions drivers/wifi/simplelink/Kconfig.simplelink
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ menuconfig WIFI_SIMPLELINK
select WIFI_OFFLOAD
select NET_L2_WIFI_MGMT
select FDTABLE
select POSIX_SEMAPHORES

if WIFI_SIMPLELINK

Expand Down
16 changes: 16 additions & 0 deletions include/zephyr/posix/posix_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
#include <autoconf.h> /* CONFIG_* */
#include <zephyr/sys/util_macro.h> /* COND_CODE_1() */

/*
* POSIX Application Environment Profiles (AEP - IEEE Std 1003.13-2003)
*/

#ifdef CONFIG_POSIX_AEP_REALTIME_MINIMAL
#define _POSIX_AEP_REALTIME_MINIMAL 200312L
#endif

#ifdef CONFIG_POSIX_AEP_REALTIME_CONTROLLER
#define _POSIX_AEP_REALTIME_CONTROLLER 200312L
#endif

#ifdef CONFIG_POSIX_AEP_REALTIME_DEDICATED
#define _POSIX_AEP_REALTIME_DEDICATED 200312L
#endif

/*
* POSIX System Interfaces
*/
Expand Down
8 changes: 1 addition & 7 deletions lib/posix/options/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@

menu "POSIX Options"

config POSIX_API
depends on !NATIVE_APPLICATION
bool "POSIX APIs"
select NATIVE_LIBC_INCOMPATIBLE
help
Enable mostly-standards-compliant implementations of
various POSIX (IEEE 1003.1) APIs.
rsource "Kconfig.profile"

rsource "Kconfig.aio"
rsource "Kconfig.barrier"
Expand Down
1 change: 0 additions & 1 deletion lib/posix/options/Kconfig.aio
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

config POSIX_ASYNCHRONOUS_IO
bool "POSIX asynchronous I/O [EXPERIMENTAL]"
default y if POSIX_API
select EXPERIMENTAL
help
Enable this option for asynchronous I/O. This option is present for conformance purposes
Expand Down
1 change: 0 additions & 1 deletion lib/posix/options/Kconfig.barrier
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

menuconfig POSIX_BARRIERS
bool "POSIX barriers"
default y if POSIX_API
help
Select 'y' here to enable POSIX barriers.

Expand Down
1 change: 0 additions & 1 deletion lib/posix/options/Kconfig.c_lib_ext
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

menuconfig POSIX_C_LIB_EXT
bool "POSIX general C library extension"
default y if POSIX_API
help
Select 'y' here and Zephyr will provide an implementation of the POSIX_C_LIB_EXT Option
Group, consisting of fnmatch(), getopt(), getsubopt(), optarg, opterr, optind, optopt,
Expand Down
1 change: 0 additions & 1 deletion lib/posix/options/Kconfig.device_io
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

menuconfig POSIX_DEVICE_IO
bool "POSIX device I/O [EXPERIMENTAL]"
default y if POSIX_API
select FDTABLE
select EXPERIMENTAL
help
Expand Down
1 change: 0 additions & 1 deletion lib/posix/options/Kconfig.fd_mgmt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

menuconfig POSIX_FD_MGMT
bool "POSIX file descriptor management [EXPERIMENTAL]"
default y if POSIX_API
select EXPERIMENTAL
help
Select 'y' here and Zephyr will provide implementations for the POSIX_FD_MGMT Option Group.
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/options/Kconfig.mem
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
config POSIX_PAGE_SIZE_BITS
int "Number of bits to use for PAGE_SIZE"
range 6 16
default 12 if POSIX_API
default 12 if POSIX_BASE_DEFINITIONS
default 6
help
Define PAGE_SIZE as BIT(n), where n is the value configured here.
Expand Down
1 change: 0 additions & 1 deletion lib/posix/options/Kconfig.mqueue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

menuconfig POSIX_MESSAGE_PASSING
bool "POSIX message queue support"
default y if POSIX_API
help
This enabled POSIX message queue related APIs.

Expand Down
2 changes: 0 additions & 2 deletions lib/posix/options/Kconfig.net
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

menuconfig POSIX_NETWORKING
bool "POSIX Networking API"
default y if POSIX_API
select NETWORKING
select NET_HOSTNAME_ENABLE
select NET_HOSTNAME_DYNAMIC
Expand Down Expand Up @@ -36,7 +35,6 @@ config POSIX_IPV6

config POSIX_RAW_SOCKETS
bool "POSIX IPv6 support"
default y
select NET_SOCKETS_PACKET
help
Enable this option to support the raw sockets.
Expand Down
1 change: 0 additions & 1 deletion lib/posix/options/Kconfig.proc1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

menuconfig POSIX_SINGLE_PROCESS
bool "POSIX single process support"
default y if POSIX_API
imply COMMON_LIBC_MALLOC # for env.c
help
Select 'y' here to use confstr(), environ, errno, getenv(), setenv(), sysconf(), uname(),
Expand Down
1 change: 0 additions & 1 deletion lib/posix/options/Kconfig.procN
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

menuconfig POSIX_MULTI_PROCESS
bool "POSIX multi-process support [EXPERIMENTAL]"
default y if POSIX_API
select EXPERIMENTAL
help
Support for multi-processing.
Expand Down
168 changes: 168 additions & 0 deletions lib/posix/options/Kconfig.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Copyright (c) 2024 Tenstorrent
#
# SPDX-License-Identifier: Apache-2.0

config POSIX_API
depends on !NATIVE_APPLICATION
bool "All POSIX APIs"
select NATIVE_LIBC_INCOMPATIBLE
select POSIX_BASE_DEFINITIONS
select POSIX_AEP_REALTIME_MINIMAL
select POSIX_FD_MGMT
select POSIX_MESSAGE_PASSING
select POSIX_NETWORKING
select POSIX_MULTI_PROCESS
help
This option enables the required POSIX System Interfaces (base definitions), as well as
features found in PSE51 and PSE52.

Note: in the future, this option may be deprecated in favour of subprofiling options.

choice POSIX_AEP_CHOICE
prompt "POSIX Subprofile"
default POSIX_AEP_CHOICE_NONE
help
This choice is intended to help users select the correct POSIX profile for their
application. Choices are based on IEEE 1003.13-2003 (now inactive / reserved) and
extrapolated to the more recent Subprofiling Option Groups in IEEE 1003.3-2017.

For more information, please refer to
https://standards.ieee.org/ieee/1003.13/3322/

config POSIX_AEP_CHOICE_NONE
bool "No pre-defined POSIX subprofile"
help
No pre-defined POSIX profile is selected.

config POSIX_AEP_CHOICE_BASE
bool "Base definitions (system interfaces)"
depends on !NATIVE_APPLICATION
select NATIVE_LIBC_INCOMPATIBLE
select POSIX_BASE_DEFINITIONS
help
Only enable the base definitions required for all POSIX systems.

config POSIX_AEP_CHOICE_PSE51
bool "Minimal Realtime System Profile (PSE51)"
depends on !NATIVE_APPLICATION
select NATIVE_LIBC_INCOMPATIBLE
select POSIX_BASE_DEFINITIONS
select POSIX_AEP_REALTIME_MINIMAL
help
PSE51 includes the POSIX Base Definitions (System Interfaces) as well as several Options and
Option Groups to facilitate device I/O, signals, mandatory configuration utilities, and
threading.

For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
https://docs.zephyrproject.org/latest/services/portability/posix/aep/index.html

config POSIX_AEP_CHOICE_PSE52
bool "Realtime Controller System Profile (PSE52)"
depends on !NATIVE_APPLICATION
select NATIVE_LIBC_INCOMPATIBLE
select POSIX_BASE_DEFINITIONS
select POSIX_AEP_REALTIME_MINIMAL
select POSIX_AEP_REALTIME_CONTROLLER
help
PSE52 includes the POSIX Base Definitions (System Interfaces) as well as all features of
PSE51. Additionally, it includes interfaces for file descriptor management, filesystem
support, support for message queues, and tracing.

For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
https://docs.zephyrproject.org/latest/services/portability/posix/aep/index.html

config POSIX_AEP_CHOICE_PSE53
bool "Dedicated Realtime System Profile (PSE53)"
depends on !NATIVE_APPLICATION
select NATIVE_LIBC_INCOMPATIBLE
select POSIX_BASE_DEFINITIONS
select POSIX_AEP_REALTIME_MINIMAL
select POSIX_AEP_REALTIME_CONTROLLER
select POSIX_AEP_REALTIME_DEDICATED
help
PSE53 includes the POSIX Base Definitions (System Interfaces) as well as all features of
PSE52. Additionally, it includes interfaces for POSIX multi-processing, networking, pipes,
and prioritized I/O.

For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
https://docs.zephyrproject.org/latest/services/portability/posix/aep/index.html

# TODO: PSE54: Multi-purpose Realtime System Profile

endchoice # POSIX_AEP_CHOICE

# Base Definitions (System Interfaces)
config POSIX_BASE_DEFINITIONS
bool
select POSIX_ASYNCHRONOUS_IO
select POSIX_BARRIERS
select POSIX_CLOCK_SELECTION
# select POSIX_MAPPED_FILES
# select POSIX_MEMORY_PROTECTION
select POSIX_READER_WRITER_LOCKS
select POSIX_REALTIME_SIGNALS
select POSIX_SEMAPHORES
select POSIX_SPIN_LOCKS
select POSIX_THREAD_SAFE_FUNCTIONS
select POSIX_THREADS
select POSIX_TIMEOUTS
select POSIX_TIMERS
help
This option is not user configurable.

config POSIX_AEP_REALTIME_MINIMAL
bool
# Option Groups
select POSIX_DEVICE_IO
select POSIX_SIGNALS
select POSIX_SINGLE_PROCESS
select XSI_THREADS_EXT
# Options
select POSIX_FSYNC
# select POSIX_MEMLOCK
# select POSIX_MEMLOCK_RANGE
select POSIX_MONOTONIC_CLOCK
# select POSIX_SHARED_MEMORY_OBJECTS
select POSIX_SYNCHRONIZED_IO
select POSIX_THREAD_ATTR_STACKADDR
select POSIX_THREAD_ATTR_STACKSIZE
select POSIX_THREAD_CPUTIME
select POSIX_THREAD_PRIO_INHERIT
select POSIX_THREAD_PRIO_PROTECT
select POSIX_THREAD_PRIORITY_SCHEDULING
# select POSIX_THREAD_SPORADIC_SERVER
help
This option is not user configurable.

config POSIX_AEP_REALTIME_CONTROLLER
bool
# Option Groups
select POSIX_FD_MGMT
select POSIX_FILE_SYSTEM
# Options
select POSIX_MESSAGE_PASSING
# select POSIX_TRACE
# select POSIX_TRACE_EVENT_FILTER
# select POSIX_TRACE_LOG
help
This option is not user configurable.

config POSIX_AEP_REALTIME_DEDICATED
bool
# Option Groups
select POSIX_MULTI_PROCESS
select POSIX_NETWORKING
# select POSIX_PIPE
# select POSIX_SIGNAL_JUMP
# Options
select POSIX_CPUTIME
# select POSIX_PRIORITIZED_IO
select POSIX_PRIORITY_SCHEDULING
select POSIX_RAW_SOCKETS
# select POSIX_SPAWN
# select POSIX_SPORADIC_SERVER
help
This option is not user configurable.
Loading

0 comments on commit 432df23

Please sign in to comment.