File: cpu.h

package info (click to toggle)
powersave 0.15.20-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 4,360 kB
  • ctags: 610
  • sloc: sh: 10,767; cpp: 5,264; ansic: 1,495; makefile: 342
file content (86 lines) | stat: -rw-r--r-- 1,803 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef CPU_H
#define CPU_H

#include <string>

/** @brief class representing a generic CPU */
class CPU {
public:
	/** @brief constructor
	 *
	 * @param id the CPU is starting from 0
	 */
	CPU(int id);

	/** @brief set a CPU online
	 *
	 * CPU 0 can't be offlined
	 *
	 * @param cpu number of CPU starting from 1
	 *
	 * @retval < 0 error setting CPU online
	 * @retval 0   CPU CPU already online
	 * @retval > 0 successfully onlined CPU
	 */
	int enable();

	/** @brief set a CPU offline
	 *
	 * CPU 0 can't be offlined
	 *
	 * @param cpu number of CPU starting from 1
	 *
	 * @retval < 0 error setting CPU offline
	 * @retval 0   CPU CPU already offline
	 * @retval > 0 successfully offlined CPU
	 */
	int disable();

	/** @brief if the CPU is online
	 *
	 * @return true if CPU is online, false otherwise
	 */
	bool online();

	/** @brief enables all CPUs in system
	 *
	 * @return number of hotpluggable CPUs
	 */
	static int enableAll();

	/** @brief if the CPU can be offlined and onlined
	 *
	 * @return true if hotpluggable, false otherwise
	 */
	bool hotpluggable();

	/** @brief read a line from a file
	 *
	 * @param filename the filename to read from
	 * @param line char pointer to store the read line
	 * @param len chars to read
	 *
	 * @return false on error
	 */
	bool read_line(const char *filename, char *line, unsigned len);

	/** @brief write a line to a file
	 *
	 * @param filename the filename to read from
	 * @param fmt format to write
	 * @param ... variable argument list to write
	 *
	 * @return false on error
	 */
	bool write_line(const char *filename, const char *fmt, ...);

protected:
	/** @brief Stores which CPU this object corresponds to */
	int _cpu_base;

private:
	/** @brief filename for CPU hotplugging */
	std::string ONLINE_FILE;
};

#endif // CPU_HOTPLUG_H