Commit graph

41120 commits

Author SHA1 Message Date
Carles Cufi
10cd9e31f3 Bluetooth: HCI: Add auth payload expiry event
This adds the Authenticated Payload Timeout expired event,
used in both BR/EDR and LE and required by the LE Controller.

Change-Id: Ifbbccea6d44a7d432734090e56cbf4e7189362b0
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Carles Cufi
4392d6d737 Bluetooth: HCI: Fix and extend advertising report events
The advertising report (standard or direct) events require
a number of reports field that is used by the controller
to fill in the structure.
At the same time this fixes the subevent code of the direct
advertising report structure.

Change-Id: I0fdb9b1dcad03615ac9b3f1f38fdfbe9ab3f9c3a
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Sathish Narasimman
9738e83285 Bluetooth: HFP HF: Initialize Handsfree profile
Initialize Handsfree profile for HF Role and register RFCOMM server
channel number to the RFCOMM. And also exposes some basic callbacks
which is required for the application.

Change-Id: Ic79cbd66ef9529c4eb134cc21efcdbc388bb707d
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
2016-09-14 08:45:45 +03:00
Sukumar Ghorai
17117f306a Bluetooth: Pre-allocated RFCOMM Channels
Limited number of RFCOMM channels(1-31). Pre-allocated
for profile use and to avoid conflicts.

Change-Id: Ibd081435cf927aa7386161710e48b7371d20af24
Signed-off-by: Sukumar Ghorai <sukumar.ghorai@intel.com>
2016-09-14 08:45:45 +03:00
Carles Cufi
0c463077ad Bluetooth: Controller: Unify handling of async events
This changes the way that aysnchronous events are handled
in the BLE controller's HCI layer. It performs all common
operations in a single place to avoid code repetition of the
same memory accesses over and over.

Jira: ZEP-726

Change-Id: Id9e8395944e8800f32dd9749da2b4f5c901c8682
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Carles Cufi
9d48ef5888 Bluetooth: Controller: Switch to Zephyr's hci.h for cmd handling
Continue using Zephyr's include/bluetooth/hci.h for HCI command
handling in more of the commands.
This commit deletes all command and command complete and
command status event definitions and structures present in
hci.c.
This is the sixth commit in a series that transitions from
the structures in hci.c to the ones in hci.h.

Jira: ZEP-726

Change-Id: I34635a1f55f3aef124fd5ff005c99cedb40b8a49
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Carles Cufi
be2bbbae2d Bluetooth: Controller: Switch to Zephyr's hci.h for cmd handling
Continue using Zephyr's include/bluetooth/hci.h for HCI command
handling in more of the commands.
This commit cleans up hci_cmd_handle() to use the new macros
added in previous commits.
This is the fifth commit in a series that transitions from
the structures in hci.c to the ones in hci.h.

Jira: ZEP-726

Change-Id: I152e02ed15042d367e95432bdd07ae5c74935be8
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Carles Cufi
69e1816868 Bluetooth: Controller: Switch to Zephyr's hci.h for cmd handling
Continue using Zephyr's include/bluetooth/hci.h for HCI command
handling in more of the commands.
This commit removes Nordic Semiconductor Vendor-Specific
commands, since they are currently unused and
manufacturer-specific.
This is the fourth commit in a series that transitions from
the structures in hci.c to the ones in hci.h.

Jira: ZEP-726

Change-Id: If0141072489777bfecc06e4aaa5f569898a5c449
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Carles Cufi
21b3fa240d Bluetooth: Controller: Switch to Zephyr's hci.h for cmd handling
Continue using Zephyr's include/bluetooth/hci.h for HCI command
handling in more of the commands.
This commit ports the LE controller commands to hci.h.
This is the third commit in a series that transitions from
the structures in hci.c to the ones in hci.h.

Jira: ZEP-726

Change-Id: I3f11cca1da4aa6a20cce9706362818f8f6c87b0a
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Jaganath Kanakkassery
d73814a1d5 Bluetooth: RFCOMM: Implement RX flow control
RX credits is defined based on the number of acl buffers and
it will be updated to remote if it goes beyond the defined
threshold. Controller to host flow control will take care if
acl buffers are not free wrt outstanding RX credits.

Change-Id: Ie597513bda07f39b6934a704f6db6dad14e323d5
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-09-14 08:45:45 +03:00
Luiz Augusto von Dentz
c5dc094f7e Bluetooth: ATT: Fix not handling error response properly
The code should check if there is an existing buffer to match with the
response code.

