Commit graph

2221 commits

Author SHA1 Message Date
Marti Bolivar 92e29680c1 arm: soc: stm32f4: add flash driver for IMG_MANAGER
Add definition required to enable the DFU subsystem image manager.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-10-06 22:12:23 -04:00
Marti Bolivar 2e6744f215 arm: soc: nxp: k6x: add flash driver for IMG_MANAGER
Add definition required to enable the DFU subsystem image manager.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-10-06 22:12:23 -04:00
Thiago Silveira e11b9fb4e3 arm: soc: nRF52: Add workaround for incorrect RESETREAS bits, errata 136
This workaround fixes the issue that, after pin reset, RESETREAS bits
other than RESETPIN might also be set.

The workaround was added to both nRF52832 and nRF52840 SoCs.

Signed-off-by: Thiago Silveira <thiago@exati.com.br>
2017-10-06 22:11:21 -04:00
Paul Sokolovsky 808b315cf6 arm: nxp: kw41z: Select IEEE802154_KW41Z driver for networking
802.15.4 is the networking hardware available in KW41Z SoC (and
supported by Zephyr). So, if networking in enabled, automatically
select the corresponding driver. This is similar to how frdm_k64f
automatically selects Ethernet driver, 96b_carbon selects BLE/IPSP
drivers, etc. (But we apply it on SoC level to reuse across the
boards.)

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-10-06 14:39:17 -05:00
Savinay Dharmappa 58d54c0f2d dts: x86: qemu_x86: Add device support for uart ns16550
Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2017-10-06 08:35:42 -04:00
Savinay Dharmappa ddf6a69577 dts: x86: Add device tree support for qemu_x86
patch add device tree support for ia32 soc and qemu_x86
board port

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2017-10-06 08:35:42 -04:00
Andrew Boie 3e3a237930 x86: fix stack zeroing when dropping to user mode
For 'rep stosl' ECX isn't a size value, it's how many times to repeat
the 4-byte string copy operation.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-05 18:49:09 -04:00
David B. Kinder f00f58517b doc: replace UTF-8 chars
Some our Zephyr tools don't like seeing UTF-8 characters, as reported in
issue #4131) so a quick scan and replace for UTF-8 characters in .rst,
.h, and Kconfig files using "file --mime-encoding" (excluding the /ext
folders) finds these files to tweak.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-10-03 20:03:57 -04:00
Anas Nashif ae2e91155e arch: riscv32: define soc family in correct Kconfig
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-03 08:43:50 -04:00
Anas Nashif be9a0b35ee arm: atmel: define soc family in correct Kconfig
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-03 08:43:50 -04:00
Chunlin Han e9c9702818 kernel: add memory domain APIs
Add the following application-facing memory domain APIs:

k_mem_domain_init() - to initialize a memory domain
k_mem_domain_destroy() - to destroy a memory domain
k_mem_domain_add_partition() - to add a partition into a domain
k_mem_domain_remove_partition() - to remove a partition from a domain
k_mem_domain_add_thread() - to add a thread into a domain
k_mem_domain_remove_thread() - to remove a thread from a domain

A memory domain would contain some number of memory partitions.
A memory partition is a memory region (might be RAM, peripheral
registers, flash...) with specific attributes (access permission,
e.g. privileged read/write, unprivileged read-only, execute never...).
Memory partitions would be defined by set of MPU regions or MMU tables
underneath.
A thread could only belong to a single memory domain any point in time
but a memory domain could contain multiple threads.
Threads in the same memory domain would have the same access permission
to the memory partitions belong to the memory domain.

The memory domain APIs are used by unprivileged threads to share data
to the threads in the same memory and protect sensitive data from
threads outside their domain. It is not only for improving the security
but also useful for debugging (unexpected access would cause exception).

Jira: ZEP-2281

Signed-off-by: Chunlin Han <chunlin.han@linaro.org>
2017-09-29 16:48:53 -07:00
Andrew Boie 13ca6fe284 syscalls: reorganize headers
- syscall.h now contains those APIs needed to support invoking calls
  from user code. Some stuff moved out of main kernel.h.
- syscall_handler.h now contains directives useful for implementing
  system call handler functions. This header is not pulled in by
  kernel.h and is intended to be used by C files implementing kernel
  system calls and driver subsystem APIs.
- syscall_list.h now contains the #defines for system call IDs. This
  list is expected to grow quite large so it is put in its own header.
  This is now an enumerated type instead of defines to make things
  easier as we introduce system calls over the new few months. In the
  fullness of time when we desire to have a fixed userspace/kernel ABI,
  this can always be converted to defines.

Some new code added:

- _SYSCALL_MEMORY() macro added to check memory regions passed up from
  userspace in handler functions
- _syscall_invoke{7...10}() inline functions declare for invoking system
  calls with more than 6 arguments. 10 was chosen as the limit as that
  corresponds to the largest arg list we currently have
  which is for k_thread_create()

Other changes

- auto-generated K_SYSCALL_DECLARE* macros documented
- _k_syscall_table in userspace.c is not a placeholder. There's no
  strong need to generate it and doing so would require the introduction
  of a third build phase.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-28 08:56:20 -07:00
Chunlin Han 95d28e53bb arch: arm: add initial support for CONFIG_USERSPACE
add related configs & (stub) functions for enabling
CONFIG_USERSPACE on arm w/o build errors.

Signed-off-by: Chunlin Han <chunlin.han@linaro.org>
2017-09-26 10:00:53 -07:00
Maureen Helm f0d50979e8 mcux: nxp_kinetis: Move HAS_TRNG config to ext
SoCs outside the Kinetis family can have the TRNG module, so move the
HAS_TRNG config from arch/arm/soc/nxp_kinetis to ext/hal/nxp/mcux

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-09-25 12:31:59 -05:00
Maureen Helm 5ba9f26b46 mcux: nxp_kinetis: Move HAS_RNGA config to ext
SoCs outside the Kinetis family can have the RNGA module, so move the
HAS_RNGA config from arch/arm/soc/nxp_kinetis to ext/hal/nxp/mcux

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-09-25 12:31:59 -05:00
Maureen Helm 694c7f5ca4 mcux: nxp_kinetis: Move HAS_FTM config to ext
SoCs outside the Kinetis family can have the FTM module, so move the
HAS_FTM config from arch/arm/soc/nxp_kinetis to ext/hal/nxp/mcux

Note that 'select HAS_FTM' was previously missing from Kconfig.soc and
is now fixed.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-09-25 12:31:59 -05:00
Maureen Helm f7a37cea8d mcux: nxp_kinetis: Move HAS_ADC16 config to ext
SoCs outside the Kinetis family can have the ADC16 module, so move the
HAS_ADC16 config from arch/arm/soc/nxp_kinetis to ext/hal/nxp/mcux

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-09-25 12:31:59 -05:00
Maureen Helm fe4c3aacba mcux: nxp_kinetis: Move HAS_LPSCI config to ext
SoCs outside the Kinetis family can have the LPSCI module, so move the
HAS_LPSCI config from arch/arm/soc/nxp_kinetis to ext/hal/nxp/mcux

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-09-25 12:31:59 -05:00
Maureen Helm bbafc833db mcux: nxp_kinetis: Move HAS_LPUART config to ext
SoCs outside the Kinetis family can have the LPUART module, so move the
HAS_LPUART config from arch/arm/soc/nxp_kinetis to ext/hal/nxp/mcux

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-09-25 12:31:59 -05:00
Anas Nashif 66f1f89da9 qemu: cleanup qemu configurations
Move all QEMU related defines to the boards and cleanup xtensa platforms
which were marked to be QEMU capable by mistake.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-23 16:51:20 -07:00
Andrew Boie df5cc172f4 gen_mmu.py: load directly
On most workstations this was unintentionally being run under Python 2.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-21 13:27:25 -04:00
Anas Nashif db4eba64da dfu: img_util: move flash defines to SoC
mcuboot_constraints.h had FLASH information related to the SoC that
should be maintained as part of the SoC and not in the subsystem. Also
fixed Makefiles to check for IMG_UTIL Kconfig and not MCUBOOT.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-21 06:46:27 -04:00
Andrew Boie 1956f09590 kernel: allow up to 6 arguments for system calls
A quick look at "man syscall" shows that in Linux, all architectures
support at least 6 argument system calls, with a few supporting 7. We
can at least do 6 in Zephyr.

x86 port modified to use EBP register to carry the 6th system call
argument.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-20 09:18:59 -07:00
Andrew Boie a23c245a9a userspace: flesh out internal syscall interface
* Instead of a common system call entry function, we instead create a
table mapping system call ids to handler skeleton functions which are
invoked directly by the architecture code which receives the system
call.

* system call handler prototype specified. All but the most trivial
system calls will implement one of these. They validate all the
arguments, including verifying kernel/device object pointers, ensuring
that the calling thread has appropriate access to any memory buffers
passed in, and performing other parameter checks that the base system
call implementation does not check, or only checks with __ASSERT().

It's only possible to install a system call implementation directly
inside this table if the implementation has a return value and requires
no validation of any of its arguments.

A sample handler implementation for k_mutex_unlock() might look like:

u32_t _syscall_k_mutex_unlock(u32_t mutex_arg, u32_t arg2, u32_t arg3,
                              u32_t arg4, u32_t arg5, void *ssf)
{
        struct k_mutex *mutex = (struct k_mutex *)mutex_arg;
        _SYSCALL_ARG1;

        _SYSCALL_IS_OBJ(mutex, K_OBJ_MUTEX, 0,  ssf);
        _SYSCALL_VERIFY(mutex->lock_count > 0, ssf);
        _SYSCALL_VERIFY(mutex->owner == _current, ssf);

        k_mutex_unlock(mutex);

        return 0;
}

* the x86 port modified to work with the system call table instead of
calling a common handler function. fixed an issue where registers being
changed could confuse the compiler has been fixed; all registers, even
ones used for parameters, must be preserved across the system call.

* a new arch API for producing a kernel oops when validating system call
arguments added. The debug information reported will be from the system
call site and not inside the handler function.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-15 13:44:45 -07:00
Andrew Boie 424e993b41 x86: implement userspace APIs
- _arch_user_mode_enter() implemented
- _arch_is_user_context() implemented
- _new_thread() will honor K_USER option if passed in
- System call triggering macros implemented
- _thread_entry_wrapper moved and now looks for the next function to
call in EDI

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-12 12:46:36 -07:00
Andrew Boie 9f70c7b281 kernel: reorganize CONFIG_USERSPACE
This now depends on a capability Kconfig.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-12 12:46:36 -07:00
Anas Nashif 1e8afbfe5a cleanup: remove lots of references to unified kernel
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-12 12:37:11 -04:00
Andrew Boie d81f9c1e4d x86: revise _x86_mmu_buffer_validate
- There's no point in building up "validity" (declared volatile for some
  strange reason), just exit with false return value if any of the page
  directory or page table checks don't come out as expected

- The function was returning the opposite value as its documentation
  (0 on success, -EPERM on failure). Documentation updated.

- This function will only be used to verify buffers from user-space.
  There's no need for a flags parameter, the only option that needs to
  be passed in is whether the buffer has write permissions or not.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-12 08:40:41 -07:00
Andrew Boie 3bb677d6eb x86: don't set FS/GS segment selectors
We shouldn't be imposing any policy here, we do not yet use these in
Zephyr. Zero these at boot and otherwise leave alone.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-12 08:40:08 -07:00
Erwan Gouriou 1ded7d7b33 arch: arm: stm32: factorize stm32f417xy socs defconfig files
stm32f417xe and stm32f417xg have been introduced with 2
different defconfig files. Since same code is declared
in both files, mutualize declarations in a single file.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-09-12 11:24:56 -04:00
Yannis Damigos 0f408a003c arch: soc: st_stm32: Remove unused enumeration from F4, F3 SoCs
The enumerations stm32{f3,f4}x_pin_config_mode aren't used any
more. This patch removes them.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-09-12 11:24:56 -04:00
Andrew Boie 1e06ffc815 zephyr: use k_thread_entry_t everywhere
In various places, a private _thread_entry_t, or the full prototype
were being used. Be consistent and use the same typedef everywhere.

Signen-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-11 11:18:22 -07:00
Anas Nashif d414e7c7ee kconfig: move fatal error handler to arch options
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 09:42:35 -07:00
Anas Nashif 8379b7b433 kconfig: move interrupt options into arch menu
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 09:42:35 -07:00
Anas Nashif 46f66f4295 kconfig: generalised stack protection options
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 09:42:35 -07:00
Anas Nashif 939889a202 kconfig: remove unused config DEBUG_IRQS
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 09:42:35 -07:00
Anas Nashif 261f898e8f kconfig: remove exta menu for x86 core options
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 09:42:35 -07:00
Anas Nashif 7c71608fc1 cleanup: remove commented #include
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 12:41:07 -04:00
Anas Nashif b1991eba94 cleanup: remove the whitespaces before the # character
Indenting preprocessor directives reduces the code readability, because
it make preprocessor directives harder to spot.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 12:41:07 -04:00
Anas Nashif 8920cf127a cleanup: Move #include directives
Move all #include directives at the very top of the file, before any
code.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 12:41:07 -04:00
Marti Bolivar 32482e9cb8 flash: stm32: stm32f4: add page layout support
Add flash page layout support for STM32F4 SoCs.

