|
|
#include <sys/types.h> #include <sys/hpci.h> #include <sys/ddi.h>int hpci_postevent(int hpcid, hpci_socket_info_t *socket, int evtype);
The data structure tree information (controller, bus, socket, device, and function) in the hpci_hpcd_t(D4hpci) structure must be in a consistent state when hpci_postevent( ) is called because this call uses that information to notify the operating system about any changes to the hardware state.
``Hotplug devices'' in HDK Technical Reference
``PCI'' in HDK Technical Reference
1 int
2 socket_state_change(int cmd,
3 hpci_socket_info_t *socket)
4 {
/* save current state */
5 socket->prev_state = socket->current_state;
6 switch(cmd)
7 {
8 case CARD_PRESENT:
/* update data structure tree */
/* set the bit in current state to reflect the presence of a card */
9 socket->current_state &= ~SOCKET_EMPTY;
/* inform HPCI about state change */
10 hpci_postevent(socket->hpcid, socket, EVENT_STATE_CHANGE);
11 break;
12 case CARD_NOT_PRESENT:
/* update data structure tree */
/* set the bit in current state to reflect the absence of the card */
13 socket->current_state |= SOCKET_EMPTY;
/* inform HPCI about state change */
14 hpci_postevent(socket->hpcid, socket, EVENT_STATE_CHANGE);
15 break;
16 case xxx: /* handle other cases here */
17 break;
18 default:
19 cmn_err(CE_WARN, "%s: socket_state_change: invalid request 0x%x for hpcid=%d\n",
20 modname, cmd, socket->hpcid);
21 return(EINVAL);
22 }
23 return(0);
24 }