Commit graph

97 commits

Author SHA1 Message Date
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
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
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
Carlo Caione
87d8a035dd arch: arm64: Support aarch64-gcc compiler
To be able to successfully compile the kernel for the ARM64 architecture
we have to tweak the compiler-related files to be able to use the
AArch64 GCC compiler.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Peter Bigot
bfa3eb17b2 toolchain: gcc: respect existing deprecated macro define
The __deprecated symbol can be pre-defined to avoid warnings of use of
deprecated API in tests of that API.  Enable that same feature for
macros that are deprecated.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-31 12:32:50 -08:00
Stephanos Ioannidis
2d7460482d headers: Refactor kernel and arch headers.
This commit refactors kernel and arch headers to establish a boundary
between private and public interface headers.

The refactoring strategy used in this commit is detailed in the issue

This commit introduces the following major changes:

1. Establish a clear boundary between private and public headers by
  removing "kernel/include" and "arch/*/include" from the global
  include paths. Ideally, only kernel/ and arch/*/ source files should
  reference the headers in these directories. If these headers must be
  used by a component, these include paths shall be manually added to
  the CMakeLists.txt file of the component. This is intended to
  discourage applications from including private kernel and arch
  headers either knowingly and unknowingly.

  - kernel/include/ (PRIVATE)
    This directory contains the private headers that provide private
   kernel definitions which should not be visible outside the kernel
   and arch source code. All public kernel definitions must be added
   to an appropriate header located under include/.

  - arch/*/include/ (PRIVATE)
    This directory contains the private headers that provide private
   architecture-specific definitions which should not be visible
   outside the arch and kernel source code. All public architecture-
   specific definitions must be added to an appropriate header located
   under include/arch/*/.

  - include/ AND include/sys/ (PUBLIC)
    This directory contains the public headers that provide public
   kernel definitions which can be referenced by both kernel and
   application code.

  - include/arch/*/ (PUBLIC)
    This directory contains the public headers that provide public
   architecture-specific definitions which can be referenced by both
   kernel and application code.

2. Split arch_interface.h into "kernel-to-arch interface" and "public
  arch interface" divisions.

  - kernel/include/kernel_arch_interface.h
    * provides private "kernel-to-arch interface" definition.
    * includes arch/*/include/kernel_arch_func.h to ensure that the
     interface function implementations are always available.
    * includes sys/arch_interface.h so that public arch interface
     definitions are automatically included when including this file.

  - arch/*/include/kernel_arch_func.h
    * provides architecture-specific "kernel-to-arch interface"
     implementation.
    * only the functions that will be used in kernel and arch source
     files are defined here.

  - include/sys/arch_interface.h
    * provides "public arch interface" definition.
    * includes include/arch/arch_inlines.h to ensure that the
     architecture-specific public inline interface function
     implementations are always available.

  - include/arch/arch_inlines.h
    * includes architecture-specific arch_inlines.h in
     include/arch/*/arch_inline.h.

  - include/arch/*/arch_inline.h
    * provides architecture-specific "public arch interface" inline
     function implementation.
    * supersedes include/sys/arch_inline.h.