Change-Id: I08546fdf416884560cf497a34cc4eee95079a589
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-09-14 08:45:45 +03:00
Vinayak Chettimada
e00eed79aa Bluetooth: Controller: Use BT_ASSERT instead of custom impl.
As part of closer integration into Zephyr, remove the use
of custom assert mechanism and use BT_ASSERT instead.

Jira: ZEP-761

Change-id: I27f37d697b0a84bc001754a8d0b4dbb6ddb54298
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Vinayak Chettimada
feb342140a Bluetooth: log: Include nanokernel.h to use BT_ASSERT()
_SysFatalErrorHandler referenced in BT_ASSERT() is arch
defined. Include nanokernel.h in bluetooth/log.h to include
the necessary arch definitions, as required.

Change-id: Ia39690d2a49db0c9db669a68147fe410abb4213b
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Vinayak Chettimada
4a4b76afbc Bluetooth: log: Call _SysFatalErrorHandler in BT_ASSERT()
Change-id: I0cd55426b4dbae0cc95b6b6b57fcf1a02c9103b4
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Vinayak Chettimada
190ac96fad Bluetooth: ATT: Remove unnecessary call to BT_ASSERT
Change-id: Ic8038392e540445b718beb05a3375aaa6a50ad61
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Carles Cufi
ca4b5b93d8 Bluetooth: HCI: Add handle to conn param update command complete
The BT_HCI_OP_LE_CONN_PARAM_REQ_REPLY and
BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY command complete events contain
a connection handle that serves to match the command with their
corresponding command complete event when there's more than one
pending. For now this just adds the structure definitions required,
and later on code will need to be added to handle possible mismatches.

Change-Id: I4585888b32ec995b18847c2a6ed488a2da9c8520
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Carles Cufi
102aee8f55 Bluetooth: HCI: Add handle to LTK command complete events
The BT_HCI_OP_LE_LTK_REQ_REPLY and BT_HCI_OP_LE_LTK_REQ_NEG_REPLY
command complete events contain a connection handle that serves to
match the command with their corresponding command complete event
when there's more than one pending. For now this just adds the
structure definitions required, and later on code will need to
be added to handle possible mismatches.

Change-Id: I37e88070bc0d4d1b80f085f7e162c30715a82103
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Mariusz Skamra
044e15743d Bluetooth: tester: Add support for L2CAP send data command
Adds support for handling L2CAP send data command.

Change-Id: I120a9ed56506ce205e32c5efe15c5d967d7726b6
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-09-14 08:45:45 +03:00
Grzegorz Kolodziejczyk
a4f526fb6b Bluetooth: tester: Add support for L2CAP listen command
This patch adds support for handling L2CAP listen command.

Change-Id: I2c9c27f925c923a14ddb28b41fbefd612b32d63a
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-09-14 08:45:45 +03:00
Grzegorz Kolodziejczyk
c4957ea0e8 Bluetooth: tester: Add support for L2CAP disconnect commands
This patch adds support for handling L2CAP disconnect command.

Change-Id: If6f8f3a7485dc8ae270481ed6af4f0a4d4c69fac
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-09-14 08:45:45 +03:00
Carles Cufi
34cd316301 Bluetooth: Controller: Switch to Zephyr's hci.h for cmd handling
Continue using Zephyr's include/bluetooth/hci.h for HCI command
handling in more of the commands, including the informational ones.
This is the second commit in a series that transitions from
the structures in hci.c to the ones in hci.h.

Jira: ZEP-726

Change-Id: Iecbc7ae5ba2c8435a51d62d59e8095aa25e6dc0e
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03:00
Grzegorz Kolodziejczyk
086eac4344 Bluetooth: tester: Add support for L2CAP connect command
This patch adds support for handling L2CAP connect command.

Change-Id: I95d27831f65ed6a3e02e1d6e7583baa6890b588c
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-09-14 08:45:45 +03:00
Carles Cufi
80d1fba9e9 Bluetooth: HCI: Fix the length of supported commands
The length of the commands array in the return parameters of
the HCI Read Local Supported Commands event is 64 bytes
according to the spec. This was mistakenly set as 36 bytes due
to the fact that only 36 out of the 64 bytes currently contain
meaningful data. The actual array as received from the driver
will always be 64 bytes however, and is therefore sized
accordingly.

