Commit graph

300 commits

Author SHA1 Message Date
Andy Ross d3376f2781 kernel, esp32: Add SMP kconfig flag and MP_NUM_CPUS variable
Simply define the Kconfig variables in this patch so they can be used
in later patches.  Define MP_NUM_CPUS correctly on esp32.  No code
changes.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-02-16 10:44:29 -05:00
Andy Ross 042d8ecca9 kernel: Add alternative _arch_switch context switch primitive
The existing __swap() mechanism is too high level for some
applications because of its scheduler-awareness.  This introduces a
new _arch_switch() mechanism, which is a simpler primitive that looks
like:

    void _arch_switch(void *handle, void **old_handle_out);

The new thread handle (typically just a stack pointer) is specified
explicitly instead of being picked up from the scheduler by
per-architecture code, and on return the "old" thread handle that got
switched out is returned through the pointer.

The new primitive (currently available only on xtensa) is selected
when CONFIG_USE_SWITCH is "y".  A new C _Swap() implementation based
on this primitive is then added which operates compatibly.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2018-02-16 10:44:29 -05:00
Anas Nashif a805c97edb kernel: enable boot banner by default
Have all samples and tests print the banner and timestamp. This can
easily be turned off if needed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-08 10:03:57 -05:00
Anas Nashif 94d034dd5e kernel: support custom k_busy_wait()
Support architectures implementing their own k_busy_wait.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-27 14:16:08 -05:00
Anas Nashif 429c2a4d9d kconfig: fix help syntax and add spaces
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-13 17:43:28 -06:00
Kumar Gala a2caf36103 kernel: Remove deprecated k_mem_pool_defrag code
Remove references to k_mem_pool_defrag and any related bits associated
with mem_pool defrag that don't make sense anymore.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-11-28 15:23:22 -05:00
Anas Nashif 54d19f2719 kconfig: update BOOT_BANNER help message
USAP is a thing of the past, remove it and update the help message of
this option.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-27 22:15:30 -05:00
Leandro Pereira b007b64d30 kernel: Add option to ensure writable pages are not executable
This adds CONFIG_EXECUTE_XOR_WRITE, which is enabled by default on
systems that support controlling whether a page can contain executable
code.  This is also known as W^X[1].

Trying to add a memory domain with a page that is both executable and
writable, either for supervisor mode threads, or for user mode threads,
will result in a kernel panic.

There are few cases where a writable page should also be executable
(JIT compilers, which are most likely out of scope for Zephyr), so an
option is provided to disable the check.

Since the memory domain APIs are executed in supervisor mode, a
determined person could bypass these checks with ease.  This is seen
more as a way to avoid people shooting themselves in the foot.

[1] https://en.wikipedia.org/wiki/W%5EX

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-02 13:40:50 -07: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 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
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
Andy Ross 53c859998d kernel: POSIX thread IPC support
Partial implementation of the IEEE 1003.1 pthread API, including
mutexes and condition variables in their default behaviors, and
pthread barrier objects.  The rwlock and spinlocks abstractions are
not supported in this commit (both only make sense in the presence of
multiple SMP processors).

Note that this is the IPC mechanisms only.  The thread creation API
itself is unsupported: Zephyr threads work differently from pthreads
and don't port cleanly in all cases.  Likewise the "_INITIALIZER"
macros from pthreads don't work cleanly here, and _DECLARE macros have
been provided to statically initialize pthread primitives in a manner
more native to Zephyr

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-08-15 19:42:07 -04:00
Kumar Gala bd9a1548ac ztest: reduce MAIN_STACK_SIZE stack to 512 bytes
Save some memory for small memory systems when running ztests.  We have
our own stack in ztest so we should be able to get away reducing down
the main stack.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-08-10 18:24:16 -04:00
Anas Nashif c6ba67fe3f kconfig: move dts Kconfigs to dts/
Those were placed under kernel/ for no good reason.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-03 07:19:29 -05:00
Maureen Helm 7bf0df3aec dts: Generate Kinetis adc settings from device tree
Adds common and Kinetis-specific adc device tree properties, and updates
all Kinetis SoC and board dts files to include adc nodes.

Jira: ZEP-1396

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-07-19 14:28:08 -05:00
Paul Sokolovsky b1e7481763 kernel: boot: Fix double prompt definition for CONFIG_BOOT_DELAY
This fixes Kconfig warning:

