aboutsummaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu-api.h
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2020-03-18 15:56:20 +0100
committerKarel Zak <kzak@redhat.com>2020-11-13 09:19:02 +0100
commitcbf8f1297bebc33b9155e5a5826e8c2b783a9e80 (patch)
treed3ddaa0e3b5cecefdf279d43ce79446bc937a6ed /sys-utils/lscpu-api.h
parent329ec35ff03b073d13ec6bb52283cb6711537569 (diff)
downloadutil-linux-cbf8f1297bebc33b9155e5a5826e8c2b783a9e80.tar.gz
lscpu: (cputype) add header file, cleanup patterns code
* move structs definitions to header file * define set of /proc/cpuinfo parsing patterns for cpu-type and for CPUs Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/lscpu-api.h')
-rw-r--r--sys-utils/lscpu-api.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/sys-utils/lscpu-api.h b/sys-utils/lscpu-api.h
new file mode 100644
index 0000000000..a82dd4b433
--- /dev/null
+++ b/sys-utils/lscpu-api.h
@@ -0,0 +1,99 @@
+#ifndef LSCPU_API_H
+#define LSCPU_API_H
+
+#include "c.h"
+#include "nls.h"
+#include "cpuset.h"
+#include "xalloc.h"
+#include "strutils.h"
+#include "bitops.h"
+#include "path.h"
+#include "pathnames.h"
+#include "all-io.h"
+#include "debug.h"
+
+#define LSCPU_DEBUG_INIT (1 << 1)
+#define LSCPU_DEBUG_MISC (1 << 2)
+#define LSCPU_DEBUG_GATHER (1 << 3)
+#define LSCPU_DEBUG_TYPE (1 << 4)
+#define LSBLK_DEBUG_ALL 0xFFFF
+
+UL_DEBUG_DECLARE_MASK(lscpu);
+#define DBG(m, x) __UL_DBG(lscpu, LSCPU_DEBUG_, m, x)
+#define ON_DBG(m, x) __UL_DBG_CALL(lscpu, LSCPU_DEBUG_, m, x)
+
+#define UL_DEBUG_CURRENT_MASK UL_DEBUG_MASK(lscpu)
+#include "debugobj.h"
+
+#define _PATH_SYS_SYSTEM "/sys/devices/system"
+#define _PATH_SYS_HYP_FEATURES "/sys/hypervisor/properties/features"
+#define _PATH_SYS_CPU _PATH_SYS_SYSTEM "/cpu"
+#define _PATH_SYS_NODE _PATH_SYS_SYSTEM "/node"
+
+struct lscpu_cputype {
+ cpu_set_t *map; /* which cpus use this type */
+
+ int refcount;
+
+ char *arch;
+ char *vendor;
+ char *machinetype; /* s390 */
+ char *family;
+ char *model;
+ char *modelname;
+ char *revision; /* alternative for model (ppc) */
+ char *cpu; /* alternative for modelname (ppc, sparc) */
+ char *virtflag; /* virtualization flag (vmx, svm) */
+ char *hypervisor; /* hypervisor software */
+ int hyper; /* hypervisor vendor ID */
+ int virtype; /* VIRT_PARA|FULL|NONE ? */
+ char *stepping;
+ char *bogomips;
+ char *dynamic_mhz;
+ char *static_mhz;
+ char *flags;
+ char *mtid; /* maximum thread id (s390) */
+ char *addrsz; /* address sizes */
+ int dispatching; /* none, horizontal or vertical */
+ int freqboost; /* -1 if not evailable */
+
+ int *polarization; /* cpu polarization */
+ int *addresses; /* physical cpu addresses */
+ int *configured; /* cpu configured */
+ int physsockets; /* Physical sockets (modules) */
+ int physchips; /* Physical chips */
+ int physcoresperchip; /* Physical cores per chip */
+
+ int ncores;
+ int nbooks;
+ int threads;
+ int ndrawers;
+
+ unsigned int bit32:1,
+ bit64:1;
+};
+
+struct lscpu_cpu {
+ int logical_id;
+ char *mhz;
+};
+
+struct lscpu_cxt {
+ const char *prefix; /* path to /sys and /proc snapshot or NULL */
+
+ struct path_cxt *syscpu; /* _PATH_SYS_CPU path handler */
+ struct path_cxt *procfs; /* /proc path handler */
+
+ size_t ncputypes;
+ struct lscpu_cputype **cputypes;
+};
+
+struct lscpu_cputype *lscpu_new_cputype(void);
+void lscpu_ref_cputype(struct lscpu_cputype *ct);
+void lscpu_unref_cputype(struct lscpu_cputype *ct);
+int lscpu_read_cpuinfo(struct lscpu_cxt *cxt);
+
+struct lscpu_cxt *lscpu_new_context(void);
+static void lscpu_free_context(struct lscpu_cxt *cxt);
+
+#endif /* LSCPU_API_H */