This almost eliminates the need for flash_map.h, except for
STM32F4X_SECTOR_MASK, so delete the file and move the define into the
F4 implementation, to keep things simple.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-09-11 11:41:57 -04:00
Adithya Baglody 609ade891b x86: MMU: Updated MMU code to use the new macros.
Use of X86_MMU_GET_PTE to increase readability of the MMU code.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-09-07 17:13:06 -07:00
Adithya Baglody 65c2432791 x86: MMU: Miscellaneous macros related to MMU.
Helper macros to ease the usage of the MMU page table structures.
Added Macros to get Page table address and Page Table Entry
values.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-09-07 17:13:06 -07:00
Andrew Boie a34f4fb94f x86: add printk for protection faults
Most x86 exceptions that don't already have their own handlers
are fairly rare, but with the introduction of userspace
people will be seeing General Protection Faults much more
often. Report it as text so that users unfamiliar with x86
internals will know what is happening.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:35:27 -07:00
Andrew Boie 8eaff5d6d2 k_thread_abort(): assert if abort essential thread
Previously, this was only done if an essential thread self-exited,
and was a runtime check that generated a kernel panic.

Now if any thread has k_thread_abort() called on it, and that thread
is essential to the system operation, this check is made. It is now
an assertion.

_NANO_ERR_INVALID_TASK_EXIT checks and printouts removed since this
is now an assertion.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:35:16 -07:00
Andrew Boie 8eeb09765b x86: cleanup _new_thread()
Years of iterative development had made this function more complicated
than it needed to be. Fixed some errors in the documentation as well.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:33:50 -07:00
Andrew Boie 945af95f42 kernel: introduce object validation mechanism
All system calls made from userspace which involve pointers to kernel
objects (including device drivers) will need to have those pointers
validated; userspace should never be able to crash the kernel by passing
it garbage.

The actual validation with _k_object_validate() will be in the system
call receiver code, which doesn't exist yet.

- CONFIG_USERSPACE introduced. We are somewhat far away from having an
  end-to-end implementation, but at least need a Kconfig symbol to
  guard the incoming code with. Formal documentation doesn't exist yet
  either, but will appear later down the road once the implementation is
  mostly finalized.

- In the memory region for RAM, the data section has been moved last,
  past bss and noinit. This ensures that inserting generated tables
  with addresses of kernel objects does not change the addresses of
  those objects (which would make the table invalid)

- The DWARF debug information in the generated ELF binary is parsed to
  fetch the locations of all kernel objects and pass this to gperf to
  create a perfect hash table of their memory addresses.

- The generated gperf code doesn't know that we are exclusively working
  with memory addresses and uses memory inefficently. A post-processing
  script process_gperf.py adjusts the generated code before it is
  compiled to work with pointer values directly and not strings
  containing them.

- _k_object_init() calls inserted into the init functions for the set of
  kernel object types we are going to support so far

Issue: ZEP-2187
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-09-07 16:33:33 -07:00
Youvedeep Singh 7f2aaedfd7 arch: arm: store/restore regs r0-r3 while making function call.
In benchmark test (test_info) while making function call regs
r0 - r4 are modified into called function. Due to this value
inside r3 is getting lost.
This patch saves and restore the value in r0-r4 regs while making
function calls from assembly language.

Jira: ZEP-2314

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2017-08-31 14:25:31 -04:00
Youvedeep Singh 76b577e180 tests: benchmark: timing_info: Change API/variable Name.
The API/Variable names in timing_info looks very speicific to
platform (like systick etc), whereas these variabled are used
across platforms (nrf/arm/quark).
So this patch :-
1. changing API/Variable names to generic one.
2. Creating some of Macros whose implimentation is platform
depenent.

Jira: ZEP-2314

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2017-08-31 14:25:31 -04:00
Andy Gross ecb0f3e159 arm: mpu: Account for stack guard size correctly
This patch fixes a couple of issues with the stack guard size and
properly constructs the STACK_ALIGN and STACK_ALIGN_SIZE definitions.

The ARM AAPCS requires that the stack pointers be 8 byte aligned.  The
STACK_ALIGN_SIZE definition is meant to contain the stack pointer
alignment requirements.  This is the required alignment at public API
boundaries (ie stack frames).

The STACK_ALIGN definition is the required alignment for the start
address for stack buffer storage.  STACK_ALIGN is used to validate
the allocation sizes for stack buffers.

The MPU_GUARD_ALIGN_AND_SIZE definition is the minimum alignment and
size for the MPU.  The minimum size and alignment just so happen to be
32 bytes for vanilla ARM MPU implementations.

When defining stack buffers, the stack guard alignment requirements
must be taken into consideration when allocating the stack memory.
The __align() must be filled in with either STACK_ALIGN_SIZE or the
align/size of the MPU stack guard.  The align/size for the guard region
will be 0 when CONFIG_MPU_STACK_GUARD is not set, and 32 bytes when it
is.

The _ARCH_THREAD_STACK_XXXXXX APIs need to know the minimum alignment
requirements for the stack buffer memory and the stack guard size to
correctly allocate and reference the stack memory.  This is reflected
in the macros with the use of the STACK_ALIGN definition and the
MPU_GUARD_ALIGN_AND_SIZE definition.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2017-08-31 11:20:26 -05:00
Andy Gross 85481d997b arch: arm: Remove redundant check and fix rounding
This patch removes the redundant stack alignment check being done.  The
stack definition macros enforce the alignment requirements via the
__align() directives.

In addition, fix the rounding down of the psp to be correct.  The
actual initial stack pointer is the end of the stack minus the size of
the __esf structure.  Rounding down after the subtraction will get us
to the correct offset.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2017-08-31 11:20:26 -05:00
Leandro Pereira 510e5d7ced arch: xtensa: Use the alternate _Level4Vector routine on ESP32
For some reason, the ESP32 HAL defines XCHAL_EXCM_LEVEL to 3.  This
enables a version of _Level4Vector that doesn't work on this hardware.

Without complete visibility if the version that should work be axed,
keep both in the tree, but build the working other version instead
if building for ESP32.

Jira: ZEP-2556
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-08-25 15:31:46 -04:00
Kumar Gala e25ee68bbd arch: arm: stm32f1: Fix how we determine pull-up/pull-down for gpio
When we mask out the GPIO High impedance/Pull-up/Pull-down field we
should be shifting the mask file, not shifting the field.  This is
because all the other defines already assume the shift.

Coverity-CID: 173640

Jira: ZEP-2538

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-08-21 11:18:03 -05:00
Leandro Pereira d52de29fba esp32: Fix redefinition of BIT() macro
Esp-idf defines the BIT macro that is also defined in Zephyr's
misc/util.h.  Fix the issue by including the esp-idf headers first, so
that a check in util.h won't redefine the macro if it's already
defined.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-08-19 07:50:18 -04:00
David B. Kinder 81f7c82625 doc: fix misspellings and missing EOF newlines
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-16 17:38:41 -05:00
Wayne Ren 480cfac4f2 arch: arc: apply STACK_GUARD_SIZE and optimize the mpu driver
* apply STACK_GUARD_SIZE, no extra space will be added if
  MPU_STACK_GUARD is disabled
* When ARC_STACK_CHECKING is enabled, MPU_STACK_GUARD will be
  disabled
* add two new api: arc_core_mpu_default and arc_core_mpu_region
  to configure mpu regions
* improve arc_core_mpu_enable and arc_core_mpu_disable

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2017-08-16 16:09:45 -04:00
Wayne Ren 12cc6598b0 arch: arc: Add mpu support
* add arc mpu driver
* modify the corresponding kconfig and kbuild
* currently only em_starterkit 2.2's em7d configuration
  has mpu feature (mpu version 2)
* as the minimum region size of arc mpu version 2 is 2048 bytes and
  region size should be power of 2, the stack size of threads
  (including main thread and idle thread) should be at least
  2048 bytes and power of 2
* for mpu stack guard feature, a stack guard region of 2048 bytes
  is generated. This brings more memory footprint
* For arc mpu version 3, the minimum region size is 32 bytes.
* the codes are tested by the mpu_stack_guard_test and stackprot

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2017-08-16 16:09:45 -04:00
Andrew Boie e434260e19 xtensa: soc: fix IRQ table
The linker scripts were not properly updated to the new
gen_isr_tables mechanism.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-16 10:59:10 -07:00
Gil Pitney 4f67a6c76d cc3200: Remove TI cc3200 SOC and LaunchXL board support
Per ZEP-1958, Phase 2 of adding CC3220sf LaunchXL support,
was to "deprecate the CC3200 launchxl support in Zephyr
(redundant to the CC3220)."

Effectively, the CC3220 SOC replaces the CC3200.

This patch removes the following:
* the imported CC3200 SDK
* CC3200 SOC, board, DTS files.
* adjusts other files where cc3200 was mentioned.

Also, it fixes explicit references to CC3200 in generic
CC32xx driver files.

Jira: ZEP-1958

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2017-08-15 11:02:48 -05:00
Andrew Boie de6663f601 esp32: fix linker script issues
- .text, .text.*, .literal, .literal.* had no matching input section
   rule and were being passed to the output binary verbatim. These
   are all now in the output "text" section as intended.

- various rules in the data section were unnecessarily using KEEP().

- SW_ISR_TABLE wasn't included in linker script anywhere and was
  ending up in its own section, and not the data section as intended.

- noinit section didn't exist at all, now defined.

Issue: ZEP-2508
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-14 15:27:17 -04:00
Andrew Boie 67a51f9a9e quark_d2000: fix IDT_LIST definition
This should be the same size as other x86 boards.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-14 14:45:07 -04:00
Gil Pitney 1a5537811f cc32xx: Redefine CMSIS IRQn_Type enum to unsigned int
Previously, calling NVIC_SetPriority(IRQn_Type irqn, ....) with
the NWP interrupt number of 171 caused a hard fault during a
subsequent svc #0 instruction during _Swap().

GNU compiler is generating a bit extension instruction (sxtb) which
converts a positive IRQ value argument to a negative value when
casting to the CMSIS IRQn_Type enum parameter type.

This generates a negative index, which then writes to an SCB
control register instead of NVIC register, causing a hard
fault later on.

This issue only occurs when passing interrupt numbers > 0x80
(eg: 171 (0xab) for the NWP) to the CMSIS NVIC apis.

The solution here is simply to redefine IRQn_Type to be an
unsigned 32 bit integer, while redefining the CMSIS IRQn_Type
enum definitions for interrupts less than zero.

Jira: ZEP-1958

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2017-08-10 16:46:49 -05:00
Wayne Ren f8d061faf7 arch: arc: add nested interrupt support
* add nested interrupt support for interrupts
   + use a varibale exc_nest_count to trace nest interrupt and exception
   + regular interrupts can be nested by regular interrupts and fast
interrupts
   + fast interrupt's priority is the highest, cannot be nested
* remove the firq stack and exception stack
   + remove the coressponding kconfig option
   + all interrupts (normal and fast) and exceptions will be handled
     in the same stack (_interrupt stack)
   + the pros are, smaller memory footprint (no firq stack), simpler
     stack management, simpler codes, etc.. The cons are, possible
     10-15 instructions overhead for the case where fast irq nests
     regular irq
* add the case of ARC in test/kernel/gen_isr_table

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-10 12:47:15 -04:00
Huaqi Fang 725c525a13 boards: em_starterkit: Move peripheral configs from soc to board level
Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-08-09 23:21:13 -04:00
Huaqi Fang 7ac0a6a9d1 arc: em7d: Report error when build for 2.3's em7d
When you build application for em starterkit 2.3 em7d, it will
report error during build since it is not supported currently.

Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-08-09 23:21:13 -04:00
Huaqi Fang 8dfefdf310 arc: em9d/em11d: Update default configurations
Update configurations to support em9d and em11d in
em starterkit 2.2 and 2.3

Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-08-09 23:21:13 -04:00
Huaqi Fang c58aadfece arc: em9d/em11d: Modify and cleanup soc.h
em starterkit has two versions, 2.2 and 2.3.
Change soc.h to support both versions,
main changes are the interrupt connections.

Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-08-09 23:21:13 -04:00
Huaqi Fang 403e2803bf arc: em7d: Clean up arch/arc/soc/em7d/soc.h
Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-08-09 23:21:13 -04:00
Huaqi Fang 7a1f06b374 arc: em7d: Add support for em starterkit 2.2 EM7D
Since em starterkit has different firmware versions(2.2 and 2.3),
but the EM7D of 2.3 has new secureshield feature, which is not supported
in Zephyr, but EM7D of 2.2 is a normal EM core, which can be supported,
so we add support for 2.2 EM7D.

Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-08-09 23:21:13 -04:00
Huaqi Fang d4e9c97173 arc: Remove unused backslash in makefile of arc em9d
Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-08-09 23:21:13 -04:00
Xiaorui Hu eb48a0a73c arm: armv6-m: Support relocating vector table
An abnormal crash was encountered in ARMv6-M SoCs that don't have flash
starting at 0.  With Zephyr OS the reason for this crash is that, on
ARMv6-M the system requires an exception vector table at the 0 address.

We implement the relocate_vector_table function to move the vector table
code to address 0 on systems which don't have the start of code already
at 0.

[kumar.gala: reworderd commit message, tweaked how we check if we need
 to copy vector table]

Signed-off-by: Xiaorui Hu <xiaorui.hu@linaro.org>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-08-09 18:13:29 -04:00
Maureen Helm 469ddab780 pwm: Remove k64-specific driver and k20_sim.h
Now that we have an mcux shim driver, remove the old k64-specific
driver. Also remove include/drivers/k20_sim.h, since the old
k64-specific driver was the only thing left using it.

