Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | /* k_init.c */ /* * Copyright (c) 1997-2010, 2012-2014 Wind River Systems, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <microkernel.h> #include <micro_private.h> #include <nano_private.h> #include <string.h> #include <toolchain.h> #include <sections.h> #include <device.h> #include <init.h> #ifdef CONFIG_BOOT_TIME_MEASUREMENT #include <arch/cpu.h> #endif extern void _k_init_dynamic(void); /* defined by sysgen */ char __noinit __stack _k_server_stack[CONFIG_MICROKERNEL_SERVER_STACK_SIZE]; #ifdef CONFIG_TASK_DEBUG int _k_debug_halt; #endif #ifdef CONFIG_INIT_STACKS static uint32_t _k_server_command_stack_storage [CONFIG_COMMAND_STACK_SIZE] = { [0 ... CONFIG_COMMAND_STACK_SIZE - 1] = 0xAAAAAAAA }; #else static uint32_t __noinit _k_server_command_stack_storage [CONFIG_COMMAND_STACK_SIZE]; #endif struct nano_stack _k_command_stack = {NULL, _k_server_command_stack_storage, _k_server_command_stack_storage, #ifdef CONFIG_DEBUG_TRACING_KERNEL_OBJECTS /* _k_command stack is not tracked by * the debug tracing kernel objects feature. */ NULL, #endif }; extern void _k_server(int unused1, int unused2); extern int _k_kernel_idle(void); /** * * @brief Mainline for microkernel's idle task * * This routine completes kernel initialization and starts any application * tasks in the EXE task group. From then on it takes care of doing idle * processing whenever there is no other work for the kernel to do. * * @return N/A */ void _main(void) { _sys_device_do_config_level(_SYS_INIT_LEVEL_SECONDARY); _sys_device_do_config_level(_SYS_INIT_LEVEL_NANOKERNEL); #ifdef CONFIG_BOOT_TIME_MEASUREMENT /* * record timestamp for microkernel's _main() function */ extern uint64_t __main_tsc; __main_tsc = _NanoTscRead(); #endif /* * Most variables and data structure are statically initialized in * kernel_main.c: this only initializes what must be dynamically * initialized at runtime. */ _k_init_dynamic(); task_fiber_start(_k_server_stack, CONFIG_MICROKERNEL_SERVER_STACK_SIZE, _k_server, 0, 0, CONFIG_MICROKERNEL_SERVER_PRIORITY, 0); _sys_device_do_config_level(_SYS_INIT_LEVEL_MICROKERNEL); _sys_device_do_config_level(_SYS_INIT_LEVEL_APPLICATION); #ifdef CONFIG_CPLUSPLUS /* Process the .ctors and .init_array sections */ extern void __do_global_ctors_aux(void); extern void __do_init_array_aux(void); __do_global_ctors_aux(); __do_init_array_aux(); #endif #ifdef CONFIG_WORKLOAD_MONITOR _k_workload_monitor_calibrate(); #endif task_group_start(EXE_GROUP); _k_kernel_idle(); } |