3. Refactor kernel and the existing architecture implementations.

  - Remove circular dependency of kernel and arch headers. The
   following general rules should be observed:

    * Never include any private headers from public headers
    * Never include kernel_internal.h in kernel_arch_data.h
    * Always include kernel_arch_data.h from kernel_arch_func.h
    * Never include kernel.h from kernel_struct.h either directly or
     indirectly. Only add the kernel structures that must be referenced
     from public arch headers in this file.

  - Relocate syscall_handler.h to include/ so it can be used in the
   public code. This is necessary because many user-mode public codes
   reference the functions defined in this header.

  - Relocate kernel_arch_thread.h to include/arch/*/thread.h. This is
   necessary to provide architecture-specific thread definition for
   'struct k_thread' in kernel.h.

  - Remove any private header dependencies from public headers using
   the following methods:

    * If dependency is not required, simply omit
    * If dependency is required,
      - Relocate a portion of the required dependencies from the
       private header to an appropriate public header OR
      - Relocate the required private header to make it public.

This commit supersedes #20047, addresses #19666, and fixes #3056.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-11-06 16:07:32 -08:00
Daniel Leung
b7eb04b300 x86: consolidate x86_64 architecture, SoC and boards
There are two set of code supporting x86_64: x86_64 using x32 ABI,
and x86 long mode, and this consolidates both into one x86_64
architecture and SoC supporting truly 64-bit mode.

() Removes the x86_64:x32 architecture and SoC, and replaces
   them with the existing x86 long mode arch and SoC.
() Replace qemu_x86_64 with qemu_x86_long as qemu_x86_64.
() Updates samples and tests to remove reference to
   qemu_x86_long.
() Renames CONFIG_X86_LONGMODE to CONFIG_X86_64.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-10-25 17:57:55 -04:00
Andrew Boie
e69997eb77 include: gcc.h: include header needed by posix
This header makes a call to posix_print_error_and_exit,
but pulls in no prototype.

Linker scripts use nothing in this file, move the #ifndef
_LINKER to the toplevel.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-10-21 10:13:38 -07:00
Anas Nashif
dffc944437 toolchain: check if __deprecated is defined
This macro is defined on some operating systems, so make sure we do not
redefine it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-27 15:23:26 -04:00
Krzysztof Chruscinski
bea966dea1 toolchain: Add single arguments evaluation macros for min and max
MAX() and MIN() were evaluating arguments twice. If arguments are
functions they were called twice which resulted in bigger code
and potential misbehavior.

Added alternative macros (Z_MAX, Z_MIN) which can be used instead.
Macros have usage limitations thus they are not replacements. They
are also relying on GCC extension thus placed in gcc.h

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-09-25 17:41:03 +02:00
Stephanos Ioannidis
571741a0c5 toolchain: Add __BYTE_ORDER__ definition to the GCC toolchain header.
__BYTE_ORDER__ preprocessor definition is not defined by older versions
of GCC. The definitions for __ORDER_BIG_ENDIAN__,
__ORDER_LITTLE_ENDIAN__ and __BYTE_ORDER__ by automatic detection using
arch-specific endianness definitions have been added.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-09-19 08:13:52 -04:00
Bradley Bolen
7daf42b123 Revert "toolchain: gcc: Remove ref. to undefined sym. CONFIG_ISA_ARM"
This reverts commit e20fd5f454.

This is needed for Cortex-R support.

Signed-off-by: Bradley Bolen <bbolen@lexmark.com>
2019-08-09 22:50:50 +02:00
Nicolas Pitre
1f4b5ddd0f riscv32: rename to riscv
With the upcoming riscv64 support, it is best to use "riscv" as the
subdirectory name and common symbols as riscv32 and riscv64 support
code is almost identical. Then later decide whether 32-bit or 64-bit
compilation is wanted.

Redirects for the web documentation are also included.

Then zephyrbot complained about this:

"
New files added that are not covered in CODEOWNERS:

dts/riscv/microsemi-miv.dtsi
dts/riscv/riscv32-fe310.dtsi

Please add one or more entries in the CODEOWNERS file to cover
those files
"

So I assigned them to those who created them. Feel free to readjust
as necessary.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-08-02 13:54:48 -07:00
Jakob Olesen
f4f09dd7cd toolchain: Define a HAS_BUILTIN(x) macro in toolchain.h.
Compilers based on Clang provide a __has_builtin(x) macro which can be
used to detect in the preprocessor if a given builtin function is
supported by the compiler.

For other compilers (notably GCC), we provide an alternative definition
of HAS_BUILTIN(x) that depends on the toolchain-specific header file to
declare which builtin functions are supported based on the current
compiler version.

Signed-off-by: Jakob Olesen <jolesen@fb.com>
2019-05-14 19:53:30 -05:00
Patrik Flykt
4344e27c26 all: Update reserved function names
Update reserved function names starting with one underscore, replacing
them as follows:
   '_k_' with 'z_'
   '_K_' with 'Z_'
   '_handler_' with 'z_handl_'
   '_Cstart' with 'z_cstart'
   '_Swap' with 'z_swap'

This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.

Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.

Various generator scripts have also been updated as well as perf,
linker and usb files. These are
   drivers/serial/uart_handlers.c
   include/linker/kobject-text.ld
   kernel/include/syscall_handler.h
   scripts/gen_kobject_list.py
   scripts/gen_syscall_header.py

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-11 13:48:42 -04:00
Ulf Magnusson
e569533de0 toolchain: Remove ref. to undefined sym. CONFIG_ISA_THUMB
This symbol has never been defined in the Git history.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-02 03:46:10 +01:00
Ulf Magnusson
e20fd5f454 toolchain: gcc: Remove ref. to undefined sym. CONFIG_ISA_ARM
This Kconfig symbol was removed in commit cb04620fbd ("remove make/
directory").

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-02 03:46:10 +01:00
Aurelien Jarno
992f29a1bc arch: make __ramfunc support transparent
Instead of having to enable ramfunc support manually, just make it
transparently available to users, keeping the MPU region disabled if not
used to not waste a MPU region. This however wastes 24 bytes of code
area when the MPU is disabled and 48 bytes when it is enabled, and
probably a dozen of CPU cycles during boot. I believe it is something
acceptable.

Note that when XIP is used, code is already in RAM, so the __ramfunc
keyword does nothing, but does not generate an error.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-22 11:36:50 -08:00
qianfan Zhao
e1cc657941 arm: Placing the functions which holds __ramfunc into '.ramfunc'
Using __ramfunc to places a function in RAM instead of Flash.
Code that for example reprograms flash at runtime can't execute
from flash, in that case must placing code into RAM.

This commit create a new section named '.ramfunc' in link scripts,
all functions has __ramfunc keyword saved in thats sections and
will load from flash to sram after the system booted.

Fixes: #10253

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2019-02-22 11:36:50 -08:00
Andrew Boie
41f6011c36 userspace: remove APPLICATION_MEMORY feature
This was never a long-term solution, more of a gross hack
to get test cases working until we could figure out a good
end-to-end solution for memory domains that generated
appropriate linker sections. Now that we have this with
the app shared memory feature, and have converted all tests
to remove it, delete this feature.

To date all userspace APIs have been tagged as 'experimental'
which sidesteps deprecation policies.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-02-08 07:04:30 -05:00
Andy Ross
b69d0da82d arch/x86_64: New architecture added
This patch adds a x86_64 architecture and qemu_x86_64 board to Zephyr.
Only the basic architecture support needed to run 64 bit code is
added; no drivers are added, though a low-level console exists and is
wired to printk().

The support is built on top of a "X86 underkernel" layer, which can be
built in isolation as a unit test on a Linux host.

Limitations:

+ Right now the SDK lacks an x86_64 toolchain.  The build will fall
  back to a host toolchain if it finds no cross compiler defined,
  which is tested to work on gcc 8.2.1 right now.

+ No x87/SSE/AVX usage is allowed.  This is a stronger limitation than
  other architectures where the instructions work from one thread even
  if the context switch code doesn't support it.  We are passing
  -no-sse to prevent gcc from automatically generating SSE
  instructions for non-floating-point purposes, which has the side
  effect of changing the ABI.  Future work to handle the FPU registers
  will need to be combined with an "application" ABI distinct from the
  kernel one (or just to require USERSPACE).

+ Paging is enabled (it has to be in long mode), but is a 1:1 mapping
  of all memory.  No MMU/USERSPACE support yet.

+ We are building with -mno-red-zone for stack size reasons, but this
  is a valuable optimization.  Enabling it requires automatic stack
  switching, which requires a TSS, which means it has to happen after
  MMU support.

+ The OS runs in 64 bit mode, but for compatibility reasons is
  compiled to the 32 bit "X32" ABI.  So while the full 64 bit
  registers and instruction set are available, C pointers are 32 bits
  long and Zephyr is constrained to run in the bottom 4G of memory.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
Adithya Baglody
21d43a6fe4 include: toolchain: gcc.h: Fixed MISRA C violation.
The macros likely() and unlikely() used by the compiler for
optimization are always used inside an if condition.
According to MISRA we need to have bool type and not long.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2018-10-17 12:17:58 -04:00
Flavio Ceolin
6fdc56d286 kernel: Using boolean types for boolean constants
Make boolean expressions use boolean types.

MISRA-C rule 14.4

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-28 06:28:41 +05:30
Flavio Ceolin
67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Kumar Gala
6c6a66623a toolchain: gcc: check if __weak is defined
Avoid build conflict when __weak is defined by someone else.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-06-28 09:13:17 -05:00
Paul Sokolovsky
a37e037264 toolchain: gcc: Add compiler barrier at the end of UNALIGNED_PUT()
compiler_barrier() is itself defined down in this file. Without
adding it, newer versions of GCC (7+) for ARM Cortex-M may mistakenly
coalesce multiple strb/strh/str (store byte/half-word/word)
instructions, which support unaligned access on some
sub-architectures (Cortex-M3 and higher, but not on Cortex-M0),
into strd (store double), which doesn't support unaligned access.

Fixes: #6307

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-06-08 13:01:07 -05:00
Andy Ross
718a4cd245 include/toolchain/gcc.h: Fix static assert detection
The logic for using _Static_assert() was a little broken.  We were
using it when on GCC 4.6+ AND when __STDC_VERSION__ said we were on
C99 or better.  But it's not a C99 feature, it's a C11 feature.  And
if GCC provides it as an extension, that's unrelated to a particular
language version.  This should have been "GCC 4.6+ OR C11+".

This actually broke on the ESP-32 IDF toolchain, where (when using
-std=c99) the compiler was actually defining a C99 macro instead of
the C11 one, and choosing to use the wrong (and independently broken)
handling incorrectly.  Fixes #8093.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-06-04 11:56:43 -04:00
Leandro Pereira
666274fa60 toolchain: gcc: Only use _Static_assert if building with C11
Zephyr currently builds as C99, whereas _Static_assert is a C11
feature.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-24 04:04:36 +05:30
5f67a6119d include: improve compatibility with C++ apps.
This patch lets a C++ application use more of Zephyr by adding guards
and changeing some constructs to the C++11 equivalent.

Changes include:

- Adding guards
- Switching to static_assert
- Switching to a template for ARRAY_SIZE as g++ doesn't have the
  builtin.
- Re-ordering designated initialisers to match the struct field order
  as G++ only supports simple designated initialisers.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-04-09 23:21:52 -04:00
Anas Nashif
ce74393267 toolchain: gcc/common: add header guard
Added guards to the toolchain/gcc.h and toolchain/common.h

Those files should never be included directly, but a guard is useful
regardless.

Fixes #5130

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-02-10 11:14:32 -05:00
Alberto Escolar Piedras
76f7644118 arch: native: Run Zephyr natively in a POSIX OS
A new arch (posix) which relies on pthreads to emulate the context
switching
A new soc for it (inf_clock) which emulates a CPU running at an
infinely high clock (so when the CPU is awaken it runs till completion
in 0 time)
A new board, which provides a trivial system tick timer and
irq generation.

Origin: Original

Fixes #1891

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Andrew Boie
9928023421 kernel: make 'static inline' implicit to __syscall
The fact that these are all static inline functions internally is an
implementation detail.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-29 15:09:44 -07:00
Andrew Boie
fa94ee7460 syscalls: greatly simplify system call declaration
To define a system call, it's now sufficient to simply tag the inline
prototype with "__syscall" or "__syscall_inline" and include a special
generated header at the end of the header file.

The system call dispatch table and enumeration of system call IDs is now
automatically generated.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-29 13:02:20 -07:00
Andrew Boie
7ce3a79d80 toolchain.h: intoduce __kernel macros
In CONFIG_APPLICATION_MEMORY scenarios, these force
objects to be in kernel memory space.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-15 12:17:54 -07:00
Andrew Boie
2cb03c5cd6 toolchain.h: fix __in_section_unique()
_FILE_PATH_HASH appears to be a legacy Diab-ism that doesn't
expand to anything in GCC.

As a result, when linking the combined binary, it's quite
possible that objects in separate C files would be merged
instead of truly being in their own section. This can confound
--gc-sections and result in unused objects still being in
the final binary if one of the other objects with the same
generated section name was actually used.

We instead just use __FILE__. This results in sometimes absurdly-
long section names in the intermediate .o files, but there is no
actual limit to how long section names in ELF binaries can be;
they are not stored directly in headers but instead referenced
as an offset in the .shstrtab section, which has all the section
names stored in it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-15 12:17:54 -07:00
Andrew Boie
e0185d4c76 toolchain: gcc: add __DEPRECATED_MACRO
Add a macro which signals to the compiler that use of the macro is
deprecated.

Example:

  #define FOO __DEPRECATED_MACRO bar

Defines FOO to 'bar' but emits a warning if used in code.

Cannot filter out with -Wno-deprecated, so be careful with -Werror.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Marti Bolivar
2a9bb7af3d toolchain: override static assertions for GCC
Provide a BUILD_ASSERT and BUILD_ASSERT_MSG that are based on
_Static_assert when that's available, as its output is easier to read.

Change-Id: Ifa96d5073b1341cab2a90e4dcd04752ee80c69bb
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-04-01 20:35:45 +00:00
Benjamin Walsh
c73980654c gcc: add compiler_barrier() macro
Prevent compiler from reordering memory access instructions across
critical points.

Change-Id: Id776fe59f51315c8bd2353ea3149cf4aad52e6ba
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-16 04:56:20 +00:00
Andrew Boie
42562b9367 xtensa: fix numerous checkpatch issues
Change-Id: I903f5f0692849fb9e7bf5d978b63b12bf1bd6e33
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-02-13 11:39:03 -08:00
Mazen NEIFER
c024e429c9 Xtensa port: Added support for Xtensa cores in toolchain/gcc.h.
Change-Id: Ic76934411e79c288e1440e21ee38e9a95a0399b9
Signed-off-by: Mazen NEIFER <mazen@nestwave.com>
2017-02-13 08:04:27 -08:00
Andrew Boie
d8027a29f3 toolchain: gcc.h: add indirection to _GENERIC_SECTION() macro
Change-Id: Ic30874cafb4a79213feb93666903816d297084f6
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-02-08 19:10:55 +00:00
Andrew Boie
3c6f572361 section_tags.h: cleanup
Some stuff that was platform-specific is made common, and some repeated
code was made a macro. __in_section() is used elsewhere in the codebase
and its 2nd and 3rd arguments are not necessarily filename/counter.

GCC-specific stuff moved to the toolchain header.

Change-Id: Ibfae919b6dd8a77210801c14e9a1128b43bd63f6
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-02-08 19:10:43 +00:00
David B. Kinder
ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Jean-Paul Etienne
cd83e85edc arch: added support for the riscv32 architecture
RISC-V is an open-source instruction set architecture.
Added support for the 32bit version of RISC-V to Zephyr.

1) exceptions/interrupts/faults are handled at the architecture
   level via the __irq_wrapper handler. Context saving/restoring
   of registers can be handled at both architecture and SOC levels.
   If SOC-specific registers need to be saved, SOC level needs to
   provide __soc_save_context and __soc_restore_context functions
   that shall be accounted by the architecture level, when
   corresponding config variable RISCV_SOC_CONTEXT_SAVE is set.

2) As RISC-V architecture does not provide a clear ISA specification
   about interrupt handling, each RISC-V SOC handles it in its own
   way. Hence, at the architecture level, the __irq_wrapper handler
   expects the following functions to be provided by the SOC level:
   __soc_is_irq: to check if the exception is the result of an
                 interrupt or not.
   __soc_handle_irq: handle pending IRQ at SOC level (ex: clear
                     pending IRQ in SOC-specific IRQ register)

3) Thread/task scheduling, as well as IRQ offloading are handled via
   the RISC-V system call ("ecall"), which is also handled via the
   __irq_wrapper handler. The _Swap asm function just calls "ecall"
   to generate an exception.

4) As there is no conventional way of handling CPU power save in
   RISC-V, the default nano_cpu_idle and nano_cpu_atomic_idle
   functions just unlock interrupts and return to the caller, without
   issuing any CPU power saving instruction. Nonetheless, to allow
   SOC-level to implement proper CPU power save, nano_cpu_idle and
   nano_cpu_atomic_idle functions are defined as __weak
   at the architecture level.

Change-Id: I980a161d0009f3f404ad22b226a6229fbb492389
Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-01-13 19:52:23 +00:00
Carles Cufi
680270f809 toolchain: Add a popcount macro for GCC
Hamming Weight or "popcount" consists in counting the number of bits set
to 1 in a particular word. This commit adds a macro to be able to use
the existing builtin for this purpose with the GCC compiler.

Change-Id: Iec64c19e897de2bc02e981071465bbe230ee9add
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-12-12 20:07:53 +00:00