Commit graph

175 commits

Author SHA1 Message Date
Antony Pavlov 0369998e61 arch: add MIPS architecture support
MIPS (Microprocessor without Interlocked Pipelined Stages) is a
instruction set architecture (ISA) developed by MIPS Computer
Systems, now MIPS Technologies.

This commit provides MIPS architecture support to Zephyr. It is
compatible with the MIPS32 Release 1 specification.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
2022-01-19 13:48:21 -05:00
Carles Cufi 944a02d18a include: Add a macro to check pointer alignment
Add a new macro, IS_PTR_ALIGNED() that verifies if a pointer is aligned
sufficiently for a particular data type provided as an argument.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-12-10 14:08:59 +01:00
Emil Gydesen ce864f6e8d toolchain/xcc: Mark unsigned max as unsigned values for missing cases
Add the `U` suffix for the MAX of unsigned values
for a few missing cases.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-11-11 07:27:24 -05:00
Nicholas Lowell 0d31403318 toolchain: define ZRESTRICT for restrict aliasing
restrict keyword is not supported in C++, however
GNUC does support __restrict for C/C++ so we can use that,
however the complexity of toolchains requires a ZRESTRICT
symbol that should be used throughout the codebase to not
cause any conflicts or redefinition errors

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2021-11-05 13:29:31 +01:00
Evgeniy Paltsev 235a98e371 ARC: MWDT: enable back BUILD_ASSERT macro
BUILD_ASSERT macro was disabled for MWDT toolchain from the
moment of adding MWDT support to Zephyr. Built-in _Static_assert
is now working fine for the most of the cases with MWDT toolchain
so we can use it in BUILD_ASSERT.

The only exception is _ARCH_MEM_PARTITION_ALIGN_CHECK macro
as it often used with variable addresses as parameters
which need to be checked at compile time. We disable
_ARCH_MEM_PARTITION_ALIGN_CHECK for MWDT toolchain so we can use
BUILD_ASSERT in other places.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-10-20 07:24:03 -04:00
Daniel Leung e5a6b69683 toolchain: xcc: add macro __in_section_unique_named()
XCC doesn't like having quotes in the section name, so
workaround it by overriding __in_section_unique_named()
similar to __in_section_unique().

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-10-07 16:56:00 -04:00
Torsten Rasmussen ce8f8c9f17 armclang: adding toolchain/armclang.h header
The armclang.h includes the toolchain/llvm.h header.

Also it redifines the __GENERIC_SECTION and Z_GENERIC_SECTION so that
they includes the `used` attribute which is needed by armlink.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-30 08:54:23 -04:00
Daniel Leung 99290f7fef linker: allow symbols to be in a named __noinit section
This adds a new __noinit_named() macro which can be used to
attach named section attributes for symbols. The original
__noinit creates a section attribute with source file name
and a sequential counter. This simply replaces the counter
with the supplied name. This is useful for demand paging
as developers can choose which symbols is pinned memory.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-26 21:16:22 -04:00
Evgeniy Paltsev 27de1e2bdb ARC: MWDT: explicitly forbid to use NEWLIB / NATIVE_APPLICATION
ARC MWDT doesn't support building Zephyr as an native
application (CONFIG_NATIVE_APPLICATION).
ARC MWDT doesn't support building with CONFIG_NEWLIB_LIBC
as it doesn't have newlib.

Let's explicitly forbid to use these Kconfig options for the
MWDT toolchain.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-21 21:33:18 -04:00
Bradley Bolen d91e4a52de include: toolchain: Add LOG2CEIL macro
This macro is referenced by most of the architecture linker scripts, yet
it is only defined in the Metaware toolchain linker header.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2021-08-17 06:06:33 -04:00
Evgeniy Paltsev e0a9a93cb5 ARC: MWDT: workaround missing ssize_t definition
ARC MWDT don't provide ssize_t type which is used in Zephyr.
Define ssize_t for ARC MWDT toolchain.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-13 13:43:19 -05:00
Fabio Baltieri 171739d06e toolchain: deprecate the Z_ iterables api
Switch the actual API implementation to the external API and mark the
internal ones as __DEPRECATED_MACRO.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-08-12 17:47:04 -04:00
Fabio Baltieri 94711f1ced doc: reference: add a page for iterable sections
Group together the iterable section functions and add a corresponding
documentation page.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-08-03 19:02:43 -04:00
Fabio Baltieri ae3b792016 toolchain: redefine iterable section APIs as non internal
Redefine the APIs used to deal with iterable sections to an alias
without the Z_ prefix, so that they can be used by Zephyr applications.