Change-Id: Iee7f1fc18045dff96efcc808fd81661eced37b03
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-09-14 08:45:45 +03: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
456c6daa9f unified: initial unified kernel implementation
Summary of what this includes:

    initialization:

    Copy from nano_init.c, with the following changes:

    - the main thread is the continuation of the init thread, but an idle
      thread is created as well

    - _main() initializes threads in groups and starts the EXE group

    - the ready queues are initialized

    - the main thread is marked as non-essential once the system init is
      done

    - a weak main() symbol is provided if the application does not provide a
      main() function

    scheduler:

    Not an exhaustive list, but basically provide primitives for:

    - adding/removing a thread to/from a wait queue
    - adding/removing a thread to/from the ready queue
    - marking thread as ready
    - locking/unlocking the scheduler
      - instead of locking interrupts
    - getting/setting thread priority
      - checking what state (coop/preempt) a thread is currenlty running in
    - rescheduling threads
    - finding what thread is the next to run
    - yielding/sleeping/aborting sleep
    - finding the current thread

    threads:

    - Add operationns on threads, such as creating and starting them.

    standardized handling of kernel object return codes:

    - Kernel objects now cause _Swap() to return the following values:
         0      => operation successful
        -EAGAIN => operation timed out
        -Exxxxx => operation failed for another reason

    - The thread's swap_data field can be used to return any additional
    information required to complete the operation, such as the actual
    result of a successful operation.

    timeouts:

    - same as nano timeouts, renamed to simply 'timeouts'
    - the kernel is still tick-based, but objects take timeout values in
      ms for forward compatibility with a tickless kernel.

    semaphores:

      - Port of the nanokernel semaphores, which have the same basic behaviour
      as the microkernel ones. Semaphore groups are not yet implemented.

      - These semaphores are enhanced in that they accept an initial count and a
      count limit. This allows configuring them as binary semaphores, and also
      provisioning them without having to "give" the semaphore multiple times
      before using them.

    mutexes:

    - Straight port of the microkernel mutexes. An init function is added to
    allow defining them at runtime.

    pipes:

    - straight port

    timers:

    - amalgamation of nano and micro timers, with all functionalities
      intact.

    events:

    - re-implementation, using semaphores and workqueues.

    mailboxes:

    - straight port

    message queues:

    - straight port of  microkernel FIFOs

    memory maps:

    - straight port

    workqueues:

    - Basically, have all APIs follow the k_ naming rule, and use the _timeout
    subsystem from the unified kernel directory, and not the _nano_timeout
    one.

    stacks:

    - Port of the nanokernel stacks. They can now have multiple threads
    pending on them and threads can wait with a timeout.

    LIFOs:

    - Straight port of the nanokernel LIFOs.

    FIFOs:

    - Straight port of the nanokernel FIFOs.

Work by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
         Peter Mitsis <peter.mitsis@windriver.com>
         Allan Stephens <allan.stephens@windriver.com>
         Benjamin Walsh <benjamin.walsh@windriver.com>

Change-Id: Id3cadb3694484ab2ca467889cfb029be3cd3a7d6
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
87f1232770 unified/tests: tag working some tests kernel as 'unified_capable'
This allows running the sanitycheck with:

  --tag unified_capable -x KERNEL_TYPE=unified

to run the unified kernel with the tests it is currently known to be
able to run.

Change-Id: Ic145fc6adca162745887672372226fd67447b34a
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
8011221712 unified/test_mutex: adapt to run on unified kernel
- Use a more limited range of priorities, since the current
  implementation of the unified kernel only works with 32 priorities
  total. Instead of starting at 10 and going up by 5 up to  50, start
  at 5 and go up by 1 up to 12.

- The definition of kmutex_t has changed from a uint32_t to a struct
  k_mutex *, causing this to not work anymore:

    const kmutex_t private_mutex;

  since this makes the object constant instead of the reference to it.
  Private object must be referenced like this instead:

    kmutex_t const private_mutex;

  since const is left-associative.

Change-Id: I9d70bfa3944ea46033a6b49251a4993e9bd2b588
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
2a669da7bc unified/test_fp: mark test so that it runs the nanokernel version
The test does not run out-of-the-box currently, mark it with a #error.

Change-Id: Ia720c674290e59e95db1c2948c508c0464caa672
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
68a8059603 unified/test_sema: fix isr wrapper names
isr wrapper names conflicted with real kernel APIs.

Change-Id: Ia85245fcd3025f9d15175523982883e16e97010c
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
45054a6e02 unified: Fix test_sema/microkernel
Fixes test_sema/microkernel so that the variable assigned the return
value from task_sem_group_take() is of type 'ksem_t' instead of 'int'.

Work by: Peter Mitsis <peter.mitsis@windriver.com>

Change-Id: Iee9f321a6bd51ca3bc0cd8b0c7eceae8a5bf7ce0
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
3bcd880594 unified/test_timer: adapt for unified kernel
Test is poking into microkernel private data structuresa, but the
unified kernel provides an API to retrieve that value.