scripts/kconfig/conf --silentoldconfig Kconfig
zephyr/kernel/Kconfig:209:warning: prompt redefined

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-07-19 09:26:17 +03:00
Inaky Perez-Gonzalez c51f73f77f boot: add CONFIG_BOOT_DELAY option
Introduce a configurable boot delay option (defaulting to none) that
happens right after printing a boot delay banner, #before calling
main() in kernel/init.c:_main(), before taking timestamps for _main()
and once all the infrastructure is in place. Move also the boot banner
to happen after this delay.

The rationale for this is some boards will boot really fast and print
out some test case output in the serial port before the system that is
monitoring the serial port is able to read from the serial port.

This happens in MCUs whose serial port is embedded in a USB connection
which also is used to power the MCU board. When powering it on by
powering the USB port, there is a time it takes the host system to
detect the USB connection, enumerate the serial port, configure it and
load, start and read from the serial port. At this time, it might have
printed the output of the serial port.

While manually it is possible to press a reset button, on automation
setups this adds a lot of overhead and cabling or modifications to the
MCU that are easier (and cheaper) to overcome with this delay. Other
options (like using a separate serial line) might not be possible or
add a lot of cabling and cost, plus it'd also add extra build
configuration.

Change-Id: I2f4d1ba356de6cefa19b4ef5c9f19f87885d4dfd
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2017-07-18 08:31:45 +03:00
Marti Bolivar 4995820acf dts: i2c: fix build issue by defaulting HAS_DTS_I2C to n
Commit 1bc2fdc70 ("dts: arm: STM32 boards use DT to configure I2C")
added a new Kconfig option, HAS_DTS_I2C, which should be set when the
target supports configuration of I2C peripherals via Device Tree.

Currently, STM32 targets select this. However, the fact that
HAS_DTS_I2C has no default is causing prompting when building Zephyr
on other targets with DTS. To avoid this and allow builds to complete
as usual, have HAS_DTS_I2C default to n.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-07-12 10:40:28 -05:00
Yannis Damigos 1bc2fdc704 dts: arm: STM32 boards use DT to configure I2C
Configure I2C using DT for the following STM32 boards:

disco_l475_iot1
nucleo_f401re
96b_carbon
olimexino_stm32

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2017-07-07 10:31:34 -05:00
Andrew Boie 2dc207c987 kernel: add config for app/kernel split
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-29 07:46:58 -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
Vincenzo Frascino dfed8c4874 kernel: Add stack_info to k_thread
This patck adds the stack information into the k_thread data structure.
The information will be set by when creating a new thread (_new_thread)
and will be used by the scheduling process.

Change-Id: Ibe79fe92a9ef8bce27bf8616d8e0c878508c267d
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
2017-04-25 16:02:38 +00:00
David B. Kinder 61de8f892b spell: Kconfig help typos: /kernel /misc /subsys
Fix misspellings in Kconfig help text

Change-Id: I6eda081c7b6f38287ace8c0a741e65df92d6817b
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-22 01:04:56 +00:00
Anas Nashif 0b1d41d31d kernel: remove mentions of obsolete CONFIG_NANO_TIMERS
Change-Id: I0a2d6caae6d37b45968e61be8eaf7c4ebb6fdc46
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-20 12:27:36 +00:00
Anas Nashif af6bf1c9ed kernel: remove legacy semaphore groups support
Change-Id: Ia84ed11de3c88e714c275c42556c1dba2bfea3b6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-19 10:59:35 -05:00
Anas Nashif 45a7e5d076 kernel: remove legacy.h and MDEF support
Change-Id: I953797f6965354c5b599f4ad91d63901401d2632
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-19 10:59:35 -05:00
Anas Nashif 306e15e0a1 kernel: remove legacy kernel support
Change-Id: Iac1e21677d74f81a93cd29d64cce261676ae78a6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-19 15:48:37 +00:00
Anas Nashif 8e1dffd192 kernel: disable legacy APIs by default
First step to removing legacy APIs, this will be a wakeup call for this
still using legacy APIs before we completely remove them.

Change-Id: I32db62ff73efaa7eb5ab9ebc4d4fdc4a7c34ae56
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-03-29 16:08:01 -04:00
Florian Vaussard 8fcb780034 kernel: arm: Increase idle stack size to fix corruption by FP_SHARING
When enabling CONFIG_FP_SHARING on ARM, 64 extra bytes are necessary
on the stack of each task in order to save FPU registers S16 to S31.

In the case of the idle stack, the default value of 256 bytes is too
small. As described in ZEP-1470, when the idle task is scheduled out,
floating point registers are saved, which corrupts the stack frame
(especially the saved PC value). When scheduling the idle task, the
restored PC will jump to nowhere, leading to a Usage Fault.

Increase the size of the idle stack by 64 bytes to fix this issue.

