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-02 18:55:39 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2010-2012, 2014-2015 Wind River Systems, Inc.
|
|
|
|
|
*
|
2017-01-18 17:01:01 -08: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-02 18:55:39 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @file
|
2016-12-19 20:25:56 -05: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-02 18:55:39 -04:00
|
|
|
*
|
2016-12-19 20:25:56 -05: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-02 18:55:39 -04:00
|
|
|
*/
|
|
|
|
|
|
2018-09-13 15:06:35 -07: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-02 18:55:39 -04:00
|
|
|
|
2022-05-06 11:04:23 +02:00
|
|
|
#include <zephyr/kernel.h>
|
2019-10-25 00:08:21 +09:00
|
|
|
#include <kernel_arch_interface.h>
|
2025-09-04 06:25:45 -04:00
|
|
|
#include <kthread.h>
|
2019-10-25 00:08:21 +09:00
|
|
|
#include <string.h>
|
2016-11-18 15:35:05 -05: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-02 18:55:39 -04:00
|
|
|
#ifndef _ASMLANGUAGE
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-11-15 12:32:53 -08:00
|
|
|
/* Initialize per-CPU kernel data */
|
|
|
|
|
void z_init_cpu(int id);
|
|
|
|
|
|
2023-09-18 12:52:08 -04: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-02 18:55:39 -04:00
|
|
|
|
2021-02-23 13:33:38 -08:00
|
|
|
|
2019-03-08 14:19:05 -07: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-02 18:55:39 -04:00
|
|
|
|
2026-06-29 23:27:12 -04:00
|
|
|
/*
|
|
|
|
|
* Lean kernel-internal init model.
|
|
|
|
|
*
|
|
|
|
|
* A subsystem registers a parameterless init function that the boot path runs
|
|
|
|
|
* at a fixed phase, without the SYS_INIT level/priority machinery (kernel init
|
|
|
|
|
* order is fixed at compile time). Each entry is emitted into the subsystem's
|
|
|
|
|
* own translation unit, so it -- and its init -- is linked only when the
|
|
|
|
|
* subsystem itself is linked, preserving the pay-per-use linkage that SYS_INIT
|
|
|
|
|
* provides. The entry holds a single function pointer (no device back-pointer
|
|
|
|
|
* and no priority), so it is half the size of a SYS_INIT init_entry.
|
|
|
|
|
*/
|
|
|
|
|
struct k_kernel_init_pre_entry {
|
|
|
|
|
void (*init_fn)(void);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct k_kernel_init_post_entry {
|
|
|
|
|
void (*init_fn)(void);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Register a kernel init function to run before multithreading starts (the
|
|
|
|
|
* PRE_KERNEL phase), ahead of PRE_KERNEL device init.
|
|
|
|
|
*/
|
|
|
|
|
#define K_KERNEL_INIT_PRE(_fn) \
|
|
|
|
|
static const STRUCT_SECTION_ITERABLE(k_kernel_init_pre_entry, \
|
|
|
|
|
_kernel_init_pre_##_fn) = { \
|
|
|
|
|
.init_fn = (_fn), \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Register a kernel init function to run after the kernel is up (the
|
|
|
|
|
* POST_KERNEL phase), before POST_KERNEL device init.
|
|
|
|
|
*/
|
|
|
|
|
#define K_KERNEL_INIT_POST(_fn) \
|
|
|
|
|
static const STRUCT_SECTION_ITERABLE(k_kernel_init_post_entry, \
|
|
|
|
|
_kernel_init_post_##_fn) = { \
|
|
|
|
|
.init_fn = (_fn), \
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-08 14:19:05 -07:00
|
|
|
extern FUNC_NORETURN void z_thread_entry(k_thread_entry_t entry,
|
2017-09-11 09:30:04 -07: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-02 18:55:39 -04:00
|
|
|
|
2020-04-24 11:29:47 -07: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 14:31:03 -07:00
|
|
|
|
2020-12-15 13:37:11 -08: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-12 17:12:15 -07: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 10:38:43 -07:00
|
|
|
* If called from an ISR, the k_malloc() system heap will be used if it exists.
|
|
|
|
|
*
|
2018-04-12 17:12:15 -07:00
|
|
|
* @param size Memory allocation size
|
|
|
|
|
* @return A pointer to the allocated memory, or NULL if there is insufficient
|
2019-05-22 10:38:43 -07:00
|
|
|
* RAM in the pool or there is no pool to draw memory from
|
2018-04-12 17:12:15 -07:00
|
|
|
*/
|
2025-03-10 22:39:37 -04:00
|
|
|
void *z_thread_malloc(size_t size);
|
2018-04-12 17:12:15 -07: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-02 18:55:39 -04:00
|
|
|
|
2019-10-25 00:08:21 +09: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 12:43:29 -08:00
|
|
|
arch_thread_return_value_set(struct k_thread *thread, unsigned int value)
|
2019-10-25 00:08:21 +09: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 12:43:29 -08:00
|
|
|
arch_thread_return_value_set(thread, value);
|
2019-10-25 00:08:21 +09:00
|
|
|
thread->base.swap_data = data;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-15 09:36:45 +02:00
|
|
|
#ifdef CONFIG_SMP
|
2019-06-05 08:58:42 -07:00
|
|
|
extern void z_smp_init(void);
|
2023-06-19 17:18:03 +01:00
|
|
|
#ifdef CONFIG_SYS_CLOCK_EXISTS
|
2018-01-26 12:30:21 -08: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 12:30:21 -08:00
|
|
|
|
2023-10-09 15:22:18 -07:00
|
|
|
extern void z_early_rand_get(uint8_t *buf, size_t length);
|
2018-05-23 15:25:23 -07:00
|
|
|
|
2024-04-29 14:08:04 +02:00
|
|
|
#if defined(CONFIG_STACK_POINTER_RANDOM) && (CONFIG_STACK_POINTER_RANDOM != 0)
|
2018-05-23 15:25:23 -07:00
|
|
|
extern int z_stack_adjust_initialized;
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_STACK_POINTER_RANDOM */
|
2018-05-23 15:25:23 -07:00
|
|
|
|
2026-07-06 16:35:52 -05:00
|
|
|
#ifdef CONFIG_MULTITHREADING
|
2019-09-21 17:54:37 -07:00
|
|
|
extern struct k_thread z_main_thread;
|
2026-07-06 16:35:52 -05:00
|
|
|
#endif /* CONFIG_MULTITHREADING */
|
2020-03-12 15:37:29 -07:00
|
|
|
|
|
|
|
|
|
kernel: mmu: remove LINKER_USE_PINNED_SECTION and __pinned_* tagging
CONFIG_LINKER_USE_PINNED_SECTION is the second half of the selective
kernel-pinning model removed in issue #108773. With the kernel image
now always resident at boot (previous commit), the __pinned_*
attribute family is a no-op: every page they would have segregated is
already pinned by z_mem_manage_init()'s whole-image loop, so the
tagging contract neither adds safety nor remains maintainable.
Drop it.
Mechanical removals:
* All ~219 in-tree uses of __pinned_text, __pinned_rodata,
__pinned_data, __pinned_bss, __pinned_noinit, and __pinned_func
across arch/x86, drivers/interrupt_controller, drivers/timer,
arch/common, kernel, lib/libc, subsys/portability/posix, tests, and
the syscall code generator (scripts/build/gen_syscalls.py).
* The assembly aliases PINNED_TEXT/RODATA/DATA/BSS/NOINIT used in
arch/x86/core/ia32/*.S and drivers/interrupt_controller/
intc_loapic_spurious.S become plain TEXT/RODATA/DATA/BSS/NOINIT.
* K_KERNEL_PINNED_STACK_DEFINE, K_KERNEL_PINNED_STACK_ARRAY_DEFINE,
K_KERNEL_PINNED_STACK_ARRAY_DECLARE, K_THREAD_PINNED_STACK_DEFINE,
and K_THREAD_PINNED_STACK_ARRAY_DEFINE are removed. The few
in-tree callers (kernel/init.c, arch/arm/core/cortex_a_r/smp.c,
arch/arm64/core/fatal.c, arch/rx/core/prep_c.c,
arch/x86/core/prep_c.c, kernel/include/kernel_internal.h,
tests/bluetooth/hci_uart_async) move to the corresponding
non-pinned macros.
Machinery removals:
* Kconfig.zephyr drops CONFIG_LINKER_USE_PINNED_SECTION.
qemu_x86_tiny and qemu_x86_atom_virt drop their =y overrides.
* include/zephyr/linker/section_tags.h drops the __pinned_* macro
definitions (both arms). __isr collapses to an empty macro since
its only purpose was to alias __pinned_func.
* include/zephyr/linker/sections.h drops PINNED_TEXT_SECTION_NAME,
PINNED_BSS_SECTION_NAME, etc. and the bare PINNED_TEXT/RODATA/etc.
forwarders, plus the _APP_SMEM_PINNED_SECTION_NAME constant.
* include/zephyr/linker/linker-defs.h drops the lnkr_pinned_*
externs, the _app_smem_pinned_* externs, and the lnkr_is_pinned()
/ lnkr_is_region_pinned() inline helpers.
* include/zephyr/linker/utils.h drops the lnkr_pinned_rodata branch
in linker_is_in_rodata().
* include/zephyr/linker/app_smem_pinned{,_aligned,_unaligned}.ld
are deleted; cmake/linker/ld/target_configure.cmake stops
configuring them.
* boards/qemu/x86/qemu_x86_tiny.ld and
include/zephyr/arch/x86/ia32/linker.ld drop their pinned-section
blocks and the now-redundant #ifndef CONFIG_LINKER_USE_PINNED_SECTION
conditionals throughout the body. The
LIB_KERNEL_IN_SECT / LIB_ARCH_X86_IN_SECT / LIB_ZEPHYR_IN_SECT /
LIB_C_IN_SECT / LIB_DRIVERS_IN_SECT / LIB_SUBSYS_LOGGING_IN_SECT /
LIB_ZEPHYR_OBJECT_FILE_IN_SECT / ZEPHYR_KERNEL_FUNCS_IN_SECT macros
in qemu_x86_tiny.ld are deleted; they existed only to feed the
pinned text/rodata/data/bss/noinit sections.
* kernel/mmu.c drops the mark_linker_section_pinned(lnkr_pinned_start,
...) call. The mark_linker_section_pinned() helper survives but is
now gated only on CONFIG_LINKER_USE_BOOT_SECTION.
* arch/common/init.c and include/zephyr/arch/common/init.h drop
arch_bss_zero_pinned(); arch/x86/core/ia32/crt0.S drops the call
to it.
* arch/x86/core/userspace.c drops the eager k_mem_page_in() of the
thread's privileged stack on user-mode entry. With the kernel
image fully resident the stack is already mapped.
* arch/x86/gen_mmu.py drops map_region("lnkr_pinned") and the
set_region_perms() calls for lnkr_pinned_text / lnkr_pinned_rodata.
* CMakeLists.txt drops the LINKER_USE_PINNED_SECTION block that
generated APP_SMEM_PINNED_* variables and the
pinned_partitions target property feeding gen_app_partitions.py.
cmake/modules/extensions.cmake removes the PINNED_RODATA /
PINNED_RAM_SECTIONS / PINNED_DATA_SECTIONS zephyr_linker_sources()
location keywords and their snippet files.
scripts/build/gen_app_partitions.py drops --pinoutput /
--pinpartitions arguments and the pinned-output branch.
subsys/testsuite/coverage/CMakeLists.txt drops its
CONFIG_DEMAND_PAGING-conditional fork.
* scripts/build/gen_kobject_list.py drops the
app_smem_pinned_start / _end fallback for kobject placement
validation.
* tests/arch/x86/pagetables and tests/kernel/mem_protect/userspace
drop their lnkr_pinned_text / lnkr_pinned_rodata branches.
* include/zephyr/arch/x86/ia32/arch.h folds IRQSTUBS_TEXT_SECTION
to the unconditional ".text.irqstubs" form.
* tests/subsys/llext/src/syscalls_ext.c drops a stale comment about
syscalls landing in .pinned_text.
Targeted retentions:
* arch/x86/core/bootargs.c keeps multiboot_cmdline and efi_bootargs
in .noinit (was __pinned_noinit, which decayed to __noinit when
LINKER_USE_PINNED_SECTION was unset). The multiboot and zefi loader
paths write these buffers before Zephyr's BSS-zero step, so
zeroing them at boot loses the cmdline.
* arch/x86/core/ia32/fatal.c keeps _df_esf and _df_stack in .noinit.
They are scratch space written by the double-fault handler and have
no zero-init requirement; keeping them in .noinit also preserves
the historical post-noinit alignment that gen_mmu.py relies on
(z_mapped_size is computed before CMake-injected iterable sections
are appended to the linker script, so the post-noinit page padding
is what keeps those sections within the mapped region).
* include/zephyr/arch/x86/ia32/syscall.h and
include/zephyr/arch/x86/arch.h wrap the per-arch
arch_syscall_invoke* / arch_is_user_context / arch_k_cycle_get_*
implementations in @cond INTERNAL_HIDDEN. The public Doxygen
contract lives on the prototypes in
include/zephyr/arch/arch_interface.h; the per-arch implementations
are internal. Without this, removing the __pinned_func attribute
exposes the implementations to the doxygen-coverage delta check
as 10 newly-undocumented APIs.
Documentation updates are deferred to a separate commit.
Issue: #108773
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-05-15 16:33:20 -04:00
|
|
|
K_KERNEL_STACK_ARRAY_DECLARE(z_interrupt_stacks, CONFIG_MP_MAX_NUM_CPUS,
|
2022-06-18 00:32:42 +09:00
|
|
|
CONFIG_ISR_STACK_SIZE);
|
2024-10-23 14:07:24 +02:00
|
|
|
K_THREAD_STACK_DECLARE(z_main_stack, CONFIG_MAIN_STACK_SIZE);
|
2019-09-21 17:54:37 -07:00
|
|
|
|
2020-03-11 10:56:19 -07:00
|
|
|
#ifdef CONFIG_GEN_PRIV_STACKS
|
2020-05-27 11:26:57 -05: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 10:56:19 -07: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-24 16:24:46 -07:00
|
|
|
#ifdef CONFIG_USERSPACE
|
|
|
|
|
bool z_stack_is_user_capable(k_thread_stack_t *stack);
|
2020-10-06 13:39:29 -07:00
|
|
|
|
|
|
|
|
/* Memory domain setup hook, called from z_setup_new_thread() */
|
|
|
|
|
void z_mem_domain_init_thread(struct k_thread *thread);
|
|
|
|
|
|
2021-02-19 15:32:19 -08:00
|
|
|
/* Memory domain teardown hook, called from z_thread_abort() */
|
2020-10-06 13:39:29 -07:00
|
|
|
void z_mem_domain_exit_thread(struct k_thread *thread);
|
2020-10-06 15:53:43 -07: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-24 16:24:46 -07:00
|
|
|
#endif /* CONFIG_USERSPACE */
|
|
|
|
|
|
2020-05-21 16:55:28 -07: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 14:53:28 -07:00
|
|
|
extern int z_gdb_main_loop(struct gdb_ctx *ctx);
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_GDBSTUB */
|
2020-05-21 16:55:28 -07:00
|
|
|
|
2020-08-27 16:12:01 -07:00
|
|
|
#ifdef CONFIG_INSTRUMENT_THREAD_SWITCHING
|
2020-08-27 13:54:14 -07:00
|
|
|
void z_thread_mark_switched_in(void);
|
|
|
|
|
void z_thread_mark_switched_out(void);
|
|
|
|
|
#else
|
|
|
|
|
|
2020-08-27 16:12:01 -07: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-21 16:55:28 -07:00
|
|
|
|
2020-12-09 12:18:40 -08: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 13:15:29 -07:00
|
|
|
/**
|
|
|
|
|
* @brief Finalize page frame management at the end of boot process.
|
|
|
|
|
*/
|
|
|
|
|
void z_mem_manage_boot_finish(void);
|
|
|
|
|
|
2023-09-14 14:08:07 +00:00
|
|
|
|
2024-12-16 14:15:58 -08:00
|
|
|
bool z_handle_obj_poll_events(sys_dlist_t *events, uint32_t state);
|
2023-09-14 14:08:07 +00:00
|
|
|
|
2021-02-23 08:59:28 -08: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.
|
|
|
|
|
*
|
2026-05-12 21:24:02 +08:00
|
|
|
* This function is entered with the idle thread's interrupt lock held. If it
|
|
|
|
|
* enters a power state, it returns before the idle thread restores the saved
|
|
|
|
|
* interrupt key. SoC PM code may use architecture helpers around the
|
|
|
|
|
* low-power instruction, but normal IRQ dispatch must remain blocked until
|
|
|
|
|
* that final idle-thread restore.
|
2021-10-30 23:13:08 -07:00
|
|
|
*
|
|
|
|
|
* @return True if the system suspended, otherwise return false
|
2021-02-23 08:59:28 -08:00
|
|
|
*/
|
2021-10-30 23:13:08 -07:00
|
|
|
bool pm_system_suspend(int32_t ticks);
|
2021-02-23 08:59:28 -08:00
|
|
|
|
2024-03-08 12:00:10 +01:00
|
|
|
#endif /* CONFIG_PM */
|
2021-02-23 08:59:28 -08:00
|
|
|
|
2021-03-30 14:38:00 -07: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 12:16:40 -04: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 12:16:40 -04: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 12:16:40 -04:00
|
|
|
|
2024-03-26 11:54:31 -07:00
|
|
|
#if defined(CONFIG_THREAD_ABORT_NEED_CLEANUP)
|
|
|
|
|
/**
|
|
|
|
|
* Perform cleanup at the end of k_thread_abort().
|
|
|
|
|
*
|
|
|
|
|
* This performs additional cleanup steps at the end of k_thread_abort()
|
|
|
|
|
* where these steps require that the thread is no longer running.
|
|
|
|
|
* If the target thread is not the current running thread, the cleanup
|
|
|
|
|
* steps will be performed immediately. However, if the target thread is
|
2025-01-07 12:00:43 -05:00
|
|
|
* the current running thread (e.g. k_thread_abort(_current)), it defers
|
2024-03-26 11:54:31 -07:00
|
|
|
* the cleanup steps to later when the work will be finished in another
|
|
|
|
|
* context.
|
|
|
|
|
*
|
|
|
|
|
* @param thread Pointer to thread to be cleaned up.
|
|
|
|
|
*/
|
|
|
|
|
void k_thread_abort_cleanup(struct k_thread *thread);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if thread is the same as the one waiting for cleanup.
|
|
|
|
|
*
|
|
|
|
|
* This is used to guard against reusing the same thread object
|
|
|
|
|
* before the previous cleanup has finished. This will perform
|
|
|
|
|
* the necessary cleanups before the thread object can be
|
|
|
|
|
* reused. Should mainly be used during thread creation.
|
|
|
|
|
*
|
|
|
|
|
* @param thread Pointer to thread to be checked.
|
|
|
|
|
*/
|
|
|
|
|
void k_thread_abort_cleanup_check_reuse(struct k_thread *thread);
|
|
|
|
|
#endif /* CONFIG_THREAD_ABORT_NEED_CLEANUP */
|
|
|
|
|
|
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-02 18:55:39 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
|
2018-09-13 15:06:35 -07:00
|
|
|
#endif /* ZEPHYR_KERNEL_INCLUDE_KERNEL_INTERNAL_H_ */
|