/***************************************************************************
*
* sysevent.c : Solaris sysevents
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Licensed under the Academic Free License version 2.1
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <libdevinfo.h>
#include <libsysevent.h>
#include <glib.h>
#include <config_admin.h>
#include <kstat.h>
#include "../osspec.h"
#include "../logger.h"
#include "../hald.h"
#include "../hald_dbus.h"
#include "../device_info.h"
#include "../util.h"
#include "osspec_solaris.h"
#include "hotplug.h"
#include "devinfo.h"
#include "devinfo_storage.h"
#include "devinfo_acpi.h"
#include "devinfo_usb.h"
#include "sysevent.h"
#include "devinfo_misc.h"
#include "devinfo_cpu.h"
#ifndef ESC_LOFI
#endif
static void sysevent_dev_handler(sysevent_t *);
static void sysevent_dev_branch(gchar *);
static void sysevent_devfs_add(gchar *);
sysevent_init(void)
{
/*
* pipe used to serialize sysevents through the main loop
*/
if (pipe (sysevent_pipe_fds) != 0) {
return (FALSE);
}
if (sysevent_iochannel == NULL) {
HAL_INFO (("g_io_channel_unix_new failed"));
return (FALSE);
}
return (FALSE);
}
return (FALSE);
}
return (FALSE);
}
subcl[0] = ESC_DEV_BRANCH_REMOVE;
return (FALSE);
}
subcl[0] = ESC_PWRCTL_ADD;
return (FALSE);
}
subcl[0] = ESC_DEVFS_DEVI_ADD;
return (FALSE);
}
subcl[0] = ESC_DR_AP_STATE_CHANGE;
HAL_INFO (("subscribe(dynamic reconfiguration) failed %d",
errno));
return (FALSE);
}
return (B_TRUE);
}
void
sysevent_fini(void)
{
}
static void
{
char *class;
char *subclass;
char *phys_path;
char *dev_name;
char *dev_hid;
char *dev_uid;
char s[1024];
return;
return;
return;
goto out;
}
snprintf(s, sizeof (s), "%s %s %s\n",
goto out;
}
&phys_path) != 0) {
goto out;
}
&phys_path) != 0) {
goto out;
}
!= 0) {
goto out;
}
/*
* In case of EC_DR, use dev_name to store DR_HINT val
*/
goto out;
}
dev_name = "noname";
} else {
dev_name = "";
}
}
dev_hid = "";
}
dev_uid = "";
}
!= 0) {
dev_index = 0;
}
snprintf(s, sizeof (s), "%s %s %s %s %s %s %d\n",
out:
}
static gboolean
{
int matches;
HAL_INFO (("sysevent_iochannel_data"));
&err) == G_IO_STATUS_NORMAL) {
if (len == 0) {
break;
}
HAL_INFO (("IOChannel val => %s", s));
g_free (s);
s = NULL;
if (matches < 3) {
continue;
}
}
}
}
/*
* Note: AP_ID is stored in phys_path and HINT is
* stored in dev_name, to avoid creating seperate
* variables and multiple conditions checking
*/
}
}
}
if (err) {
g_error_free (err);
}
return (TRUE);
}
static void
{
return;
}
}
static void
{
}
static void
{
}
static void
{
const char *parent_udi;
if ((d = hal_device_store_match_key_value_string (hald_get_gdl (),
return;
}
return;
}
return;
}
return;
}
}
static void
{
}
static HalDevice *
{
char *p;
if (p == NULL) {
return (NULL);
}
*p = '\0';
/* Look up the parent node in the gdl. */
"solaris.devfs_path", path);
/* Look up the parent node in the tdl. */
"solaris.devfs_path", path);
}
return (parent);
}
/*
* Handle the USB bus devices hot plugging events.
*/
static void
{
char *driver_name;
return;
}
goto out;
/* The disk and printer devices are handled by EC_DEV_ADD class. */
goto out;
goto out;
return;
out:
}
static void
{
} else {
HAL_INFO(("Unmatched EC_PWRCTL"));
}
}
static void
{
const char *cpu_devfs_path;
/*
* Find the CPU's that are DR removed. For each "processor" device in
* HAL device tree, check if it has its corresponding kstat_info. If
* not, then, that cpu has been removed and can remove the entry from
* HAL entry
*/
HAL_DEBUG (("sysevent_dr_remove_cpu()"));
kc = kstat_open ();
HAL_INFO (("Error in removing HAL cpu entry during DR. Could"
return;
}
/*
* Iterate through the HAL device list to get the processor devices
*/
gdl = hald_get_gdl ();
if (!hal_device_has_property (d, "processor.number")) {
continue;
}
/*
* Check if the above cpu_id has its info in kstat
*/
continue;
}
/*
* kstat info not found. Delete the device entry
*/
"solaris.devfs_path");
if (cpu_devfs_path == NULL) {
HAL_INFO (("Could not get cpu_devfs_path to "
"remove for cpu_id %d", cpu_id));
} else {
/*
* Remove the cpu device
*/
}
}
if (kc) {
kstat_close (kc);
}
}
int
{
char *devfs_path;
&device_type);
return (DI_WALK_CONTINUE);
}
/*
* Note: Currently it supports only CPU DR events
*/
static void
{
int nlist;
char *errstr;
return;
HAL_INFO (("DR sysevent process %d config_list_ext error: %s",
goto out;
}
/*
* Check if the device type is CPU
*/
cfg_stat->ap_r_state));
/*
* Go through the device list and add the new cpu
* entries into HAL
*/
if ((root_node =
HAL_INFO (("di_init failed. "\
"Cannot insert CPU"));
goto out;
}
}
} else {
HAL_INFO (("Not a CPU, so cannot DR"));
}
out:
if (cfg_stat)
if (errstr)
}