Jira: ZEP-2025

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-09 18:13:29 -04:00
Maureen Helm 57bd281d4d nxp_kinetis: Switch default pwm driver to mcux
Switches the default pwm driver from the k64-specific driver to the
mcux shim, which can be used on other SoCs with the ftm peripheral.

Jira: ZEP-2025

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-09 18:13:29 -04:00
Maureen Helm 060bf8ea6a pwm: Introduce new mcux ftm shim driver
Adds a shim layer around the mcux ftm driver to adapt it to the Zephyr
pwm interface.

Jira: ZEP-2025

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-08-09 18:13:29 -04:00
Erwin Rol 8e6ebdb090 arm: support for stm32f417 SOC
Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-08-09 14:53:47 -05:00
Leandro Pereira 99181eb661 arch: xtensa: Move exception table to xtensa_intr.c
This cleans up the exception handling by removing the table declaration
from xtensa_intr_asm.S, and removing the unused
_xt_set_exception_handler() function.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-08-09 12:26:14 -07:00
Leandro Pereira 27ea2d8eb7 arch: xtensa: Convert Xtensa port to use gen_isr_table
The Xtensa port was the only one remaining to be converted to the new
way of connecting interrupts in Zephyr.  Some things are still
unconverted, mainly the exception table, and this will be performed
another time.

Of note: _irq_priority_set() isn't called on _ARCH_IRQ_CONNECT(), since
IRQs can't change priority on Xtensa: while the architecture has the
concept of interrupt priority levels, each line has a fixed level and
can't be changed.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-08-09 12:26:14 -07:00
Leandro Pereira 1e506d3b42 arch: xtensa: Remove mentions of dynamic interrupt settings
Dynamic IRQ allocation has been yanked from Zephyr a few releases ago,
so there's no point in keeping these options available.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-08-09 12:26:14 -07:00
Leandro Pereira c0c79a8041 drivers: gpio: esp32: Add ESP32 GPIO driver
This provides basic GPIO support, with interrupts, and the ability to
read and write to ports on a pin-by-pin basis.

Jira: ZEP-2286
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-08-09 12:26:14 -07:00
Erwin Rol 57746488d4 arm: support for stm32f405 SOC
Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-08-09 14:24:21 -05:00
Andy Gross 5930e9d02d arm: mpu: Adjust to use opaque kernel data types
This patch adjusts the ARM MPU implementation to be compliant to the
recent changes that introduced the opaque kernel data types.

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2017-08-09 13:36:09 -05:00
Michel Jaouen deeaa40e1e arm: mpu: fix: align stack for mpu stack guard
The mimimum mpu size is 32 bytes, but requires mpu base address to be
aligned on 32 bytes to work. Define architecture thread macro when
MPU_STACK_GUARD config to allocate stack with 32 more bytes.

Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
2017-08-09 13:36:09 -05:00
Yannis Damigos 0848843c04 arch: arm: stm32f1: Add missing input port configuration
This patch adds missing configuration bits when GPIO is
configured as input

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-08-09 10:11:51 -05:00
Yannis Damigos a66b92459b arch: arm: stm32f1: Shift GPIO pin configuration values only once
In the stm32_gpio_flags_to_conf function the configuration
values of the GPIO pin are shifted two times. One in the
stm32-pinctrlf1 header and one in the function. This patch
removes one of those shifts.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-08-09 10:11:51 -05:00
Adithya Baglody ab7b02ce67 x86: MMU: Bug in _x86_mmu_buffer_validate
The value of the PTE (starting_pte_num) was not
calulated correctly. If size of the buffer exceeded 4KB,
the buffer validation API was failing.

JIRA: ZEP-2489

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-08-09 07:06:22 -07:00
Johan Hedberg 2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +03:00
Vincenzo Frascino de81c16c5a arm: core: mpu: Add Allow write on Flash
This patch adds the allow flash write CONFIG option to the ARM MPU
configuration in privileged mode.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: David Brown <david.brown@linaro.org>
2017-08-08 11:20:46 -05:00
Vincenzo Frascino 6489b9a0f2 arm: soc: nxp k6x: Add Allow write on Flash
This patch adds the allow flash write CONFIG option to the NXP MPU
configuration in privileged mode.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Signed-off-by: David Brown <david.brown@linaro.org>
2017-08-08 11:20:46 -05:00
Youvedeep Singh 24e083c5d6 arm: handle time slicing before context switch on exception.
Currently Thread time slice is getting reset at end of timer
interrupt. Due to which equal priority threads behind current thread
in ready_q are not getting chance to run and leading to starvation.

This patch handles time slice in _ExcExit section context switch is
required.

Jira: ZEP-2444

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-08 09:33:25 -04:00
Anas Nashif 09bcd8ee74 Kconfig: make all syslog variables depend on SYS_LOG
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-04 14:34:54 -05:00
Andrew Boie 80e82e7205 x86: stack overflow improvements
As luck would have it, the TSS for the main IA task has
all the information we need, populate an exception stack
frame with it.

The double-fault handler just stashes data and makes the main
hardware thread runnable again, and processing of the
exception continues from there.

We check the first byte before the faulting ESP value to see
if the stack pointer had run up to a non-present page, a sign
that this is a stack overflow and not a double fault for
some other reason.

Stack overflows in kernel mode are now recoverable for non-
essential threads, with the caveat that we hope we weren't in
a critical section updating kernel data structures when it
happened.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-03 11:46:26 -04:00
Andrew Boie 25a8aef275 x86: enable MMU for application memory
Configuring the RAM/ROM regions will be the same for all
x86 targets as this is done with linker symbols.

Peripheral configuration left at the SOC level.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-03 11:46:26 -04:00
Andrew Boie 0f16d98b32 x86: mmu: add runtime modification indicator
The CPU first checks the page directory entry for write
or user permissions on a particular page before looking
at the page table entry.

If a region configured all pages to be non user accessible,
and this was changed for a page within it to be accessible,
the PDE would not be updated and any access would still
return a page fault.

The least amount of runtime logic to deal with this is to
indicate at build time that some pages within a region may
be marked writable or user accessible at runtime, and to
pre-set the flags in the page directory entry accordingly.

The driving need for this is the region configuration for
kernel memory, which will have user permissions set at
runtime for stacks and user-configured memory domains.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-03 11:46:26 -04:00
Andrew Boie 9ffaaae5ad x86: additional debug output for page faults
Page faults will additionally dump out some interesting
page directory and page table flags for the faulting
memory address.

Intended to help determine whether the page tables have been
configured incorrectly as we enable memory protection features.

This only happens if CONFIG_EXCEPTION_DEBUG is turned on.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-03 11:46:26 -04:00
Erwin Rol cf7765327b arch: arm: stm32: f3/f4/l4: write output speed to hardware register
The ouput speed of the gpio pins passed via the 'conf' argument was
ignored, causing the speed to always be in its reset state (lowest
possible speed for most pins). This was causing problems for pins that
actually need a speed faster than the default, like the ethernet
controller pins.

Combined with the correct pinmux configuration this fixes problems
of the olimex_stm32_e407 board not being able to send ethernet data.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-08-02 12:28:11 -05:00
Andrew Boie 507852a4ad kernel: introduce opaque data type for stacks
Historically, stacks were just character buffers and could be treated
as such if the user wanted to look inside the stack data, and also
declared as an array of the desired stack size.

This is no longer the case. Certain architectures will create a memory
region much larger to account for MPU/MMU guard pages. Unfortunately,
the kernel interfaces treat both the declared stack, and the valid
stack buffer within it as the same char * data type, even though these
absolutely cannot be used interchangeably.

We introduce an opaque k_thread_stack_t which gets instantiated by
K_THREAD_STACK_DECLARE(), this is no longer treated by the compiler
as a character pointer, even though it really is.

To access the real stack buffer within, the result of
K_THREAD_STACK_BUFFER() can be used, which will return a char * type.

This should catch a bunch of programming mistakes at build time:

- Declaring a character array outside of K_THREAD_STACK_DECLARE() and
  passing it to K_THREAD_CREATE
- Directly examining the stack created by K_THREAD_STACK_DECLARE()
  which is not actually the memory desired and may trigger a CPU
  exception

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-01 16:43:15 -07:00
Kumar Gala 68732efe00 arm: nxp: mcux lpuart: Get IRQ info from DTS
Move to using the generated IRQ defines from the DTS instead of soc.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-27 09:27:47 -05:00
Kumar Gala 0ef91e4d07 arm: nxp: mcux uart: Get IRQ info from DTS
Move to using the generated IRQ defines from the DTS instead of soc.h.
This change also fixes a minor bug in that the error irq priority wasn't
getting correctly picked up from device tree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-27 09:27:47 -05:00
Erwan Gouriou 72d2960741 arch: arm: stm32f3: Rework pinmux handler
STM32F3 pinmux handler is reworked to support future pinmux dts
generation.
Preliminary change is done to move pin configuration
informations in a {pin, conf} structure closer to dts fields
"pins" array is removed as information is transfered to
"pinconf" array

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-07-26 15:16:52 -05:00
Erwan Gouriou 8763939763 arch: arm: stm32f4: Rework pinmux handler
STM32F4 pinmux handler is reworked to support future pinmux dts
generation.
Preliminary change is done to move pin configuration
informations in a {pin, conf} structure closer to dts fields
"pins" array is removed as information is transfered to
"pinconf" array

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-07-26 15:16:52 -05:00
Erwan Gouriou 8d0150000c arch: stm32f1: rework pinmux driver
Rework stm32f1 pinmux code for future dts based pinmux code
generation.
Pin configuration is now done directly thanks to gpio port
configuration. Reference to pseudo alternate functions are
now removed same as the use of pins[] array.
Pins function (uart tx for instance) is set implicitly by
defining gpio mode and configuration.
This behavior is specific to stm32f10x series.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-07-26 15:16:52 -05:00
Erwan Gouriou 2366d23573 arch: arm: stm32l4: Rework pinmux driver
STM32L4 pinmux handler is reworked to support future pinmux dts
generation.
Preliminary change is done to move pin configuration
informations in a {pin, conf} structure closer to dts fields
"pins" array is removed and information is transferred to
"pinconf" array

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-07-26 15:16:52 -05:00
Erwan Gouriou 92c7ef5939 arch: stm32: l4: factorize HAS_STM32CUBE
In L4 series, select HAS_STM32CUBE is done per soc.
This could be factorized in Kconfig.series.
Aim is  to lower the steps to add a new SoC.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-07-26 09:52:59 -05:00
Andrew Boie d944950aaa x86: install guard page for interrupt stack
We need to know when the interrupt stack overflows as well as
thread stacks.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-26 05:57:45 -04:00
Kumar Gala 0e7067c6be arm: dts: cleanup uart related Kconfig options
Now that we generate BLUETOOTH_UART_ON_DEV_NAME, UART_PIPE_ON_DEV_NAME,
and BLUETOOTH_MONITOR_ON_DEV_NAME Kconfig defines for dts enabled
platforms add those into the appropriate dts files and remove from the
various board/Kconfig.defconfig files.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-25 12:23:20 -05:00
Andrew Boie 054d47b29c x86: set stack guard page non-writable
This will trigger a page fault if the guard area
is written to. Since the exception itself will try
to write to the memory, a double fault will be triggered
and we will do an IA task switch to the df_tss and panic.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Andrew Boie 0fab8a6dc5 x86: page-aligned stacks with guard page
Subsequent patches will set this guard page as unmapped,
triggering a page fault on access. If this is due to
stack overflow, a double fault will be triggered,
which we are now capable of handling with a switch to
a know good stack.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Andrew Boie 6101aa6220 x86: add API for modifying page tables
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Andrew Boie bc666ae7f7 x86: implement improved double-fault handler
We now create a special IA hardware task for handling
double faults. This has a known good stack so that if
the kernel tries to push stack data onto an unmapped page,
we don't triple-fault and reset the system.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Andrew Boie 08c291306e x86: generate RAM-based GDT dynamically
We will need this for stack memory protection scenarios
where a writable GDT with Task State Segment descriptors
will be used. The addresses of the TSS segments cannot be
put in the GDT via preprocessor magic due to architecture
requirments that the address be split up into different
fields in the segment descriptor.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Andrew Boie 8a102e44ed x86: allow IDT vectors to be task gates
This has one use-case: configuring the double-fault #DF
exception handler to do an IA task switch to a special
IA task with a known good stack, such that we can dump
diagnostic information and then panic.

Will be used for stack overflow detection in kernel mode,
as otherwise the CPU will triple-fault and reset.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Andrew Boie ddf9f4be31 x86: convert gen_idt to Python
This is one less host tool we have to compile for every build,
and makes the build tools more portable across host OSes.
The code is also much simpler to maintain.

