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-03 00:55:39 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010-2012, 2014-2015 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 02:01:01 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
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-03 00:55:39 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
2016-12-20 02:25:56 +01:00
|
|
|
* @brief Architecture-independent private kernel APIs
|
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-03 00:55:39 +02:00
|
|
|
*
|
2016-12-20 02:25:56 +01:00
|
|
|
* This file contains private kernel APIs that are not architecture-specific.
|
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-03 00:55:39 +02:00
|
|
|
*/
|
|
|
|
|
2018-09-14 00:06:35 +02:00
|
|
|
#ifndef ZEPHYR_KERNEL_INCLUDE_KERNEL_INTERNAL_H_
|
|
|
|
#define ZEPHYR_KERNEL_INCLUDE_KERNEL_INTERNAL_H_
|
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-03 00:55:39 +02:00
|
|
|
|
2022-05-06 11:04:23 +02:00
|
|
|
#include <zephyr/kernel.h>
|
2019-10-24 17:08:21 +02:00
|
|
|
#include <kernel_arch_interface.h>
|
|
|
|
#include <string.h>
|
2016-11-18 21:35:05 +01:00
|
|
|
|
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-03 00:55:39 +02:00
|
|
|
#ifndef _ASMLANGUAGE
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-11-15 21:32:53 +01:00
|
|
|
/* Initialize per-CPU kernel data */
|
|
|
|
void z_init_cpu(int id);
|
|
|
|
|
2023-09-18 18:52:08 +02:00
|
|
|
/* Initialize a thread */
|
|
|
|
void z_init_thread_base(struct _thread_base *thread_base, int priority,
|
|
|
|
uint32_t initial_state, unsigned int options);
|
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-03 00:55:39 +02:00
|
|
|
|
2023-09-18 18:52:08 +02:00
|
|
|
/* Early boot functions */
|
2022-02-10 19:54:49 +01:00
|
|
|
void z_early_memset(void *dst, int c, size_t n);
|
|
|
|
void z_early_memcpy(void *dst, const void *src, size_t n);
|
|
|
|
|
2019-03-08 22:19:05 +01:00
|
|
|
void z_bss_zero(void);
|
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-03 00:55:39 +02:00
|
|
|
#ifdef CONFIG_XIP
|
2019-03-08 22:19:05 +01:00
|
|
|
void z_data_copy(void);
|
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-03 00:55:39 +02:00
|
|
|
#else
|
2019-03-08 22:19:05 +01:00
|
|
|
static inline void z_data_copy(void)
|
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-03 00:55:39 +02:00
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
}
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_XIP */
|
2021-02-24 19:18:34 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_LINKER_USE_BOOT_SECTION
|
|
|
|
void z_bss_zero_boot(void);
|
|
|
|
#else
|
|
|
|
static inline void z_bss_zero_boot(void)
|
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
}
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_LINKER_USE_BOOT_SECTION */
|
2021-02-24 19:18:34 +01:00
|
|
|
|
2021-02-23 22:33:38 +01:00
|
|
|
#ifdef CONFIG_LINKER_USE_PINNED_SECTION
|
|
|
|
void z_bss_zero_pinned(void);
|
|
|
|
#else
|
|
|
|
static inline void z_bss_zero_pinned(void)
|
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
}
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_LINKER_USE_PINNED_SECTION */
|
2021-02-23 22:33:38 +01:00
|
|
|
|
2019-03-08 22:19:05 +01:00
|
|
|
FUNC_NORETURN void z_cstart(void);
|
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-03 00:55:39 +02:00
|
|
|
|
2021-02-02 17:07:18 +01:00
|
|
|
void z_device_state_init(void);
|
|
|
|
|
2019-03-08 22:19:05 +01:00
|
|
|
extern FUNC_NORETURN void z_thread_entry(k_thread_entry_t entry,
|
2017-09-11 18:30:04 +02:00
|
|
|
void *p1, void *p2, void *p3);
|
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-03 00:55:39 +02:00
|
|
|
|
2020-04-24 20:29:47 +02:00
|
|
|
extern char *z_setup_new_thread(struct k_thread *new_thread,
|
|
|
|
k_thread_stack_t *stack, size_t stack_size,
|
|
|
|
k_thread_entry_t entry,
|
|
|
|
void *p1, void *p2, void *p3,
|
|
|
|
int prio, uint32_t options, const char *name);
|
2017-08-30 23:31:03 +02:00
|
|
|
|
2020-12-15 22:37:11 +01:00
|
|
|
/**
|
|
|
|
* @brief Allocate aligned memory from the current thread's resource pool
|
|
|
|
*
|
|
|
|
* Threads may be assigned a resource pool, which will be used to allocate
|
|
|
|
* memory on behalf of certain kernel and driver APIs. Memory reserved
|
|
|
|
* in this way should be freed with k_free().
|
|
|
|
*
|
|
|
|
* If called from an ISR, the k_malloc() system heap will be used if it exists.
|
|
|
|
*
|
|
|
|
* @param align Required memory alignment
|
|
|
|
* @param size Memory allocation size
|
|
|
|
* @return A pointer to the allocated memory, or NULL if there is insufficient
|
|
|
|
* RAM in the pool or there is no pool to draw memory from
|
|
|
|
*/
|
|
|
|
void *z_thread_aligned_alloc(size_t align, size_t size);
|
|
|
|
|
2018-04-13 02:12:15 +02:00
|
|
|
/**
|
|
|
|
* @brief Allocate some memory from the current thread's resource pool
|
|
|
|
*
|
|
|
|
* Threads may be assigned a resource pool, which will be used to allocate
|
|
|
|
* memory on behalf of certain kernel and driver APIs. Memory reserved
|
|
|
|
* in this way should be freed with k_free().
|
|
|
|
*
|
2019-05-22 19:38:43 +02:00
|
|
|
* If called from an ISR, the k_malloc() system heap will be used if it exists.
|
|
|
|
*
|
2018-04-13 02:12:15 +02:00
|
|
|
* @param size Memory allocation size
|
|
|
|
* @return A pointer to the allocated memory, or NULL if there is insufficient
|
2019-05-22 19:38:43 +02:00
|
|
|
* RAM in the pool or there is no pool to draw memory from
|
2018-04-13 02:12:15 +02:00
|
|
|
*/
|
2020-12-15 22:37:11 +01:00
|
|
|
static inline void *z_thread_malloc(size_t size)
|
|
|
|
{
|
|
|
|
return z_thread_aligned_alloc(0, size);
|
|
|
|
}
|
2018-04-13 02:12:15 +02:00
|
|
|
|
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-03 00:55:39 +02:00
|
|
|
|
2019-10-24 17:08:21 +02:00
|
|
|
#ifdef CONFIG_USE_SWITCH
|
|
|
|
/* This is a arch function traditionally, but when the switch-based
|
|
|
|
* z_swap() is in use it's a simple inline provided by the kernel.
|
|
|
|
*/
|
|
|
|
static ALWAYS_INLINE void
|
2019-11-07 21:43:29 +01:00
|
|
|
arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
|
2019-10-24 17:08:21 +02:00
|
|
|
{
|
|
|
|
thread->swap_retval = value;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static ALWAYS_INLINE void
|
|
|
|
z_thread_return_value_set_with_data(struct k_thread *thread,
|
|
|
|
unsigned int value,
|
|
|
|
void *data)
|
|
|
|
{
|
2019-11-07 21:43:29 +01:00
|
|
|
arch_thread_return_value_set(thread, value);
|
2019-10-24 17:08:21 +02:00
|
|
|
thread->base.swap_data = data;
|
|
|
|
}
|
|
|
|
|
2021-07-15 09:36:45 +02:00
|
|
|
#ifdef CONFIG_SMP
|
2019-06-05 17:58:42 +02:00
|
|
|
extern void z_smp_init(void);
|
2023-06-19 18:18:03 +02:00
|
|
|
#ifdef CONFIG_SYS_CLOCK_EXISTS
|
2018-01-26 21:30:21 +01:00
|
|
|
extern void smp_timer_init(void);
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_SYS_CLOCK_EXISTS */
|
|
|
|
#endif /* CONFIG_SMP */
|
2018-01-26 21:30:21 +01:00
|
|
|
|
2023-10-10 00:22:18 +02:00
|
|
|
extern void z_early_rand_get(uint8_t *buf, size_t length);
|
2018-05-24 00:25:23 +02:00
|
|
|
|
|
|
|
#if CONFIG_STACK_POINTER_RANDOM
|
|
|
|
extern int z_stack_adjust_initialized;
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_STACK_POINTER_RANDOM */
|
2018-05-24 00:25:23 +02:00
|
|
|
|
2019-09-22 02:54:37 +02:00
|
|
|
extern struct k_thread z_main_thread;
|
2020-03-12 23:37:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_MULTITHREADING
|
2022-10-12 17:55:36 +02:00
|
|
|
extern struct k_thread z_idle_threads[CONFIG_MP_MAX_NUM_CPUS];
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_MULTITHREADING */
|
2022-10-12 17:55:36 +02:00
|
|
|
K_KERNEL_PINNED_STACK_ARRAY_DECLARE(z_interrupt_stacks, CONFIG_MP_MAX_NUM_CPUS,
|
2022-06-17 17:32:42 +02:00
|
|
|
CONFIG_ISR_STACK_SIZE);
|
2019-09-22 02:54:37 +02:00
|
|
|
|
2020-03-11 18:56:19 +01:00
|
|
|
#ifdef CONFIG_GEN_PRIV_STACKS
|
2020-05-27 18:26:57 +02:00
|
|
|
extern uint8_t *z_priv_stack_find(k_thread_stack_t *stack);
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_GEN_PRIV_STACKS */
|
2020-03-11 18:56:19 +01:00
|
|
|
|
2022-01-28 15:40:37 +01:00
|
|
|
/* Calculate stack usage. */
|
|
|
|
int z_stack_space_get(const uint8_t *stack_start, size_t size, size_t *unused_ptr);
|
|
|
|
|
2020-04-25 01:24:46 +02:00
|
|
|
#ifdef CONFIG_USERSPACE
|
|
|
|
bool z_stack_is_user_capable(k_thread_stack_t *stack);
|
2020-10-06 22:39:29 +02:00
|
|
|
|
|
|
|
/* Memory domain setup hook, called from z_setup_new_thread() */
|
|
|
|
void z_mem_domain_init_thread(struct k_thread *thread);
|
|
|
|
|
2021-02-20 00:32:19 +01:00
|
|
|
/* Memory domain teardown hook, called from z_thread_abort() */
|
2020-10-06 22:39:29 +02:00
|
|
|
void z_mem_domain_exit_thread(struct k_thread *thread);
|
2020-10-07 00:53:43 +02:00
|
|
|
|
|
|
|
/* This spinlock:
|
|
|
|
*
|
|
|
|
* - Protects the full set of active k_mem_domain objects and their contents
|
|
|
|
* - Serializes calls to arch_mem_domain_* APIs
|
|
|
|
*
|
|
|
|
* If architecture code needs to access k_mem_domain structures or the
|
|
|
|
* partitions they contain at any other point, this spinlock should be held.
|
|
|
|
* Uniprocessor systems can get away with just locking interrupts but this is
|
|
|
|
* not recommended.
|
|
|
|
*/
|
|
|
|
extern struct k_spinlock z_mem_domain_lock;
|
2020-04-25 01:24:46 +02:00
|
|
|
#endif /* CONFIG_USERSPACE */
|
|
|
|
|
2020-05-22 01:55:28 +02:00
|
|
|
#ifdef CONFIG_GDBSTUB
|
|
|
|
struct gdb_ctx;
|
|
|
|
|
|
|
|
/* Should be called by the arch layer. This is the gdbstub main loop
|
|
|
|
* and synchronously communicate with gdb on host.
|
|
|
|
*/
|
2021-10-28 23:53:28 +02:00
|
|
|
extern int z_gdb_main_loop(struct gdb_ctx *ctx);
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_GDBSTUB */
|
2020-05-22 01:55:28 +02:00
|
|
|
|
2020-08-28 01:12:01 +02:00
|
|
|
#ifdef CONFIG_INSTRUMENT_THREAD_SWITCHING
|
2020-08-27 22:54:14 +02:00
|
|
|
void z_thread_mark_switched_in(void);
|
|
|
|
void z_thread_mark_switched_out(void);
|
|
|
|
#else
|
|
|
|
|
2020-08-28 01:12:01 +02:00
|
|
|
/**
|
|
|
|
* @brief Called after a thread has been selected to run
|
|
|
|
*/
|
|
|
|
#define z_thread_mark_switched_in()
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Called before a thread has been selected to run
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define z_thread_mark_switched_out()
|
|
|
|
|
|
|
|
#endif /* CONFIG_INSTRUMENT_THREAD_SWITCHING */
|
2020-05-22 01:55:28 +02:00
|
|
|
|
2020-12-09 21:18:40 +01:00
|
|
|
/* Init hook for page frame management, invoked immediately upon entry of
|
|
|
|
* main thread, before POST_KERNEL tasks
|
|
|
|
*/
|
|
|
|
void z_mem_manage_init(void);
|
|
|
|
|
2021-07-15 22:15:29 +02:00
|
|
|
/**
|
|
|
|
* @brief Finalize page frame management at the end of boot process.
|
|
|
|
*/
|
|
|
|
void z_mem_manage_boot_finish(void);
|
|
|
|
|
2023-09-14 16:08:07 +02:00
|
|
|
|
|
|
|
void z_handle_obj_poll_events(sys_dlist_t *events, uint32_t state);
|
|
|
|
|
2021-02-23 17:59:28 +01:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
/* When the kernel is about to go idle, it calls this function to notify the
|
|
|
|
* power management subsystem, that the kernel is ready to enter the idle state.
|
|
|
|
*
|
|
|
|
* At this point, the kernel has disabled interrupts and computed the maximum
|
|
|
|
* time the system can remain idle. The function passes the time that the system
|
|
|
|
* can remain idle. The SOC interface performs power operations that can be done
|
|
|
|
* in the available time. The power management operations must halt execution of
|
|
|
|
* the CPU.
|
|
|
|
*
|
|
|
|
* This function assumes that a wake up event has already been set up by the
|
|
|
|
* application.
|
|
|
|
*
|
|
|
|
* This function is entered with interrupts disabled. It should re-enable
|
|
|
|
* interrupts if it had entered a power state.
|
2021-10-31 07:13:08 +01:00
|
|
|
*
|
|
|
|
* @return True if the system suspended, otherwise return false
|
2021-02-23 17:59:28 +01:00
|
|
|
*/
|
2021-10-31 07:13:08 +01:00
|
|
|
bool pm_system_suspend(int32_t ticks);
|
2021-02-23 17:59:28 +01:00
|
|
|
|
2021-02-25 00:53:46 +01:00
|
|
|
/**
|
|
|
|
* Notify exit from kernel idling after PM operations
|
|
|
|
*
|
|
|
|
* This function would notify exit from kernel idling if a corresponding
|
|
|
|
* pm_system_suspend() notification was handled and did not return
|
|
|
|
* PM_STATE_ACTIVE.
|
|
|
|
*
|
|
|
|
* This function would be called from the ISR context of the event
|
|
|
|
* that caused the exit from kernel idling. This will be called immediately
|
|
|
|
* after interrupts are enabled. This is called to give a chance to do
|
|
|
|
* any operations before the kernel would switch tasks or processes nested
|
|
|
|
* interrupts. This is required for cpu low power states that would require
|
|
|
|
* interrupts to be enabled while entering low power states. e.g. C1 in x86. In
|
|
|
|
* those cases, the ISR would be invoked immediately after the event wakes up
|
|
|
|
* the CPU, before code following the CPU wait, gets a chance to execute. This
|
|
|
|
* can be ignored if no operation needs to be done at the wake event
|
2021-11-20 03:20:46 +01:00
|
|
|
* notification.
|
2021-02-25 00:53:46 +01:00
|
|
|
*/
|
|
|
|
void pm_system_resume(void);
|
|
|
|
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_PM */
|
2021-02-23 17:59:28 +01:00
|
|
|
|
2021-03-30 23:38:00 +02:00
|
|
|
#ifdef CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM
|
|
|
|
/**
|
|
|
|
* Initialize the timing histograms for demand paging.
|
|
|
|
*/
|
|
|
|
void z_paging_histogram_init(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Increment the counter in the timing histogram.
|
|
|
|
*
|
|
|
|
* @param hist The timing histogram to be updated.
|
|
|
|
* @param cycles Time spent in measured operation.
|
|
|
|
*/
|
|
|
|
void z_paging_histogram_inc(struct k_mem_paging_histogram_t *hist,
|
|
|
|
uint32_t cycles);
|
|
|
|
#endif /* CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM */
|
|
|
|
|
2023-06-01 18:16:40 +02:00
|
|
|
#ifdef CONFIG_OBJ_CORE_STATS_THREAD
|
|
|
|
int z_thread_stats_raw(struct k_obj_core *obj_core, void *stats);
|
|
|
|
int z_thread_stats_query(struct k_obj_core *obj_core, void *stats);
|
|
|
|
int z_thread_stats_reset(struct k_obj_core *obj_core);
|
|
|
|
int z_thread_stats_disable(struct k_obj_core *obj_core);
|
|
|
|
int z_thread_stats_enable(struct k_obj_core *obj_core);
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_OBJ_CORE_STATS_THREAD */
|
2023-06-01 18:16:40 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_OBJ_CORE_STATS_SYSTEM
|
|
|
|
int z_cpu_stats_raw(struct k_obj_core *obj_core, void *stats);
|
|
|
|
int z_cpu_stats_query(struct k_obj_core *obj_core, void *stats);
|
|
|
|
|
|
|
|
int z_kernel_stats_raw(struct k_obj_core *obj_core, void *stats);
|
|
|
|
int z_kernel_stats_query(struct k_obj_core *obj_core, void *stats);
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_OBJ_CORE_STATS_SYSTEM */
|
2023-06-01 18:16:40 +02:00
|
|
|
|
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-03 00:55:39 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
2018-09-14 00:06:35 +02:00
|
|
|
#endif /* ZEPHYR_KERNEL_INCLUDE_KERNEL_INTERNAL_H_ */
|