Commit graph

13 commits

Author SHA1 Message Date
Nicolas Pitre 52e2f83185 kernel/timeout: introduce the timepoint API
This is meant as a substitute for sys_clock_timeout_end_calc()

Current sys_clock_timeout_end_calc() usage opens up many bug
possibilities due to the actual timeout evaluation's open-coded nature.

Issue ##50611 is one example.

- Some users store the returned value in a signed variable, others in
  an unsigned one, making the comparison with UINT64_MAX (corresponding
  to K_FOREVER) wrong in the signed case.

- Some users compute the difference and store that in a signed variable
  to compare against 0 which still doesn't work with K_FOREVER. And when
  this difference is used as a timeout argument then the K_FOREVER
  nature of the timeout is lost.

- Some users complexify their code by special-casing K_NO_WAIT and
  K_FOREVER inline which is bad for both code readability and binary
  size.

Let's introduce a better abstraction to deal with absolute timepoints
with an opaque type to be used with a well-defined API.
The word "timeout" was avoided in the naming on purpose as the timeout
namespace is quite crowded already and it is preferable to make a
distinction between relative time periods (timeouts) and absolute time
values (timepoints).

A few stacks are also adjusted as they were too tight on X86.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Gerard Marull-Paretas 0a4b248047 scripts: checkpatch: add Atmel Pwm typedef
Add Atmel Pwm typedef so that when doing `Pwm * const pwm` definition
checkpatch doesn't complain about the position of the '*'. If not added,
we must define `Pwm *const pwm` to make checkpatch happy, but,
clang-format results in `Pwm * const pwm` (correct).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-07-12 17:51:23 +02:00
Erwan Gouriou 3b4544005c scripts/checkpatch: typdefsfile: Derogate on STM32Cube CMSIS *_TypeDef
Add a derogation to checkpatch's 'SPACING' rule, which randomly returns
the following type of issue when STM32Cube HAL *_TypeDef are used:

-:10: ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
#10: FILE: drivers/adc/adc_stm32.c:806:
+	ADC_TypeDef *adc = config->base;

This derogation applies to all _TypDef structures defined in STM32Cube
CMSIS descriptions:
FMC_Bank1E_6_TypeDef
DMA_Channel_TypeDef
ADC_TypeDef

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-03-21 10:11:54 +01:00
Otavio Salvador e2edb3e405 scripts: Allow use of bash outside of /bin
Even though bash is commonly available as /bin/bash there are
exceptions (e.g NixOS). This commit allow the use of the scripts in my
environment and is generic.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2022-03-08 11:11:10 +01:00
Yonatan Schachter a2aa02dbc8 drivers: gpio: Added support for raspberry pi
Added GPIO support for the RP2040 SoC. Only one
core is supported.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2022-02-02 16:23:35 +01:00
Gerard Marull-Paretas 92b9aff9b3 scripts: checkpatch: typedefsfile: add pinctrl_soc_pin_t
The pinctrl_soc_pin_t is used as an opaque type in pinctrl to store pin
configurations which are SoC dependent.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-03 13:21:40 +01:00
Nicolas Pitre f97d12936e kernel: add an architecture specific structs header
Add the ability to define architecture specific structures, notably
the ability to extend struct _cpu with per-CPU arch-specific stuff that
can be accessed with _current_cpu->arch.* similarly to _current->arch.*
for per-thead architecture data.

This is opt-in for architectures that want to benefit from this,
otherwise empty defaults are provided. A placeholder for ARM64 is
included to show the pattern.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-04-21 09:03:47 -04:00
Carlo Caione 6ff37886dd aarch64: mem_domain: Introduce k_mem_partition_attr_t
Introduce the kernel macros for memory attribution also for AArch64.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-03-01 09:25:44 -05:00
Andrew Boie 96571a8c40 kernel: rename NANO_ESF
This is now called z_arch_esf_t, conforming to our naming
convention.

This needs to remain a typedef due to how our offset generation
header mechanism works.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-07-25 15:06:58 -07:00
Anas Nashif fdadb501f7 scripts: cleanup scripts directory
Remove unused and obsolete scripts we used with Kbuild or scripts that
were copied from Linux but never used or modified for Zephyr:

- vercomp: not needed with cmake, version comparison is built-in
- mksysmap: Linux script
- make-ll parallel build script, something that is more suitable in
  $HOME/bin, not in Zephyr tree
- headerdep.pl: Linux specific, not adapted or used with Zephyr
- timestamp: used by other checkpatch scripts under scripts/checkpatch
- move uncrustify.cfg to .uncrustify.cfg in top tree for easy access and
  alongside other configuration files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-03 09:28:09 -04:00
Anas Nashif 440087e388 checkpatch: add NANO_ESF as a typedef to avoid spacing errors
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-03 10:29:41 -04:00
Anas Nashif a8d259939b checkpatch: define typedefsfile to deal with a few false positives
checkpatch expects typedefs to be suffixed with _t and has different
rules when typedefs are being used as arguments of a function. This
seems to be a known issue and defining typedefs in a file resolves this
issue.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-09 10:43:05 -04:00
Anas Nashif 9186b6801c scripts: move checkpatch scripts to checkpatch/
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 08:53:56 -07:00