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