JIRA: ZEP-1470

Change-Id: Ib800cd51e5189dda8bf59332db661c21399db3e3
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
2017-03-27 09:05:57 -05:00
Mazen NEIFER 5718676aad Xtensa port: Increased idle thread stack size to avoid stack overflow.
Xtensa port uses more stack than others. This was discussed with the team and
we agreed that this can be accepted for the first beta.
We will investigate this later to see how to avoid allocating coproc registers
for the system threads in order to reduce the stack overhead. However this
will not be before the port is considered stable.

Change-Id: Icd5b2b0ab68d0906b5408f35f081b100acabc010
Signed-off-by: Mazen NEIFER <mazen@nestwave.com>
2017-02-13 08:04:27 -08:00
Andy Gross bb063164aa dts: Add support for Device Tree
This patch adds support for using device tree configuration files for
configuring ARM platforms.

In this patch, only the FLASH_SIZE, SRAM_SIZE, NUM_IRQS, and
NUM_IRQ_PRIO_BITS were removed from the Kconfig options.  A minimal set
of options were removed so that it would be easier to work through the
plumbing of the build system.

It should be noted that the host system must provide access to the
device tree compiler (DTC).  The DTC can usually be installed on host
systems through distribution packages or by downloading and compiling
from https://git.kernel.org/pub/scm/utils/dtc/dtc.git

This patch also requires the Python yaml package.

This change implements parts of each of the following Jira:
ZEP-1304
ZEP-1305
ZEP-1306
ZEP-1307
ZEP-1589

Change-Id: If1403801e19d9d85031401b55308935dadf8c9d8
Signed-off-by: Andy Gross <andy.gross@linaro.org>
2017-02-10 18:13:58 +00:00
Ramesh Thomas 444ecafeee kernel: Remove redundant TICKLESS_IDLE_SUPPORTED option
This flag is no longer necessary and TICKLESS_IDLE will be
enabled by default if SYS_POWER_MANAGEMENT is enabled.

Jira: ZEP-1325
Change-Id: Ic6cd4b8dc0a17c6a413cabf6509b215a4558318d
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
2017-02-08 13:02:34 +00:00
Benjamin Walsh acc68c1e59 kernel: add k_poll() API
k_poll() is similar to the POSIX poll() API in spirit in that it allows
a single thread to monitor multiple events without actively polling
them, but rather pending for one or more to become ready. Such events
can be a direct event, or kernel objects (currently only semaphores and
fifos).

When a kernel object being polled on is ready, it is not "given" to the
poller: the poller must then acquire it via the regular API for the
object (e.g. k_sem_take()). Only one thread can poll on a particular
object at one time. These restrictions mean that k_poll() is most
effective when a single thread monitors multiple events that are not
subject for contention. For example, being the sole reader on multiple
fifos, or the only thread being signalled by multiple semaphores, or a
combination of both.

Change-Id: I7035a9baf4aa016fb87afc5f5c0f5f8cb216480f
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-02 00:30:00 +00:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

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

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

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Benjamin Walsh e669559010 kernel: fix main/work_q prios in coop/preempt-only modes
-1 is reserved for the idle thread in coop-only mode and -1 does not
exist as a priority in preempt-only mode.

With this change, the philosophers demo runs in preempt-only mode.

Change-Id: Id15a6eafc7582966deaf0db9ed6960b5da74be33
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-01-17 12:17:26 +00:00
Jean-Paul Etienne c76abeeae5 kernel: updated default IDLE_STACK_SIZE to 512 for RISCV32
Default 256 bytes stack size for idle task is not enough, as
stack grows/shrinks by a multiple of 16-bytes in the
RISC-V architecture.

Increase it to 512 bytes for RISCV32 architecture

Change-Id: I8321c48e4c1a877b252ba5561f3cbdd1fe475fc7
Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-01-13 19:54:35 +00:00
Kumar Gala a3629e838c kernel: have boot banner depend on console existing
For some of our samples/test we disable all console support, yet enable
BOOT_BANNER in tests/include/test.config, this can generate warnings
like:

warning: (BOOT_BANNER && BLUETOOTH_DEBUG_LOG && BLUETOOTH_DEBUG_MONITOR)
selects PRINTK which has unmet direct dependencies (CONSOLE_HAS_DRIVER)

So having BOOT_BANNER depend on CONSOLE_HAS_DRIVER cleans things up.

Change-Id: Ia6a6348fc08b0808ea6eaedb8c8833507f82c702
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-12 01:00:14 +00:00
Benjamin Walsh f955476559 kernel/arch: optimize memory use of some thread fields
Some thread fields were 32-bit wide, when they are not even close to
using that full range of values. They are instead changed to 8-bit fields.

