/***************************************************************************
*
* devinfo_cpu : cpu devices
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Licensed under the Academic Free License version 2.1
*
**************************************************************************/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <kstat.h>
#include <libdevinfo.h>
#include <sys/systeminfo.h>
#include "../osspec.h"
#include "../logger.h"
#include "../hald.h"
#include "../hald_dbus.h"
#include "../device_info.h"
#include "../util.h"
#include "devinfo_cpu.h"
NULL,
NULL,
NULL,
NULL,
};
static HalDevice *
{
HalDevice *d;
int *int_cpu_id;
char *driver_name, *s;
/*
* If it is x86, the software device tree node will have the
* device_type information which is the one passed above. If it is
* NULL, check if the node has a PROM entry, and check the device_type
* in case of sparc. Else return NULL
*/
if (device_type == NULL) {
/*
* Check the device type if it has a PROM entry. Because
* in sparc, the device_type entry will in the PROM node
*/
phdl = di_prom_init ();
if (phdl == DI_PROM_HANDLE_NIL) {
HAL_ERROR (("Error in Initializing the PROM "
"handle to find cpu device: %s",
return (NULL);
}
di_prom_fini (phdl);
return (NULL);
}
di_prom_fini (phdl);
return (NULL);
}
/*
* Get cpuid if available
*/
"cpuid", &int_cpu_id) > 0) {
cpu_id = *int_cpu_id;
} else {
/*
* There is no cpuid entry in this arch.Just
* increment the cpuid which will be the
* current instance
*/
++cpu_id;
}
di_prom_fini (phdl);
} else {
return (NULL);
}
/*
* This is a x86 arch, because software device tree node
* has the device_type entry for cpu. The "reg" property
* will have the cpuid. If not just increment the cpuid
* which will be the current cpu instance in the kstat
*/
"reg", &int_cpu_id) > 0) {
cpu_id = *int_cpu_id;
} else {
/*
* There is no cpuid entry in this arch. Just
* increment the cpuid which will be the
* current instance
*/
++cpu_id;
}
} else {
return (NULL);
}
d = hal_device_new ();
/*
* devinfo_set_default_properties () uses di_instance() as part of
* the udi. For some solaris devices like cpu di_instance() is not
* present and it returns -1. For the udi to be unique can use the
* cpu_id.
*/
hal_device_property_set_string (d, "info.parent",
"/org/freedesktop/Hal/devices/local");
/*
* If cpu driver is not installed, then devfs_path returned by
* libdevinfo will be same for all cpu's.
* Since HAL stores the devices in its tree based on the devfs_path,
* To make it unique, will be concatenating devfs_path with cpu_id
*/
devfs_path, cpu_id);
} else {
}
hal_device_set_udi (d, udi);
hal_device_property_set_string (d, "info.product", s);
} else {
hal_device_property_set_string (d, "info.product",
di_node_name (node));
}
hal_device_property_set_string (d, "solaris.devfs_path",
hal_device_property_set_string (d, "info.solaris.driver",
}
hal_device_add_capability (d, "processor");
/*
* Get the cpu related info from the kstat
*/
kc = kstat_open ();
HAL_ERROR (("Could not open kstat to get cpu info: %s",
goto next;
}
HAL_ERROR (("Could not lookup kstat to get cpu info: %s",
if (kc) {
kstat_close (kc);
}
return (NULL);
}
HAL_ERROR (("Could not get kstat clock_MHz data for cpu: %s",
goto next;
}
if (hal_device_property_set_uint64 (d, "processor.maximum_speed",
HAL_INFO (("Could not set the processor speed device prop"));
}
"supported_frequencies_Hz");
HAL_INFO (("Could not get kstat supported_frequencies_Hz data"
} else {
/*
* If more than one freq is supported, then they are seperated
* by a ":"
*/
} else {
}
}
if (hal_device_property_set_bool (d, "processor.can_throttle",
is_supp_freqs) == FALSE) {
HAL_INFO (("Could not set the processor.can_throttle"
" device prop"));
}
next:
if (kc) {
kstat_close (kc);
}
return (d);
}