From 381f0c0a5cd98a48dc6d5a5e0b98443707d8ea81 Mon Sep 17 00:00:00 2001 From: Peter Schiffer Date: Thu, 4 Apr 2013 19:02:29 +0200 Subject: 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 --- src/hardware/sysfs.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/hardware/sysfs.h (limited to 'src/hardware/sysfs.h') 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 + */ + +#ifndef SYSFS_H_ +#define SYSFS_H_ + +#include +#include +#include +#include +#include +#include +#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_ */ -- cgit