psci_lib.h 3.35 KB
Newer Older
1
/*
2
 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
 */

7
8
#ifndef PSCI_LIB_H
#define PSCI_LIB_H
9

10
#include <common/ep_info.h>
11

12
#ifndef __ASSEMBLER__
13

14
15
#include <cdefs.h>
#include <stdint.h>
16
17
18
19
20
21
22
23
24

/*******************************************************************************
 * Optional structure populated by the Secure Payload Dispatcher to be given a
 * chance to perform any bookkeeping before PSCI executes a power management
 * operation. It also allows PSCI to determine certain properties of the SP e.g.
 * migrate capability etc.
 ******************************************************************************/
typedef struct spd_pm_ops {
	void (*svc_on)(u_register_t target_cpu);
25
	int32_t (*svc_off)(u_register_t __unused unused);
26
	void (*svc_suspend)(u_register_t max_off_pwrlvl);
27
	void (*svc_on_finish)(u_register_t __unused unused);
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
	void (*svc_suspend_finish)(u_register_t max_off_pwrlvl);
	int32_t (*svc_migrate)(u_register_t from_cpu, u_register_t to_cpu);
	int32_t (*svc_migrate_info)(u_register_t *resident_cpu);
	void (*svc_system_off)(void);
	void (*svc_system_reset)(void);
} spd_pm_ops_t;

/*
 * Function prototype for the warmboot entrypoint function which will be
 * programmed in the mailbox by the platform.
 */
typedef void (*mailbox_entrypoint_t)(void);

/******************************************************************************
 * Structure to pass PSCI Library arguments.
 *****************************************************************************/
typedef struct psci_lib_args {
	/* The version information of PSCI Library Interface */
	param_header_t		h;
	/* The warm boot entrypoint function */
	mailbox_entrypoint_t	mailbox_ep;
} psci_lib_args_t;

/* Helper macro to set the psci_lib_args_t structure at runtime */
#define SET_PSCI_LIB_ARGS_V1(_p, _entry)	do {			\
	SET_PARAM_HEAD(_p, PARAM_PSCI_LIB_ARGS, VERSION_1, 0);		\
	(_p)->mailbox_ep = (_entry);					\
	} while (0)

/* Helper macro to define the psci_lib_args_t statically */
#define DEFINE_STATIC_PSCI_LIB_ARGS_V1(_name, _entry)		\
	static const psci_lib_args_t (_name) = {		\
		.h.type = (uint8_t)PARAM_PSCI_LIB_ARGS,		\
		.h.version = (uint8_t)VERSION_1,		\
		.h.size = (uint16_t)sizeof(_name),		\
63
		.h.attr = 0U,					\
64
65
66
67
		.mailbox_ep = (_entry)				\
	}

/* Helper macro to verify the pointer to psci_lib_args_t structure */
68
#define VERIFY_PSCI_LIB_ARGS_V1(_p)	(((_p) != NULL)		\
69
70
71
72
		&& ((_p)->h.type == PARAM_PSCI_LIB_ARGS)	\
		&& ((_p)->h.version == VERSION_1)		\
		&& ((_p)->h.size == sizeof(*(_p)))		\
		&& ((_p)->h.attr == 0)				\
73
		&& ((_p)->mailbox_ep != NULL))
74
75
76
77
78
79
80
81
82
83
84
85
86

/******************************************************************************
 * PSCI Library Interfaces
 *****************************************************************************/
u_register_t psci_smc_handler(uint32_t smc_fid,
			  u_register_t x1,
			  u_register_t x2,
			  u_register_t x3,
			  u_register_t x4,
			  void *cookie,
			  void *handle,
			  u_register_t flags);
int psci_setup(const psci_lib_args_t *lib_args);
87
int psci_secondaries_brought_up(void);
88
89
90
91
void psci_warmboot_entrypoint(void);
void psci_register_spd_pm_hook(const spd_pm_ops_t *pm);
void psci_prepare_next_non_secure_ctx(
			  entry_point_info_t *next_image_info);
92
93
int psci_stop_other_cores(unsigned int wait_ms,
			  void (*stop_func)(u_register_t mpidr));
94
#endif /* __ASSEMBLER__ */
95

96
#endif /* PSCI_LIB_H */