Abstract the call in the microkernel case to minic the unified kernel
API.

Work by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>

Change-Id: Ic3195d470fda178164268d9c71c55a2a6daa61a3
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
c24d844eec unified/test_pipe: adapt to not use sem groups
Not available yet on unified kernel.

Change-Id: I70c7c07ab26a66b7a89246a335fa2af0db2ec72c
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
cda52c7adb unified/test_mail: adapt test to not use sem groups and mem pools
Not available on unified kernel yet.

Change-Id: I834482f3ad94d1c6ecc67c70c1fce78e43db31c5
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
6f4b9a64cf unified/test_context: adapt test to run on unified kernel
Fixing issues with the test itself really:

- reply_timeout semaphore was not initialized, causing its limit value
  to be 0 on unified kernel

- There is no API to set a fiber's priority after it is started in a
  nanokernel. However, tcs.prio can be written to and this works without
  issues. On unified kernel, this does not work however because the
  thread has to move between linked lists representing each priority in
  the ready queue.

Change-Id: I3c5585da05cbc4ac3d2f0f9ae0297d24d41b1309
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
c72acc9333 zperf_shell: add unified kernel string for unified kernel case
Change-Id: I61053d6aff6381eb32626b457da6ef5170ffc503
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
ee99373afa unified/object_tracing: disable object tracing in unified kernel
Not implemented yet, prevent access to APIs.

Change-Id: I112c1cdee2ad516a0dcffa3239623c61a089d9bc
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
43f39020df unified/sys_timer: guard microkernel announce with !KERNEL_V2
KERNEL_V2 enables the MICROKERNEL flag, but we want the nanokernel
ticker in the unified kernel.

Change-Id: I04e2d31d3834f2d7142bfe0ce9e3334a2faf6fb3
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
3caec4e95d unified/drivers: adapt timer drivers to unified kernel
They must provide the k_cycles_get_32() API and must not refer to
command packets: the latter do not exist on unified kernels.

Change-Id: Ia354dc060e5ad2595850f97da82d8feb590d16b7
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
5d23818070 unified: include kernel.h via major top-level header files
This allows current code to build but using the definitions from
kernel.h instead of the original headers.

Change-Id: I8f51a83bab4448cd63aa6c54b8e357a8ad6cc1e2
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
d4e78bce0a workqueue: use kernel.h for workqueue header file
Workqueues will be brought in as a first-class unified kernel object,
not a misc functionality. Do not use the contents of the header file
when building a unified kernel, but kernel.h instead.

Change-Id: I649558fee92b6565ada0eee81bde9f542a468f9f
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
68f6d52eb1 atomic: fix bug in ATOMIC_INIT()
Macro should not use {}, since atomic_t is a scalar type rather
than a structure.

Work by: Allan Stephens <allan.stephens@windriver.com>

Change-Id: Id0991b6ecf841e07015cad01351701bb61b4333c
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
983cbe398c unified/x86: add unified kernel support for x86 arch
The x86 architecture port is fitted with support for the unified kernel,
namely:

- the interrupt exit code now calls _Swap() if the current
  thread is not a coop thread and if the scheduler is not locked

- there is no 'task' fields in the _nanokernel anymore: _Swap()
  now calls _get_next_ready_thread instead

- the _nanokernel.fiber field is replaced by a more sophisticated
  ready_q, based on the microkernel's priority-bitmap-based one

- nano_private includes nano_internal.h from the unified directory

- the FIBER, TASK and PREEMPTIBLE flags do not exist anymore: the thread
  priority drives the behaviour

- the tcs uses a dlist for queuing in both ready and wait queues instead
  of a custom singly-linked list

- other new fields in the tcs include a schedule-lock count, a
  back-pointer to init data (when the task is static) and a pointer to
  swap data, needed when a thread pending on _Swap() must be passed more
  then just one value (e.g. k_stack_pop() needs an error code and data)

- fiberRtnValueSet() is aliased to _set_thread_return_value since it
  also operates on preempt threads now

- _set_thread_return_value_with_data() sets the swap_data field in
  addition to a return value from _Swap()

- convenience aliases are created for shorter names:

  - _current is defined as _nanokernel.current
  - _ready_q is defined as _nanokernel.ready_q

- _Swap() sets the threads's return code to -EAGAIN before swapping out
  to prevent timeouts to have to set it (solves hard issues in some
  kernel objects).

- Floating point support.

Note that, in _Swap(), the register holding the thread to be swapped in has
been changed from %ecx to %eax in both the legacy kernel and the unified kernel
to take advantage of the fact that the return value of _get_next_ready_thread()
is stored in %eax, and this avoids moving it to %ecx.

