#ifndef _SYS_SGHSC_H
#define _SYS_SGHSC_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/hotplug/hpctrl.h>
#include <sys/hotplug/hpcsvc.h>
#include <sys/sgsbbc_mailbox.h>
#define SGHSC_PATH "/ssm@%x,0/pci@%x,%x00000"
#define SGHSC_MUTEX(sghsc) \
(&sghsc->sghsc_mutex)
#define SGHSC_MUTEX_OWNED(sghsc) \
mutex_owned(SGHSC_MUTEX(sghsc))
#define SGHSC_MUTEX_ENTER(sghsc) \
mutex_enter(SGHSC_MUTEX(sghsc))
#define SGHSC_MUTEX_EXIT(sghsc) \
mutex_exit(SGHSC_MUTEX(sghsc))
#define SGHSC_SLOT_MUTEX(sghsc, slot_num) \
(&sghsc->sghsc_slot_table[slot_num]->slot_mutex)
#define SGHSC_SLOT_MUTEX_OWNED(sghsc, slot_num) \
mutex_owned(SGHSC_SLOT_MUTEX(sghsc, slot_num));
#define SGHSC_SLOT_MUTEX_ENTER(sghsc, slot_num) \
mutex_enter(SGHSC_SLOT_MUTEX(sghsc, slot_num));
#define SGHSC_SLOT_MUTEX_EXIT(sghsc, slot_num) \
mutex_exit(SGHSC_SLOT_MUTEX(sghsc, slot_num));
#define SGHSC_ALL_SLOTS_ENABLE 0x3F
#define SGHSC_SLOT_ENABLE 0x01
#define SGHSC_ALL_SLOTS_DISABLE 0x02
#define SGHSC_SLOT_DISABLE 0x03
#define SGHSC_ALL_LEDS_ENABLE 0x3F3F
#define SGHSC_LED_ENABLE 0x04
#define SGHSC_ALL_LEDS_DISABLE 0x05
#define SGHSC_LED_DISABLE 0x06
#define SGHSC_LED_BLINKING 0x07
#define SGHSC_SLOT_ISOLATE 0x08
#define SGHSC_SLOT_POWER 0x09
#define SGHSC_LED_ENABLE_MASK 0x0000FFFF
#define SGHSC_SAFARI_ID_EVEN 0x3fe
#define SGHSC_EVENT_CARD_INSERT 0x1
#define SGHSC_EVENT_CARD_REMOVE 0x2
#define SGHSC_EVENT_LEVER_ACTION 0x3
#define SGHSC_EVENT_HEALTHY_LOST 0x4
#define SGHSC_EVENT_POWER_ON 0x5
#define SGHSC_EVENT_POWER_OFF 0x6
#define SGHSC_SLOT_AUTO_CFG_EN 0x1
#define SGHSC_SLOT_HEALTHY_LOST 0x2
#define SGHSC_POWER_LED 0x10
#define SGHSC_FAULT_LED 0x20
#define SGHSC_ACTIVE_LED 0x40
#define SGHSC_ATTN_LED 0x80
#define SGHSC_RING_BUFFER_SZ 0x10
typedef struct sghsc_slot {
kmutex_t slot_mutex;
char nexus_path[MAXPATHLEN];
hpc_slot_info_t slot_info;
hpc_slot_state_t slot_status;
uint32_t slot_capb;
uint8_t pci_device_num;
hpc_slot_ops_t *slot_ops;
hpc_slot_t handle;
uint32_t flags;
uint32_t state;
uint32_t board_type;
} sghsc_slot_t;
typedef struct sghsc {
dev_info_t *sghsc_dip;
kmutex_t sghsc_mutex;
uint32_t sghsc_instance;
uint32_t sghsc_board;
uint32_t sghsc_node_id;
uint32_t sghsc_portid;
uint32_t sghsc_num_slots;
uint32_t sghsc_valid;
sghsc_slot_t *sghsc_slot_table;
} sghsc_t;
typedef struct sdesc {
uint32_t agent_delta;
uint32_t off;
uint32_t pcidev;
uint32_t slot_type;
} sdesc_t;
#define CPCI_GET_SLOT_STATUS 0x5000
#define CPCI_SET_SLOT_FAULT_LED 0x5001
#define CPCI_SET_SLOT_STATUS 0x5002
#define CPCI_SET_SLOT_POWER 0x5003
#define CPCI_GET_NUM_SLOTS 0x5004
#define CPCI_SET_ENUM_CLEARED 0x5005
#define CPCI_BOARD_TYPE 0x5006
#define NO_BOARD_TYPE 0
#define PCI_BOARD 1
#define CPCI_BOARD 2
#define SP_CPCI_BOARD 3
#define WCI_CPCI_BOARD 4
#define WCI_SP_CPCI_BOARD 5
#define ONE_BIT 1
#define TWO_BITS 3
#define THREE_BITS 7
#define CPCI_STAT_POWER_ON_SHIFT 0
#define CPCI_STAT_LED_POWER_SHIFT 1
#define CPCI_STAT_LED_FAULT_SHIFT 2
#define CPCI_STAT_LED_HP_SHIFT 3
#define CPCI_STAT_SLOT_EMPTY_SHIFT 4
#define CPCI_STAT_HOT_SWAP_STATUS_SHIFT 5
#define CPCI_STAT_HEALTHY_SHIFT 12
#define CPCI_STAT_RESET_SHIFT 13
#define CPCI_SET_STATUS_SLOT_RESET 0x00001
#define CPCI_SET_STATUS_SLOT_READY 0x00000
#define CPCI_SET_FAULT_LED_OFF 0x00000
#define CPCI_SET_FAULT_LED_ON 0x00001
#define CPCI_SET_FAULT_LED_KEEP 0x00002
#define CPCI_SET_FAULT_LED_TOGGLE 0x00003
#define CPCI_POWER_OFF 0x0
#define CPCI_POWER_ON 0x1
#define SGHSC_MBX_TIMEOUT 600
#define _SGHSC_CODE ('N' << 16)
#define SGHSC_GET_SLOT_STATUS (_SGHSC_CODE | 0x14)
#define SGHSC_SET_SLOT_STATUS_RESET (_SGHSC_CODE | 0x15)
#define SGHSC_SET_SLOT_STATUS_READY (_SGHSC_CODE | 0x16)
#define SGHSC_SET_SLOT_FAULT_LED_ON (_SGHSC_CODE | 0x17)
#define SGHSC_SET_SLOT_FAULT_LED_OFF (_SGHSC_CODE | 0x18)
#define SGHSC_SET_SLOT_FAULT_LED_KEEP (_SGHSC_CODE | 0x19)
#define SGHSC_SET_SLOT_FAULT_LED_TOGGLE (_SGHSC_CODE | 0x1a)
#define SGHSC_SET_SLOT_POWER_OFF (_SGHSC_CODE | 0x1b)
#define SGHSC_SET_SLOT_POWER_ON (_SGHSC_CODE | 0x1c)
#define SGHSC_GET_NUM_SLOTS (_SGHSC_CODE | 0x1d)
#define SGHSC_SET_ENUM_CLEARED (_SGHSC_CODE | 0x1e)
#define SGHSC_GET_CPCI_BOARD_TYPE (_SGHSC_CODE | 0x1f)
typedef struct {
uint32_t cmd_id;
uint32_t node_id;
uint32_t board;
uint32_t slot;
uint32_t info;
} bitcmd_info_t;
typedef struct {
uint32_t cmd_id;
uint32_t result;
} bitcmd_resp_t;
typedef enum { SGHSC_RB_EMPTY, SGHSC_RB_FLOAT,
SGHSC_RB_FULL } sghsc_rb_state_t;
typedef struct sghsc_event {
int type;
int node_id;
int board;
int slot;
int info;
} sghsc_event_t;
typedef struct sghsc_rb_head {
sghsc_event_t *buf;
int put_idx;
int get_idx;
int size;
sghsc_rb_state_t state;
} sghsc_rb_head_t;
#ifdef __cplusplus
}
#endif
#endif