1// vi:set ft=cpp: -*- Mode: C++ -*- 2/** 3 * \file 4 * Platform control object. 5 */ 6/* 7 * (c) 2014 Steffen Liebergeld <steffen.liebergeld@kernkonzept.com> 8 * Adam Lackorzynski <adam@os.inf.tu-dresden.de>, 9 * Alexander Warg <warg@os.inf.tu-dresden.de> 10 * economic rights: Technische Universität Dresden (Germany) 11 * 12 * This file is part of TUD:OS and distributed under the terms of the 13 * GNU General Public License 2. 14 * Please see the COPYING-GPL-2 file for details. 15 * 16 * As a special exception, you may use this file as part of a free software 17 * library without restriction. Specifically, if other files instantiate 18 * templates or use macros or inline functions from this file, or you compile 19 * this file and link it with other files to produce an executable, this 20 * file does not by itself cause the resulting executable to be covered by 21 * the GNU General Public License. This exception does not however 22 * invalidate any other reasons why the executable file might be covered by 23 * the GNU General Public License. 24 */ 25 26#pragma once 27 28#include <l4/sys/capability> 29#include <l4/sys/platform_control.h> 30#include <l4/sys/cxx/ipc_iface> 31 32namespace L4 { 33 34/** 35 * L4 C++ interface for controlling platform-wide properties. 36 * 37 * Add 38 * 39 * #include <l4/sys/platform_control> 40 * 41 * to your code to use the platform control functions. The API allows a 42 * client to suspend, reboot or shutdown the system. 43 * 44 * For the C interface refer to the \ref l4_platform_control_api. 45 */ 46class L4_EXPORT Platform_control 47: public Kobject_t<Platform_control, Kobject, L4_PROTO_PLATFORM_CTL> 48{ 49public: 50 /** 51 * Enter suspend to RAM. 52 * 53 * \param extras Some extra platform-specific information needed to enter 54 * suspend to RAM. On x86 platforms and when using the 55 * Platform_control object provided by Fiasco, the value 56 * defines the sleep state. The sleep states are defined in the 57 * ACPI table. Other platforms as well as Io's Platform_control 58 * object don't make use of this value at the moment. 59 */ 60 L4_INLINE_RPC_OP(L4_PLATFORM_CTL_SYS_SUSPEND_OP, 61 l4_msgtag_t, system_suspend, (l4_umword_t extras)); 62 63 /** 64 * Shutdown/Reboot the system. 65 * 66 * \param reboot 1 for reboot, 0 for power off 67 */ 68 L4_INLINE_RPC_OP(L4_PLATFORM_CTL_SYS_SHUTDOWN_OP, 69 l4_msgtag_t, system_shutdown, (l4_umword_t reboot)); 70 71 /** 72 * Allow CPU shutdown. 73 * 74 * \param phys_id Physical CPU id of CPU (e.g. local APIC id) to disable. 75 * \param enable Allow shutdown when 1, disallow when 0. 76 * 77 * Sets or unsets a hint that a CPU that is not currently used may be powered 78 * down. 79 */ 80 L4_INLINE_RPC_OP(L4_PLATFORM_CTL_CPU_ALLOW_SHUTDOWN_OP, 81 l4_msgtag_t, cpu_allow_shutdown, 82 (l4_umword_t phys_id, l4_umword_t enable)); 83 84 /** 85 * Enable an offline CPU. 86 * 87 * \param phys_id Physical CPU id of CPU (e.g. local APIC id) to enable. 88 * 89 * \return System call message tag 90 * 91 * This function is currently only supported on the ARM EXYNOS platform. 92 */ 93 L4_INLINE_RPC_OP(L4_PLATFORM_CTL_CPU_ENABLE_OP, 94 l4_msgtag_t, cpu_enable, (l4_umword_t phys_id)); 95 96 /** 97 * Disable an online CPU. 98 * 99 * \param phys_id Physical CPU id of CPU (e.g. local APIC id) to disable. 100 * 101 * \return System call message tag 102 * 103 * This function is currently only supported on the ARM EXYNOS platform. 104 */ 105 L4_INLINE_RPC_OP(L4_PLATFORM_CTL_CPU_DISABLE_OP, 106 l4_msgtag_t, cpu_disable, (l4_umword_t phys_id)); 107 108 typedef L4::Typeid::Rpcs_sys<system_suspend_t, system_shutdown_t, 109 cpu_allow_shutdown_t, cpu_enable_t, 110 cpu_disable_t> Rpcs; 111}; 112 113} 114 115