Fix the associated comments so that they are handled correctly by
Doxygen.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-08-03 19:02:43 -04:00
Johan Hedberg 49987e8eca toolchain: Add macro for warning for unused return values
This will let us get compiler warnings whenever the return value of
specific functions stays unused. I called this __must_check since that's
the name Linux uses as well.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2021-06-16 10:42:17 +02:00
Kumar Gala 6d51863e0d toolchain: remove deprecated BUILD_ASSERT_MSG macro
The macros have been deprecated for 2 releases so remove the code
associated with them.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-11 16:35:19 -05:00
Daniel Leung e6dc91466c toolchain: gcc: fix extra space when using SECTION_VAR
The generic version of SECTION_VAR() is adding an extra space
during expansion before second argument (e.g.
SECTION_VAR(section, variable) => ".section. variable"
instead of ".section.variable") which would result in build
error. So remove the "##" in macro to fix this, and now it
will also behave the same as SECTION_FUNC().

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-10 16:00:43 -05:00
Daniel Leung 8297eafc60 toolchain: add Z_GENERIC_DOT_SECTION() macro
This is similar to Z_GENERIC_SECTION() but the resulting
section name has a period as prefix. This eases the need
to create a section name macro for both assembly and C.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-10 16:00:43 -05:00
Anas Nashif 1b95d96a72 toolchain: add llvm abstraction
Add abstraction for llvm to allow for toolchain customizations that are
different from the gcc defaults.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-22 07:42:58 -04:00
Anas Nashif 9614581ebe tests: dsp: filtering: exclude on llvm
optimize attribute is not supported by LLVM.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-22 07:42:58 -04:00
Nicolas Pitre 0dc7b9ee46 k_current_get(): make it a "const" function
This function always returns the same value for a given thread.
Add the const attribute to it so the compiler won't call it over and
over needlessly each time _current is referenced, making for far more
efficient code.

The __attribute_const__ symbol is used to mimic the Linux equivalent.
We want to make it clear that this is distinct from the const keyword.

Fix the test_x86_cpu_scrubs_regs where the compiler wasn't told that a
bunch of registers are being clobbered as highlighted by this change.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-04-14 20:32:05 -04:00
Anas Nashif 5fa12073cb drivers: remove what appears to be code from comments
Some tools consider this as commented code because of the ifdef, so
remove that and fix a coding guideline violation.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-01 05:34:17 -04:00
Carlo Caione 3539c2fbb3 arm/arm64: Make ARM64 a standalone architecture
Split ARM and ARM64 architectures.

Details:

- CONFIG_ARM64 is decoupled from CONFIG_ARM (not a subset anymore)
- Arch and include AArch64 files are in a dedicated directory
  (arch/arm64 and include/arch/arm64)
- AArch64 boards and SoC are moved to soc/arm64 and boards/arm64
- AArch64-specific DTS files are moved to dts/arm64
- The A72 support for the bcm_vk/viper board is moved in the
  boards/bcm_vk/viper directory

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-03-31 10:34:33 -05:00
Yasushi SHOJI 8466df0d22 include: toolchain: Fix typos in comments
Fix a few typos in the comment sections of the header file.

No functionality has been changed.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2021-03-29 11:42:23 -05:00
Daniel Leung 21f6217313 toolchain: xcc: nullify __deprecated macro
XCC does not support using the deprecated attribute for enum
as it is based on old GCC 4.2. So nullify the macro to avoid
compilation errors.