Issue: ZEP-2063
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Andrew Boie dff21de082 x86: add CONFIG_X86_STACK_PROTECTION
This enables the MMU-based stack protection feature,
which will cause a fatal error if a thread overflows
its stack in kernel mode, at a nontrivial cost in memory
(4K per thread).

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-25 11:32:36 -04:00
Andrew Boie a717050140 qemu_x86: terminate emulator on fatal system error
This will cause sanitycheck runs to finish more quickly
instead of sitting there waiting on a timeout. We already
do this with the Xtensa simulator.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-22 09:46:26 -04:00
Erwan Gouriou 46d66163eb arch: arm: stm32l4: Add pin config for USART1 on PB6/PB7
With introduction of commit "pinmux: stm32: directly return error if
stm32_get_pin_config fails", pin configuration fails when
pins are not configured in pins[] array.
This was the case for configuration UART1 assigned on PB6/PB7.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-07-20 07:30:32 -05:00
Michał Kruszewski fda632adec nrf5: uart: Add support for 300 and 600 baud rates.
Signed-off-by: Michał Kruszewski <michal.kruszewski@nordicsemi.no>
2017-07-20 07:30:04 -05:00
Savinay Dharmappa addb12b463 arch: quark_se: select config UART_QMSI_0 by default
'commit
("devicetree: Generate BLUETOOTH_UART ,UART_PIPE etc config from dt")'
created a dependency of selecting UART_QMSI_0 on device tree.
This change is reverted as it incorrect.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2017-07-20 07:12:00 -05:00
Maureen Helm db3891fc23 arm: nxp_kinetis: Enable the mcux adc16 driver for all Kinetis SoCs
If the adc driver configuration is enabled (CONFIG_ADC=y), then enable
the mcux shim driver by default for all Kinetis SoCs.

Jira: ZEP-1396

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-07-19 14:28:08 -05:00
Maureen Helm 8ff51559da adc: Introduce new mcux adc16 driver
Adds a shim layer around the mcux adc16 driver to adapt it to the Zephyr
adc interface.

Jira: ZEP-1396

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-07-19 14:28:08 -05:00
Savinay Dharmappa c1e5cbfd41 devicetree: Generate BLUETOOTH_UART,UART_PIPE etc config from dt
patch uses chosen property zephyr,bt-uart, zephyr,uart-pipe
and zephyr,bt-mon-uart to determine the uart instance to be
used for bluetooth,uart_pipe and bluetooth_monitor and generate
appropriate configs.

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2017-07-19 11:52:35 -04:00
Savinay Dharmappa 7578035f4c dts: x86: Add device tree support for quark_d2000 microcontroller
Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2017-07-19 11:25:43 -04:00
Adithya Baglody 079b17b312 x86: MMU: Validate user Buffer
A user space buffer must be validated before required operation
can proceed. This API will check the current MMU
configuration to determine if the buffer held by the user is valid.

Jira: ZEP-2326

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-07-19 08:06:44 -07:00
Andrew Boie 74afcb67ae arches: move _NanoFatalErrorHandler defintion
This needs to be in <arch/cpu.h> so that it can be called
from the k_panic()/k_oops() macros in kernel.h.

Fixes build errors on these arches when using k_panic() or
k_oops().

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-18 09:34:23 +03:00
Andrew Boie 08a9fcdb80 x86: ia32: set access based on linker regions
This will set program text and rodata as read-only even in
non-XIP systems.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-15 12:17:36 -07:00
Erwin Rol be88626695 pinmux: stm32: add ethernet controller pins
Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-07-12 12:53:51 +03:00
Kumar Gala 65e72be8f7 devicetree: Generate CONFIG_UART_CONSOLE_ON_DEV_NAME from dt
We can use the chosen property "zephyr,console" to determine what uart
should be used as the console and find its name to generate a define for
CONFIG_UART_CONSOLE_ON_DEV_NAME.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-11 12:09:10 -05:00
Andrew Boie c9814f5104 mmustructs: don't use addr to name structures
This breaks too easily, for example if &some_linker_variable
is used. The names don't matter at all, use preprocessor
__COUNTER__.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Andrew Boie 103d655dee qemu_x86: increase to 8MB of RAM
Previously we were instantiating QEMU with 32MB of RAM but
only enabling a small fraction of it.

Now we boot with 8MB of ram. We ignore the first 4K so we can
make that an unmapped paged to catch NULL pointer dereferences.

If XIP is enabled, the "ROM" region will be the first half of
memory, the "RAM" region the latter.

Move the IDT_LIST and MMU_LIST regions elsewhere so they don't
overlap the new memory arrangement.

Use !XIP to fix a problem where CONFIG_RAM_SIZE was set incorrectly
for XIP case.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Erwin Rol 2fc9dc61d4 drivers: stm32: random: Initial STM32 random number generator driver
Add a STM32 LL based driver for the RNG processor. The RNG processor
is a random number generator, based on a continuous analog noise, that
provides a random 32-bit value to the host when read. The RNG passed
the FIPS PUB 140-2 (2001 October 10) tests with a success ratio of 99%.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-07-07 07:27:39 -05:00
Kumar Gala 8e8d49a620 i2c: stm32: Cleanup how we enable the specific I2C driver
Right now we allow for the I2C subsystem to be built without any drivers
enabled that utilize it.  When we added support for the new STM32 I2C
driver we forced the I2C driver to be enabled if the I2C subsystem was
enabled.  While this makes a reasonable amount of sense, it breaks
current assumptions for various testcases that we need to cleanup.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-05 11:33:08 -05:00
Jorge Ramirez-Ortiz dd2eeaf352 pinmux: stm32f4: Add SPI2 pins on PB12, PB13, PB14 & PB15
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-07-01 08:36:51 -04:00
Jorge Ramirez-Ortiz 3ebb412fa9 pinmux: stm32f4: Add SPI1 pins on PA4, PA5, PA6 & PA7
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-07-01 08:36:51 -04:00
Jorge Ramirez-Ortiz ae4363817b stm32cube: build stm32xxx_ll_spi if CONFIG_SPI
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-07-01 08:36:51 -04:00
Jorge Ramirez-Ortiz 21fbc9b07e drivers: i2c: stm32 LL F1/F4 (v1) STM32 F3/L4X (v2)
Supports STM32 F1/F4 (v1 controller) and STM32 F3/L4X (v2
controller)

v1 could also support L1X.
v2 could also support F7X.

Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Reviewed-by: Yannis Damigos <giannis.damigos@gmail.com>
Tested-by: Yannis Damigos <giannis.damigos@gmail.com>
Tested-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
2017-07-01 08:36:51 -04:00
Yannis Damigos 220ddb9738 soc: stm32: F1/F3/F4/L4: enable I2C LL
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
2017-07-01 08:36:51 -04:00
Yannis Damigos 676a82cd73 arch: stm32f1: Fix typo in soc_config
Fix typo in soc_config.c

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-07-01 08:36:51 -04:00
Yannis Damigos ecbb3b6c04 pinmux: stm32 F1X/F3X/F4X: add I2C
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
2017-07-01 08:36:51 -04:00
Jean-Paul Etienne 34862656b9 riscv32: fixed context restore upon exiting ISR
By now, t0 register restored value is overwritten
by mepc and mstatus values prior to returning from ISR.

Fixed by restoring mstatus and mepc registers before
restoring the caller-saved registers.

As t0 is a temporary register within the riscv ABI,
this issue was unnoticed for most applications, except
for computation intensive apps, like crypto tests.

Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-06-30 06:31:51 -04:00
Andrew Boie 2bc0fa9bd5 qemu_x86: ia32: fix ROM size with XIP enabled
The defaults of 0x100000 for ROM and 0x400000 for RAM are intended
to 'fake' a XIP configuration, this all takes place in just RAM.

The gap between these two values is 3 megabytes, specify this
properly.

Fixes numerous test cases on qemu_x86 if CONFIG_XIP is enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-29 07:46:58 -04:00
Andrew Boie 3d8aaf7099 x86: implement bss zero and data copy for application
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-29 07:46:58 -04:00
Kumar Gala 534beb34c9 tests: boot_time: cleanup boot_time test to work on ARM
Enabled the boot_time test on ARM SoCs, set __start_time_stamp on ARM
since we don't have a free running counter similar to TSC on x86.
Also moved to printing the values out as %u to increase the range of
values.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-06-29 07:08:59 -04:00
Johann Fischer 08df5961b3 arch: intel_quark: use DW device driver when USB is selected
This patch allows more generic USB configuration in the samples
and removes platform dependent driver configuration.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2017-06-28 15:14:15 -04:00
Andrzej Puzdrowski 8b7a8448ab Drivers: flash: NRF5x: synchronous mode for co-operation with BLE radio
In added mode flash operation are performed in timeslice
(in radio idle time).
Kconfig for mode enabling CONFIG_SOC_FLASH_NRF5_RADIO_SYNC.

Erase and write API implementations were rewritten and preserved against
concurrent execution.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-06-28 12:29:50 +02:00
Kumar Gala d426d122f1 boards; cc2650_sensortag: Get building with sanitycheck
Board port was done before the yaml transition, so was missing a
cc2650_sensortag.yaml.  As such when we build all the test we get a few
build errors that we also fixed up.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-06-23 15:05:10 -05:00
Siddharth Chandrasekaran f7705af136 boards: arm: Add support for STM32 Minimum Development Board
Add configuration, documentation, pinmux, fixup and dts support for
STM32F103x8 based Minimum System Development board.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2017-06-23 15:05:10 -05:00
Siddharth Chandrasekaran 09fb996c70 arm: stm32f1: Add support for STM32F103x8 SoC
Add configuration and memory definitions to support STM32F103x8
Medium-density performance line SoC with 64 KB Flash.

Merge multiple files into single Kconfig.defconfig.stm32f103xx

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2017-06-23 15:05:10 -05:00
Michel Jaouen a868fdb13d arm: soc: stm32: f3: add MPU capability
Since not all socs from f3 series (i.e stm32f334x8 no MPU) have MPU
capability, add capability only for MPU capable socs in Kconfig.soc

JIRA: ZEP-2220

Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
2017-06-23 15:05:10 -05:00
Michel Jaouen 5cdfe0fcb7 arm: soc: stm32: l4: add MPU capability for series
Since all l4 socs support MPU, add MPU capability in KConfig.series

JIRA: ZEP-2220

Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
2017-06-23 15:05:10 -05:00
Michel Jaouen 1dadfaa3b4 arm: soc: stm32: make mpu f4 config useable for other family
As other stm32 series support MPU, move common file in a file tree
useable by socs from other series

JIRA: ZEP-2220

Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
2017-06-23 15:05:10 -05:00
Savinay Dharmappa ce1add260b dts: x86: Add dts support for x86
patch adds necessary files and does the modification to the existing
files to add device support for x86 based intel quark microcontroller

Signed-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>
2017-06-22 10:23:39 -05:00
Leandro Pereira d19252a46d arch: xtensa: Use CONFIG_SIMULATOR_XTENSA to set XT_{BOARD,SIMULATOR}
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-21 18:09:13 -04:00
Leandro Pereira 0e08b946de soc: esp32: Define __start as a C function
The first stage bootloader, part of the ESP32 ROM, already sets up
a stack that's sufficient to execute C programs.  So, instead of
implementing __stack() in assembly, do it in C to simplify things
slightly.

This ESP32-specific initialization will perform the following:

  - Disable the watchdog timer that's enabled by the bootloader
  - Move exception handlers to IRAM
  - Disable normal interrupts
  - Disable the second CPU
  - Zero out the BSS segment

Things that might be performed in the future include setting up the
CPU frequency, memory protection regions, and enabling the flash
cache.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-21 12:35:49 -04:00
Leandro Pereira 4ca586e62d arch: xtensa: Use Zephyr configuration options
Unconditionally use CONFIG_SIMULATOR_XTENSA to determine if XT_SIMULATOR
or XT_BOARD should be defined.

If CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, also define XT_CLOCK_FREQ.  This
isn't ideal as the clock frequency might be changed in runtime and this
effectively makes it a constant.

Until we can control the clock frequency in runtime, this will suffice.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-21 12:35:49 -04:00
Ivan Grokhotkov d58d5d1265 xtensa: esp32: configure default UART using ROM functions
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-21 12:35:49 -04:00
Ivan Grokhotkov f7005105e9 xtensa: esp32: place .rodata into DRAM
Until ESP32’s flash cache is utilized, .rodata must be stored in RAM.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-21 12:35:49 -04:00
Leandro Pereira 37ea77173c drivers: esp32: Add minimal UART driver based on ROM routines
This is a minimal driver enabling console output during the port
bringup.  While the driver works, only one of the three UART devices
are supported, and there isn't any way to change any parameters or
use interrupts.  This will most likely be superceded by a proper
driver after the port has matured.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-21 12:35:49 -04:00
Leandro Pereira 88790ae71d arch: xtensa: Add ESP32 SoC
Due to the configurable nature of the Xtensa platform, the generic name of
"LX6" cannot be used to describe an SoC as far as Zephyr goes.  So ESP32 is
defined both as a SoC and as a board.

This is based on work by Rajavardhan Gundi.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-21 12:35:49 -04:00
Anas Nashif 397d29db42 linker: move all linker headers to include/linker
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-18 09:24:04 -05:00
Geoffrey Le Gourriérec fdf1785775 arm: Add support for TI's CC2650 SoC.
Add support in arch/arm/soc/ti_simplelink, along with support
for CC32xx SoC.

Signed-off-by: Geoffrey Le Gourriérec <geoffrey.legourrierec@smile.fr>
2017-06-16 16:18:12 -04:00
Geoffrey Le Gourriérec 6341258ef5 drivers: serial: uart_stellaris: Remove UART_IRQ_FLAGS
We always have UART_IRQ_FLAGS set to 0, so just call IRQ_CONNECT with a
0 argument for the flags, and remove the UART_IRQ_FLAGS.  This is
towards support for using the driver on the TI CC2650.  (we add a
comment about that as well).

