Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010-2012, 2014-2015 Wind River Systems, Inc. |
| 3 | * |
David B. Kinder | ac74d8b | 2017-01-18 17:01:01 -0800 | [diff] [blame] | 4 | * SPDX-License-Identifier: Apache-2.0 |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /** |
| 8 | * @file |
Anas Nashif | dc3d73b | 2016-12-19 20:25:56 -0500 | [diff] [blame] | 9 | * @brief Architecture-independent private kernel APIs |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 10 | * |
Anas Nashif | dc3d73b | 2016-12-19 20:25:56 -0500 | [diff] [blame] | 11 | * This file contains private kernel APIs that are not architecture-specific. |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #ifndef _NANO_INTERNAL__H_ |
| 15 | #define _NANO_INTERNAL__H_ |
| 16 | |
Andrew Boie | 73abd32 | 2017-04-04 13:19:13 -0700 | [diff] [blame] | 17 | #include <kernel.h> |
| 18 | |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 19 | #define K_NUM_PRIORITIES \ |
| 20 | (CONFIG_NUM_COOP_PRIORITIES + CONFIG_NUM_PREEMPT_PRIORITIES + 1) |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 21 | |
Benjamin Walsh | 358a53c | 2016-11-18 15:35:05 -0500 | [diff] [blame] | 22 | #define K_NUM_PRIO_BITMAPS ((K_NUM_PRIORITIES + 31) >> 5) |
| 23 | |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 24 | #ifndef _ASMLANGUAGE |
| 25 | |
| 26 | #ifdef __cplusplus |
| 27 | extern "C" { |
| 28 | #endif |
| 29 | |
| 30 | /* Early boot functions */ |
| 31 | |
| 32 | void _bss_zero(void); |
| 33 | #ifdef CONFIG_XIP |
| 34 | void _data_copy(void); |
| 35 | #else |
| 36 | static inline void _data_copy(void) |
| 37 | { |
| 38 | /* Do nothing */ |
| 39 | } |
| 40 | #endif |
| 41 | FUNC_NORETURN void _Cstart(void); |
| 42 | |
Andrew Boie | 1e06ffc | 2017-09-11 09:30:04 -0700 | [diff] [blame^] | 43 | extern FUNC_NORETURN void _thread_entry(k_thread_entry_t entry, |
| 44 | void *p1, void *p2, void *p3); |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 45 | |
Andrew Boie | 507852a | 2017-07-25 18:47:07 -0700 | [diff] [blame] | 46 | extern void _new_thread(struct k_thread *thread, k_thread_stack_t pStack, |
Andrew Boie | 1e06ffc | 2017-09-11 09:30:04 -0700 | [diff] [blame^] | 47 | size_t stackSize, k_thread_entry_t entry, |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 48 | void *p1, void *p2, void *p3, |
Kumar Gala | 5742a50 | 2017-04-21 11:41:26 -0500 | [diff] [blame] | 49 | int prio, unsigned int options); |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 50 | |
| 51 | /* context switching and scheduling-related routines */ |
| 52 | |
Ramesh Thomas | 62eea12 | 2017-04-06 15:30:27 -0700 | [diff] [blame] | 53 | extern unsigned int __swap(unsigned int key); |
| 54 | |
Andrew Boie | ae1a75b | 2017-06-07 09:33:16 -0700 | [diff] [blame] | 55 | #ifdef CONFIG_TIMESLICING |
Ramesh Thomas | 89ffd44 | 2017-02-05 19:37:19 -0800 | [diff] [blame] | 56 | extern void _update_time_slice_before_swap(void); |
Andrew Boie | ae1a75b | 2017-06-07 09:33:16 -0700 | [diff] [blame] | 57 | #endif |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 58 | |
Andrew Boie | ae1a75b | 2017-06-07 09:33:16 -0700 | [diff] [blame] | 59 | #ifdef CONFIG_STACK_SENTINEL |
| 60 | extern void _check_stack_sentinel(void); |
| 61 | #endif |
| 62 | |
| 63 | static inline unsigned int _Swap(unsigned int key) |
Ramesh Thomas | 89ffd44 | 2017-02-05 19:37:19 -0800 | [diff] [blame] | 64 | { |
Andrew Boie | ae1a75b | 2017-06-07 09:33:16 -0700 | [diff] [blame] | 65 | |
| 66 | #ifdef CONFIG_STACK_SENTINEL |
| 67 | _check_stack_sentinel(); |
| 68 | #endif |
| 69 | #ifdef CONFIG_TIMESLICING |
Ramesh Thomas | 89ffd44 | 2017-02-05 19:37:19 -0800 | [diff] [blame] | 70 | _update_time_slice_before_swap(); |
Andrew Boie | ae1a75b | 2017-06-07 09:33:16 -0700 | [diff] [blame] | 71 | #endif |
| 72 | |
Ramesh Thomas | 89ffd44 | 2017-02-05 19:37:19 -0800 | [diff] [blame] | 73 | return __swap(key); |
| 74 | } |
| 75 | |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 76 | /* set and clear essential fiber/task flag */ |
| 77 | |
| 78 | extern void _thread_essential_set(void); |
| 79 | extern void _thread_essential_clear(void); |
| 80 | |
| 81 | /* clean up when a thread is aborted */ |
| 82 | |
| 83 | #if defined(CONFIG_THREAD_MONITOR) |
Benjamin Walsh | f6ca7de | 2016-11-08 10:36:50 -0500 | [diff] [blame] | 84 | extern void _thread_monitor_exit(struct k_thread *thread); |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 85 | #else |
Benjamin Walsh | f6ca7de | 2016-11-08 10:36:50 -0500 | [diff] [blame] | 86 | #define _thread_monitor_exit(thread) \ |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 87 | do {/* nothing */ \ |
| 88 | } while (0) |
| 89 | #endif /* CONFIG_THREAD_MONITOR */ |
| 90 | |
Benjamin Walsh | 456c6da | 2016-09-02 18:55:39 -0400 | [diff] [blame] | 91 | #ifdef __cplusplus |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | #endif /* _ASMLANGUAGE */ |
| 96 | |
| 97 | #endif /* _NANO_INTERNAL__H_ */ |