Fixes #33548

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-03-29 07:53:23 -04:00
Anas Nashif bfe4dde2a4 xcc: we do not support build asserts
Cover toolchains that do not have build asserts.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-08 16:04:28 -05:00
Daniel Leung 5ef8db8ac9 xcc: define __INT*_C() and __UINT*_C()
Our minimal C library makes an alias of UINT*_C() to
be __UINT*_C() and INT*_C() to __INT*_C(). However,
in XCC, these are not defined by default, so define
them ourselves.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-02-05 07:45:07 -05:00
Daniel Leung 92c12d1f82 toolchain: add GEN_ABSOLUTE_SYM_KCONFIG()
This adds a new GEN_ABSOLUTE_SYM_KCONFIG() specifically for
generating absolute symbols in assembly for kconfig values.
This is needed as the existing GEN_ABSOLUTE_SYM() with
constraints in extended assembly parses the "value" as
signed 32-bit integers. An unsigned 32-bit integer with
MSB set results in a negative number in the final binary.
This also prevents integers larger than 32-bit. So this
new macro simply puts the value inline within the assembly
instrcution instead of having it as parameter.

Fixes #31562

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-02-02 09:23:45 -05:00
Martin Åberg ffc89b59a2 sparc: Add compiler and linker tool support
GCC and binutils support for the SPARC architecture.

Co-authored-by: Nikolaus Huber <nikolaus.huber.melk@gmail.com>
Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-13 14:53:55 -08:00
Trond Einar Snekvik ed1f75da74 sys: util: Add clamp macro
Adds CLAMP macro to complement the current min/max macros, as well as a
gcc specific Z_CLAMP macro for single-evaluation expansion.

CLAMP combines the functionality of MIN and MAX, eliminating the
bug-prone usage of MIN(MAX(value, FLOOR), CEIL) found throughout the
codebase in every possible combination.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-11-05 12:12:17 +01:00
Anas Nashif efebf3fb64 toolchain: make clang happy with inline asm
clang did not like %p on x86, make it use %c.

Did not explore why this is happening..

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-11-02 14:30:37 -05:00
Eugeniy Paltsev effd2fa834 toolchain: define __no_optimization attribute across toolchains
The __attribute__((optimize("-O0"))) attribute is used to disable
optimization of some test functions. ARC MWDT toolchain doesn't
support it, however it supports __attribute__((optnone)) with
similar functionality.

Define __no_optimization attribute across all toolchains so it
can be used in tests.

NOTE: we don't define __no_optimization for XCC as it includes
GCC header with __no_optimization defined.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-10-06 11:41:23 -04:00
Eugeniy Paltsev 2167ffbe45 ARC: toolchain: handle difference in macros for MWDT and ARC GNU
Create include/toolchain/mwdt.h to handle difference in
several macros for MWDT and ARC GNU toolchains.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
2020-09-05 10:22:56 -05:00
Wayne Ren ef224ce1cd ARC: make the assembly codes compatible
Make the assembly codes compatible with both GNU
and Metaware toolchain.

* replace ".balign" with ".align"
  ".align" assembler directive is supposed by all
  ARC toolchains and it is implemented in a same
  way across ARC toolchains.
* replace "mov_s __certain_reg" with "mov __certain_reg"
  Even though GCC encodes those mnemonics and even real
  HW executes them according to PRM these are restricted
  ones for mov_s and CCAC rightfully refuses to accept
  such mnemonics. So for compatibility and clarity sake
  we switch to 32-bit mov instruction which allows use
  of all those instructions.
* Add "%%" prefix while accessing registers from inline
  ASM as it is required by MWDT.
* Drop "@" prefix while accessing symbols (defined in C
  code) from ASM code as it is required by MWDT.

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>

/#
2020-09-05 10:22:56 -05:00
Flavio Ceolin b62f2df5d4 toolchain: gcc: Fix fallthrough attribute for old versions
fallthrough attribute was introduced in gcc 7. For older versions the
macro is empty to avoid the follow warnning:

~/zephyrproject/zephyr/lib/os/printk.c:268:5: warning: empty declaration
     __fallthrough;

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-09-04 22:25:17 -04:00
Flavio Ceolin f0ec286759 toolchain: gcc: Add macro to fallthrough attribute
This macro is intended to be used in intentional fallthroughs on
switch / case statements.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-08-24 20:28:47 -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
Andrew Boie 45979dafb4 linker: add iterable section macros
For iterable areas defined with Z_STRUCT_SECTION_ITERABLE(),
the corresponding output section in the linker script is just
boilerplate. Add macros to make these definitions simpler.

Unfortunately, we have a fair number of iterable sections not
defined with Z_STRUCT_SECTION_ITERABLE(), this patch does not
address this.

The output sections are all named <struct name>_area, update
sanitylib.py with this.