Signed-off-by: Geoffrey Le Gourriérec <geoffrey.legourrierec@smile.fr>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-06-16 16:18:12 -04:00
Piotr Mienkowski c1c1ce3cbb arch: same70: Fix ERASE pin configuration
Correct code that allows to disable ERASE pin functionality
during boot.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-06-16 16:18:12 -04:00
Maureen Helm 257e22bf38 arm: nxp: mpu: Fix region descriptor 0 attributes
Clearing fields in the region descriptor attributes doesn't always have
the expected effect of revoking permissions. In the case of bus master
supervisor mode fields (MxSM), setting to zero actually enables read,
write, and execute access.

When we reworked handling of region descriptor 0, we inadvertently
enabled execution from RAM by clearing the MxSM fields and enabling the
descriptor. This caused samples/mpu_test run to throw a usage fault
instead of an MPU-triggered bus fault.

Fix this by setting all the MxSM fields to 2'b11, which gives supervisor
mode the same access as user mode.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-06-16 16:18:12 -04:00
Adithya Baglody be1cb961ad tests: benchmark: boot_time: Reading time stamps made arch agnostic
1. Changed _tsc_read() to k_cycles_get_32(). Thus reading the
time stamp will be agnostic of the architecutre used.
2. Changed the variable names from *_tsc to *_time_stamp.

JIRA: ZEP-1426

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-06-16 07:37:37 -05:00
Adithya Baglody 05c9dd08b0 quark_se: MMU: Add linker support for MMU page table generation.
Add a separate section in the linker to place the MMU configuration
information. This location is read by the gen_mmu.py script to
create the actual page tables.

JIRA: ZEP-2095

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-06-13 11:36:54 -04:00
Adithya Baglody aab1c1f63c quark_se: MMU: Memory regions for arduino 101(quark_se)
Define the memory regions needed to generate boot time page tables.

JIRA: ZEP-2097

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-06-13 11:36:54 -04:00
Adithya Baglody 43dfd98469 kernel: x86: MMU: Enable MMU at boot time.
In crt0.S the MMU is initialized. It uses the statically build
page tables. Here 32-bit paging scheme is used, thereby each page
table entry maps to a 4KB page. The valid regions of the memory are
specified by SOC specific file(soc.c).

JIRA: ZEP-2099

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-06-13 11:36:54 -04:00
Adithya Baglody 576c1ebba2 qemu: MMU: Memory regions for qemu_x86
Define the memory regions needed to generate boot time page
tables.

JIRA:ZEP-2098

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-06-13 11:36:54 -04:00
Adithya Baglody 83644a493e kernel: x86: MMU: Build system support for x86 MMU
Makefile rule to create the MMU page tables at boot time. This
rule invokes the gen_mmu.py script to create a binary which is
then placed into the kernel image using objcopy.
Makefile.mmu is included only when CONFIG_X86_MMU is enabled.

JIRA: ZEP-2095

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-06-13 11:36:54 -04:00
Adithya Baglody 9bbf5335b9 kernel: x86: MMU: Macros & Linker scripts for Boot time table creation
Macro is used to create a structure to specify the boot time
page table configuration. Needed by the gen_mmu.py script to generate
the actual page tables.

Linker script is needed for the following:
     1. To place the MMU page tables at 4KByte boundary.
     2. To keep the configuration structure created by
        the Macro(mentioned above).

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-06-13 11:36:54 -04:00
Adithya Baglody 569c6e5203 kernel: MMU: kconfig definition to enable the MMU on x86.
Kconfig definition for enabling the memory management Unit
on x86 based platforms.

JIRA: ZEP-2093

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-06-13 11:36:54 -04:00
Michael R Rosen b5d4a25a11 arc: fix balign position to properly 4byte align global vars
The .balign directives were not working correctly in their
previous positions as the directive was applying to the section
before the variable's section, causing in some builds the
variables to be misaligned, and accesses to them causing faults.
With the alignments after the section declaration, the variables
will now be aligned as specified. Any future variable declarations
should use this form instead to ensure proper alignment.

Signed-off-by: Michael R Rosen <michael.r.rosen@intel.com>
2017-06-12 23:33:31 -04:00
David B. Kinder 9faa5f2033 doc: spelling fixes in Kconfig files
regular spelling check on Kconfig.* files

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-06-12 19:40:51 -04:00
Maureen Helm 1f3f440b22 arm: nxp: mpu: Fix off-by-1 error in region index calculation
Both the ARM and NXP MPU drivers incorrectly calculated the region index
by assuming the region type (e.g., THREAD_STACK_GUARD_REGION) was
zero-indexed, when in reality it is one-indexed. This had the effect of
wasting one region.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-06-12 11:40:12 -05:00
Maureen Helm bacbea6e21 arm: nxp: mpu: Rework handling of region descriptor 0
The NXP MPU requires special handling of region descriptor 0 to
guarantee that the debugger has access to the entire address space. It
does not allow writes from the core to affect the start or end
addresses, or the permissions associated with the debugger.

The original implementation of this driver attempted to work around
region descriptor 0, resulting in an off-by-1 error caught by Coverity.

Instead, define region descriptor 0 explicitly in the mpu_regions array,
and add some asserts to ensure that one doesn't try to change its start
or end addresses. This has an added benefit such that more permissions
can be enabled in region 0 if desired, whereas the previous
implementation always forced all writable permissions to be cleared.

Coverity-CID: 170473
Jira: ZEP-2258

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-06-12 11:40:12 -05:00
Maureen Helm d2e38decf0 arm: nxp: mpu: Return constant number of mpu regions
The original implementation of _get_num_regions() parsed the CESR[NRGD]
register field to determine the number of mpu region descriptors
implemented in hardware. There was a possible path in the code to return
zero, which would cause underflow later on in arm_core_mpu_configure().
Coverity complained despite an assert to catch this condition. Instead,
use a preprocessor macro from mcux that defines the number of mpu region
descriptors.

Coverity-CID: 169811
Jira: ZEP-2208

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-06-12 11:40:12 -05:00
Anas Nashif 243671bcdb samples: ipm: fix macro name
replace undefined K_STACK_DECLARE with K_THREAD_STACK_DEFINE.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-09 22:36:23 -04:00
Andrew Boie 567c6c7683 misc: use K_THREAD_STACK_DEFINE macros
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Andrew Boie e3550a29ff stack_sentinel: hang system on failure
Stack sentinel doesn't prevent corruption, it just notices when
it happens. Any memory could be in a bad state and it's more
appropriate to take the entire system down rather than just kill
the thread.

Fatal testcase will still work since it installs its own
_SysFatalErrorHandler.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-08 13:49:36 -05:00
Andrew Boie 998f905445 arches: declare _SysFatalErrorHandler __weak
This function is intended to be easily overridable by applications.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-08 13:49:36 -05:00
Andrew Boie ae1a75b82e stack_sentinel: change cooperative check
One of the stack sentinel policies was to check the sentinel
any time a cooperative context switch is done (i.e, _Swap is
called).

This was done by adding a hook to _check_stack_sentinel in
every arch's __swap function.

This way is cleaner as we just have the hook in one inline
function rather than implemented in several different assembly
dialects.

The check upon interrupt is now made unconditionally rather
than checking if we are calling __swap, since the check now
is only called on cooperative _Swap(). The interrupt is always
serviced first.

Issue: ZEP-2244
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-08 13:49:36 -05:00
chunlin e125e5b9c6 arm: core: mpu: Prevent updating unexpected region
The REGION bits (bit[3:0]) of MPU_RBAR register can specify the number
of the region to update if the VALID bit (bit[4]) is also set.

If the bit[3:0] of "region_addr" are not zero, might cause to update
unexpected region. This could happen since we might not declare stack
memory with specific alignment.

This patch will mask the bit[4:0] of "region_addr" to prevent updating
unexpected region.

Signed-off-by: Chunlin Han <chunlin.han@linaro.org>
2017-06-06 12:21:21 -05:00
Andrew Boie 6d4763129d riscv32: update time slice before swap
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-02 14:47:01 -04:00
Andrew Boie 7b7fbf851e nios2: reset timeslice on interrupt-induced swap
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-02 14:47:01 -04:00
Andrew Boie 3989de7e3b kernel: fix short time-slice reset
The kernel tracks time slice usage with the _time_slice_elapsed global.
Every time the timer interrupt goes off and the timer driver calls
_nano_sys_clock_tick_announce() with the elapsed time, this is added to
_time_slice_elapsed. If it exceeds the total time slice, the thread is
moved to the back of the queue for that priority level and
_time_slice_elapsed is reset to zero.

In a non-tickless kernel, this is the only time _time_slice_elapsed is
reset.  If a thread uses up a partial time slice, and then cooperatively
switches to another thread, the next thread will inherit the remaining
time slice, causing it not to be able to run as long as it ought to.

There does exist code to properly reset the elapsed count, but it was
only compiled in a tickless kernel. Now it is built any time
CONFIG_TIMESLICING is enabled.

Issue: ZEP-2107
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-02 14:47:01 -04:00
Florian Vaussard 6ad43279ec arm: stm32f4: Add basic support for STM32F412
Add necessary Kconfig and minimal device tree in order to support
STM32F412ZG variant as found on the Nucleo STM32F412 board.

Origin: Original

Change-Id: Ic98a686f478ce551dc6101466ed0cf16924109e8
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-06-02 14:11:13 -04:00
Erwan Gouriou 9413c8ba4d stm32: clean up after completion of transition to ll Clock control
Following migration of stm32f1xx series clock control driver to
STM32Cube LL API, cleanup stm32 code base in order to take into
account that this is the only clock driver available for stm32
family.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-06-02 14:11:13 -04:00
Erwan Gouriou f2e8a21d7f stm32f1xx: remove references to native driver
Following introduction of stm32cube LL based clock control driver,
remove references to former native driver.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-06-02 14:11:13 -04:00
Erwan Gouriou e1a90583d4 drivers: clock_control: provide LL based driver to stm32f1xx series
Align stm32f1xx series clock driver to other parts of stm32 family.
Driver support both Connectivity and Density lines of stm32f1 series,
that are based on different Reset and Clock Control architectures.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-06-02 14:11:13 -04:00
Florian Vaussard 3540f03ef3 stm32f4: mpu: Add support for 1.5MB Flash / 320kB SRAM variants
The STM32F413ZH has 1536kB of Flash and 320kB of SRAM. This
configuration is currently not supported by ST MPU driver, so fill in
the blanks.

Note: The MPU does not support region size that is not a power-of-2 (see
the SIZE field in the MPU_RASR register). This is a problem for our
1536kB Flash region, so it was rounded up to the nearest choice. This is
possible because the memory in the range 0x0818000 - 0x0FFFFFFF is
"Reserved" and thus not mapped anyway.

Change-Id: If0c3d1db564ca45e77f8b5bafa2afdbafa85b40f
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-06-02 14:11:13 -04:00
Piotr Mienkowski b686102465 arch: sam3x: Fix TWI pin naming
SAM3X has TWI module, not TWIHS. Pin names are corrected accordingly.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-06-02 14:11:13 -04:00
Andrew Boie a2156fec2c arm: implement __svc on Cortex M0
This is needed for irq_offload() and k_oops()/k_panic()

Issue: ZEP-2221
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-02 02:17:32 -04:00
Anas Nashif b330e0e4a9 Revert "x86: call gen_idt with $ZEPHYR_BASE too"
This reverts commit 37f4178f58.

This change builds gen_idt in the zephyr project tree instead of
building it in outdir of the application. The build process should all
happen inside outdir and no binaries should be placed in the zephyr
tree.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-01 10:26:57 -04:00
Vinayak Kariappa Chettimada 1084165158 arch: arm: Fix compile error on ARMv6-M SoCs with TICKLESS_KERNEL
pop {lr} instruction is not supported in ARMv6-M, fixed by
using pop {r0}; mov lr, r0; instructions.

Jira: ZEP-2222

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-06-01 08:00:46 -04:00
Michael Scott b4b3e56a09 arm: soc: nordic nRF52: Add MPU support
We now have generic ARM M4 MPU support added to Zephyr.
Let's enable it for use with Nordic nRF52 chips.

Memory Layout was generated from Section 8.3 "Memory
Map" of nRF52 Product Specifications (for both nRF52832
and nRF52840):
0x00000000: Flash
0x10000000: Factory Information Config Registers
0x10001000: User Information Config Registers
0x20000000: SRAM
0x40000000: APB Peripherals
0x50000000: AHB Peripherals
0xE0000000: ARM M4 Private Peripheral Registers

NOT Configured:
0x60000000: External RAM
0x80000000: External RAM
0xA0000000: External Device
0xC0000000: External Device

NOTE: More work will be needed for future Nordic MWU (Memory
Watching Unit) support.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-05-28 09:18:54 -05:00
Justin Watson 145ef259c0 arch: arm: Fix SoC issues with Atmel SAM4S series.
Signed-off-by: Justin Watson <jwatson5@gmail.com>
2017-05-28 09:18:54 -05:00
Vincenzo Frascino 68f3b71b5d arm: core: mpu: Add core support to NXP MPU
This patch add arm core MPU support to NXP MPU driver.

