15dffb46cSSoby Mathew /* 25dffb46cSSoby Mathew * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. 35dffb46cSSoby Mathew * 4*82cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 55dffb46cSSoby Mathew */ 65dffb46cSSoby Mathew 75dffb46cSSoby Mathew #ifndef __PSCI_LIB_H__ 85dffb46cSSoby Mathew #define __PSCI_LIB_H__ 95dffb46cSSoby Mathew 105dffb46cSSoby Mathew #include <ep_info.h> 115dffb46cSSoby Mathew 125dffb46cSSoby Mathew #ifndef __ASSEMBLY__ 135dffb46cSSoby Mathew #include <types.h> 145dffb46cSSoby Mathew 155dffb46cSSoby Mathew /******************************************************************************* 165dffb46cSSoby Mathew * Optional structure populated by the Secure Payload Dispatcher to be given a 175dffb46cSSoby Mathew * chance to perform any bookkeeping before PSCI executes a power management 185dffb46cSSoby Mathew * operation. It also allows PSCI to determine certain properties of the SP e.g. 195dffb46cSSoby Mathew * migrate capability etc. 205dffb46cSSoby Mathew ******************************************************************************/ 215dffb46cSSoby Mathew typedef struct spd_pm_ops { 225dffb46cSSoby Mathew void (*svc_on)(u_register_t target_cpu); 235dffb46cSSoby Mathew int32_t (*svc_off)(u_register_t __unused); 245dffb46cSSoby Mathew void (*svc_suspend)(u_register_t max_off_pwrlvl); 255dffb46cSSoby Mathew void (*svc_on_finish)(u_register_t __unused); 265dffb46cSSoby Mathew void (*svc_suspend_finish)(u_register_t max_off_pwrlvl); 275dffb46cSSoby Mathew int32_t (*svc_migrate)(u_register_t from_cpu, u_register_t to_cpu); 285dffb46cSSoby Mathew int32_t (*svc_migrate_info)(u_register_t *resident_cpu); 295dffb46cSSoby Mathew void (*svc_system_off)(void); 305dffb46cSSoby Mathew void (*svc_system_reset)(void); 315dffb46cSSoby Mathew } spd_pm_ops_t; 325dffb46cSSoby Mathew 335dffb46cSSoby Mathew /* 345dffb46cSSoby Mathew * Function prototype for the warmboot entrypoint function which will be 355dffb46cSSoby Mathew * programmed in the mailbox by the platform. 365dffb46cSSoby Mathew */ 375dffb46cSSoby Mathew typedef void (*mailbox_entrypoint_t)(void); 385dffb46cSSoby Mathew 395dffb46cSSoby Mathew /****************************************************************************** 405dffb46cSSoby Mathew * Structure to pass PSCI Library arguments. 415dffb46cSSoby Mathew *****************************************************************************/ 425dffb46cSSoby Mathew typedef struct psci_lib_args { 435dffb46cSSoby Mathew /* The version information of PSCI Library Interface */ 445dffb46cSSoby Mathew param_header_t h; 455dffb46cSSoby Mathew /* The warm boot entrypoint function */ 465dffb46cSSoby Mathew mailbox_entrypoint_t mailbox_ep; 475dffb46cSSoby Mathew } psci_lib_args_t; 485dffb46cSSoby Mathew 495dffb46cSSoby Mathew /* Helper macro to set the psci_lib_args_t structure at runtime */ 505dffb46cSSoby Mathew #define SET_PSCI_LIB_ARGS_V1(_p, _entry) do { \ 515dffb46cSSoby Mathew SET_PARAM_HEAD(_p, PARAM_PSCI_LIB_ARGS, VERSION_1, 0); \ 525dffb46cSSoby Mathew (_p)->mailbox_ep = (_entry); \ 535dffb46cSSoby Mathew } while (0) 545dffb46cSSoby Mathew 555dffb46cSSoby Mathew /* Helper macro to define the psci_lib_args_t statically */ 565dffb46cSSoby Mathew #define DEFINE_STATIC_PSCI_LIB_ARGS_V1(_name, _entry) \ 575dffb46cSSoby Mathew static const psci_lib_args_t (_name) = { \ 585dffb46cSSoby Mathew .h.type = (uint8_t)PARAM_PSCI_LIB_ARGS, \ 595dffb46cSSoby Mathew .h.version = (uint8_t)VERSION_1, \ 605dffb46cSSoby Mathew .h.size = (uint16_t)sizeof(_name), \ 615dffb46cSSoby Mathew .h.attr = 0, \ 625dffb46cSSoby Mathew .mailbox_ep = (_entry) \ 635dffb46cSSoby Mathew } 645dffb46cSSoby Mathew 655dffb46cSSoby Mathew /* Helper macro to verify the pointer to psci_lib_args_t structure */ 665dffb46cSSoby Mathew #define VERIFY_PSCI_LIB_ARGS_V1(_p) ((_p) \ 675dffb46cSSoby Mathew && ((_p)->h.type == PARAM_PSCI_LIB_ARGS) \ 685dffb46cSSoby Mathew && ((_p)->h.version == VERSION_1) \ 695dffb46cSSoby Mathew && ((_p)->h.size == sizeof(*(_p))) \ 705dffb46cSSoby Mathew && ((_p)->h.attr == 0) \ 715dffb46cSSoby Mathew && ((_p)->mailbox_ep)) 725dffb46cSSoby Mathew 735dffb46cSSoby Mathew /****************************************************************************** 745dffb46cSSoby Mathew * PSCI Library Interfaces 755dffb46cSSoby Mathew *****************************************************************************/ 765dffb46cSSoby Mathew u_register_t psci_smc_handler(uint32_t smc_fid, 775dffb46cSSoby Mathew u_register_t x1, 785dffb46cSSoby Mathew u_register_t x2, 795dffb46cSSoby Mathew u_register_t x3, 805dffb46cSSoby Mathew u_register_t x4, 815dffb46cSSoby Mathew void *cookie, 825dffb46cSSoby Mathew void *handle, 835dffb46cSSoby Mathew u_register_t flags); 845dffb46cSSoby Mathew int psci_setup(const psci_lib_args_t *lib_args); 855dffb46cSSoby Mathew void psci_warmboot_entrypoint(void); 865dffb46cSSoby Mathew void psci_register_spd_pm_hook(const spd_pm_ops_t *pm); 875dffb46cSSoby Mathew void psci_prepare_next_non_secure_ctx( 885dffb46cSSoby Mathew entry_point_info_t *next_image_info); 895dffb46cSSoby Mathew #endif /* __ASSEMBLY__ */ 905dffb46cSSoby Mathew 915dffb46cSSoby Mathew #endif /* __PSCI_LIB_H */ 925dffb46cSSoby Mathew 93