sys_sem with no userspace, and k_lifo/k_fifo are special cases
where different data types that are all equivalent need to be
put in the same iterable area. Add
Z_STRUCT_SECTION_ITERABLE_ALTERNATE() for this special case.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-24 17:09:22 -04:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Kumar Gala 7dc3ecd63d stdint.h: Make {u}int64_t types consistent regardless of arch
On 64-bit arch's like AARCH64, x86_64, or riscv-64 the way {u}int64_t
will differ from how its defined on 32-bit arch's.  Do the same trick we
do for {u}int32_t for {u}int64_t so that the type is the same regardless
of what we are building for.

This keeps things like %lld working the same regardless of 32-bit or
64-bit arch.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Andrew Boie 299ec8f1b5 userspace: net sockets are kernel objects
Any data structure declaration tagged with __net_socket will end up
in the kernel object table with type K_OBJ_NET_SOCKET. These all
correspond to objects which are associated with socket file
descriptors and can handle the socket vtable API.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-06-03 22:33:32 +02:00
Daniel Leung 04a3d9906c toolchain: Fix warning about too few arguments on BUILD_ASSERT()
Commit c408fa88a3 introduced changes
to the BUILD_ASSERT() macro so the MSG argument is optional.
However, in include/toolchain/common.h, the BUILD_ASSERT()
definition has not made the MSG argument as optional which results
in build errors complaing about too few arguments. Fix by adding
some dots there.

This is observed when using XCC (based on Clang 3.9).

Fixes #24008

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-04-11 11:09:20 -04:00
Oleg Zhurakivskyy c408fa88a3 toolchain: common: Merge build assert macros
In order to de-duplicate 2 macros with the same use,
merge BUILD_ASSERT(), BUILD_ASSERT_MSG() into one macro.

Make BUILD_ASSERT_MSG() deprecated.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-31 07:18:06 +02:00
Carles Cufi cd38fb1610 Revert "toolchain: common: Merge build assert macros"
This reverts commit 974aa3add4.

Pull Request #23437 was merged by mistake with an invalid manifest.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-19 18:45:13 +01:00
Oleg Zhurakivskyy 974aa3add4 toolchain: common: Merge build assert macros
In order to de-duplicate 2 macros with the same use,
merge BUILD_ASSERT(), BUILD_ASSERT_MSG() into one macro.

Make BUILD_ASSERT_MSG() deprecated.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-19 15:47:53 +01:00
Corey Wharton ccd15df510 scripts: Dynamically add driver subsystems to subsystems list
This change extends the parse_syscalls.py script to scan for a
__subsystem sentinal added to driver api declarations. It thens
generates a list that is passed into gen_kobject_list.py to extend
the subsystems list. This allows subsystems to be declared in the
code instead of a separate python list and provides a mechanism for
defining out-of-tree subsystems.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2020-03-11 17:13:39 +02:00
Carlo Caione b4335a04ac arm: aarch64: Reintroduce _ASM_FILE_PROLOGUE
This is currently missing from the AArch64 assembly files.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-03-11 09:34:24 +01:00
Stephanos Ioannidis 0bd86f3604 arch: arm: aarch32: Allow selecting compiler instruction set
This commit introduces the `COMPILER_ISA_THUMB2` symbol to allow
choosing either the ARM or Thumb instruction set for C code
compilation.

In addition, this commit introduces the `ASSEMBLER_ISA_THUMB2` helper
symbol to specify the default target instruction set for the assembler.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2020-03-10 17:51:32 +01:00
Andrew Boie f1b1332c94 x86: fix large Kconfig values on 64-bit
Use the special x86 operand modifier 'p' to print the raw value.
This fixes an issue on x86-64 where errors were generated
if a constant larger than INT_MAX was used.

Values larger than UINT_MAX are still unsupported (on any arch).

Fixes: #22542

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-02-13 09:03:03 +02:00
Ulf Magnusson 46f98d86c7 include: gcc.h: Add a __WARN() macro with a custom warning on expansion
Works like __DEPRECATED_MACRO with a custom message. Can do this for
example:

    #define FOO __WARN("Please use BAR instead") ...

Implement __DEPRECATED_MACRO with __WARN().

Useful for https://github.com/zephyrproject-rtos/zephyr/pull/21506.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-01 08:48:17 -05:00