1 /* Copyright (c) 2003-2011
2 * Stefano Ceccherini <stefano.ceccherini@gmail.com>. All rights reserved.
7 #include <KernelExport.h>
19 int32 api_version
= B_CUR_DRIVER_API_VERSION
;
21 pci_module_info
* gPci
;
22 char* gDevNameList
[MAX_CARDS
+ 1];
23 pci_info
* gDevList
[MAX_CARDS
];
29 if ((item
->vendor_id
== WB_VENDORID
&& item
->device_id
== WB_DEVICEID_840F
)
30 || (item
->vendor_id
== CP_VENDORID
&& item
->device_id
== CP_DEVICEID_RL100
))
39 LOG((DEVICE_NAME
": init_hardware\n"));
47 struct pci_info
* item
= NULL
;
53 LOG((DEVICE_NAME
": init_driver\n"));
56 set_dprintf_enabled(true);
59 status
= get_module(B_PCI_MODULE_NAME
, (module_info
**)&gPci
);
63 item
= (pci_info
*)malloc(sizeof(pci_info
));
65 put_module(B_PCI_MODULE_NAME
);
69 while (gPci
->get_nth_pci_info(index
, item
) == B_OK
) {
71 gPci
->write_pci_config(item
->bus
, item
->device
, item
->function
,
72 PCI_command
, 2, PCI_command_master
| gPci
->read_pci_config(
73 item
->bus
, item
->device
, item
->function
,
75 gDevList
[card_found
++] = item
;
77 dprintf(DEVICE_NAME
": revision = %x\n", item
->revision
);
79 item
= (pci_info
*)malloc(sizeof(pci_info
));
85 gDevList
[card_found
] = NULL
;
87 if (card_found
== 0) {
88 put_module(B_PCI_MODULE_NAME
);
92 for (index
= 0; index
< card_found
; index
++) {
93 sprintf(devName
, DEVICE_NAME
"/%d", index
);
94 LOG((DEVICE_NAME
":enabled %s\n", devName
));
95 gDevNameList
[index
] = strdup(devName
);
98 gDevNameList
[index
] = NULL
;
109 LOG((DEVICE_NAME
": uninit_driver()\n"));
110 while(gDevNameList
[i
] != NULL
) {
112 free(gDevNameList
[i
]);
116 put_module(B_PCI_MODULE_NAME
);
123 return (const char**)gDevNameList
;
128 find_device(const char* name
)
133 LOG((DEVICE_NAME
": find_device()\n"));
135 for (i
= 0; (item
= gDevNameList
[i
]); i
++) {
136 if (!strcmp(name
, item
)) {
137 return &gDeviceHooks
;
140 return NULL
; // Device not found