| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2022-2023, The Puppy RTOS Authors | ||
| 3 | * | ||
| 4 | * SPDX-License-Identifier: Apache-2.0 | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <puppy.h> | ||
| 8 | #include <puppy/kobj.h> | ||
| 9 | |||
| 10 | #define KLOG_TAG "init" | ||
| 11 | #define KLOG_LVL KLOG_WARNING | ||
| 12 | #include <puppy/klog.h> | ||
| 13 | |||
| 14 | static struct _thread_obj _idle[P_CPU_NR]; | ||
| 15 | p_align(P_ALIGN_SIZE) | ||
| 16 | static uint8_t _idle_thread_stack[P_CPU_NR][P_IDLE_THREAD_STACK_SIZE]; | ||
| 17 | |||
| 18 | |||
| 19 | 4 | static void idle_thread_entry(void *parm) | |
| 20 | { | ||
| 21 | 4 | uint8_t cpu_id = p_cpu_self_id(); | |
| 22 | while(1) | ||
| 23 | { | ||
| 24 |
2/2✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2341 times.
|
2353 | if (!p_list_is_empty(&p_cpu_index(cpu_id)->dead_queue)) |
| 25 | { | ||
| 26 | 11 | p_thread_dead_clean(); | |
| 27 | } | ||
| 28 | else | ||
| 29 | { | ||
| 30 | 2341 | __asm("wfi"); | |
| 31 | } | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | const P_SECTION_START_DEFINE(P_INIT_SECTION, _init_start); | ||
| 36 | const P_SECTION_END_DEFINE(P_INIT_SECTION, _init_end); | ||
| 37 | 1 | static void _init_fn_run(void) | |
| 38 | { | ||
| 39 | struct p_ex_fn *ptr_begin, *ptr_end; | ||
| 40 | volatile struct p_ex_fn *init_fn; | ||
| 41 | 1 | ptr_begin = (struct p_ex_fn *)P_SECTION_START_ADDR(_init_start); | |
| 42 | 1 | ptr_end = (struct p_ex_fn *)P_SECTION_END_ADDR(_init_end); | |
| 43 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (init_fn = ptr_begin; init_fn < ptr_end;) |
| 44 | { | ||
| 45 | KLOG_D("init [%s] init...", init_fn->name); | ||
| 46 | 2 | (init_fn ++)->func(); | |
| 47 | } | ||
| 48 | 1 | } | |
| 49 | |||
| 50 | 1 | void p_show_version(void) | |
| 51 | { | ||
| 52 | 1 | printk("\n\nBuild Time: %s %s\n", __DATE__, __TIME__); | |
| 53 | 1 | printk(" _ \n"); | |
| 54 | 1 | printk(" ____ ____ _____ (_) _ __\n"); | |
| 55 | 1 | printk(" / __ \\ / __ \\ / ___/ / / | |/_/\n"); | |
| 56 | 1 | printk(" / /_/ // /_/ / (__ ) / / > < \n"); | |
| 57 | 1 | printk(" / .___/ \\____/ /____/ /_/ /_/|_| \n"); | |
| 58 | 1 | printk("/_/ Powered dy puppy-rtos\n"); | |
| 59 | 1 | } | |
| 60 | |||
| 61 | ✗ | p_weak void p_subcpu_start(void) | |
| 62 | { | ||
| 63 | ; | ||
| 64 | ✗ | } | |
| 65 | |||
| 66 | 1 | void puppy_init(void) | |
| 67 | { | ||
| 68 | 1 | puppy_board_init(); | |
| 69 | 1 | p_cpu_init(); | |
| 70 | 1 | p_show_version(); | |
| 71 | 1 | _init_fn_run(); | |
| 72 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (uint8_t i = 0; i < P_CPU_NR; i++) |
| 73 | { | ||
| 74 | 4 | p_thread_init(&_idle[i], "idle", idle_thread_entry, NULL, | |
| 75 | 4 | _idle_thread_stack[i], P_IDLE_THREAD_STACK_SIZE, | |
| 76 | P_THREAD_PRIO_MAX, i); | ||
| 77 | 4 | p_thread_start(&_idle[i]); | |
| 78 | } | ||
| 79 | 1 | p_subcpu_start(); | |
| 80 | 1 | } | |
| 81 | |||
| 82 | 4 | void puppy_start(void) | |
| 83 | { | ||
| 84 | 4 | p_sched_unlock(); | |
| 85 | ✗ | } | |
| 86 |