Commit graph

15409 commits

Author SHA1 Message Date
Martí Bolívar
884d6e6941 devicetree: gpio: make flags default to 0
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>
2020-08-04 07:35:26 -05:00
Martí Bolívar
922b469fd4 devicetree: add accessors with default values
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>
2020-08-04 07:35:26 -05:00
Martí Bolívar
a5582fbaf4 devicetree: reorder instance property macros
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>
2020-08-04 07:35:26 -05:00
Krzysztof Chruscinski
2891256b67 drivers: serial: Add error code to uart_rx_buf_rsp
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>
2020-08-03 13:49:57 +02:00
Andrew Boie
5a137998bf shell: SHELL_DEFINE() create kernel stacks
These shell threads run in supervisor mode.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-01 08:12:47 -04:00
Jukka Rissanen
dea5b74a2c net: Separate net_pkt priority from traffic class
User can always set the network packet priority as it is not
related to traffic class.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-07-31 18:11:51 +02:00
Carles Cufi
c200b1c5e6 mgmt: Move mcumgr into its own folder
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>
2020-07-31 08:46:53 -05:00
Andrew Boie
8ce260d8df kernel: introduce supervisor-only stacks
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>
2020-07-30 21:11:14 -04:00
Andrew Boie
59a75dd3a8 arches: centralize noinit linker defintiions
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>
2020-07-30 21:11:14 -04:00
Andrew Boie
d538f098a7 thread_stack: clarify Z_THREAD_STACK_BUFFER docs
Make it clear that this just returns a pointer past the
reserved area.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-07-30 21:11:14 -04:00
Andrew Boie
82b5940fa0 kernel: clarify k_thread_create() docs
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>
2020-07-30 21:11:14 -04:00
Andrew Boie
b0c155f3ca kernel: overhaul stack specification
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>
2020-07-30 21:11:14 -04:00
Andrew Boie
d4b6226aa9 thread_stack: add Z_THREAD_STACK_SIZE_ADJUST()
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>
2020-07-30 21:11:14 -04:00
Andrew Boie
27c8aadf94 thread_stack: move up K_THREAD_STACK_RESERVED defn
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>
2020-07-30 21:11:14 -04:00
Andrew Boie
0cb1f07c6f thread_stack: z_stack_ptr_align() as function
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>
2020-07-30 21:11:14 -04:00
Andrew Boie
db0d6aedfb kernel: add stack object alignment macro interface
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>
2020-07-30 21:11:14 -04:00
Andrew Boie
79728eccca toolchain: add Z_POW2_CEIL()
Helper macro for rounding up to next power of two.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-07-30 21:11:14 -04:00
Dominik Ermel
cac07629bf subsys/fs: Add open flags parameter to fs_open
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>
2020-07-30 16:33:18 +02:00
Tomasz Bursztyka
0d4477604a ipm: Callback's user data has to be called user_data
s/context/user_data

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:51:51 +02:00
Tomasz Bursztyka
e4479f907f api: ipm: Pass the ipm device as first parameter to callback
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>
2020-07-30 09:51:51 +02:00
Tomasz Bursztyka
8144de1513 dma: Callback's user data has to be called user_data
s/callback_arg/user_data

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:48:00 +02:00
Tomasz Bursztyka
800e6c3a28 dma: Generalize dma callback signature by adding a dedicated typedef
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>
2020-07-30 09:48:00 +02:00
Tomasz Bursztyka
020dab824c api: dma: Pass the dma device pointer as parameter to callback
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>
2020-07-30 09:48:00 +02:00
Tomasz Bursztyka
b258f2d3a3 uart: Removing uart_irq_callback_t type
This type of callback does not exist anymore and can be safely removed.

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:43:12 +02:00
Tomasz Bursztyka
e4e6b8e193 uart: Normalize irq callback signature
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>
2020-07-30 09:43:12 +02:00
Tomasz Bursztyka
4644d4a40c uart: Normalize user callback signature
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>
2020-07-30 09:43:12 +02:00
Tomasz Bursztyka
a010241cb3 uart: Normalizing device parameter name
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>
2020-07-30 09:43:12 +02:00
Maxime Bittan
ed4511ea8c drivers: clock_control: lpc11u6x: Add support for clock controller
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>
2020-07-29 20:12:24 +02:00
Maxime Bittan
1724bf49be dts: arm: nxp: Add node and bindings for lpc11u6x clock controller
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>
2020-07-29 20:12:24 +02:00
Simon Guinot
6eb7841bf3 dts: lpc11u6x: add pinmux node and binding
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>
2020-07-29 20:12:24 +02:00
Marcin Niestroj
5a754af945 net: l2: ppp: drop old option parsing routine
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>
2020-07-29 16:38:37 +02:00
Marcin Niestroj
8e5ea59ed5 net: l2: ppp: remove unused 'accepted options'
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>
2020-07-29 16:38:37 +02:00
Marcin Niestroj
5326d11e8c net: l2: ppp: add generalized "my options" negotiation
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>
2020-07-29 16:38:37 +02:00
Marcin Niestroj
08988999ca net: l2: ppp: prepare Configure-Req with net_pkt API
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>
2020-07-29 16:38:37 +02:00
Marcin Niestroj
50b2cafc42 net: l2: ppp: use net_pkt API for replying to Configure-Req
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>
2020-07-29 16:38:37 +02:00
Marcin Niestroj
f161af9996 net: l2: ppp: drop unused negotiation flags
Those flags were never used and any plans for them are not known. So
drop them.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-29 16:38:37 +02:00
Jukka Rissanen
336bcfa471 net: if: Make sure only allowed threads can access syscalls
Make sure that only those threads that have been granted access
to net_if objects, can call the functions that modify net_if data.

