/**
* $Id: k10sensor_info.c 756 2012-06-30 06:36:09Z elkner $
*
* * CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each file.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* All Rights reserved.
* CDDL HEADER END
*/
/*
* Copyright (c) 2011,2012 by Jens Elkner,
* Otto-von-Guericke Universitaet Magdeburg. All rights reserved.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <dirent.h>
#include <libdevinfo.h>
#include "k10sensor.h"
#include "../configure.h"
#ifndef LINKMOD_FILE
#endif
};
static boolean_t
if (device == -1) {
return B_FALSE;
}
return B_FALSE;
}
return B_TRUE;
}
/**
* Dump CPU temperature data by directly accessing the related PCI devices
* @return number of CPUs found.
*/
static int
{
char *str;
/* since we know, that a box can't have mixed CPU families, we do
not cycle through all knownDevIds but obtain the info directly */
perror("Couldn't obtain CPU ID infos");
return (0);
}
/* Actually some different silicon revision CPUs can be mixed in a box
* (see Revision Guide if in doubt).
* However, to keep this easy, we assume here, all have the same. The
* kernel driver handles each CPU separately - provides the final word. */
} else {
}
if (pci_system_init()) {
perror("Couldn't initialize PCI system");
return (0);
}
match.device_class_mask = 0;
eax = 0;
eax++;
}
return (eax);
}
/**
* Simple helper function to check, whether all chars of the given string
* are digits.
* @param p string to check
* @return B_FALSE if p is NULL or empty or contains a non-digit char.
*/
static boolean_t
allDigits(char *p) {
if (p == NULL || *p == '\0') {
return B_FALSE;
}
for (; *p != '\0'; p++) {
if (!isdigit(*p)) {
return B_FALSE;
}
}
return B_TRUE;
}
#pragma inline(allDigits)
static int
static cpu_vars_t v[1];
int32_t t[2];
return 0;
}
/* now fetch data */
bzero(v, sizeof(v));
perror("ioctl K10IOC_INFO failed");
goto done;
}
dumpCpuInfo(buf, v);
res++;
perror("ioctl K10IOC_TCTRL failed");
goto done;
}
t[0] == 0 ? 0 : (t[0] - v->diode_offset)/1000.0);
} else {
t[0] == 0 ? 0 : (t[0] - v->diode_offset)/1000.0);
}
done:
if (res > 0) {
}
}
return (res);
}
static int
{
int instance;
return (DI_WALK_CONTINUE);
}
return (DI_WALK_CONTINUE);
}
return (DI_WALK_CONTINUE);
}
/**
* Dump CPU temperature data by accessing the kernel modul via ioctl()s.
* @return number of CPUs found.
*/
static int
dump() {
int count;
if (chdir("/devices") != 0) {
perror("Unable to cd into /devices/");
return 0;
}
/* we could walk through 'pci[:xdigit:]+,[:xdigit:]+/' and
find all char dev files which match
'@pci1022,1[:xdigit:]03@[:xdigit:]+,3:k10sensor' but better is: */
if (count > 0) {
}
} else {
return 0;
}
return 0;
}
/* some sanity checks first */
continue;
}
continue;
}
}
}
return (count);
}
/**
* Print out help info.
*/
void
"Find all AMD CPUs and print out their temperature related data.\n\n"
"Options:\n\n"
" -h .. print this help and exit.\n"
" -d .. obtain the data directly via PCI devices. Otherwise\n"
" obtain the data from the kernel driver (default).\n"
, progname);
}
int
int c;
switch (c) {
}
}
if (c == 0) {
}
return (EXIT_SUCCESS);
}
/* vim: tabstop=4:shiftwidth=4:noexpandtab
*/