Branch data Line data Source code
1 : : /*
2 : : * Copyright (c) 2011-2015 Wind River Systems, Inc.
3 : : * Copyright (c) 2017 Oticon A/S
4 : : *
5 : : * SPDX-License-Identifier: Apache-2.0
6 : : */
7 : : /**
8 : : * @file CPU power management code for POSIX
9 : : *
10 : : * This module provides:
11 : : *
12 : : * An implementation of the architecture-specific
13 : : * arch_cpu_idle() primitive required by the kernel idle loop component.
14 : : * It can be called within an implementation of _pm_save_idle(),
15 : : * which is provided for the kernel by the platform.
16 : : *
17 : : * An implementation of arch_cpu_atomic_idle(), which
18 : : * atomically re-enables interrupts and enters low power mode.
19 : : *
20 : : * A weak stub for sys_arch_reboot(), which does nothing
21 : : */
22 : :
23 : : #include "posix_core.h"
24 : : #include "posix_board_if.h"
25 : : #include <zephyr/arch/posix/posix_soc_if.h>
26 : : #include <zephyr/tracing/tracing.h>
27 : :
28 : : #if !defined(CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT)
29 : : #error "The POSIX architecture needs a custom busy_wait implementation. \
30 : : CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT must be selected"
31 : : /* Each POSIX arch board (or SOC) must provide an implementation of
32 : : * arch_busy_wait()
33 : : */
34 : : #endif
35 : :
36 : 0 : void arch_cpu_idle(void)
37 : : {
38 : : #if defined(CONFIG_TRACING)
39 : : sys_trace_idle();
40 : : #endif
41 : 0 : posix_irq_full_unlock();
42 : 0 : posix_halt_cpu();
43 : 0 : }
44 : :
45 : 0 : void arch_cpu_atomic_idle(unsigned int key)
46 : : {
47 : : #if defined(CONFIG_TRACING)
48 : : sys_trace_idle();
49 : : #endif
50 : 0 : posix_atomic_halt_cpu(key);
51 : 0 : }
52 : :
53 : : #if defined(CONFIG_REBOOT)
54 : : /**
55 : : * @brief Stub for sys_arch_reboot
56 : : *
57 : : * Does nothing
58 : : */
59 : : void __weak sys_arch_reboot(int type)
60 : : {
61 : : posix_print_warning("%s called with type %d. Exiting\n",
62 : : __func__, type);
63 : : posix_exit(1);
64 : : }
65 : : #endif /* CONFIG_REBOOT */
|