/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* 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 and include the License file at usr/src/OPENSOLARIS.LICENSE.
* 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]
*
* CDDL HEADER END
*/
/*
* Copyright 2000, 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/hpc3130_events.h>
#include <values.h> /* for BITSPERBYTE */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <strings.h>
#include <poll.h>
#include <libintl.h>
#include <errno.h>
#include <assert.h>
#include <config_admin.h>
#include "sf880drd.h"
/*
* Hotplug Controller addresses.
*/
{ 0xe2, 0xe6, 0xe8, 0xec };
/*
* Local variables.
*/
/*
* Local prototypes.
*/
static void init_poll_events(void);
static void process_event(int);
static void report_cfgadm_error(int, char *);
static int i2c_set_bit(int, int, uint8_t);
static void report_syscall_error(char *);
static void pushbutton_event(char *);
static void fault_led_event(hpc3130_event_type_t, int);
static void removable_led_event(hpc3130_event_type_t, int);
/*
* main(): loops forever looking for events.
*/
int
main()
{
int i;
int rv;
for (;;) {
/* sleep in poll() waiting an event */
if (rv < 0) {
report_syscall_error("poll");
continue;
}
/* woken up from poll() process the event */
for (i = 0; i < NUM_FDS; ++i) {
process_event(i);
}
}
/* NOTREACHED */
return (0);
}
/*
* Set up poll fds.
*/
static void
{
int c;
int p;
int i = 0;
for (c = 0; c < NUM_CONTROLLERS; ++c) {
for (p = 0; p < SLOTS_PER_CONTROLLER; ++p) {
controller_names[c], p);
exit(-1);
}
i++;
}
}
}
/*
* Process poll events.
*/
static void
{
struct hpc3130_event e;
int rv;
if (rv == -1) {
report_syscall_error("HPC3130_GET_EVENT");
return;
}
switch (e.id) {
case HPC3130_EVENT_INSERTION:
case HPC3130_EVENT_REMOVAL:
case HPC3130_EVENT_POWERON:
case HPC3130_EVENT_POWEROFF:
break;
case HPC3130_EVENT_BUTTON:
pushbutton_event(e.name);
break;
case HPC3130_LED_FAULT_ON:
DPRINTF(("\nFAULT LED ON EVENT\n"));
break;
case HPC3130_LED_FAULT_OFF:
DPRINTF(("\nFAULT LED OFF EVENT\n"));
break;
case HPC3130_LED_REMOVABLE_ON:
DPRINTF(("\nREMOVABLE LED ON EVENT\n"));
break;
DPRINTF(("\nREMOVABLE LED OFF EVENT\n"));
break;
default:
}
}
/*
* Button Event handler.
*/
static void
{
int nlist;
goto out;
}
/* The only types of hotplug with buttons */
switch (stat->ap_o_state) {
case CFGA_STAT_UNCONFIGURED:
break;
case CFGA_STAT_CONFIGURED:
break;
default:
/* Should never get here */
assert(0);
}
/*
* confp & msgp are NULL: when using the pushbutton,
* simply fail if prompting is required.
*/
/* FALLTHRU to "out" */
}
out:
if (errstr)
if (stat)
}
static void
{
int side = 0;
unsigned int old;
/* It's a PCI slot; left side of chassis */
side = 1;
}
switch (event) {
case HPC3130_LED_FAULT_ON:
DPRINTF(("fault_led_event: HPC3130_LED_FAULT_ON\n"));
break;
case HPC3130_LED_FAULT_OFF:
DPRINTF(("fault_led_event: HPC3130_LED_FAULT_OFF\n"));
break;
}
DPRINTF(("fault_led_event: old(0x%x), fault_leds[%d](0x%x)\n",
/*
* The first FAULT LED has come on, or the last one has gone
* off on this side, and all the OK2REMOVE LEDS are off on this
* side. So we have to update the front panel ARROW LED.
*/
}
}
static void
{
int side = 0;
unsigned int old;
/* It's a PCI slot; left side of chassis */
side = 1;
}
switch (event) {
case HPC3130_LED_REMOVABLE_ON:
DPRINTF(("removable_led_event: HPC3130_LED_REMOVABLE_ON\n"));
break;
DPRINTF(("removable_led_event: HPC3130_LED_REMOVABLE_OFF\n"));
break;
}
DPRINTF(("removable_led_event: old(0x%x), ok2rem_leds[%d](0x%x)\n",
/*
* The first OKAY2REMOVE LED has come on, or the last
* one has gone off (on this side). We may have to update
* the front panel LEDs.
*/
if (ok2rem_leds[!side] == 0) {
/*
* The OK2REMOVE LEDs are all off on the other
* side of the chassis, so this side determines
* whether the front OK2REMOVE is on or off.
*/
}
if (fault_leds[side] == 0) {
/*
* All the FAULT LEDs are off on this side. So the
* OK2REMOVE LEDs determine whether the ARROW LED is on.
*/
}
}
}
/*
* Set front panel system leds either on or off.
*/
static void
{
int fd;
int rv;
if (fd == -1) {
report_syscall_error("ssc050");
return;
}
if (rv == -1)
report_syscall_error("LED I2C_SET_BIT");
}
static int
{
int rv;
return (rv);
}
static void
{
const char *ep;
} else {
}
}
static void
{
}