Debian Codegraph @

lib/psci/psci_system_off.c

raw
1 /*
2 * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <assert.h>
8 #include <stddef.h>
9
10 #include <arch_helpers.h>
11 #include <common/debug.h>
12 #include <drivers/console.h>
13 #include <plat/common/platform.h>
14
15 #include "psci_private.h"
16
17 void __dead2 psci_system_off(void)
18 {
19 psci_print_power_domain_map();
20
21 assert(psci_plat_pm_ops->system_off != NULL);
22
23 /* Notify the Secure Payload Dispatcher */
24 if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_off != NULL)) {
25 psci_spd_pm->svc_system_off();
26 }
27
28 console_flush();
29
30 /* Call the platform specific hook */
31 psci_plat_pm_ops->system_off();
32
33 /* This function does not return. We should never get here */
34 }
35
36 void __dead2 psci_system_reset(void)
37 {
38 psci_print_power_domain_map();
39
40 assert(psci_plat_pm_ops->system_reset != NULL);
41
42 /* Notify the Secure Payload Dispatcher */
43 if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) {
44 psci_spd_pm->svc_system_reset();
45 }
46
47 console_flush();
48
49 /* Call the platform specific hook */
50 psci_plat_pm_ops->system_reset();
51
52 /* This function does not return. We should never get here */
53 }
54
55 u_register_t psci_system_reset2(uint32_t reset_type, u_register_t cookie)
56 {
57 unsigned int is_vendor;
58
59 psci_print_power_domain_map();
60
61 assert(psci_plat_pm_ops->system_reset2 != NULL);
62
63 is_vendor = (reset_type >> PSCI_RESET2_TYPE_VENDOR_SHIFT) & 1U;
64 if (is_vendor == 0U) {
65 /*
66 * Only WARM_RESET is allowed for architectural type resets.
67 */
68 if (reset_type != PSCI_RESET2_SYSTEM_WARM_RESET)
69 return (u_register_t) PSCI_E_INVALID_PARAMS;
70 if ((psci_plat_pm_ops->write_mem_protect != NULL) &&
71 (psci_plat_pm_ops->write_mem_protect(0) < 0)) {
72 return (u_register_t) PSCI_E_NOT_SUPPORTED;
73 }
74 }
75
76 /* Notify the Secure Payload Dispatcher */
77 if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) {
78 psci_spd_pm->svc_system_reset();
79 }
80 console_flush();
81
82 return (u_register_t)
83 psci_plat_pm_ops->system_reset2((int) is_vendor, reset_type,
84 cookie);
85 }