- prio can fit in one byte, limiting the priorities range to -128 to 127

- recursive scheduler locking can be limited to 255; a rollover results
  most probably from a logic error

- flags are split into execution flags and thread states; 8 bits is
  enough for each of them currently, with at worst two states and four
  flags to spare (on x86, on other archs, there are six flags to spare)

Doing this saves 8 bytes per stack. It also sets up an incoming
enhancement when checking if the current thread is preemptible on
interrupt exit.

Change-Id: Ieb5321a5b99f99173b0605dd4a193c3bc7ddabf4
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2017-01-09 20:52:24 +00:00
Anas Nashif 70a2e138b7 kernel: add LEGACY_KERNEL option
Add global option for legacy configurations and enable by default for
backward compatibility. Disable option on tests and keep it on legacy
samples and tests.

Jira: ZEP-964
Change-Id: I0831e2aa74d438b1ac74eb762186cb220a504beb
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-09 19:42:13 +00:00
Benjamin Walsh 6209218f40 kernel: optimize ms-to-ticks for certain tick frequencies
Some tick frequencies lend themselves to optimized conversions from ms
to ticks and vice-versa.

- 1000Hz which does not need any conversion
- 500Hz, 250Hz, 125Hz where the division/multiplication are a straight
  shift since they are power-of-two factors of 1000.

In addition, some more generally used values are made to use optimized
conversion equations rather than the generic one that uses 64-bit math,
and often results in calling compiler intrinsics.

These values are: 100Hz, 50Hz, 25Hz, 20Hz, 10Hz, 1Hz (the last one used
in some testing).

Avoiding the 64-bit math intrisics has the additional benefit, in
addition to increased performance, of using a significant lower amount
of stack space: 52 bytes on ARM Cortex-M and 80 bytes on x86.

Change-Id: I080eb338a2637d6b1c6838c119af1a9fa37fe869
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-12-21 19:50:07 +00:00
Anas Nashif 3d8e86c12c drivers: eliminate nano/micro kernel usage
Jira: ZEP-1415

Change-Id: I4a009ff57edb799750175aef574a865589f96c14
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-21 18:45:02 +00:00
Anas Nashif 9463dc0b8f kernel: merge kernel Kconfigs into one
Reorganise and cleanup Kernel Kconfig options and group options of the
same area under Menus to ease readability and to have a better structure
when using menuconfig.

Change-Id: Ic6b39730297861367abd345ede35e41c046c099d
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:43 +00:00
Anas Nashif ed116ace6d kernel: kconfig: move power management options out
Change-Id: I5d7068ca7a5793bb3499f2bf2dc1abc4e337313e
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:37 +00:00
Anas Nashif 666afe5923 kernel: kconfig: move event logger options into file
Change-Id: I1e80375df583c5a5b6f04b216b54ed5b786e4655
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:37 +00:00
Anas Nashif bd10845996 kernel: kconfig: replace task/fiber with threads
Change-Id: I6d44cad8b2cf195137f04808167614390ee2ec55
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:36 +00:00
Anas Nashif 59a7de8ddf kernel: Isolate logger options
Move those into a separate Kconfig file and include them instead.

Change-Id: Ifa25d6ec92937080ad5970af7ca5c3f07ddec961
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:35 +00:00
Anas Nashif cfbe9b05a1 kernel: rename NANOKERNEL_TICKLESS_IDLE_SUPPORTED
rename NANOKERNEL_TICKLESS_IDLE_SUPPORTED to
TICKLESS_IDLE_SUPPORTED and remove nanokernel occurances in Kconfig
files.

Make TICKLESS_IDLE depend on hardware that supports it.

Change-Id: I6a2e4fb0f7cf4b45475b48e71823ea089ee98759
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-19 19:58:35 +00:00
Anas Nashif f11fe9eca5 kernel: set CONFIG_MDEF by default
Legacy applications still need that, otherwise kernel objects are not
configured correctly. Will be removed later.

Change-Id: I22df10e4adcc11f035f9813bea8c93dd1a560a1d
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-17 10:25:20 -05:00
Anas Nashif 418058a123 kernel: remove NANOKERNEL and MICROKERNEL configs
Those are legacy and not needed anymore.

Change-Id: I8113114fd60880b3f538612db7702f6129af0a06
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-14 13:45:52 +00:00
Anas Nashif 0859df1eca kernel: disable MDEF by default
Disable MDEF option and set it only in legacy projects.

