summaryrefslogtreecommitdiffstats
path: root/src/hardware/sysfs.h
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2013-04-04 19:02:29 +0200
committerPeter Schiffer <pschiffe@redhat.com>2013-04-04 19:02:29 +0200
commit381f0c0a5cd98a48dc6d5a5e0b98443707d8ea81 (patch)
treebdad2e739aac00eb02e71dfe7d4074268c6f69a4 /src/hardware/sysfs.h
parentc47c5c19c5857439db30e40d4a691f5b700adf5f (diff)
downloadopenlmi-providers-381f0c0a5cd98a48dc6d5a5e0b98443707d8ea81.tar.gz
openlmi-providers-381f0c0a5cd98a48dc6d5a5e0b98443707d8ea81.tar.xz
openlmi-providers-381f0c0a5cd98a48dc6d5a5e0b98443707d8ea81.zip
Hardware: Added Processor Cache Memory Provider
New Providers: * LMI_ProcessorCacheMemoryProvider * LMI_AssociatedProcessorCacheMemoryProvider Other Changes: * Optimized usage of string constats * Fixed wrong usage of pointers in dmidecode.c * Filled unknown mandatory fields in providers with "Unknown" value * Replaced hard coded numbers with LMI constants * Minor optimization - don't gather data which won't be used
Diffstat (limited to 'src/hardware/sysfs.h')
-rw-r--r--src/hardware/sysfs.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/hardware/sysfs.h b/src/hardware/sysfs.h
new file mode 100644
index 0000000..0e0b523
--- /dev/null
+++ b/src/hardware/sysfs.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Peter Schiffer <pschiffe@redhat.com>
+ */
+
+#ifndef SYSFS_H_
+#define SYSFS_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <limits.h>
+#include "globals.h"
+#include "utils.h"
+
+#define SYSFS_CPU_PATH "/sys/devices/system/cpu"
+
+/* Processor cache from sysfs. */
+typedef struct _SysfsCpuCache {
+ char *id; /* ID */
+ unsigned size; /* Cache Size */
+ char *name; /* Cache Name */
+ unsigned level; /* Cache Level */
+ char *type; /* Cache Type (Data, Instruction, Unified..) */
+ unsigned ways_of_assoc; /* Number of ways of associativity */
+ unsigned line_size; /* Cache Line Size */
+} SysfsCpuCache;
+
+
+/*
+ * Get array of processor caches from sysfs.
+ * @param caches array of cpu caches, this function will allocate necessary
+ * memory, but caller is responsible for freeing it
+ * @param caches_nb number of caches in caches
+ * @return 0 if success, negative value otherwise
+ */
+short sysfs_get_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb);
+
+/*
+ * Free array of cpu cache structures.
+ * @param caches array of caches
+ * @param caches_nb number of caches
+ */
+void sysfs_free_cpu_caches(SysfsCpuCache **caches, unsigned *caches_nb);
+
+
+#endif /* SYSFS_H_ */