|
|
#include <sys/types.h> #include <sys/hpci.h> #include <sys/ddi.h>int hpci_attach(hpci_hpcd_t *hpcd_info);
Before calling hpci_attach( ), the HPCD driver allocates all and initializes the data structures representing all hot plug busses, sockets, and any devices connected to hotplug sockets. The data representation of all this hot plug information forms a tree structure that leads from the HPCD information to the function information about each device connected to any hot plug socket that is controlled by this HPCD driver. The structures that represent the data for the hot plug controller, bus, socket, and device function information are documented in the Section D4hpci manual pages in Section D4hpci manual pages.
``Hotplug devices'' in HDK Technical Reference
``Device instance'' in HDK Technical Reference
``PCI'' in HDK Technical Reference
1 typedef struct _hpcd {
2 int hpcid;
3 rm_key_t key;
4 hpci_hpcd_t hpcd_info;
5 } hpcd_t
6 int
7 xxx_config(cfg_funct_t func, void *idata, rm_key_t key)
8 {
9 hpcd_t *hpcdp;
10 switch(func)
11 {
12 case CFG_ADD:
13 hpcdp=kmem_zalloc(sizeof(hpcd_t), KM_SLEEP);
/* set the resmgr key for this driver instance */
14 hpcdp->key = key;
/* save the instance data address for later use */
15 hpcdp->hpcd_info.private = (void *) hpcdp;
/* initialize controller; attach and enable interrupts */
16 init_controller(hpcdp);
17 hpcdp->hpcd_info_modify_callback = (hpci_op_t) hpcd_modify_callback;
18 hpcdp->hpcd_info.lock_callback= (hpcd_lock_op_t) hpcd_lock_callback;
19 hpcdp->hpcd_info.unlock_callback = (hpcd_unlock_op_t) hpcd_unlock_callback;
20 build_hotplug_info_tree(hpcdp);
21 if ((hpcdp->hpcid = hpci_attach(&hpcdp->hpcd_info)) <0)
22 {
23 cmn_err(CE_WARN, "hpci_attach() failed \n");
24 return -1;
25 }
26 *((void**)idata) = hpcdp;
27 break;
28 case CFG_xxx /* handle other subfunctions */ 29 ... 30 break;31 default:
32 cmn_err(CE_WARN, "%s:xxxx_config: unexpected request 0x%x for rm_key=%d\n", 33 modname,func,key); 34 return(EINVAL); 35 } 36 return(0); 37 }
idata pointer for this driver instance
back to the kernel.