L4Re - L4 Runtime Environment
platform_control
Go to the documentation of this file.
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 
32 namespace 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  */
46 class L4_EXPORT Platform_control
47 : public Kobject_t<Platform_control, Kobject, L4_PROTO_PLATFORM_CTL>
48 {
49 public:
50  /// Opcodes for platform-control object.
51  enum Opcode
52  {
53  Suspend = L4_PLATFORM_CTL_SYS_SUSPEND_OP, ///< Opcode for suspend to RAM
54  Shutdown = L4_PLATFORM_CTL_SYS_SHUTDOWN_OP,///< Opcode for shutdown / reboot
55  Cpu_enable = L4_PLATFORM_CTL_CPU_ENABLE_OP, ///< Opcode to enable a CPU
56  Cpu_disable = L4_PLATFORM_CTL_CPU_DISABLE_OP ///< Opcode to disable a CPU
57  };
58 
59  /**
60  * Enter suspend to RAM.
61  *
62  * \param extras some extra platform-specific information needed to enter
63  * suspend to RAM.
64  */
65  L4_INLINE_RPC_OP(L4_PLATFORM_CTL_SYS_SUSPEND_OP,
66  l4_msgtag_t, system_suspend, (l4_umword_t extras));
67 
68  /**
69  * Shutdown/Reboot the system.
70  *
71  * \param reboot 1 for reboot, 0 for power off
72  */
73  L4_INLINE_RPC_OP(L4_PLATFORM_CTL_SYS_SHUTDOWN_OP,
74  l4_msgtag_t, system_shutdown, (l4_umword_t reboot));
75 
76  /**
77  * Enable an offline CPU.
78  *
79  * \param phys_id Physical CPU id of CPU (e.g. local APIC id) to enable.
80  *
81  * \return System call message tag
82  */
83  L4_INLINE_RPC_OP(L4_PLATFORM_CTL_CPU_ENABLE_OP,
84  l4_msgtag_t, cpu_enable, (l4_umword_t phys_id));
85 
86  /**
87  * Disable an online CPU.
88  *
89  * \param phys_id Physical CPU id of CPU (e.g. local APIC id) to disable.
90  *
91  * \return System call message tag
92  */
93  L4_INLINE_RPC_OP(L4_PLATFORM_CTL_CPU_DISABLE_OP,
94  l4_msgtag_t, cpu_disable, (l4_umword_t phys_id));
95 
96  typedef L4::Typeid::Rpcs_sys<system_suspend_t, system_shutdown_t,
97  cpu_enable_t, cpu_disable_t> Rpcs;
98 };
99 
100 }
101