With this feature it is now possible to enable stack guarding on NXP
MPUs.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-28 09:18:54 -05:00
Johan Hedberg 9516d63836 Bluetooth: Remove support for NBLE
NBLE has been deprecated for a few releases now and can be removed.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-05-25 09:03:16 -07:00
Tomasz Bursztyka 62941365b0 arch/x86/quark_se: Let the possibility to use native SPI driver
Set the right definitions to be able to use SPI_DW instead of SPI_QMSI.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-05-19 18:52:25 -04:00
Anas Nashif ce881890e3 arc: em7d/em9d: fix typo in soc flags
fixed typo: mnormm -> -mnorm

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-05-19 11:09:42 -04:00
Neil Armstrong a9183cd518 flash: Rework and add flash device support for STM32L4x SoCs
The STM32L4x SoCs embeds a slightly different embedded flash controller
from the STM32F4x SoCs.

This particular controller has the following properties :
 - Up to 2 512KiB banks divided in 2KiB pages
 - Flash can be accessed in any sizes
 - Flash must be written in 64bit aligned 64bit double-words

The drivers/flash/flash_stm32f4x.c is refactored into a new common
drivers/flash/flash_stm32.c and drivers/flash/flash_stm32l4x.c is
created with the STM32L4x specific functions.

To ease the refactoring and keep common functions, the STM32L4x flash
headers are slightly modified to match the hardware reference naming
and solve compilation issues.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-05-19 10:06:48 -04:00
Piotr Mienkowski 77a88da4fc arch: same70: hide soc.h defines from assembler
Neither ASF nor CMSIS provide defines that can be processed by
the assembler. Exclude those from soc.h. Before this was done
incorrectly in board.h file.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-05-19 10:06:48 -04:00
Piotr Mienkowski ee66ee6c34 arch: sam3x: Use ASF library
This patch converts Atmel sam3x MCU series to use register
header files from Atmel Software Framework (ASF) library.
By using ASF different Atmel SAM MCU series can use common
device drivers.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-05-19 10:06:48 -04:00
Piotr Mienkowski 05d0726daf arch: atmel_sam: enhance gpio driver to support sam3x
This patch adds support for remaining Atmel SAM MCU series,
like sam3x to the common GPIO driver. After this update
full SAM MCU family should be supported by the driver.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-05-19 10:06:48 -04:00
Neil Armstrong 2ea6300f21 stm32f4: Add support for STM32F469XI
Add configuration, dtsi and memory configuration fixup for the
STM32F469XI High Performance SoC.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-05-19 10:06:48 -04:00
Justin Watson 7b71d88ddd arch: arm: Convert Atmel SAM4S series MCU to use ASF
Signed-off-by: Justin Watson <jwatson5@gmail.com>
2017-05-19 10:06:48 -04:00
Neil Armstrong d6c8d819bd arm: stm32l4: Add configuration and dts for STM32L496
Add configuration and dts for the STM32L496 SoC STM32L4 variant.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-05-19 10:06:48 -04:00
Huaqi Fang 2bcd17e1af arc: Fix copyright year mistake in soc.h of arc em7d, em9d, em11d
Change 2016 to 2016-2017. I need to provide the starting date in
copyright header.

Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-05-19 15:58:41 +02:00
Wayne Ren 16028b5a38 arc: Fix the bug in _load_callee_saved_regs
load floating register first, or the value of r13 is not correct

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
2017-05-19 15:58:41 +02:00
Huaqi Fang 9bc69a46fa boards: Update arc em_starterkit support from 2.2 to 2.3
Here are the main changes:
* board: Update EMSK onboard resources such as Button, Switch and LEDs
  + update soc.h for em7d, em9d, em11d
  + update board.h for em_starterkit board
* arc: Add floating point support and code density support
  + add kconfig configuration
  + add compiler options
  + add register definitions, marcos, assembly codes
  + fixes in existing codes and configurations.
* arc: Update detailed board configurations for cores of emsk 2.3
* script: Provide arc_debugger.sh for debugging em_starterkit board
  + make BOARD=em_starterkit debug
    This will start openocd server for emsk, and arc gdb will connect
    to this debug server, user can run `continue` command if user just
    want to run the application, or other commands if debugging needed.
  + make BOARD=em_starterkit debugserver
    This will start an openocd debugger server for emsk, and user can
    connect to this debugserver using arc gdb and do what they want to.
  + make BOARD=em_starterkit flash
    This will download the zephyr application elf file to emsk,
    and run it.

Signed-off-by: Huaqi Fang <huaqi.fang@synopsys.com>
2017-05-19 15:58:41 +02:00
Andrew Boie 956089bcae xtensa: add config for toolchain version
Use TOOLCHAIN_VARIANT to indicate what XCC toolchain release
to use.

Set a reasonable default for the RG-2016.4 toolchain release.
D_108mini, D_212GP, D_233L are only in RF-2016.4, set that
appropriately.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-18 07:18:36 -04:00
Vincenzo Frascino 86aff09c77 arm: core: Integrate thread stack guard feature
This patch integrates the thread stack guard feature in the arm
Zephyr core.

Change-Id: I2022899cbc7a340be71cfaa52f79418292f93bae
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-16 09:28:06 -05:00
Vincenzo Frascino 726c7b545f arm: core: mpu: Add core MPU implementation
This patch adds the arm core MPU implementation.
This implementation currently supports the thread stack guard feature.

Change-Id: I8b3795ebaf1ebad38aaddc2ed2f05535ead2c09a
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-16 09:28:06 -05:00
Vincenzo Frascino b94c5b16fe arm: core: mpu: Add core support to ARM MPU
This patch add arm core MPU support to ARM MPU driver.

Change-Id: I5a61da4615ae687bf42f1c9947e291ebfd2d2c1d
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-16 09:28:06 -05:00
Vincenzo Frascino acc9fb29a3 arm: core: mpu: Add arm core MPU interface
This patch adds the arm core MPU interface, a common way to access the
pu functionalities by the arm zephyr kernel.

The interface can be divided in two parts:
- a core part that will be implemented by the arm_core_mpu driver and
  used directly by the kernel
- a driver part that will be implemented by the mpu drivers and used by
  the arm_core_mpu driver

Change-Id: I590bd284abc40d98b06fdf1efb5800903313aa00
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-16 09:28:06 -05:00
Vincenzo Frascino adf0bf90b6 arm: soc: nxp k6x: Add Initial support for NXP MPU
This patch adds initial MPU support to NXP K6x family.
The boot configuration prevents the following security issues:
* Prevent to read at an address that is reserved in the memory map.
* Prevent to write into the boot Flash/ROM.
* Prevent from running code located in SRAM.

This driver has been tested on FRDM-K64F.

Change-Id: I907168fff0c6028f1c665f1d3c224cbeec31be32
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-16 09:28:06 -05:00
Andrew Boie 286a2c875f xtensa: fix XCC build
XCC doesn't recognize the "I" compiler constraint but GCC does. Switch
to "i" which is understood by both.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-15 13:33:12 -04:00
Kumar Gala 26811defc7 arm: dts: Cleanup HAS_DTS
Now that all ARM platforms have a device tree we can move selecting of
HAS_DTS up and remove any !HAS_DTS cases, as well as setting in all the
defconfigs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-05-15 13:22:54 -04:00
Florian Vaussard cad822ab52 pinmux: stm32f4: Add pinmux for more UARTs
Add defines and pinmux arrays to support more UARTs on STM32F4.

Change-Id: Ib06c549bdb2b3d7065554a0a6d1a3d15441b29c9
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-05-15 13:22:54 -04:00
Florian Vaussard 55c477bb2c pinmux: stm32f4: Compile out unused pinmux
It is useless to include the pinmux for a peripheral if it is not
enabled in the Kconfig. This is unnecessary and it increases the size of
the binary.

Define macros that will default to void if the associated Kconfig is not
enabled.

Change-Id: I0857fcef335c75b8bb6d537fd859f93d5be4a228
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-05-15 13:22:54 -04:00
Florian Vaussard 4486ea0473 pinmux: stm32f4: Clean-up pinmux arrays
Clean-up the pinmux arrays as a preparatory work before adding more
pinmuxes.

This is achieved by the following two actions:
- Define the PAD macro to simplify the [x - 1] = y construct
- Reorder the declartions by bank / pin to make it easier to
  locate a pin among a high number of other pins, while minimizing the
  risk of conflict when two people add a new declaration for two
  different pins

Change-Id: I1ca0cc4f48bcd8cfd35b331e9821935f5c855876
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-05-15 13:22:54 -04:00
Florian Vaussard 0b9f6a25ed arm: stm32f4: Add basic support for STM32F413
Add necessary Kconfig and minimal device tree in order to support
STM32F413xH variants as found on the Nucleo STM32F413 board.

Origin: Original

Change-Id: I60230c240d6acb610f16a02c62048d448476e9c5
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-05-15 13:22:54 -04:00
Kumar Gala 04c8709355 soc: stm32f3/f4/l4: gpio: Fix unnecessary else statement
The bitfield determining the I/O direction already defines the pin
as either input or output, cannot be none or both at the same time

This issue was reported by Coverity

Coverity-CID: 151970

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-05-15 13:22:54 -04:00
Florian Vaussard b5ff4cdb6f arm: stm32f4: Do not enable USART1/USART2 by default
Not all the boards (for instance the Nuclo F412) use USART1 or USART2.
Let each board enable these USARTs when really used.

Change-Id: Idfe79c724bd7b1ab154310b4a8234b52eef2298d
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-05-15 13:22:54 -04:00
Florian Vaussard eba1327719 soc: stm32f429zi: finish SOC renaming
Commit 87893ddf7ad4 ("soc: stm32f429zi: rename SOC config flag") renamed
SOC_STM32F429XX to SOC_STM32F429XI but the text of the option should be
changed as well to reflect this restriction in scope.

Change-Id: I2627b59f805e73d6c8a3534e0feec71a4269c9ab
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-05-15 13:22:54 -04:00
Florian Vaussard fd5011ebf7 soc: stm32f407xg: finish SOC renaming
Commit 599149dfb831 ("soc: stm32f407xg: rename SOC config flag") renamed
SOC_STM32F407XX to SOC_STM32F407XG but the text of the option should be
changed as well to reflect this restriction in scope.

Change-Id: Id03529452f5ec7d7ffee214b152c4aa555e1208a
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-05-15 13:22:54 -04:00
Erwan Gouriou 8986f33559 soc: stm32f407xg: rename SOC config flag
Rename SOC_STM32F407XX to SOC_STM32F407XG to keep flash
size information.
Aim is to be able to distinguish flash size variants of
the SoC when needed (for instance in dts/arm/st/mem.h file).

Change-Id: I0afa16e86b7c99b9e685004f96beeb888f9e7568
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-05-15 13:22:54 -04:00
Erwan Gouriou 2a10920aaf soc: stm32f429zi: rename SOC config flag
Rename SOC_STM32F429XX to SOC_STM32F429XI to keep flash
size information.
Aim is to be able to distinguish flash size variants of
the SoC when needed (for instance in dts/arm/st/mem.h file)

Change-Id: Id188b7703d2bce0a3ded09132ff0f205efa9c143
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-05-15 13:22:54 -04:00
Erwan Gouriou 19a91c0272 soc: stm32l476rg: rename SOC config flag
Rename SOC_STM32L476XX to SOC_STM32L476XG to keep flash
size information.
Aim is to be able to distinguish flash size variants of
the SoC when needed (for instance in dts/arm/st/mem.h file)

Change-Id: I834bb5b83c24c39e90c0492a2b22a7c7802de361
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-05-15 13:22:54 -04:00
Neil Armstrong 558d50242d arm: stm32l432: Switch to STM32L432XC to retain flash size
The xC tag in the SoC reference indicates the flash size, use it in the
configuration to permit selection of correct flash size for dts.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-05-15 13:22:54 -04:00
Vincenzo Frascino 051da9fd4a dts: mps2_an385: Add ARM CMSDK support
This patch adds device tree support for ARM CMSDK IPs on MPS2
AN385.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-15 10:51:13 -05:00
Vincenzo Frascino df3cec7641 dts: v2m_beetle: Add GPIO support
This patch adds the ARM CMSDK GPIO support to the V2M Beetle
device tree.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-15 10:51:13 -05:00
Vincenzo Frascino f906e7b099 dts: v2m_beetle: Add DualTimer support
This patch adds the ARM CMSDK DualTimer support to the V2M Beetle
device tree.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-15 10:51:13 -05:00
Vincenzo Frascino 2fe95044c2 dts: v2m_beetle: Add Timer support
This patch adds the ARM CMSDK Timer support to the V2M Beetle device
tree.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-15 10:51:13 -05:00
Vincenzo Frascino 8219923c26 dts: v2m_beetle: Add WDOG support
This patch adds the ARM CMSDK WDOG support to the V2M Beetle device
tree.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-15 10:51:13 -05:00
Vincenzo Frascino 603c826fa4 dts: v2m_beetle: Generate Uart base addr
This patch enables the generation of the ARM CMSDK UART base address
from the device tree.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-15 10:51:13 -05:00
Andrew Boie 5dcb279df8 debug: add stack sentinel feature
This places a sentinel value at the lowest 4 bytes of a stack
memory region and checks it at various intervals, including when
servicing interrupts or context switching.