Change-Id: I2e1f011eb1f876af929140e36f71f0efb5e955c1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-12 20:25:07 +00:00
Allan Stephens dd07b4779f kernel: Eliminate use of KERNEL_V2 configuration option
The unified kernel is now the only supported kernel, so this
option is unnessary. Eliminating this option also enables
the removal of some legacy code that is no longer required.

Change-Id: Ibfc339d643c8de16a2ed2009c9b468848b8b4972
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-11-12 12:04:39 +00:00
Anas Nashif 33118f9212 sensor: grove: use global sensor init priority
Change-Id: Ie56ee7e4b267b4dc67026be4531834f550134969
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-07 20:53:29 +00:00
Ricardo Salveti 81e7749cd5 kernel: event logger needs ring buffer
Change-Id: Ia5bb7e0c7cf7f94b03aad9826d5798af7813d0b5
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2016-10-06 12:56:19 +00:00
Peter Mitsis 96cb05ca50 unified: Add tickless idle support for x86 and ARM
Change-Id: I42d20355321f431900727768a0836ee18e96b667
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-10-04 20:02:50 +00:00
Dmitriy Korovkin 4223ba7964 unified: Add initialization priority level for kernel objects
The separate initialization priority provides more
flexibility when it's needed to arrange the initialization
sequence.

Change-Id: Ie1b7b48d282618f6d641320bf3b24f63716a7342
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-09-28 19:13:35 +00:00
Benjamin Walsh 7e6dacd65f unified/build: allow building the unified kernel
Added needed kconfig options. KERNEL_V2 selects MICROKERNEL to allow
middleware and application that differentiate between NANOKERNEL and
MICROKERNEL to run unmodified.

Build the unified/ kernel directory: do not touch the
nanokernel/microkernel directories.

Invoke sysgen for both microkernel and unified kernel. Only have sysgen
reference include/microkernel if building an original microkernel.

Change-Id: If74779146143434f7ee274bbef32d6c894b9f1a1
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh 851c537f29 kernel: add CONFIG_MDEF
Easier to build logic for when an MDEF file is to be parsed since
unified kernel needs to do it as well. Can also be useful for testing,
when toggling between static and dynamic objects in the same test case.

Change-Id: I51eb8919e18443516ade13caab04698d37d91803
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
David B. Kinder d748577706 doc: Fix terminology in Kconfig files for 'platform'
Completing the terminology change started with change 4008
by updating the Kconfig files processed to produce the
online documentation, plus header files processed by
doxygen.  References to 'platform' are change to 'board'

Change-Id: Id0ed3dc1439a0ea0a4bd19d4904889cf79bec33e
Jira: ZEP-534
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2016-08-18 21:17:29 +00:00
Kumar Gala 9ec2f3be80 Cleanup whitespace in Kconfig files
Convert leading whitespace into tabs in Kconfig files.  Also replaced
double spaces between config and <prompt>.

Change-Id: I341c718ecf4143529b477c239bbde88e18f37062
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-05-25 13:28:07 -05:00
Fabrice Olivero 128dcbbe13 kernel event logger: add possibility to use custom timestamp
By default, kernel event logger is using the system timer. But on
some platforms where the timer driver maintains the system timer
cycle accumulator in software, such as ones using the LOAPIC timer,
the system timer behavior leads to timestamp errors. For example,
the timer interrupt is logged with a wrong timestamp since the HW
timer value has been reset (periodic mode) but accumulated value not
updated yet (done later in the ISR).

This patch is adding the possibility to register a timer callback
function that will be used by the kernel event logger. For example,
on Quark SE, this allows using RTC or AON counter which accuracy is
sufficient and behavior more straight forward compared to system
timer.

Change-Id: I754c7557350ef29fc10701e62a35a5425e035f11
Signed-off-by: Fabrice Olivero <fabrice.olivero@intel.com>
2016-05-23 21:27:49 +00:00
Fabrice Olivero f39b9b85a1 kernel event profiler: add dynamic enable/disable/configure
Added CONFIG_KERNEL_EVENT_PROFILER_DYNAMIC flag for enabling that
capability. When set, nothing will be logged by default

Change-Id: I03552483e5a6bfd9e2505eda56908f0d0ae98618
Signed-off-by: Fabrice Olivero <fabrice.olivero@intel.com>
2016-05-12 02:19:19 +00:00
Daniel Leung 546b8ade37 refactor common driver initialization priorities
Most of the SoC and board Kconfig use the same values for
driver initialization priorities. So refactor them, and
discard duplicate ones.

The shared IRQ init priority was changed so that the kernel
default init and device init priorities can be standardized
across all SoC/boards. Same goes for DesignWare SPI driver.

