diva.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /* $Id: diva.c,v 1.21.4.1 2004/05/08 14:33:43 armin Exp $ */
  2. #define CARDTYPE_H_WANT_DATA 1
  3. #define CARDTYPE_H_WANT_IDI_DATA 0
  4. #define CARDTYPE_H_WANT_RESOURCE_DATA 0
  5. #define CARDTYPE_H_WANT_FILE_DATA 0
  6. #include "platform.h"
  7. #include "debuglib.h"
  8. #include "cardtype.h"
  9. #include "pc.h"
  10. #include "di_defs.h"
  11. #include "di.h"
  12. #include "io.h"
  13. #include "pc_maint.h"
  14. #include "xdi_msg.h"
  15. #include "xdi_adapter.h"
  16. #include "diva_pci.h"
  17. #include "diva.h"
  18. #ifdef CONFIG_ISDN_DIVAS_PRIPCI
  19. #include "os_pri.h"
  20. #endif
  21. #ifdef CONFIG_ISDN_DIVAS_BRIPCI
  22. #include "os_bri.h"
  23. #include "os_4bri.h"
  24. #endif
  25. PISDN_ADAPTER IoAdapters[MAX_ADAPTER];
  26. extern IDI_CALL Requests[MAX_ADAPTER];
  27. extern int create_adapter_proc(diva_os_xdi_adapter_t *a);
  28. extern void remove_adapter_proc(diva_os_xdi_adapter_t *a);
  29. #define DivaIdiReqFunc(N) \
  30. static void DivaIdiRequest##N(ENTITY *e) \
  31. { if (IoAdapters[N]) (*IoAdapters[N]->DIRequest)(IoAdapters[N], e); }
  32. /*
  33. ** Create own 32 Adapters
  34. */
  35. DivaIdiReqFunc(0)
  36. DivaIdiReqFunc(1)
  37. DivaIdiReqFunc(2)
  38. DivaIdiReqFunc(3)
  39. DivaIdiReqFunc(4)
  40. DivaIdiReqFunc(5)
  41. DivaIdiReqFunc(6)
  42. DivaIdiReqFunc(7)
  43. DivaIdiReqFunc(8)
  44. DivaIdiReqFunc(9)
  45. DivaIdiReqFunc(10)
  46. DivaIdiReqFunc(11)
  47. DivaIdiReqFunc(12)
  48. DivaIdiReqFunc(13)
  49. DivaIdiReqFunc(14)
  50. DivaIdiReqFunc(15)
  51. DivaIdiReqFunc(16)
  52. DivaIdiReqFunc(17)
  53. DivaIdiReqFunc(18)
  54. DivaIdiReqFunc(19)
  55. DivaIdiReqFunc(20)
  56. DivaIdiReqFunc(21)
  57. DivaIdiReqFunc(22)
  58. DivaIdiReqFunc(23)
  59. DivaIdiReqFunc(24)
  60. DivaIdiReqFunc(25)
  61. DivaIdiReqFunc(26)
  62. DivaIdiReqFunc(27)
  63. DivaIdiReqFunc(28)
  64. DivaIdiReqFunc(29)
  65. DivaIdiReqFunc(30)
  66. DivaIdiReqFunc(31)
  67. /*
  68. ** LOCALS
  69. */
  70. static LIST_HEAD(adapter_queue);
  71. typedef struct _diva_get_xlog {
  72. word command;
  73. byte req;
  74. byte rc;
  75. byte data[sizeof(struct mi_pc_maint)];
  76. } diva_get_xlog_t;
  77. typedef struct _diva_supported_cards_info {
  78. int CardOrdinal;
  79. diva_init_card_proc_t init_card;
  80. } diva_supported_cards_info_t;
  81. static diva_supported_cards_info_t divas_supported_cards[] = {
  82. #ifdef CONFIG_ISDN_DIVAS_PRIPCI
  83. /*
  84. PRI Cards
  85. */
  86. {CARDTYPE_DIVASRV_P_30M_PCI, diva_pri_init_card},
  87. /*
  88. PRI Rev.2 Cards
  89. */
  90. {CARDTYPE_DIVASRV_P_30M_V2_PCI, diva_pri_init_card},
  91. /*
  92. PRI Rev.2 VoIP Cards
  93. */
  94. {CARDTYPE_DIVASRV_VOICE_P_30M_V2_PCI, diva_pri_init_card},
  95. #endif
  96. #ifdef CONFIG_ISDN_DIVAS_BRIPCI
  97. /*
  98. 4BRI Rev 1 Cards
  99. */
  100. {CARDTYPE_DIVASRV_Q_8M_PCI, diva_4bri_init_card},
  101. {CARDTYPE_DIVASRV_VOICE_Q_8M_PCI, diva_4bri_init_card},
  102. /*
  103. 4BRI Rev 2 Cards
  104. */
  105. {CARDTYPE_DIVASRV_Q_8M_V2_PCI, diva_4bri_init_card},
  106. {CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI, diva_4bri_init_card},
  107. /*
  108. 4BRI Based BRI Rev 2 Cards
  109. */
  110. {CARDTYPE_DIVASRV_B_2M_V2_PCI, diva_4bri_init_card},
  111. {CARDTYPE_DIVASRV_B_2F_PCI, diva_4bri_init_card},
  112. {CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI, diva_4bri_init_card},
  113. /*
  114. BRI
  115. */
  116. {CARDTYPE_MAESTRA_PCI, diva_bri_init_card},
  117. #endif
  118. /*
  119. EOL
  120. */
  121. {-1}
  122. };
  123. static void diva_init_request_array(void);
  124. static void *divas_create_pci_card(int handle, void *pci_dev_handle);
  125. static diva_os_spin_lock_t adapter_lock;
  126. static int diva_find_free_adapters(int base, int nr)
  127. {
  128. int i;
  129. for (i = 0; i < nr; i++) {
  130. if (IoAdapters[base + i]) {
  131. return (-1);
  132. }
  133. }
  134. return (0);
  135. }
  136. static diva_os_xdi_adapter_t *diva_q_get_next(struct list_head *what)
  137. {
  138. diva_os_xdi_adapter_t *a = NULL;
  139. if (what && (what->next != &adapter_queue))
  140. a = list_entry(what->next, diva_os_xdi_adapter_t, link);
  141. return (a);
  142. }
  143. /* --------------------------------------------------------------------------
  144. Add card to the card list
  145. -------------------------------------------------------------------------- */
  146. void *diva_driver_add_card(void *pdev, unsigned long CardOrdinal)
  147. {
  148. diva_os_spin_lock_magic_t old_irql;
  149. diva_os_xdi_adapter_t *pdiva, *pa;
  150. int i, j, max, nr;
  151. for (i = 0; divas_supported_cards[i].CardOrdinal != -1; i++) {
  152. if (divas_supported_cards[i].CardOrdinal == CardOrdinal) {
  153. if (!(pdiva = divas_create_pci_card(i, pdev))) {
  154. return NULL;
  155. }
  156. switch (CardOrdinal) {
  157. case CARDTYPE_DIVASRV_Q_8M_PCI:
  158. case CARDTYPE_DIVASRV_VOICE_Q_8M_PCI:
  159. case CARDTYPE_DIVASRV_Q_8M_V2_PCI:
  160. case CARDTYPE_DIVASRV_VOICE_Q_8M_V2_PCI:
  161. max = MAX_ADAPTER - 4;
  162. nr = 4;
  163. break;
  164. default:
  165. max = MAX_ADAPTER;
  166. nr = 1;
  167. }
  168. diva_os_enter_spin_lock(&adapter_lock, &old_irql, "add card");
  169. for (i = 0; i < max; i++) {
  170. if (!diva_find_free_adapters(i, nr)) {
  171. pdiva->controller = i + 1;
  172. pdiva->xdi_adapter.ANum = pdiva->controller;
  173. IoAdapters[i] = &pdiva->xdi_adapter;
  174. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "add card");
  175. create_adapter_proc(pdiva); /* add adapter to proc file system */
  176. DBG_LOG(("add %s:%d",
  177. CardProperties
  178. [CardOrdinal].Name,
  179. pdiva->controller))
  180. diva_os_enter_spin_lock(&adapter_lock, &old_irql, "add card");
  181. pa = pdiva;
  182. for (j = 1; j < nr; j++) { /* slave adapters, if any */
  183. pa = diva_q_get_next(&pa->link);
  184. if (pa && !pa->interface.cleanup_adapter_proc) {
  185. pa->controller = i + 1 + j;
  186. pa->xdi_adapter.ANum = pa->controller;
  187. IoAdapters[i + j] = &pa->xdi_adapter;
  188. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "add card");
  189. DBG_LOG(("add slave adapter (%d)",
  190. pa->controller))
  191. create_adapter_proc(pa); /* add adapter to proc file system */
  192. diva_os_enter_spin_lock(&adapter_lock, &old_irql, "add card");
  193. } else {
  194. DBG_ERR(("slave adapter problem"))
  195. break;
  196. }
  197. }
  198. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "add card");
  199. return (pdiva);
  200. }
  201. }
  202. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "add card");
  203. /*
  204. Not able to add adapter - remove it and return error
  205. */
  206. DBG_ERR(("can not alloc request array"))
  207. diva_driver_remove_card(pdiva);
  208. return NULL;
  209. }
  210. }
  211. return NULL;
  212. }
  213. /* --------------------------------------------------------------------------
  214. Called on driver load, MAIN, main, DriverEntry
  215. -------------------------------------------------------------------------- */
  216. int divasa_xdi_driver_entry(void)
  217. {
  218. diva_os_initialize_spin_lock(&adapter_lock, "adapter");
  219. memset(&IoAdapters[0], 0x00, sizeof(IoAdapters));
  220. diva_init_request_array();
  221. return (0);
  222. }
  223. /* --------------------------------------------------------------------------
  224. Remove adapter from list
  225. -------------------------------------------------------------------------- */
  226. static diva_os_xdi_adapter_t *get_and_remove_from_queue(void)
  227. {
  228. diva_os_spin_lock_magic_t old_irql;
  229. diva_os_xdi_adapter_t *a = NULL;
  230. diva_os_enter_spin_lock(&adapter_lock, &old_irql, "driver_unload");
  231. if (!list_empty(&adapter_queue)) {
  232. a = list_entry(adapter_queue.next, diva_os_xdi_adapter_t, link);
  233. list_del(adapter_queue.next);
  234. }
  235. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "driver_unload");
  236. return (a);
  237. }
  238. /* --------------------------------------------------------------------------
  239. Remove card from the card list
  240. -------------------------------------------------------------------------- */
  241. void diva_driver_remove_card(void *pdiva)
  242. {
  243. diva_os_spin_lock_magic_t old_irql;
  244. diva_os_xdi_adapter_t *a[4];
  245. diva_os_xdi_adapter_t *pa;
  246. int i;
  247. pa = a[0] = (diva_os_xdi_adapter_t *) pdiva;
  248. a[1] = a[2] = a[3] = NULL;
  249. diva_os_enter_spin_lock(&adapter_lock, &old_irql, "remode adapter");
  250. for (i = 1; i < 4; i++) {
  251. if ((pa = diva_q_get_next(&pa->link))
  252. && !pa->interface.cleanup_adapter_proc) {
  253. a[i] = pa;
  254. } else {
  255. break;
  256. }
  257. }
  258. for (i = 0; ((i < 4) && a[i]); i++) {
  259. list_del(&a[i]->link);
  260. }
  261. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "driver_unload");
  262. (*(a[0]->interface.cleanup_adapter_proc)) (a[0]);
  263. for (i = 0; i < 4; i++) {
  264. if (a[i]) {
  265. if (a[i]->controller) {
  266. DBG_LOG(("remove adapter (%d)",
  267. a[i]->controller)) IoAdapters[a[i]->controller - 1] = NULL;
  268. remove_adapter_proc(a[i]);
  269. }
  270. diva_os_free(0, a[i]);
  271. }
  272. }
  273. }
  274. /* --------------------------------------------------------------------------
  275. Create diva PCI adapter and init internal adapter structures
  276. -------------------------------------------------------------------------- */
  277. static void *divas_create_pci_card(int handle, void *pci_dev_handle)
  278. {
  279. diva_supported_cards_info_t *pI = &divas_supported_cards[handle];
  280. diva_os_spin_lock_magic_t old_irql;
  281. diva_os_xdi_adapter_t *a;
  282. DBG_LOG(("found %d-%s", pI->CardOrdinal, CardProperties[pI->CardOrdinal].Name))
  283. if (!(a = (diva_os_xdi_adapter_t *) diva_os_malloc(0, sizeof(*a)))) {
  284. DBG_ERR(("A: can't alloc adapter"));
  285. return NULL;
  286. }
  287. memset(a, 0x00, sizeof(*a));
  288. a->CardIndex = handle;
  289. a->CardOrdinal = pI->CardOrdinal;
  290. a->Bus = DIVAS_XDI_ADAPTER_BUS_PCI;
  291. a->xdi_adapter.cardType = a->CardOrdinal;
  292. a->resources.pci.bus = diva_os_get_pci_bus(pci_dev_handle);
  293. a->resources.pci.func = diva_os_get_pci_func(pci_dev_handle);
  294. a->resources.pci.hdev = pci_dev_handle;
  295. /*
  296. Add master adapter first, so slave adapters will receive higher
  297. numbers as master adapter
  298. */
  299. diva_os_enter_spin_lock(&adapter_lock, &old_irql, "found_pci_card");
  300. list_add_tail(&a->link, &adapter_queue);
  301. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "found_pci_card");
  302. if ((*(pI->init_card)) (a)) {
  303. diva_os_enter_spin_lock(&adapter_lock, &old_irql, "found_pci_card");
  304. list_del(&a->link);
  305. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "found_pci_card");
  306. diva_os_free(0, a);
  307. DBG_ERR(("A: can't get adapter resources"));
  308. return NULL;
  309. }
  310. return (a);
  311. }
  312. /* --------------------------------------------------------------------------
  313. Called on driver unload FINIT, finit, Unload
  314. -------------------------------------------------------------------------- */
  315. void divasa_xdi_driver_unload(void)
  316. {
  317. diva_os_xdi_adapter_t *a;
  318. while ((a = get_and_remove_from_queue())) {
  319. if (a->interface.cleanup_adapter_proc) {
  320. (*(a->interface.cleanup_adapter_proc)) (a);
  321. }
  322. if (a->controller) {
  323. IoAdapters[a->controller - 1] = NULL;
  324. remove_adapter_proc(a);
  325. }
  326. diva_os_free(0, a);
  327. }
  328. diva_os_destroy_spin_lock(&adapter_lock, "adapter");
  329. }
  330. /*
  331. ** Receive and process command from user mode utility
  332. */
  333. void *diva_xdi_open_adapter(void *os_handle, const void __user *src,
  334. int length, void *mptr,
  335. divas_xdi_copy_from_user_fn_t cp_fn)
  336. {
  337. diva_xdi_um_cfg_cmd_t *msg = (diva_xdi_um_cfg_cmd_t *)mptr;
  338. diva_os_xdi_adapter_t *a = NULL;
  339. diva_os_spin_lock_magic_t old_irql;
  340. struct list_head *tmp;
  341. if (length < sizeof(diva_xdi_um_cfg_cmd_t)) {
  342. DBG_ERR(("A: A(?) open, msg too small (%d < %d)",
  343. length, sizeof(diva_xdi_um_cfg_cmd_t)))
  344. return NULL;
  345. }
  346. if ((*cp_fn) (os_handle, msg, src, sizeof(*msg)) <= 0) {
  347. DBG_ERR(("A: A(?) open, write error"))
  348. return NULL;
  349. }
  350. diva_os_enter_spin_lock(&adapter_lock, &old_irql, "open_adapter");
  351. list_for_each(tmp, &adapter_queue) {
  352. a = list_entry(tmp, diva_os_xdi_adapter_t, link);
  353. if (a->controller == (int)msg->adapter)
  354. break;
  355. a = NULL;
  356. }
  357. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "open_adapter");
  358. if (!a) {
  359. DBG_ERR(("A: A(%d) open, adapter not found", msg->adapter))
  360. }
  361. return (a);
  362. }
  363. /*
  364. ** Easy cleanup mailbox status
  365. */
  366. void diva_xdi_close_adapter(void *adapter, void *os_handle)
  367. {
  368. diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) adapter;
  369. a->xdi_mbox.status &= ~DIVA_XDI_MBOX_BUSY;
  370. if (a->xdi_mbox.data) {
  371. diva_os_free(0, a->xdi_mbox.data);
  372. a->xdi_mbox.data = NULL;
  373. }
  374. }
  375. int
  376. diva_xdi_write(void *adapter, void *os_handle, const void __user *src,
  377. int length, void *mptr,
  378. divas_xdi_copy_from_user_fn_t cp_fn)
  379. {
  380. diva_xdi_um_cfg_cmd_t *msg = (diva_xdi_um_cfg_cmd_t *)mptr;
  381. diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) adapter;
  382. void *data;
  383. if (a->xdi_mbox.status & DIVA_XDI_MBOX_BUSY) {
  384. DBG_ERR(("A: A(%d) write, mbox busy", a->controller))
  385. return (-1);
  386. }
  387. if (length < sizeof(diva_xdi_um_cfg_cmd_t)) {
  388. DBG_ERR(("A: A(%d) write, message too small (%d < %d)",
  389. a->controller, length,
  390. sizeof(diva_xdi_um_cfg_cmd_t)))
  391. return (-3);
  392. }
  393. if (!(data = diva_os_malloc(0, length))) {
  394. DBG_ERR(("A: A(%d) write, ENOMEM", a->controller))
  395. return (-2);
  396. }
  397. if (msg) {
  398. *(diva_xdi_um_cfg_cmd_t *)data = *msg;
  399. length = (*cp_fn) (os_handle, (char *)data + sizeof(*msg),
  400. src + sizeof(*msg), length - sizeof(*msg));
  401. } else {
  402. length = (*cp_fn) (os_handle, data, src, length);
  403. }
  404. if (length > 0) {
  405. if ((*(a->interface.cmd_proc))
  406. (a, (diva_xdi_um_cfg_cmd_t *) data, length)) {
  407. length = -3;
  408. }
  409. } else {
  410. DBG_ERR(("A: A(%d) write error (%d)", a->controller,
  411. length))
  412. }
  413. diva_os_free(0, data);
  414. return (length);
  415. }
  416. /*
  417. ** Write answers to user mode utility, if any
  418. */
  419. int
  420. diva_xdi_read(void *adapter, void *os_handle, void __user *dst,
  421. int max_length, divas_xdi_copy_to_user_fn_t cp_fn)
  422. {
  423. diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) adapter;
  424. int ret;
  425. if (!(a->xdi_mbox.status & DIVA_XDI_MBOX_BUSY)) {
  426. DBG_ERR(("A: A(%d) rx mbox empty", a->controller))
  427. return (-1);
  428. }
  429. if (!a->xdi_mbox.data) {
  430. a->xdi_mbox.status &= ~DIVA_XDI_MBOX_BUSY;
  431. DBG_ERR(("A: A(%d) rx ENOMEM", a->controller))
  432. return (-2);
  433. }
  434. if (max_length < a->xdi_mbox.data_length) {
  435. DBG_ERR(("A: A(%d) rx buffer too short(%d < %d)",
  436. a->controller, max_length,
  437. a->xdi_mbox.data_length))
  438. return (-3);
  439. }
  440. ret = (*cp_fn) (os_handle, dst, a->xdi_mbox.data,
  441. a->xdi_mbox.data_length);
  442. if (ret > 0) {
  443. diva_os_free(0, a->xdi_mbox.data);
  444. a->xdi_mbox.data = NULL;
  445. a->xdi_mbox.status &= ~DIVA_XDI_MBOX_BUSY;
  446. }
  447. return (ret);
  448. }
  449. irqreturn_t diva_os_irq_wrapper(int irq, void *context)
  450. {
  451. diva_os_xdi_adapter_t *a = context;
  452. diva_xdi_clear_interrupts_proc_t clear_int_proc;
  453. if (!a || !a->xdi_adapter.diva_isr_handler)
  454. return IRQ_NONE;
  455. if ((clear_int_proc = a->clear_interrupts_proc)) {
  456. (*clear_int_proc) (a);
  457. a->clear_interrupts_proc = NULL;
  458. return IRQ_HANDLED;
  459. }
  460. (*(a->xdi_adapter.diva_isr_handler)) (&a->xdi_adapter);
  461. return IRQ_HANDLED;
  462. }
  463. static void diva_init_request_array(void)
  464. {
  465. Requests[0] = DivaIdiRequest0;
  466. Requests[1] = DivaIdiRequest1;
  467. Requests[2] = DivaIdiRequest2;
  468. Requests[3] = DivaIdiRequest3;
  469. Requests[4] = DivaIdiRequest4;
  470. Requests[5] = DivaIdiRequest5;
  471. Requests[6] = DivaIdiRequest6;
  472. Requests[7] = DivaIdiRequest7;
  473. Requests[8] = DivaIdiRequest8;
  474. Requests[9] = DivaIdiRequest9;
  475. Requests[10] = DivaIdiRequest10;
  476. Requests[11] = DivaIdiRequest11;
  477. Requests[12] = DivaIdiRequest12;
  478. Requests[13] = DivaIdiRequest13;
  479. Requests[14] = DivaIdiRequest14;
  480. Requests[15] = DivaIdiRequest15;
  481. Requests[16] = DivaIdiRequest16;
  482. Requests[17] = DivaIdiRequest17;
  483. Requests[18] = DivaIdiRequest18;
  484. Requests[19] = DivaIdiRequest19;
  485. Requests[20] = DivaIdiRequest20;
  486. Requests[21] = DivaIdiRequest21;
  487. Requests[22] = DivaIdiRequest22;
  488. Requests[23] = DivaIdiRequest23;
  489. Requests[24] = DivaIdiRequest24;
  490. Requests[25] = DivaIdiRequest25;
  491. Requests[26] = DivaIdiRequest26;
  492. Requests[27] = DivaIdiRequest27;
  493. Requests[28] = DivaIdiRequest28;
  494. Requests[29] = DivaIdiRequest29;
  495. Requests[30] = DivaIdiRequest30;
  496. Requests[31] = DivaIdiRequest31;
  497. }
  498. void diva_xdi_display_adapter_features(int card)
  499. {
  500. dword features;
  501. if (!card || ((card - 1) >= MAX_ADAPTER) || !IoAdapters[card - 1]) {
  502. return;
  503. }
  504. card--;
  505. features = IoAdapters[card]->Properties.Features;
  506. DBG_LOG(("FEATURES FOR ADAPTER: %d", card + 1))
  507. DBG_LOG((" DI_FAX3 : %s",
  508. (features & DI_FAX3) ? "Y" : "N"))
  509. DBG_LOG((" DI_MODEM : %s",
  510. (features & DI_MODEM) ? "Y" : "N"))
  511. DBG_LOG((" DI_POST : %s",
  512. (features & DI_POST) ? "Y" : "N"))
  513. DBG_LOG((" DI_V110 : %s",
  514. (features & DI_V110) ? "Y" : "N"))
  515. DBG_LOG((" DI_V120 : %s",
  516. (features & DI_V120) ? "Y" : "N"))
  517. DBG_LOG((" DI_POTS : %s",
  518. (features & DI_POTS) ? "Y" : "N"))
  519. DBG_LOG((" DI_CODEC : %s",
  520. (features & DI_CODEC) ? "Y" : "N"))
  521. DBG_LOG((" DI_MANAGE : %s",
  522. (features & DI_MANAGE) ? "Y" : "N"))
  523. DBG_LOG((" DI_V_42 : %s",
  524. (features & DI_V_42) ? "Y" : "N"))
  525. DBG_LOG((" DI_EXTD_FAX : %s",
  526. (features & DI_EXTD_FAX) ? "Y" : "N"))
  527. DBG_LOG((" DI_AT_PARSER : %s",
  528. (features & DI_AT_PARSER) ? "Y" : "N"))
  529. DBG_LOG((" DI_VOICE_OVER_IP : %s",
  530. (features & DI_VOICE_OVER_IP) ? "Y" : "N"))
  531. }
  532. void diva_add_slave_adapter(diva_os_xdi_adapter_t *a)
  533. {
  534. diva_os_spin_lock_magic_t old_irql;
  535. diva_os_enter_spin_lock(&adapter_lock, &old_irql, "add_slave");
  536. list_add_tail(&a->link, &adapter_queue);
  537. diva_os_leave_spin_lock(&adapter_lock, &old_irql, "add_slave");
  538. }
  539. int diva_card_read_xlog(diva_os_xdi_adapter_t *a)
  540. {
  541. diva_get_xlog_t *req;
  542. byte *data;
  543. if (!a->xdi_adapter.Initialized || !a->xdi_adapter.DIRequest) {
  544. return (-1);
  545. }
  546. if (!(data = diva_os_malloc(0, sizeof(struct mi_pc_maint)))) {
  547. return (-1);
  548. }
  549. memset(data, 0x00, sizeof(struct mi_pc_maint));
  550. if (!(req = diva_os_malloc(0, sizeof(*req)))) {
  551. diva_os_free(0, data);
  552. return (-1);
  553. }
  554. req->command = 0x0400;
  555. req->req = LOG;
  556. req->rc = 0x00;
  557. (*(a->xdi_adapter.DIRequest)) (&a->xdi_adapter, (ENTITY *) req);
  558. if (!req->rc || req->req) {
  559. diva_os_free(0, data);
  560. diva_os_free(0, req);
  561. return (-1);
  562. }
  563. memcpy(data, &req->req, sizeof(struct mi_pc_maint));
  564. diva_os_free(0, req);
  565. a->xdi_mbox.data_length = sizeof(struct mi_pc_maint);
  566. a->xdi_mbox.data = data;
  567. a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY;
  568. return (0);
  569. }
  570. void xdiFreeFile(void *handle)
  571. {
  572. }