This is implemented on all arches except ARC, which supports stack
bounds checking directly in hardware.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-13 15:14:41 -04:00
Andrew Boie 9175d20ceb arc: fix CONFIG_ARC_STACK_CHECKING
- There's no clear need to disable frame pointers if this feature is
used, remove this directive.
- The 'top' and 'base' terms are reversed. The 'base' is the high
address of the stack. The top is the lowest address, where we cannot
push further down. Fixup member and offset names to correspond to how
these terms are used in hardware documentation.
- Use correct pointers for stack top location
- Fatal exceptions now go through _NanoFatalErrorHandler to report the
faulting ip and thread.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-13 15:14:41 -04:00
Andrew Boie 174f301147 build: simplfy how extra build steps are specified
For various reasons its often necessary to generate certain
complex data structures at build-time by separate tools outside
of the C compiler. Data is populated to these tools by way of
special binary sections not intended to be included in the final
binary. We currently do this to generate interrupt tables, forthcoming
work will also use this to generate MMU page tables.

The way we have been doing this is to generatea "kernel_prebuilt.elf",
extract the metadata sections with objcopy, run the tool, and then
re-link the kernel with the extra data *and* use objcopy to pull
out the unwanted sections.

This doesn't scale well if multiple post-build steps are needed.
Now this is much simpler; in any Makefile, a special
GENERATED_KERNEL_OBJECT_FILES variable may be appended to containing
the filenames to the generated object files, which will be generated
by Make in the usual fashion.

Instead of using objcopy to pull out, we now create a linker-pass2.cmd
which additionally defines LINKER_PASS2. The source linker script
can #ifdef around this to use the special /DISCARD/ section target
to not include metadata sections in the final binary.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-13 14:07:09 -04:00
Andrew Boie 3d3d6a85df x86: remove hacks to include functions
None of this is currently necessary, the spurious interrupt
stubs and exception entry code is included in the binary just
fine. To make matters worse, some data referenced lives in the
.intList section which is completely stripped out of the binary.

If in the future we find certain essential functions are being
garbage collected when they should not be, the proper way to
mitigate this is with KEEP() directives in the linker script.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-13 14:07:09 -04:00
Andrew Boie 51df312abc xtensa: merge crt1-*.S
We had two assembly files to prepare for entry into C domain,
one intended for the simulator and one intended for real boards.

- Both files merged into a single crt1.S for either simulated or real
  targets
- Extra logic to populate command line arguments from simulator removed,
  we don't use it.
- BSS zeroing logic from crt1-boards.S used
- Reference to missing reset-unneeded.S removed
- exit() implementation moved to fatal.c, now invokes a kernel panic
  if we are not running under the simulator

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-12 12:56:12 -04:00
Andrew Boie b7aa6b7bd0 xtensa: optionally build reset vector code
In real-world use-cases this isn't always needed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-12 12:56:12 -04:00
Anas Nashif f628c12b04 xtensa: rename SOC_SAMPLE_CONTROLLER
SOC_SAMPLE_CONTROLLER option name is too generic, make it Xtensa
specific to avoid confusion.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-05-12 07:00:04 -04:00
Andrew Boie d26cf2dc33 kernel: add k_thread_create() API
Unline k_thread_spawn(), the struct k_thread can live anywhere and not
in the thread's stack region. This will be useful for memory protection
scenarios where private kernel structures for a thread are not
accessible by that thread, or we want to allow the thread to use all the
stack space we gave it.

This requires a change to the internal _new_thread() API as we need to
provide a separate pointer for the k_thread.

By default, we still create internal threads with the k_thread in stack
memory. Forthcoming patches will change this, but we first need to make
it easier to define k_thread memory of variable size depending on
whether we need to store coprocessor state or not.

Change-Id: I533bbcf317833ba67a771b356b6bbc6596bf60f5
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 20:24:22 -04:00
Anas Nashif 09b239102a xtensa: xt-sim: mark it as a board with simulator features
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-05-11 16:51:56 -04:00
Max Filippov 4b8419e420 xtensa: drop references to C library
C library is not actually used by the xtensa port, we only need the
'exit' function. Implement 'exit' in crt1-* and drop remaining
references to the C library.

Change-Id: I8a562363956b4755a6b5baee7acf3726485e5ce3
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2017-05-11 16:51:56 -04:00
Max Filippov 0538dc1a1c xtensa: make sample_controller runnable on QEMU
Add QEMU_CPU_TYPE for the sample_controller, so that zephyr image could
be run on QEMU with sample_controller core.

Change-Id: Id9e97a43c4b7921142289dcf97ff782993ca0463
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2017-05-11 16:51:56 -04:00
Max Filippov 6a89999787 xtensa: use inline assembly instead of XT_* macros
XT_* macros are defined in xtensa HAL headers as xcc intrinsics. gcc
does not have any of these intrinsics. Replace XT_* macros with inline
assembly or provide gcc-compatible definitions.

Change-Id: If823ea8a7898a11a3a8363b17efdba27dee4c6a4
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2017-05-11 16:51:56 -04:00
Andrew Boie f57e79b6d5 xtensa: remove Kconfig.cores
This file is no longer used by the build system.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 12:47:23 -04:00
Andrew Boie 99c89e17e3 xtensa: fix coprocessor save area
A bad rebase of a patch that moved these defines around
unintentionally reverted a necessary change to the coprocessor
save area.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 12:47:23 -04:00
Vincenzo Frascino 255f19891a dts: mps2_an385: Initial device tree support
This patch adds the intial device tree support to V2M MPS2 AN385
platform.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-05-09 11:16:52 -04:00
Neil Armstrong 092be24061 arm: stm32l4: Add configuration and dts for STM32L432XX
Add configuration and dts for the STM32L432XX SoC STM32L4 variant.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
2017-05-08 15:03:15 -04:00
fallrisk 20f41814de arch: Add Atmel SAM4S SoC support
Added support for Atmel SAM4S (Cortex-M4) MCU:
- Kconfig files
- Devicetree files

Signed-off-by: Justin Watson <jwatson5@gmail.com>
2017-05-08 15:03:15 -04:00
fallrisk 44c421b4a3 boards: arduino_due: Added DTS to the Arduino Due.
Change-Id: I006f9d4080a1351534ede5cc601e43526c39aa83
Origin: Original
Signed-off-by: Justin Watson <jwatson5@gmail.com>
2017-05-08 15:03:15 -04:00
Piotr Mienkowski 38d8c863d4 arm: dts: Add DTS support for SAME70 SoC
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2017-05-05 16:44:41 -05:00
kontais 3b0b7671a0 stm32f4/arm_mpu_mem_cfg.h compile error fix
Signed-off-by: kontais <kontais@aliyun.com>
2017-05-05 10:13:08 -05:00
Justin Watson 558281b096 arch: sam3x: update Kconfig options after move to SAM SoC family tree
The files for the Arduino Due needed to be updated to use the new
configuration when the SoC moved from the atmel_sam3 directory to
the atmel_sam/sam3x directory.

Jira: ZEP-2067

Signed-off-by: Justin Watson <jwatson5@gmail.com>
2017-05-03 13:51:37 -04:00
Jon Medhurst 14ce362972 boards: mps2_an385: Enable I2C devices
The FPGA on the MPS2 board implements 4 SBCon devices for I2C which are
connected to:
- a touchscreen controller
- the audio device (for configuration)
- both shield connectors

Change-Id: I55ca985e18b45d68f5e7421c4768dfc9bf2fcb3f
Signed-off-by: Jon Medhurst <tixy@linaro.org>
2017-05-03 13:51:37 -04:00
Adithya Baglody d03b2496cd test: benchmarking: Timing metrics for the kernel
JIRA: ZEP-1822, ZEP-1823, ZEP-1825

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
2017-05-03 08:46:30 -04:00
Kumar Gala ac0bb050dd arm: dts: ti_lm3s6965: Add device tree support for Stellaris UART
Converted Stellaris UART driver over to utilize device tree generated
defines.  Added a yaml description for the uart, and converted over the
ti_lm3s6965 SoC & qemu_cortex_m3 board port over to utilize it.

Change-Id: Ie20844eb63d2c68eb59ad4160f7f5b5a35e2943b
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-28 15:26:40 -05:00
Kumar Gala f6284cfbec arm: dts: ti_lm3s6965: Add Device Tree Support
Introduce a simple device tree for the TI lm3s6965 SoC and QEMU
Cortex-M3 board port.  We get flash and memory base addresses and sizes
from the device tree as well as the ARM NVIC number of priority bits.

Change-Id: I4452b5543de7be55518997e54837ccbfd4f121df
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-28 15:26:40 -05:00
Florian Vaussard 45dde7eb3f arm: stm32f4: Reorder Kconfig options
Reorder config entries alphabetically to make it easier to add new ones.

Change-Id: Ib118405a150a408638232513fba7198b458ecfa7
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-04-28 15:26:39 -05:00
Kumar Gala a22e5924b5 arm: dts: nrf: Remove !HAS_DTS Kconfig bits
Now that all the nRF based board/SoCs have device trees, we can remove
the Kconfig bits that are now coming from device tree.

Change-Id: Ia1a870a50582d4109070d2833660f58fd6f8691f
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-28 15:26:39 -05:00
Kumar Gala ca3c7ec0a9 arm: dts: nrf: Add Device Tree Support for nRF51822 SoC & boards
Add device tree support for nRF51822 SoCs and Arduino 101-BLE,
Curie-BLE, BLE Nano, PCA10028-DK, and Quark-SE BLE boards. This
is minimal support for memory, flash, and UART.

Change-Id: I7e572bea537e384b6d66e520462f023ace0c9b35
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-28 15:26:39 -05:00
Kumar Gala 9b30a9b308 arm: dts: nrf: Fixup nRF52840-QIAA SoC support for device tree
Fixup the nRF52840-QIAA to allow getting its SRAM & FLASH sizes from
device tree.

Change-Id: I67ecd7da5f0472402064f158030d9f97f49d7d20
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-28 15:26:39 -05:00
Kumar Gala 62b0750499 arm: soc: ti_lm3s6965: remove dead code
Nothing calls _ScpMainOscEnable, so lets remove it and associated files
that aren't used anymore.

Change-Id: Ibe900d039c531c4da56baa673d309ee961b09e52
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-28 15:26:38 -05:00
Kumar Gala 62d2d362ac arm: nxp: kl2x: Move to using UART_MCUX_LPSCI for UART0
Cleanup soc code to enable UART_MCUX_LPSCI to support UART0.

Change-Id: I173febffcffc902f228946124e0434f122a67607
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-28 15:26:38 -05:00
Kumar Gala ed467a695a serial: mcux: Shim driver for LPSCI UART on KL25Z
Adds a shim layer around the mcux lpsci driver to adapt it to the Zephyr
serial interface.

Change-Id: I024f1605e3194f34bb57e8a121900e05b3085a82
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-28 15:26:38 -05:00
Erwan Gouriou eee56a7c10 soc: stm32l4xx: add support for STM32L475XG
Add support for STM32L475xG SoC as a preliminary for
Discovery IOT board support.
stm32l476.dtsi file is now including stm32l475.dtsi
since STM32L476 SoC is a STM32L475 SoC with LCD support

Change-Id: I7567255e4172231cbf4899474617ecae0cd68d64
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-28 15:26:38 -05:00
Erwan Gouriou 242ed389a3 stm32f4: Clean references to stm32f4 specific clock control
Following activation of stm32 common clock driver for stm32f4 series
remove references to stm32f4 specific driver.

Change-Id: I372a0ea046007bcb34944d6b2b8880077583b1d3
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-28 15:26:11 -05:00
Erwan Gouriou 80b7bec12c soc: stm32f4: Enable LL based clock control
This commit disables native stm32f4x clock control
driver and enables stm32 LL clock control driver
for stm32f4 family

Jira: ZEP-2039

Change-Id: I98ba6c89c4a3a1f39658c5808cd47a2d1f344130
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-28 15:26:11 -05:00
Erwan Gouriou fda01e52c2 drivers: clock control: Provide LL based clock control for stm32f4 series
This commit enables STM32Cube LL based driver for stm32f4 series.
This generic driver provides a unified API to clock driver for all
stm32 series.
LL API allows driver to be lightweight and to keep genericity across
stm32 family to ease further devlopment and maintenance.

Change-Id: Ie31ae8f433313787f9c9eda77de41925721d54dd
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2017-04-28 15:06:41 -05:00
Gil Pitney c73a1eb806 cc3220sf: Add support for the TI CC3220SF SoC
The CC3220SF is a replacement for the CC3200 SoC, comprising
a network coprocessor and Cortex-M4 MPU.

This leverages the CC3220 SDK driver peripheral library in ROM,
and some files built from ext/hal/ti/.

Jira: ZEP-1958

Change-Id: I892b212c178e05d84ff1d716dde593ced653ae6d
Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2017-04-28 15:06:41 -05:00
Mazen NEIFER 51eb081311 xtensa port: Fixed crash on interrupt handlers when logger is enabled.
This fixes ZEP-1955. The issue was that the interrupt stack frame only
allocates 4 registers. This means that if any window overflow happens,
only 4 registers can be saved. This implies that the interrupt handler
can not call functions other than using call4. If this rule is not
honored, then it will result in the registers being overwriting other
context information and thus a stack corruption.

The fix consists on using call4 for calling even t logger function,
which is by the way more optimal as the interrupt handler does not need
to save more than 4 registers when these functions are called.

Issue: ZEP-1955

Change-Id: Iacea626443d1d61d95a52253ac8ff15fc3722d2c
Signed-off-by: Mazen NEIFER <mazen@nestwave.com>
2017-04-28 15:49:01 +00:00
Andrew Boie 8bfee13cd3 x86: define MMU data structures
This was more or less transplanted from old Viper codebase (Zephyr's
ancestor which supported paging) and adapted to current coding style.

