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 20825482adSJean-Christophe DUBOIS 21825482adSJean-Christophe DUBOIS /* 22825482adSJean-Christophe DUBOIS * arm_get_cpu_by_id: 23825482adSJean-Christophe DUBOIS * @cpuid: the id of the CPU we want to retrieve the state 24825482adSJean-Christophe DUBOIS * 25825482adSJean-Christophe DUBOIS * Retrieve a CPUState object from its CPU ID provided in @cpuid. 26825482adSJean-Christophe DUBOIS * 27825482adSJean-Christophe DUBOIS * Returns: a pointer to the CPUState structure of the requested CPU. 28825482adSJean-Christophe DUBOIS */ 29825482adSJean-Christophe DUBOIS CPUState *arm_get_cpu_by_id(uint64_t cpuid); 30825482adSJean-Christophe DUBOIS 31825482adSJean-Christophe DUBOIS /* 32825482adSJean-Christophe DUBOIS * arm_set_cpu_on: 33825482adSJean-Christophe DUBOIS * @cpuid: the id of the CPU we want to start/wake up. 34825482adSJean-Christophe DUBOIS * @entry: the address the CPU shall start from. 35825482adSJean-Christophe DUBOIS * @context_id: the value to put in r0/x0. 36825482adSJean-Christophe DUBOIS * @target_el: The desired exception level. 37825482adSJean-Christophe DUBOIS * @target_aa64: 1 if the requested mode is AArch64. 0 otherwise. 38825482adSJean-Christophe DUBOIS * 39825482adSJean-Christophe DUBOIS * Start the cpu designated by @cpuid in @target_el exception level. The mode 40825482adSJean-Christophe DUBOIS * shall be AArch64 if @target_aa64 is set to 1. Otherwise the mode is 41825482adSJean-Christophe DUBOIS * AArch32. The CPU shall start at @entry with @context_id in r0/x0. 42825482adSJean-Christophe DUBOIS * 43825482adSJean-Christophe DUBOIS * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success. 44825482adSJean-Christophe DUBOIS * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided. 45825482adSJean-Christophe DUBOIS * QEMU_ARM_POWERCTL_ALREADY_ON if the CPU was already started. 46825482adSJean-Christophe DUBOIS */ 47825482adSJean-Christophe DUBOIS int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id, 48825482adSJean-Christophe DUBOIS uint32_t target_el, bool target_aa64); 49825482adSJean-Christophe DUBOIS 50825482adSJean-Christophe DUBOIS /* 51825482adSJean-Christophe DUBOIS * arm_set_cpu_off: 52825482adSJean-Christophe DUBOIS * @cpuid: the id of the CPU we want to stop/shut down. 53825482adSJean-Christophe DUBOIS * 54825482adSJean-Christophe DUBOIS * Stop the cpu designated by @cpuid. 55825482adSJean-Christophe DUBOIS * 56825482adSJean-Christophe DUBOIS * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success. 57825482adSJean-Christophe DUBOIS * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided. 58825482adSJean-Christophe DUBOIS * QEMU_ARM_POWERCTL_IS_OFF if CPU is already off 59825482adSJean-Christophe DUBOIS */ 60825482adSJean-Christophe DUBOIS 61825482adSJean-Christophe DUBOIS int arm_set_cpu_off(uint64_t cpuid); 62825482adSJean-Christophe DUBOIS 63825482adSJean-Christophe DUBOIS /* 64825482adSJean-Christophe DUBOIS * arm_reset_cpu: 65825482adSJean-Christophe DUBOIS * @cpuid: the id of the CPU we want to reset. 66825482adSJean-Christophe DUBOIS * 67825482adSJean-Christophe DUBOIS * Reset the cpu designated by @cpuid. 68825482adSJean-Christophe DUBOIS * 69825482adSJean-Christophe DUBOIS * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success. 70825482adSJean-Christophe DUBOIS * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided. 71825482adSJean-Christophe DUBOIS * QEMU_ARM_POWERCTL_IS_OFF if CPU is off 72825482adSJean-Christophe DUBOIS */ 73825482adSJean-Christophe DUBOIS int arm_reset_cpu(uint64_t cpuid); 74825482adSJean-Christophe DUBOIS 75825482adSJean-Christophe DUBOIS #endif 76