Work by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
         Allan Stephens <allan.stephens@windriver.com>
	 Benjamin Walsh <benjamin.walsh@windriver.com>

Change-Id: I4ce2bd47bcdc62034c669b5e889fc0f29480c43b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
b9a0d90a5f x86: load _nanokernel in %edi in _Swap()
Loading the _nanokernel address in %edi rather than in %eax allows
calling funtions in _Swap() without having to restore it, since %eax is
used for the return value. %edi is a callee-saved register and does not
have to be restored.

Change-Id: I338086d8e15857e835d5d7487de975791926f869
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
3cf3778d31 unified/arm: add unified kernel support for ARM arch
The ARM architecture port is fitted with support for the unified kernel,
namely:

- the interrupt/exception exit code now pends PendSV if the current
  thread is not a coop thread and if the scheduler is not locked

- fiber_abort is replaced by k_thread_abort(), which takes a thread ID
  as a parameter (i.e. does not only operate on the current thread)

- the _nanokernel.flags cache of _current.flags is not used anymore
  (could be a source of bugs) and is not needed in the scheduling algo

- there is no 'task' field in the _nanokernel anymore: PendSV not calls
  _get_next_ready_thread instead

- the _nanokernel.fiber field is replaced by a more sophisticated
  ready_q, based on the microkernel's priority-bitmap-based one

- thread initialization initializes new fields in the tcs, and does not
  initialize obsolete ones

- nano_private includes nano_internal.h from the unified directory

- The FIBER, TASK and PREEMPTIBLE flags do not exist anymore: the thread
  priority drives the behaviour

- the tcs uses a dlist for queuing in both ready and wait queues instead
  of a custom singly-linked list

- other new fields in the tcs include a schedule-lock count, a
  back-pointer to init data (when the task is static) and a pointer to
  swap data, needed when a thread pending on _Swap() must be passed more
  then just one value (e.g. k_stack_pop() needs an error code and data)

- the 'fiber' and 'task' fields of _nanokernel are replaced with an O(1)
  ready queue (taken from the microkernel)

- fiberRtnValueSet() is aliased to _set_thread_return_value since it
  also operates on preempt threads now

- _set_thread_return_value_with_data() sets the swap_data field in
  addition to a return value from _Swap()

- convenience aliases are created for shorter names:

  - _current is defined as _nanokernel.current
  - _ready_q is defined as _nanokernel.ready_q

- _Swap() sets the threads's return code to -EAGAIN before swapping out
  to prevent timeouts to have to set it (solves hard issues in some
  kernel objects).

Change-Id: I36c03c362bc2908dae064ec67e6b8469fc573983
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
d4006c9ad4 unified/build: adapt Kbuild for unified kernel
Changes needed to build system to build a unified kernel:

- NUM_COMMAND_PACKETS, NUM_TIMER_PACKETS, NUM_TASK_PRIRITIES must be
  passed to sysgen to avoid modifying it. Simply set them to 0. The
  unified build does not need them.

- Pass a different kernel type to sysgen if building for a unified
  kernel.

- Build kernel_main.c if building an MDEF file (micro/unified).

- The location of the include files for building offsets.h is different
  for unified kernels and nano/micro kernels.

Change-Id: I46b30a2b5ffc3ca675b3413150643b92c117c2c8
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
a8a830b5db arm: only compile gdb stubs when CONFIG_GDB_INFO=y
They use data that is unavailable to the unified kernel, and are not
used anymore really. For now, only compile them when CONFIG_GDB_INFO=y,
and never enable CONFIG_GDB_INFO when building the unified kernel.

These files should go away when the unified kernel is made the only
kernel type.

Change-Id: I0a2a917dd453ecaae729125008756e0f676df16d
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
781561c855 arm: add __ASSERT() for stack alignment
Change-Id: Id5c23f502a17ad3e889a0de7c7ad18085b123078
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
b05ce0e0c7 build: only generate the SSE group for x86
SSE is an x86 concept.

Change-Id: Ifb5810201afe734e8b13b949001cd97e7e2f0727
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
20f7ae47e4 sysgen: add --kernel_type argument
Needs to sort out differences between microkernel and unified MDEF
syntax.

Change-Id: I8f7cb192bdd90c0f9c40593cfbd0aa86b12c7c74
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00
Benjamin Walsh
f6684147c1 build: make sysgen take optional command line arguments
Cleaner than positional parameters, easier to add new arguments.

Change-Id: I30e85f7b2643775c1006564d18da115599688e88
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-09-13 17:12:55 -04:00