This also changes the UART_CONSOLE_PRIORITY and
IPM_CONSOLE_PRIORITY to UART_CONSOLE_INIT_PRIORITY and
IPM_CONSOLE_INIT_PRIORITY, to standardize across all drivers.

Note that this does not take away the ability to override
those values. This just provides reasonable defaults such
that there is virtually no need to override.

Change-Id: Ibbd95d802c637df06f9a2fd48763ee1e6f4ff627
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-28 15:58:29 -07:00
Daniel Leung 8df10d4584 kconfig: untangle ordering and dependencies
There are two major issues with the kconfig:

() Some of the config options have incorrect dependencies inside help
   under menuconfig. For example, CONFIG_GPIO depends on BOARD_GALILEO.

() Since the SoC and board specific kconfig files are parsed first,
   the help screen would say, for example, CONFIG_SPI is defined at
   arch/arm/soc/fsl_frdm_k64f/Kconfig. This is incorrect because
   the actual config is defined in drivers/spi/Kconfig.

These cause great confusion to users of menuconfig/xconfig.

To fix these, the SoC and board defaults are now to be parsed last.

Note that the position swapping of defaults in this patch is due to
the fact the the default parsed last will be used.

And, spi_test is broken due to the fact that it requires
CONFIG_SPI_INTEL_PORT_1, but never enables it anywhere. This is
bypassed for now.

Origin: refactored and edited from existing files
Change-Id: I2a4b1ae5be4d27e68c960aa47d91ef350f2d500f
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-26 20:36:32 -04:00
Ramesh Thomas bb19e6f82f power_mgmt: Make names consistent with new RFC
Changed names of Kconfig flags, variables, functions, files and
return codes consistent with names used in the RFC. Updated
relevant comments to match the changes.

Origin: Original
Change-Id: Ie7941032d7ad7af61fc02928f74538745e7966e8
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-03-26 14:35:11 -04:00
Anas Nashif 6b8c6403ec kconfig: move kernel options close together
have micro and nano kernel next to eachother.

JIRA: ZEP-107
Change-Id: I8d6e4354cf6a8cdf1193c641b112a078cd7ec460
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-03-17 13:00:20 +00:00
Anas Nashif 207d0e799e kconfig: remove redundant EVENT_LOGGER option
KERNEL_EVENT_LOGGER selects EVENT_LOGGER which is then used to
enabling building. Skip EVENT_LOGGER and use KERNEL_EVENT_LOGGER
directly.

Change-Id: Ib9cf3a58b12bf4e78f264d8e8ac48a8104120c3b
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-03-14 16:50:51 -04:00
Anas Nashif a033c14dd1 kconfig: add power management options into a menu
Change-Id: I8e847c7f3305b63647f01a83a002a7962056732a
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-03-14 16:50:50 -04:00
Juan Manuel Cruz c15259aca1 debug: expose thread monitor in object tracing header
Exposes the CONFIG_THREAD_MONITOR functionality as part of the
object tracing header.

Change-Id: I2022a580df2cf33e543b980dc9c33b9adca3d3bf
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-03-11 22:07:16 +00:00
Yannis Damigos baddeadda1 arch: & kernel: Updated Kconfigs to remove errors in html generation
This patch updates some help sections to remove the "ERROR:
Unexpected indentation" messages during hmtl documentation
generation.

Change-Id: Idcdc17727b921b6145f9eb28d85975ceca273ce2
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2016-03-04 13:26:15 +00:00
Ramesh Thomas 3888735e0d adv_power:Advanced Power Management APIs
This is part of an ongoing development of power management
support in zephyr. This implementation builds upon an existing
hook interface and adds more enhancements. This was tested
with reference implementations on quark_d2000 and quark_se.

Change-Id: I28092b7ec90ce1f1cc661cf99ca88708910c8eb2
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
2016-02-12 11:20:32 -08:00
Benjamin Walsh 1ffdea1eb9 idle: add infrastructure for tickless support in nanokernels
An architecture that supports tickless idle in the nanokernel can allow
selecting TICKLESS_IDLE by forcing NANOKERNEL_TICKLESS_IDLE_SUPPORTED to
be enabled.

Change-Id: I4e45b619c599913d40b7bc19902094fb361b1e3b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:13 -05:00
Dirk Brandewie ad99c3f93b kconfig: remove useless tickless idle dependency
Re-applying this patch, which was lost when moving to kbuild:

	commit 64c0f13f9380 ("kconfig: remove useless tickless idle dependency")
	Author: Benjamin Walsh <benjamin.walsh@windriver.com>
	Date:   Mon May 11 15:13:46 2015 -0400

	kconfig: remove useless tickless idle dependency

	TICKLESS_IDLE_THRESH depends on TICKLESS_IDLE, which depends on
	ADVANCED_POWER_MANAGEMENT, which itself already depends on
	MICROKERNEL. There is thus no point in having TICKLESS_IDLE_THRESH
	depend on MICROKERNEL.

