xref: /openbmc/qemu/target/arm/arm-powerctl.h (revision f1733749)
1 /*
2  * QEMU support -- ARM Power Control specific functions.
3  *
4  * Copyright (c) 2016 Jean-Christophe Dubois
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  *
9  */
10 
11 #ifndef QEMU_ARM_POWERCTL_H
12 #define QEMU_ARM_POWERCTL_H
13 
14 #include "kvm-consts.h"
15 
16 #define QEMU_ARM_POWERCTL_RET_SUCCESS QEMU_PSCI_RET_SUCCESS
17 #define QEMU_ARM_POWERCTL_INVALID_PARAM QEMU_PSCI_RET_INVALID_PARAMS
18 #define QEMU_ARM_POWERCTL_ALREADY_ON QEMU_PSCI_RET_ALREADY_ON
19 #define QEMU_ARM_POWERCTL_IS_OFF QEMU_PSCI_RET_DENIED
20 #define QEMU_ARM_POWERCTL_ON_PENDING QEMU_PSCI_RET_ON_PENDING
21 
22 /*
23  * arm_get_cpu_by_id:
24  * @cpuid: the id of the CPU we want to retrieve the state
25  *
26  * Retrieve a CPUState object from its CPU ID provided in @cpuid.
27  *
28  * Returns: a pointer to the CPUState structure of the requested CPU.
29  */
30 CPUState *arm_get_cpu_by_id(uint64_t cpuid);
31 
32 /*
33  * arm_set_cpu_on:
34  * @cpuid: the id of the CPU we want to start/wake up.
35  * @entry: the address the CPU shall start from.
36  * @context_id: the value to put in r0/x0.
37  * @target_el: The desired exception level.
38  * @target_aa64: 1 if the requested mode is AArch64. 0 otherwise.
39  *
40  * Start the cpu designated by @cpuid in @target_el exception level. The mode
41  * shall be AArch64 if @target_aa64 is set to 1. Otherwise the mode is
42  * AArch32. The CPU shall start at @entry with @context_id in r0/x0.
43  *
44  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
45  * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided.
46  * QEMU_ARM_POWERCTL_ALREADY_ON if the CPU was already started.
47  * QEMU_ARM_POWERCTL_ON_PENDING if the CPU is still powering up
48  */
49 int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id,
50                    uint32_t target_el, bool target_aa64);
51 
52 /*
53  * arm_set_cpu_off:
54  * @cpuid: the id of the CPU we want to stop/shut down.
55  *
56  * Stop the cpu designated by @cpuid.
57  *
58  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
59  * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided.
60  * QEMU_ARM_POWERCTL_IS_OFF if CPU is already off
61  */
62 
63 int arm_set_cpu_off(uint64_t cpuid);
64 
65 /*
66  * arm_reset_cpu:
67  * @cpuid: the id of the CPU we want to reset.
68  *
69  * Reset the cpu designated by @cpuid.
70  *
71  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
72  * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided.
73  * QEMU_ARM_POWERCTL_IS_OFF if CPU is off
74  */
75 int arm_reset_cpu(uint64_t cpuid);
76 
77 /*
78  * arm_set_cpu_on_and_reset:
79  * @cpuid: the id of the CPU we want to star
80  *
81  * Start the cpu designated by @cpuid and put it through its normal
82  * CPU reset process. The CPU will start in the way it is architected
83  * to start after a power-on reset.
84  *
85  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
86  * QEMU_ARM_POWERCTL_INVALID_PARAM if there is no CPU with that ID.
87  * QEMU_ARM_POWERCTL_ALREADY_ON if the CPU is already on.
88  * QEMU_ARM_POWERCTL_ON_PENDING if the CPU is already partway through
89  * powering on.
90  */
91 int arm_set_cpu_on_and_reset(uint64_t cpuid);
92 
93 #endif
94