MISRA-C Directive 4.7 says that error information returned from
a function needs to be tested. In the logging macros,
return from _is_user_context() is not needed until logging is
enabled and above minimal logging level. There is a potential
that the return is not being used at all. So move it one level
below as it is surely being used within the if block.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Compile with arm-none-eabi-g++ (10.2.0) fails with:
error: designator order for field 'net_buf_pool::free' does not match declaration order in 'net_buf_pool'
because C++ doesn't support out-of-order designated initializers.
Signed-off-by: Rihards Skuja <rihardssk@mikrotik.com>
There exist zsock_ counterparts of the two mentioned
functions, but they were not exposed in the Zephyr POSIX API
(CONFIG_POSIX_API=y). This commit fills the gap.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Unaligned read-out capability become fact among all drivers.
Let's cut this in stone as API requirement.
fixes#16439
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
include/cache.h: System calls declaration and implementation
kernel/cache_handlers.c: Defination of verification functions
Signed-off-by: Aastha Grover <aastha.grover@intel.com>
Numbers in C macros are treated as signed integer. This causes
issues when using macro KB(x). If the result is larger than
(2^31 - 1), it is treated as a negative number downstream.
For example, the RAM size of up_squared is 2GB. The result of
KB(CONFIG_SRAM_SIZE) should be 2147483648, but due to being
casted as signed, the result is instead -2147483648. Any
calculations using this would be incorrectly. Fix it by
casting x in KB(x) to size_t first.
Fixes#27164
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Add note regarding safe use of the k_work_pending return value. Similar
to the note for k_delayed_work_pending.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add k_delayed_work_pending similar to k_work_pending to check if the
delayed work item has been submitted but not yet completed.
This would compliment the API since using k_work_pending or
k_delayed_work_remaining_get is not enough to check this condition.
This is because the timeout could have run out, but the timeout handler
not yet processed and put the work into the workqueue.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
A proper way to match a Security object instance with a Server object
instance is via Short Server ID resource. Both coupled object instances
should carry the same value of this resource in order to me considered
matched.
This was not implemented in the LwM2M library and it was incorrectly
assumed that the Security object instance index corresponds to the
Server object instance index. While such apporach works is simple
scenario, it might yield incorrect results when bootstrap is used.
Fix this, by verifyng the Short Server ID resource in the Secuirty
instance used, and finding a matching Server instance. The server object
instance is stored for future use in the engine.
Additionally, remove an extra Server object instance that was created
when the bootstrap procedure was used. Since the boostrap Security
object instance does not have the corresponding Server object, it's
enough to have a single Server instance.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Value of this member was never assigned, so it was always 0. Remove it
to simplify code a little bit.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Just as was done for GPIO flags, make PWM flag accessors default to 0
when there are no flags. This makes the API easier to use correctly.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The vast majority of devicetree bindings for GPIO controllers are
expected to have "flags" cells in their respective GPIO specifiers,
but that's not required by the specification and we want to make sure
to support that.
However, so many drivers and applications initialize gpio_dt_flags_t
values that it's silly to require each and every one of them to check
for the flags value and fall back to the sensible default flags value
of 0 when it does not exist.
Make the API easier to use correctly by returning 0 in the devicetree
core API for accessing flags, whenever there are no flags defined.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Add a variety of property and specifier cell accessors that fall back
on a default value supplied by the caller if the devicetree does not
contain the requested data.
This is useful for avoiding use of COND_CODE_1() and similarly tricky
macros in applications and drivers.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Reorder the instance number property access macros. The non-instance
number ones appear in this order: DT_PROP(), DT_PROP_LEN(),
DT_PROP_HAS_IDX(), DT_PROP_BY_IDX(), DT_LABEL().
Improves readability slightly by moving code around so INST versions
appear in the same order as non-INST versions.
No functional changes expected.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
API did not cover a case when uart_rx_buf_rsp is called when receiver
is already disabled. It may happen if uart_rx_buf_rsp is called too
late and active transfer is already finished. In that case -EACCES is
returned.
Some implementations already returned that error in that case.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
In order to be able to add more entries under 'subsys/mgmt', move the
current contents of it, which relate exclusively to MCUMgr, to its own
folder.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
These stacks are appropriate for threads that run purely in
supervisor mode, and also as stacks for interrupt and exception
handling.
Two new arch defines are introduced:
- ARCH_KERNEL_STACK_GUARD_SIZE
- ARCH_KERNEL_STACK_OBJ_ALIGN
New public declaration macros:
- K_KERNEL_STACK_RESERVED
- K_KERNEL_STACK_EXTERN
- K_KERNEL_STACK_DEFINE
- K_KERNEL_STACK_ARRAY_DEFINE
- K_KERNEL_STACK_MEMBER
- K_KERNEL_STACK_SIZEOF
If user mode is not enabled, K_KERNEL_STACK_* and K_THREAD_STACK_*
are equivalent.
Separately generated privilege elevation stacks are now declared
like kernel stacks, removing the need for K_PRIVILEGE_STACK_ALIGN.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This had been copy-pasted between linker scripts, create
a central header for it.
The linker scripts for xtensa and posix have very different
structure and have been left alone.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Thread objects were moved out of the stack a long time ago.
Replacing this incorrect information is some clarification
on acceptable size values to pass in.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The core kernel computes the initial stack pointer
for a thread, properly aligning it and subtracting out
any random offsets or thread-local storage areas.
arch_new_thread() no longer needs to make any calculations,
an initial stack frame may be placed at the bounds of
the new 'stack_ptr' parameter passed in. This parameter
replaces 'stack_size'.
thread->stack_info is now set before arch_new_thread()
is invoked, z_new_thread_init() has been removed.
The values populated may need to be adjusted on arches
which carve-out MPU guard space from the actual stack
buffer.
thread->stack_info now has a new member 'delta' which
indicates any offset applied for TLS or random offset.
It's used so the calculations don't need to be repeated
if the thread later drops to user mode.
CONFIG_INIT_STACKS logic is now performed inside
z_setup_new_thread(), before arch_new_thread() is called.
thread->stack_info is now defined as the canonical
user-accessible area within the stack object, including
random offsets and TLS. It will never include any
carved-out memory for MPU guards and must be updated at
runtime if guards are removed.
Available stack space is now optimized. Some arches may
need to significantly round up the buffer size to account
for page-level granularity or MPU power-of-two requirements.
This space is now accounted for and used by virtue of
the Z_THREAD_STACK_SIZE_ADJUST() call in z_setup_new_thread.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Define a macro which takes as input a requested stack buffer
size, and returns the size of the stack object needed to
contain it.
An optional architecture interface is provided, though many
arches will be fine with the default implementation.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Some forthcoming macros will need this. This may now
be individually defined by arch code instead of hanging
off of ARCH_THREAD_STACK_DEFINE.
Some additional details added to the documentation string.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This can be in inline function, which gains us some
type safety.
Temporarily define Z_STACK_PTR_ALIGN() in terms of it,
slated for removal once some other changes land.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
A new macro Z_THREAD_STACK_OBJ_ALIGN() defines the alignment
of the lowest memory address of a stack object.
Related is a new arch interface ARCH_THREAD_STACK_OBJ_ALIGN()
which lets arches specifiy this. ARCH_STACK_PTR_ALIGN or a
power-of-two ceiling is used if not defined.
The default stack macros now use this instead of hard-coding
ARCH_STACK_PTR_ALIGN.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The fs_open has been extended with support for open flags.
Currently supported flags are:
FS_O_READ -- open for read
FS_O_WRITE -- open for write
FS_O_CREATE -- create file if it does not exist
FS_O_APPEND -- move to the end of file before each write
The FAT FS and LittleFS front-ends within the Zephyr has also been
modified to utilize the flags.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Let's normalize the callback like it is done in other APIs.
This will avoid the need to do not so nice code (storing the ipm device
pointer as global, or else) and more importantly will help to move all
device instance to constant.
Fixes#26923
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Until now, each and every driver had to redeclare the type to store such
pointer, now they will be using this typedef.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Normalize callback like other APIs.
This clarifies the callback usage. It will also help to switch all
device instance to constants.
Fixes#26923
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
All other API provide the device pointer to the callback it's going to
call. So fixing this in UART.
This will avoid passing the actual device pointer as a user data (thus
enabling user data for something else).
Fixes#26923
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
All other API provide the device pointer to the callback it's going to
call. So fixing this in UART.
This will avoid passing the actual device pointer as a user data (thus
enabling user data for something else).
Fixes#26923
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
s/port/dev
dev is being used everywhere else so let's rename port to dev.
And the parameter documentation should be the same for all.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit adds basic support for the clock controller used in
lpc11u6x MCUs.
Signed-off-by: Maxime Bittan <maxime.bittan@seagate.com>
Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
This commit adds a bindings for the clock controller used in lpc11u6x
MCUs. It also adds a clock-controller node for the lpc11u6x soc series.
Signed-off-by: Maxime Bittan <maxime.bittan@seagate.com>
This patch adds the DT nodes and binding for the pinmux registers,
aka IOCON (I/O control), found on the LPC11U6x MCUs.
Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
Drop unused ppp_parse_options_array() function and 'struct
ppp_option_pkt' data type. Both were used in initial PPP implementation,
but are not longer needed after recent PPP refactoring.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Remove unused ppp context members ('my_accepted', 'peer_accepted'),
which were supposed to contain accepted options. Options are now
negotiated and stored in same place, which is 'my_options' and
'peer_options' structure members.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
So far there was no generalized way how to handle negotiation of "my
options" (those sent with Conf-Req packet to peer). Peer response for
proposed options and their values were not tracked in any way, so
rejected (by peer) options were sent over and over again in subsequent
Conf-Req packets. In case of IPCP it means that all sent options such as
IP_ADDRESS, DNS1, DNS2 were mandatory for being supported by peer in
order to successfully finish negotiation. For example if 'pppd' was the
configured peer (e.g. when using with QEMU and net-tools scripts),
without ms-dns being configured (which is the default), then "my
options" negotiation failed.
Introduce generalized mechanism for negotiating "my options", so it is
easier to maintain current set of supported options and easily add new
options to the implementation in future. FSM instance inititialization
function can provide information about supported "my options".
Information is is passed as a table of 'struct ppp_my_option_info'
containing:
* option code (type),
* callback for adding option to Conf-Req packet,
* callback for received Conf-Ack with that option,
* callback for received Conf-Nak with that option.
Store also runtime information about each negotiated option. First of
all remember which options have been rejected, so they are not sent to
peer once again in the next Conf-Req packet. This will solve issue with
IPCP negotiation when peer doesn't support DNS1 or DNS2 options. Keep
also track about which options have been acked, so such information can
be verified before bringing FSM instance up.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Use net_pkt API to assemble Configure-Req messages. Compared to net_buf
API it allows us to simplify code.
Remove append_to_buf() helper functions, as their functionality is now
totally replaced by net_pkt API. Additionally net_pkt API handles data
that wraps several net_buf packets, which was not the case with
append_to_buf().
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Use net_pkt instead of net_buf API for replying to Configure-Req. We use
the fact that for now we reply with either Configure-Ack or
Configure-Rej only. In both cases we can allocate net_pkt ahead, because
we know its maximum length (which is equal to length of received
Configure-Req packet).
Make also an improvement in generic FSM code and reply with
Configure-Rej to all Configure-Req for which there is no config_info_req
callback set. Use that to drop LCP specific Conf-Req handling code,
because there is no option properly supported there yet.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>