The CONFIG_NET_IF_USERSPACE_ACCESS config option is also removed
as it is no longer needed after this change.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-07-29 08:13:22 -04:00
Anas Nashif
178baee3b0 doc: group audio header using doxygen
Put audio related APIs into one doxygen group.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-28 08:14:23 -05:00
Robert Lubos
43a3b7ed27 net: openthread: Protect OT API calls from being preempted
OpenThread API is not thread safe, therefore it shall be protected
from being preempted by OT thread, or other thread issuing API calls.
The problem showed up after a recent OpenThread upmerge, where changes
in the Joiner class made this problem visible. W/o extra protection,
`otJoinerStart` call can be preempted by the OT thread, leading to an
unexpected behavior.

Introduce new function to allow to lock any API operations for others.
Anyone willing to call OT APIs, shall lock the mutex first to get
exclusive access to the stack.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-07-27 19:04:43 +02:00
Peter A. Bigot
8933c7db50 settings: disallow modifying the content of a static subtree name
There may be value in being able to rename a subtree, but there is no
identified need to be able modify the text of an assigned subtree.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-07-27 19:03:44 +02:00
Marcin Niestroj
9dd220dc2b net: l2: ppp: remove useless is_init checks
is_init field is useless, because there is only single code path that
always sets it to true before using it.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-27 13:22:01 +02:00
Eugeniy Paltsev
3f544ca5b2 ARC: replace NOP ASM inlines with builtin
NOP instruction is available via builtin for ARC so get rid of all
ASM inlines with NOP/NOP_S instructions.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-07-24 12:05:12 +02:00
Eugeniy Paltsev
79a55ae7a4 ARC: use generic lsb/msb implementation instead of ASM code
Zephyr has generic find_msb_set and find_lsb_set implementations.
They are based on builtins so they are optimized enough.
Drop custom ASM implementation.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-07-24 12:05:12 +02:00
Raveendra Padasalagi
306980816a dma: Support 64bit source/dest address
Add 64bit source_address/dest_address fields support.
This is needed in situation where DMA controller is capable
of handling more than 32bit source and destination addresses.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2020-07-24 11:54:31 +02:00
Simon Glass
49a3e49936 include: drivers: sensor: Add more channels for batteries
Add some more channels useful for batteries with fuel gauges.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-23 12:12:09 -04:00
Andrew Boie
7df42d7c25 include: libc-hooks: add comments
Clarify in documentation under what conditions this partition
is available.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-07-23 11:01:42 +02:00
Peter Bigot
a1babb7f1f drivers: eeprom_slave: add const qualifier to read-only data
The EEPROM device doesn't mutate the source data it's given, so update
the API signature to reflect this fact.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-07-22 21:41:12 +02:00
Jukka Rissanen
2705a9d61b net: if: Network interface was missing for offloaded drivers
The NET_IF_OFFLOAD_INIT() macro was not converted to use
Z_STRUCT_SECTION_ITERABLE() macros in commit 62580748e5
("net: Use section foreach macros"). This meant that for those boards
that use offloaded network stack, the network interface was not created
and network connectivity was lost.

Fixes #27037

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-07-22 14:17:37 -04:00
62a236e546 usb: cdc_acm: add a DTE rate changed callback
This is called when the USB host changes the virtual baud rate.

This is used by Arduino style boards to signal that the board should
reset into the bootloader.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-07-22 13:24:37 +02:00
Peter Bigot
0d480e78f8 settings: disallow modifying the content of a subtree name
There may be value in being able to rename a subtree, but there is no
identified need to be able modify the text of an assigned subtree
name.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-07-21 21:54:40 -04:00