xref: /qemu/target/arm/arm-powerctl.h (revision 9403bccfe3e271f04e12c8c64d306e0cff589009)
1825482adSJean-Christophe DUBOIS /*
2825482adSJean-Christophe DUBOIS  * QEMU support -- ARM Power Control specific functions.
3825482adSJean-Christophe DUBOIS  *
4825482adSJean-Christophe DUBOIS  * Copyright (c) 2016 Jean-Christophe Dubois
5825482adSJean-Christophe DUBOIS  *
6825482adSJean-Christophe DUBOIS  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7825482adSJean-Christophe DUBOIS  * See the COPYING file in the top-level directory.
8825482adSJean-Christophe DUBOIS  *
9825482adSJean-Christophe DUBOIS  */
10825482adSJean-Christophe DUBOIS 
11825482adSJean-Christophe DUBOIS #ifndef QEMU_ARM_POWERCTL_H
12825482adSJean-Christophe DUBOIS #define QEMU_ARM_POWERCTL_H
13825482adSJean-Christophe DUBOIS 
14825482adSJean-Christophe DUBOIS #include "kvm-consts.h"
15825482adSJean-Christophe DUBOIS 
16825482adSJean-Christophe DUBOIS #define QEMU_ARM_POWERCTL_RET_SUCCESS QEMU_PSCI_RET_SUCCESS
17825482adSJean-Christophe DUBOIS #define QEMU_ARM_POWERCTL_INVALID_PARAM QEMU_PSCI_RET_INVALID_PARAMS
18825482adSJean-Christophe DUBOIS #define QEMU_ARM_POWERCTL_ALREADY_ON QEMU_PSCI_RET_ALREADY_ON
19825482adSJean-Christophe DUBOIS #define QEMU_ARM_POWERCTL_IS_OFF QEMU_PSCI_RET_DENIED
20062ba099SAlex Bennée #define QEMU_ARM_POWERCTL_ON_PENDING QEMU_PSCI_RET_ON_PENDING
21825482adSJean-Christophe DUBOIS 
22825482adSJean-Christophe DUBOIS /*
23825482adSJean-Christophe DUBOIS  * arm_get_cpu_by_id:
24825482adSJean-Christophe DUBOIS  * @cpuid: the id of the CPU we want to retrieve the state
25825482adSJean-Christophe DUBOIS  *
26825482adSJean-Christophe DUBOIS  * Retrieve a CPUState object from its CPU ID provided in @cpuid.
27825482adSJean-Christophe DUBOIS  *
28825482adSJean-Christophe DUBOIS  * Returns: a pointer to the CPUState structure of the requested CPU.
29825482adSJean-Christophe DUBOIS  */
30825482adSJean-Christophe DUBOIS CPUState *arm_get_cpu_by_id(uint64_t cpuid);
31825482adSJean-Christophe DUBOIS 
32825482adSJean-Christophe DUBOIS /*
33825482adSJean-Christophe DUBOIS  * arm_set_cpu_on:
34825482adSJean-Christophe DUBOIS  * @cpuid: the id of the CPU we want to start/wake up.
35825482adSJean-Christophe DUBOIS  * @entry: the address the CPU shall start from.
36825482adSJean-Christophe DUBOIS  * @context_id: the value to put in r0/x0.
37825482adSJean-Christophe DUBOIS  * @target_el: The desired exception level.
38825482adSJean-Christophe DUBOIS  * @target_aa64: 1 if the requested mode is AArch64. 0 otherwise.
39825482adSJean-Christophe DUBOIS  *
40825482adSJean-Christophe DUBOIS  * Start the cpu designated by @cpuid in @target_el exception level. The mode
41825482adSJean-Christophe DUBOIS  * shall be AArch64 if @target_aa64 is set to 1. Otherwise the mode is
42825482adSJean-Christophe DUBOIS  * AArch32. The CPU shall start at @entry with @context_id in r0/x0.
43825482adSJean-Christophe DUBOIS  *
44825482adSJean-Christophe DUBOIS  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
45825482adSJean-Christophe DUBOIS  * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided.
46825482adSJean-Christophe DUBOIS  * QEMU_ARM_POWERCTL_ALREADY_ON if the CPU was already started.
47062ba099SAlex Bennée  * QEMU_ARM_POWERCTL_ON_PENDING if the CPU is still powering up
48825482adSJean-Christophe DUBOIS  */
49825482adSJean-Christophe DUBOIS int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id,
50825482adSJean-Christophe DUBOIS                    uint32_t target_el, bool target_aa64);
51825482adSJean-Christophe DUBOIS 
52825482adSJean-Christophe DUBOIS /*
53825482adSJean-Christophe DUBOIS  * arm_set_cpu_off:
54825482adSJean-Christophe DUBOIS  * @cpuid: the id of the CPU we want to stop/shut down.
55825482adSJean-Christophe DUBOIS  *
56825482adSJean-Christophe DUBOIS  * Stop the cpu designated by @cpuid.
57825482adSJean-Christophe DUBOIS  *
58825482adSJean-Christophe DUBOIS  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
59825482adSJean-Christophe DUBOIS  * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided.
60825482adSJean-Christophe DUBOIS  * QEMU_ARM_POWERCTL_IS_OFF if CPU is already off
61825482adSJean-Christophe DUBOIS  */
62825482adSJean-Christophe DUBOIS 
63825482adSJean-Christophe DUBOIS int arm_set_cpu_off(uint64_t cpuid);
64825482adSJean-Christophe DUBOIS 
65825482adSJean-Christophe DUBOIS /*
66825482adSJean-Christophe DUBOIS  * arm_reset_cpu:
67825482adSJean-Christophe DUBOIS  * @cpuid: the id of the CPU we want to reset.
68825482adSJean-Christophe DUBOIS  *
69825482adSJean-Christophe DUBOIS  * Reset the cpu designated by @cpuid.
70825482adSJean-Christophe DUBOIS  *
71825482adSJean-Christophe DUBOIS  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
72825482adSJean-Christophe DUBOIS  * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided.
73825482adSJean-Christophe DUBOIS  * QEMU_ARM_POWERCTL_IS_OFF if CPU is off
74825482adSJean-Christophe DUBOIS  */
75825482adSJean-Christophe DUBOIS int arm_reset_cpu(uint64_t cpuid);
76825482adSJean-Christophe DUBOIS 
77*ea824b97SPeter Maydell /*
78*ea824b97SPeter Maydell  * arm_set_cpu_on_and_reset:
79*ea824b97SPeter Maydell  * @cpuid: the id of the CPU we want to star
80*ea824b97SPeter Maydell  *
81*ea824b97SPeter Maydell  * Start the cpu designated by @cpuid and put it through its normal
82*ea824b97SPeter Maydell  * CPU reset process. The CPU will start in the way it is architected
83*ea824b97SPeter Maydell  * to start after a power-on reset.
84*ea824b97SPeter Maydell  *
85*ea824b97SPeter Maydell  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
86*ea824b97SPeter Maydell  * QEMU_ARM_POWERCTL_INVALID_PARAM if there is no CPU with that ID.
87*ea824b97SPeter Maydell  * QEMU_ARM_POWERCTL_ALREADY_ON if the CPU is already on.
88*ea824b97SPeter Maydell  * QEMU_ARM_POWERCTL_ON_PENDING if the CPU is already partway through
89*ea824b97SPeter Maydell  * powering on.
90*ea824b97SPeter Maydell  */
91*ea824b97SPeter Maydell int arm_set_cpu_on_and_reset(uint64_t cpuid);
92*ea824b97SPeter Maydell 
93825482adSJean-Christophe DUBOIS #endif
94