Change-Id: I95edcc7b927dd122b80f376c96233decdcc9afab
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:25:13 -05:00
Dmitriy Korovkin 57f2741e4f init: Implement fine-grained initialization policy
Put initialization priorities as device driver Kconfig
parameter.

Initialization priority value for each platform is defined
in the platform Kconfig file.

Drivers and platform code use SYS_DEFINE_DEVICE to add
and initialization function.

Change-Id: I2f4f3c7370dac02408a1b50a0a1bade8b427a282
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:54 -05:00
Anas Nashif 401c4da142 kconfig: do not set default for frequency
Force setting the value in the platform kconfig instead of defaulting
to 0.

Change-Id: Iceeb6346afc4217dd09d31c28898e3693b08f781
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:48 -05:00
Yonattan Louise 16ddcfa43d Fix kernel event logger sample for nanokernel-only systems.
This commit fixes the nanokernel sample of the kernel event logger
that shows the event messages for context switch and interrupt events.

Change-Id: I4e972adb06b81f2f548bbabe8cd6577af633001c
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:24:43 -05:00
Anas Nashif 6de1c20809 core: remove NO_ISRS feature
This option is not building and currently not supported, removing
it because there does not seem to be a use case for it.

Change-Id: Idb8ffedf83f43cffc68a01573c6f2d1a90fc40fb
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:42 -05:00
Yonattan Louise e378747706 Rename Profiler to Event Logger.
In order to have a name according to the functionality of the feature.
This commit rename any text, function and variable related with the
Profiler name to Event logger.

Change-Id: I4f612cbc7c37965c35a64f06cc3ce5e3249d90e5
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:24:41 -05:00
Peter Mitsis 079a0affee Remove kernel configuration option CUSTOM_SECURITY
The Kconfig option CUSTOM_SECURITY is not used anywhere.

Change-Id: Ifac00cd1234ff9498c2f977054a902e0153b6b28
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:24:34 -05:00
Javier B Perez Hernandez f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00
Dirk Brandewie feee30cc71 kernel: kconfig: remove CUSTOM_SECURTIY meta option
Change-Id: I6671760827aa1f0867be3f20a530ca50168ccc4b
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:20 -05:00
Dirk Brandewie 65c6120902 kernel: remove obsolete config option ENHANCED_SECURITY
This option is no longer used in any configuration

Change-Id: I2f9be9f286cff3f38722ae1fe807661a1f99cdcd
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:20 -05:00
Dirk Brandewie 05135ef318 kernel: remove Security options dependency on ENHANCED_SECURITY
ENHANCED_SECURITY is being used to enable security options the
projects that require security options explicitly enable these options
the dependency is not required.

Change-Id: Iec96e32bd7a5faa78672d355aad368f48b0ee087
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:20 -05:00
Dirk Brandewie b2cd0aae54 x86: change the default for ENHANCED_SECURITY to no
Change the default for ENHANCED_SECURITY to no in preparation for the
option to be removed.

Change-Id: Ic46730b187f361226064a3e205f48433b0bebdd7
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:20 -05:00
Andrew Boie 7c43992f22 profiler: use new ring buffer data structure
The profiler now uses the generic ring buffer. The dropped event
count is stored in the ring buffer's value field. The data size only
refers to the extra data attached to the message and NOT any internal
representation of metadata inside the ring buffer, the event_logger
APIs now pass this information along in dedicated parameters.

Change-Id: I1f168e6a05e8d937bf86b2a4cccecbb04b0118c6
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:15:34 -05:00
Andrew Boie f18f102feb nanokernel: add optional ring buffer data type
This patch is based on some code contributed by Dirk Brandewie.

This is a generic data structure for queuing data in a FIFO ring
buffer. Any given data enqueued is annotated with an app-specific
type identifier, and small integral value. Use of a data pointer
is optional if the necessary information can be conveyed in the
annotations. We want all the metadata to fit in a single DWORD.
The ring buffer always contains at least one free dword in the
buffer to correctly distinguish between full and empty queues.

Concurrency control is almost nonexistent; depending on usage,
apps may want to introduce the usage of semaphores and/or mutexes
to preserve the integrity of the ring buffer or provide notifications
when data is available.