Change-Id: I203e631f1dcd5f2fb4e9a2fa9339fc7521c7962d
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-04-27 17:46:54 +00:00
Ramesh Thomas 89ffd44dfb kernel: tickless: Add tickless kernel support
Adds event based scheduling logic to the kernel. Updates
management of timeouts, timers, idling etc. based on
time tracked at events rather than periodic ticks. Provides
interfaces for timers to announce and get next timer expiry
based on kernel scheduling decisions involving time slicing
of threads, timeouts and idling. Uses wall time units instead
of ticks in all scheduling activities.

The implementation involves changes in the following areas

1. Management of time in wall units like ms/us instead of ticks
The existing implementation already had an option to configure
number of ticks in a second. The new implementation builds on
top of that feature and provides option to set the size of the
scheduling granurality to mili seconds or micro seconds. This
allows most of the current implementation to be reused. Due to
this re-use and co-existence with tick based kernel, the names
of variables may contain the word "tick". However, in the
tickless kernel implementation, it represents the currently
configured time unit, which would be be mili seconds or
micro seconds. The APIs that take time as a parameter are not
impacted and they continue to pass time in mili seconds.

2. Timers would not be programmed in periodic mode
generating ticks. Instead they would be programmed in one
shot mode to generate events at the time the kernel scheduler
needs to gain control for its scheduling activities like
timers, timeouts, time slicing, idling etc.

3. The scheduler provides interfaces that the timer drivers
use to announce elapsed time and get the next time the scheduler
needs a timer event. It is possible that the scheduler may not
need another timer event, in which case the system would wait
for a non-timer event to wake it up if it is idling.

4. New APIs are defined to be implemented by timer drivers. Also
they need to handler timer events differently. These changes
have been done in the HPET timer driver. In future other timers
that support tickles kernel should implement these APIs as well.
These APIs are to re-program the timer, update and announce
elapsed time.

5. Philosopher and timer_api applications have been enabled to
test tickless kernel. Separate configuration files are created
which define the necessary CONFIG flags. Run these apps using
following command
make pristine && make BOARD=qemu_x86 CONF_FILE=prj_tickless.conf qemu

Jira: ZEP-339 ZEP-1946 ZEP-948
Change-Id: I7d950c31bf1ff929a9066fad42c2f0559a2e5983
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
2017-04-27 13:46:28 +00:00
Ramesh Thomas 62eea121b3 kernel: tickless: Rename _Swap to allow creation of macro
Future tickless kernel patches would be inserting some
code before call to Swap. To enable this it will create
a mcro named as the current _Swap which would call first
the tickless kernel code and then call the real __swap()

Jira: ZEP-339
Change-Id: Id778bfcee4f88982c958fcf22d7f04deb4bd572f
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
2017-04-27 13:46:26 +00:00
fallrisk 4792f363a4 arch: Moved atmel_sam3 to atmel_sam3x.
Found out that the SAM3 series is not a single series. There are actully
3 different series, 3U, 3A, and 3X.

Origin: Original
Jira: ZEP-2067

Change-Id: I61cdc826cc32dbdd25b5e6bafaada062c8ae8417
Signed-off-by: Justin Watson <jwatson5@gmail.com>
2017-04-26 21:36:01 +00:00
Andrew Boie 73abd32a7d kernel: expose struct k_thread implementation
Historically, space for struct k_thread was always carved out of the
thread's stack region. However, we want more control on where this data
will reside; in memory protection scenarios the stack may only be used
for actual stack data and nothing else.

On some platforms (particularly ARM), including kernel_arch_data.h from
the toplevel kernel.h exposes intractable circular dependency issues.
We create a new per-arch header "kernel_arch_thread.h" with very limited
scope; it only defines the three data structures necessary to instantiate
the arch-specific bits of a struct k_thread.

Change-Id: I3a55b4ed4270512e58cf671f327bb033ad7f4a4f
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-04-26 16:29:06 +00:00
fallrisk 94b44f03e1 arch: Moved Atmel SAM3 into the SAM SoC family tree.
Moved the Atmel SAM 3 from its own directory into
the directory tree laid out in arch/arm/soc/atmel_sam.

Origin: Original
Jira: ZEP-2067

Change-Id: I26a1a521dd7caa607c3e95a06cd574ee68ca59b8
Signed-off-by: Justin Watson <jwatson5@gmail.com>
2017-04-26 13:15:35 +00:00
Mazen NEIFER e87564bd88 xtensa port: Removed XRC_D2PM SoC configuration
This SoC, in its default configuration, does not have any SW IRQ below
the EXCM level. This make it unsuitable to use irq_offload() and thus
almost untestable.

Decision was made to remove this configuration in favorof custom one
XRC_D2PM_5swIrq, which is the same core but with additional 4 SW IRQs
of level 1 and an additional timer.

Issue: ZEP-2029

Change-Id: Iee4f8346aa9d610e14898444f78d28ef0ac4cef2
Signed-off-by: Mazen NEIFER <mazen@nestwave.com>
2017-04-26 09:50:44 +00:00
Vincenzo Frascino 5951e45580 soc: arm: stm32f4: Add Initial MPU Support
This patch adds initial MPU support to STM32F401XE.
The boot configuration prevents the following security issues:
* Prevent to read at an address that is reserved in the memory map.
* Prevent to write into the boot Flash/ROM.
* Prevent the application to access to the BootROM.
* Prevent from running code located in SRAM.

Change-Id: I4dc0669009bd5c0a829a69f8ff417c787b7043ed
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-04-25 21:53:19 +00:00
Vincenzo Frascino b125767fdb soc: arm: beetle: Add Initial MPU Support
This patch adds initial MPU support to ARM Beetle.
The boot configuration prevents the following security issues:
* Prevent to read at an address that is reserved in the memory map.
* Prevent to write into the boot Flash/ROM.
* Prevent from running code located in SRAM.

Change-Id: I64f1001369896fffb0647de6be605a95161c4695
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-04-25 21:53:17 +00:00
Vincenzo Frascino e37214062c arm: core: mpu: Add ARM MPU support
This patch adds an initial driver for the ARM MPU.
This driver has been tested on ARM Beetle and STM32F4.

Change-Id: I2bc4031961ec5a1d569929249237646f4a349f16
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-04-25 21:53:17 +00:00
Vincenzo Frascino 0974496d52 arm: core: Add MPU parameter to the arm core
This patch add the Memory Protection Unit parameter to the arm core
configuration.

Change-Id: Ifee8cdd5738391a6f182e8d0382d27eeb8c546ba
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Signed-off-by: Marc Moreno <marc.morenoberengue@linaro.org>
2017-04-25 21:53:16 +00:00
Vincenzo Frascino 8f6d874f59 arm: soc: beetle: Add regions for mpu configuration
This patch adds the regions for the mpu configuration to the soc.h file.

Change-Id: Ifd1ce96eeb4731ae01f5171924af92b9e236a3dc
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Signed-off-by: Marc Moreno <marc.morenoberengue@linaro.org>
2017-04-25 21:53:15 +00:00
Inaky Perez-Gonzalez 37f4178f58 x86: call gen_idt with $ZEPHYR_BASE too
When calling scripts/gen_idt, if we don't have $ZEPHYR_BASE/scripts in
the path, it will fail, so we can call it with its full path to avoid
such need.

Change-Id: I47b340c9f3204ad8740c29e663e12082208bb13b
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2017-04-25 02:32:29 +00:00
Mazen NEIFER 35a48decfa xtensa port: Fixed compilation error introduced by recent changes.
The error was introduced by
    b8823c4efd

Change-Id: Ibf930107a7a690e0cb0851b7c247d524e3cb89e5
Signed-off-by: Mazen NEIFER <mazen@nestwave.com>
2017-04-24 20:41:46 +00:00
Christer Weinigel 89c23e1c72 soc: stm32f4xx: Document the flash latency values
Document the flash latency values by copying the relevant tables
from the reference manuals for each MCU.

Change-Id: Ieb2824ffd7634d917399e3e62146d9243b527f44
Signed-off-by: Christer Weinigel <christer@weinigel.se>
2017-04-24 20:16:29 +00:00
David B. Kinder 3561c73ece spell: Kconfig help typos: /arch
Fix misspellings in Kconfig help text and made spelling of
RX and TX consistent (from reviewer comments)

Change-Id: Ie9d4c3863cd210e7a17b50a85a7e64156b6bf3d7
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-24 20:14:53 +00:00
Christer Weinigel 73cf531975 soc: stm32f4xx: Make missing flash latency info a compile error
If the flash latency isn't set most STM32F4xx MCU's won't be able
to run from flash when the CPU frequency is changed.  Make this a
compile time error instead of an assert at runtime.

Change-Id: Ic3421194545f8f83bd6e00f0cd011306c8d1eedd
Signed-off-by: Christer Weinigel <christer@weinigel.se>
2017-04-24 20:14:13 +00:00
Kumar Gala 4f1e304f68 build: only build gen_idt on x86
Change-Id: I0401e2557c69f1e32ddedb79758c1dde781ea69b
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-24 03:17:16 +00:00
Andrew Boie 75caa2b084 arm: exception-assisted kernel panic/oops support
Put the reason code in r0 and make a SVC #2 call, which will be
propagated to _fatal_error_handler as an exception.

The _is_in_isr() implementation had to be tweaked a bit.  User-generated
SVC exception no longer just used for irq_offload(); just because we are
in it does not mean we are in interrupt context.  Instead, have the
irq_offload code set and clear the offload_routine global; it will be
non-NULL only if it's in use. Upcoming changes to support memory
protection (which will require system calls) will need this too.

We free up some small amount of ROM deleting _default_esf struct as it's
no longer needed.

Issue: ZEP-843
Change-Id: Ie82bd708575934cffe41e64f5c128c8704ca4e48
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-04-22 10:31:49 -04:00
Andrew Boie 7827b7bf4a x86: exception-assisted panic/oops support
We reserve a specific vector in the IDT to trigger when we want to
enter a fatal exception state from software.

Disabled for drivers/build_all tests as we were up to the ROM limit
on Quark D2000.

Issue: ZEP-843
Change-Id: I4de7f025fba0691d07bcc3b3f0925973834496a0
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-04-22 10:31:49 -04:00
Andrew Boie cdb94d6425 kernel: add k_panic() and k_oops() APIs
Unlike assertions, these APIs are active at all times. The kernel will
treat these errors in the same way as fatal CPU exceptions. Ultimately,
the policy of what to do with these errors is implemented in
_SysFatalErrorHandler.

If the archtecture supports it, a real CPU exception can be triggered
which will provide a complete register dump and PC value when the
problem occurs. This will provide more helpful information than a fake
exception stack frame (_default_esf) passed to the arch-specific exception
handling code.

Issue: ZEP-843
Change-Id: I8f136905c05bb84772e1c5ed53b8e920d24eb6fd
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-04-22 10:31:49 -04:00
Andrew Boie 3b662555d1 arm: work around QEMU issue with _IsInIsr
The ICSR RETTOBASE bit is improperly implemented in QEMU (the polarity
is flipped) and the fix for it has not yet made it into a QEMU release,
although it is present in upstream master branch.

The symptom is that if we are not in thread mode, the system always
believes were are in a nested exception state, causing _IsInIsr() to
always return true.

Skip the nested exception check if we are building for QEMU.

This is a workaround until SDK-54 is resolved.

Issue: SDK-54
Change-Id: I06eafcc85fb76a9b23b4ba85ed6e111a08516231
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-04-22 01:08:27 +00:00
Andrew Boie e09a04f068 arm: fix exception handling
For exceptions where we are just going to abort the current thread, we
need to exit handler mode properly so that PendSV can run and perform a
context switch. For ARM architecture this means that the fatal error
handling code path can indeed return if we were 1) in handler mode and
2) only wish to abort the current thread.

Fixes a very long-standing bug where a thread that generates an
exception, and should only abort the thread, instead takes down the
entire system.

Issue: ZEP-2052
Change-Id: Ib356a34a6fda2e0f8aff39c4b3270efceb81e54d
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-04-22 01:08:07 +00:00
Kumar Gala 96ee45df8d kernel: refactor thread_monitor_init into common code
We do the same thing on all arch's right now for thread_monitor_init so
lets put it in a common place.  This also should fix an issue on xtensa
when thread monitor can be enabled (reference to _nanokernel.threads).

Change-Id: If2f26c1578aa1f18565a530de4880ae7bd5a0da2
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 20:34:42 +00:00
Kumar Gala b8823c4efd kernel: Refactor common _new_thread init code
We do a bit of the same stuff on all the arch's to setup a new thread.
So lets put that code in a common place so we unify it for everyone and
reduce some duplicated code.

Change-Id: Ic04121bfd6846aece16aa7ffd4382bdcdb6136e3
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 20:34:42 +00:00
Kumar Gala 5742a508a2 kernel: cleanup use of naked unsigned in _new_thread
There are a few places that we used an naked unsigned type, lets be
explicit and make it 'unsigned int'.

Change-Id: I33fcbdec4a6a1c0b1a2defb9a5844d282d02d80e
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 20:34:41 +00:00
Kumar Gala cc334c7273 Convert remaining code to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.  This handles the remaining includes and kernel, plus
touching up various points that we skipped because of include
dependancies.  We also convert the PRI printf formatters in the arch
code over to normal formatters.

Jira: ZEP-2051

Change-Id: Iecbb12601a3ee4ea936fd7ddea37788a645b08b0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 11:38:23 -05:00