2018-08-27 11:11:28 +02:00
|
|
|
/** Linux kernel related functions.
|
|
|
|
*
|
|
|
|
* @file
|
2022-03-15 09:13:39 -04:00
|
|
|
* @author Steffen Vogel <svogel2@eonerc.rwth-aachen.de>
|
2022-03-15 09:05:42 -04:00
|
|
|
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
|
2022-05-19 17:40:10 +02:00
|
|
|
* @license Apache License 2.0
|
2018-08-27 11:11:28 +02:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-10-27 20:23:47 +01:00
|
|
|
#include <cstddef>
|
|
|
|
|
2018-08-27 11:11:28 +02:00
|
|
|
#include <villas/version.hpp>
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace kernel {
|
|
|
|
|
|
|
|
/** Get the version of the kernel. */
|
|
|
|
utils::Version getVersion();
|
|
|
|
|
2019-10-27 20:23:47 +01:00
|
|
|
/** Get number of reserved hugepages. */
|
2021-05-20 06:08:12 -04:00
|
|
|
int getNrHugepages();
|
2019-10-27 20:23:47 +01:00
|
|
|
|
|
|
|
/** Set number of reserved hugepages. */
|
2021-05-20 06:08:12 -04:00
|
|
|
int setNrHugepages(int nr);
|
2019-10-27 20:23:47 +01:00
|
|
|
|
|
|
|
/** Get kernel cmdline parameter
|
|
|
|
*
|
|
|
|
* See https://www.kernel.org/doc/Documentation/kernel-parameters.txt
|
|
|
|
*
|
|
|
|
* @param param The cmdline parameter to look for.
|
|
|
|
* @param buf The string buffer to which the parameter value will be copied to.
|
|
|
|
* @param len The length of the buffer \p value
|
|
|
|
* @retval 0 Parameter \p key was found and value was copied to \p value
|
|
|
|
* @reval <>0 Kernel was not booted with parameter \p key
|
|
|
|
*/
|
2021-05-20 06:08:12 -04:00
|
|
|
int getCmdlineParam(const char *param, char *buf, size_t len);
|
2019-10-27 20:23:47 +01:00
|
|
|
|
|
|
|
/** Checks if a kernel module is loaded
|
|
|
|
*
|
|
|
|
* @param module the name of the module
|
|
|
|
* @retval 0 Module is loaded.
|
|
|
|
* @reval <>0 Module is not loaded.
|
|
|
|
*/
|
2021-05-20 06:08:12 -04:00
|
|
|
int isModuleLoaded(const char *module);
|
2019-10-27 20:23:47 +01:00
|
|
|
|
|
|
|
/** Load kernel module via modprobe */
|
2021-05-20 06:08:12 -04:00
|
|
|
int loadModule(const char *module);
|
2019-10-27 20:23:47 +01:00
|
|
|
|
|
|
|
/** Set parameter of loaded kernel module */
|
2021-05-20 06:08:12 -04:00
|
|
|
int setModuleParam(const char *module, const char *param, const char *value);
|
2019-10-27 20:23:47 +01:00
|
|
|
|
|
|
|
/** Get cacheline size in bytes */
|
2021-05-20 06:08:12 -04:00
|
|
|
int getCachelineSize();
|
2019-10-27 20:23:47 +01:00
|
|
|
|
|
|
|
/** Get the size of a standard page in bytes. */
|
2021-05-20 06:08:12 -04:00
|
|
|
int getPageSize();
|
2019-10-27 20:23:47 +01:00
|
|
|
|
|
|
|
/** Get the size of a huge page in bytes. */
|
2021-05-20 06:08:12 -04:00
|
|
|
int getHugePageSize();
|
2019-10-27 20:23:47 +01:00
|
|
|
|
|
|
|
/** Get CPU base frequency */
|
|
|
|
int get_cpu_frequency(uint64_t *freq);
|
|
|
|
|
|
|
|
/** Set SMP affinity of IRQ */
|
2021-05-20 06:08:12 -04:00
|
|
|
int setIRQAffinity(unsigned irq, uintmax_t aff , uintmax_t *old);
|
2019-10-27 20:23:47 +01:00
|
|
|
|
2019-05-28 10:50:50 +02:00
|
|
|
} /* namespace villas */
|
|
|
|
} /* namespace kernel */
|