Change-Id: I860262d2afc96db4476d4c695a92f7da355ab732
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:15:34 -05:00
Yonattan Louise 5c6ef8fdb5 Profile low condition events.
Add the sleep events point for x86 and ARM arquitectures that gives
information about when the CPU went to sleep mode, when it woke up
and which interrupt causes the CPU to awake.

Change-Id: Iaa06a678eab661357d084ee1f79c4cfcf19bf85d
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:15:28 -05:00
Yonattan Louise d2108bf084 Profile interrupt events.
Add the interrupt profile points for x86 and ARM arquitectures. This
gives information regarding the time when interrupts occur.

Change-Id: Ic876c0e7f9e8819d53e0578416f09146f4456d3d
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:15:28 -05:00
Benjamin Walsh aa78793e40 microkernel: rename K_swapper to _k_server
Align with the newer terminology used for microkernel internal symbols.

Change-Id: I623b383f90d9e37a49429a79774c7f7a4953bd5f
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:15:21 -05:00
Yonattan Louise 520542bef2 Add context switch profile point.
Add the context switch profile point for x86 and ARM arquitectures.

Change-Id: Ib7205059104ed47b96ba75b8cfefec3ff35f6813
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:15:20 -05:00
Yonattan Louise efd8e246cc Add profiler method.
Add a standardized mechanism to add profiling points to the Kernel
with a single interface for the user to collect the profiling data.

Change-Id: I4fa34ac1b42f73a73ba1fd805e755ee2fd00dff7
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:15:20 -05:00
Yonattan Louise 8c85c15a2f Add event logger.
Add a log event tool with a single interface for the user to
add/collect the event log data.

Change-Id: Ia4b78836748c5d7e44ba1bdd50c28434e8a55d65
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:15:20 -05:00
Peter Mitsis d2857404f5 Kconfig: fix SYS_CLOCK_HW_CYCLES_PER_SEC dependencies
Fixes the SYS_CLOCK_HW_CYCLES_PER_SEC Kconfig option dependencies such that
it can be overridden by a modified platform configuration file.  This is
particularly important for the LOAPIC timer driver as
SYS_CLOCK_HW_CYCLES_PER_SEC is dependent upon the target's CPU/bus frequency.

Change-Id: I0fb49b4c540888cb1988c76e2a711a85e756f82c
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:42 -05:00
Anas Nashif abeaeacab0 Kconfig: TICKLESS_IDLE_UNSUPPORTED is not used
Change-Id: Id6767a0d6b04eea6b76065d4792245b57fb0a657
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:41 -05:00
Peter Mitsis e6b8bc6477 Remove obsolete kernel references to BSP
BSP terminology is obsolete.

Change-Id: Ic23688fbaaf88e037e184c8bbfc7aaa0ba997b31
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:39 -05:00
Anas Nashif d76be85cc9 Kconfig: change kernel names in menu
Change-Id: Ib4409cfb8da273b0fd9a40e089d47a1fb0ffe0bc

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:11 -05:00
Juan Manuel Cruz d15251fec5 Kbuild: Kconfig license headers.
This commit add license headers to Kconfig files.

Change-Id: I79e60263b8c7b696463ecc84b8ad411af5415117
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
2016-02-05 20:14:10 -05:00
Anas Nashif 97f2fe9c49 Rename TICKLESS_KERNEL -> SYS_CLOCK_EXISTS
Change-Id: I2101cbbbda08099483e4b7002b6072758149203c

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:09 -05:00
Anas Nashif 4acde800b0 Kbuild: User kernel instead of TiMo
TiMo is very ambigous, be generic and call it kernel.

Change-Id: I66b3e436afbc89e874f31a89b98cc04aa821c787
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:07 -05:00
Juan Manuel Cruz c818cd288c Kbuild: Additional Kconfig symbols.
This commit adds the following Kconfig symbols:
 - INIT_STACKS
 - UART_INTERRUPT_DRIVEN
 - CONSOLE_HANDLER
 - BUILD_TIMESTAMP
 - TICKLESS_KERNEL
 - CONTEXT_CUSTOM_DATA

Change-Id: Id96a7e759c8beac73f27193df07b5c7562379b2f
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
2016-02-05 20:14:06 -05:00
Juan Manuel Cruz 0e301cc07f Kconfig symbols for kernel and misc directory.
This commit adds the Kconfig files that describe the CONFIG
symbols that belongs to the kernel directory and subdirectories.
It includes the misc directory Kconfig as well.

Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
Change-Id: I3e653562ea5c259203a63274197e3a0e1522ecc4
2016-02-05 20:14:04 -05:00