Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 3ce0e77 | 2018-07-16 17:32:37 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 3ce0e77 | 2018-07-16 17:32:37 +0100 | [diff] [blame] | 7 | #ifndef PSCI_LIB_H |
| 8 | #define PSCI_LIB_H |
Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 9 | |
| 10 | #include <ep_info.h> |
| 11 | |
| 12 | #ifndef __ASSEMBLY__ |
| 13 | #include <types.h> |
| 14 | |
| 15 | /******************************************************************************* |
| 16 | * Optional structure populated by the Secure Payload Dispatcher to be given a |
| 17 | * chance to perform any bookkeeping before PSCI executes a power management |
| 18 | * operation. It also allows PSCI to determine certain properties of the SP e.g. |
| 19 | * migrate capability etc. |
| 20 | ******************************************************************************/ |
| 21 | typedef struct spd_pm_ops { |
| 22 | void (*svc_on)(u_register_t target_cpu); |
Antonio Nino Diaz | 3ce0e77 | 2018-07-16 17:32:37 +0100 | [diff] [blame] | 23 | int32_t (*svc_off)(u_register_t __unused unused); |
Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 24 | void (*svc_suspend)(u_register_t max_off_pwrlvl); |
Antonio Nino Diaz | 3ce0e77 | 2018-07-16 17:32:37 +0100 | [diff] [blame] | 25 | void (*svc_on_finish)(u_register_t __unused unused); |
Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 26 | void (*svc_suspend_finish)(u_register_t max_off_pwrlvl); |
| 27 | int32_t (*svc_migrate)(u_register_t from_cpu, u_register_t to_cpu); |
| 28 | int32_t (*svc_migrate_info)(u_register_t *resident_cpu); |
| 29 | void (*svc_system_off)(void); |
| 30 | void (*svc_system_reset)(void); |
| 31 | } spd_pm_ops_t; |
| 32 | |
| 33 | /* |
| 34 | * Function prototype for the warmboot entrypoint function which will be |
| 35 | * programmed in the mailbox by the platform. |
| 36 | */ |
| 37 | typedef void (*mailbox_entrypoint_t)(void); |
| 38 | |
| 39 | /****************************************************************************** |
| 40 | * Structure to pass PSCI Library arguments. |
| 41 | *****************************************************************************/ |
| 42 | typedef struct psci_lib_args { |
| 43 | /* The version information of PSCI Library Interface */ |
| 44 | param_header_t h; |
| 45 | /* The warm boot entrypoint function */ |
| 46 | mailbox_entrypoint_t mailbox_ep; |
| 47 | } psci_lib_args_t; |
| 48 | |
| 49 | /* Helper macro to set the psci_lib_args_t structure at runtime */ |
| 50 | #define SET_PSCI_LIB_ARGS_V1(_p, _entry) do { \ |
| 51 | SET_PARAM_HEAD(_p, PARAM_PSCI_LIB_ARGS, VERSION_1, 0); \ |
| 52 | (_p)->mailbox_ep = (_entry); \ |
| 53 | } while (0) |
| 54 | |
| 55 | /* Helper macro to define the psci_lib_args_t statically */ |
| 56 | #define DEFINE_STATIC_PSCI_LIB_ARGS_V1(_name, _entry) \ |
| 57 | static const psci_lib_args_t (_name) = { \ |
| 58 | .h.type = (uint8_t)PARAM_PSCI_LIB_ARGS, \ |
| 59 | .h.version = (uint8_t)VERSION_1, \ |
| 60 | .h.size = (uint16_t)sizeof(_name), \ |
Antonio Nino Diaz | 78a95a6 | 2018-07-17 15:10:08 +0100 | [diff] [blame] | 61 | .h.attr = 0U, \ |
Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 62 | .mailbox_ep = (_entry) \ |
| 63 | } |
| 64 | |
| 65 | /* Helper macro to verify the pointer to psci_lib_args_t structure */ |
Antonio Nino Diaz | 78a95a6 | 2018-07-17 15:10:08 +0100 | [diff] [blame] | 66 | #define VERIFY_PSCI_LIB_ARGS_V1(_p) (((_p) != NULL) \ |
Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 67 | && ((_p)->h.type == PARAM_PSCI_LIB_ARGS) \ |
| 68 | && ((_p)->h.version == VERSION_1) \ |
| 69 | && ((_p)->h.size == sizeof(*(_p))) \ |
| 70 | && ((_p)->h.attr == 0) \ |
Antonio Nino Diaz | 78a95a6 | 2018-07-17 15:10:08 +0100 | [diff] [blame] | 71 | && ((_p)->mailbox_ep != NULL)) |
Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 72 | |
| 73 | /****************************************************************************** |
| 74 | * PSCI Library Interfaces |
| 75 | *****************************************************************************/ |
| 76 | u_register_t psci_smc_handler(uint32_t smc_fid, |
| 77 | u_register_t x1, |
| 78 | u_register_t x2, |
| 79 | u_register_t x3, |
| 80 | u_register_t x4, |
| 81 | void *cookie, |
| 82 | void *handle, |
| 83 | u_register_t flags); |
| 84 | int psci_setup(const psci_lib_args_t *lib_args); |
Jeenu Viswambharan | bc1a929 | 2017-02-16 14:55:15 +0000 | [diff] [blame] | 85 | int psci_secondaries_brought_up(void); |
Soby Mathew | b911cc7 | 2017-02-13 12:46:28 +0000 | [diff] [blame] | 86 | void psci_warmboot_entrypoint(void); |
| 87 | void psci_register_spd_pm_hook(const spd_pm_ops_t *pm); |
| 88 | void psci_prepare_next_non_secure_ctx( |
| 89 | entry_point_info_t *next_image_info); |
| 90 | #endif /* __ASSEMBLY__ */ |
| 91 | |
Antonio Nino Diaz | 3ce0e77 | 2018-07-16 17:32:37 +0100 | [diff] [blame] | 92 | #endif /* PSCI_LIB_H */ |