| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: diddfunc.c,v 1.14.6.2 2004/08/28 20:03:53 armin Exp $ | 
|  | 2 | * | 
|  | 3 | * DIDD Interface module for Eicon active cards. | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 4 | * | 
|  | 5 | * Functions are in dadapter.c | 
|  | 6 | * | 
|  | 7 | * Copyright 2002-2003 by Armin Schindler (mac@melware.de) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Copyright 2002-2003 Cytronics & Melware (info@melware.de) | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 9 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * This software may be used and distributed according to the terms | 
|  | 11 | * of the GNU General Public License, incorporated herein by reference. | 
|  | 12 | */ | 
|  | 13 |  | 
|  | 14 | #include "platform.h" | 
|  | 15 | #include "di_defs.h" | 
|  | 16 | #include "dadapter.h" | 
|  | 17 | #include "divasync.h" | 
|  | 18 |  | 
|  | 19 | #define DBG_MINIMUM  (DL_LOG + DL_FTL + DL_ERR) | 
|  | 20 | #define DBG_DEFAULT  (DBG_MINIMUM + DL_XLOG + DL_REG) | 
|  | 21 |  | 
|  | 22 |  | 
|  | 23 | extern void DIVA_DIDD_Read(void *, int); | 
|  | 24 | extern char *DRIVERRELEASE_DIDD; | 
|  | 25 | static dword notify_handle; | 
|  | 26 | static DESCRIPTOR _DAdapter; | 
|  | 27 |  | 
|  | 28 | /* | 
|  | 29 | * didd callback function | 
|  | 30 | */ | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 31 | static void *didd_callback(void *context, DESCRIPTOR *adapter, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | int removal) | 
|  | 33 | { | 
|  | 34 | if (adapter->type == IDI_DADAPTER) { | 
|  | 35 | DBG_ERR(("Notification about IDI_DADAPTER change ! Oops.")) | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 36 | return (NULL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } else if (adapter->type == IDI_DIMAINT) { | 
|  | 38 | if (removal) { | 
|  | 39 | DbgDeregister(); | 
|  | 40 | } else { | 
|  | 41 | DbgRegister("DIDD", DRIVERRELEASE_DIDD, DBG_DEFAULT); | 
|  | 42 | } | 
|  | 43 | } | 
|  | 44 | return (NULL); | 
|  | 45 | } | 
|  | 46 |  | 
|  | 47 | /* | 
|  | 48 | * connect to didd | 
|  | 49 | */ | 
| hartleys | d739889 | 2012-04-24 12:56:03 +0000 | [diff] [blame] | 50 | static int __init connect_didd(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { | 
|  | 52 | int x = 0; | 
|  | 53 | int dadapter = 0; | 
|  | 54 | IDI_SYNC_REQ req; | 
|  | 55 | DESCRIPTOR DIDD_Table[MAX_DESCRIPTORS]; | 
|  | 56 |  | 
|  | 57 | DIVA_DIDD_Read(DIDD_Table, sizeof(DIDD_Table)); | 
|  | 58 |  | 
|  | 59 | for (x = 0; x < MAX_DESCRIPTORS; x++) { | 
|  | 60 | if (DIDD_Table[x].type == IDI_DADAPTER) {	/* DADAPTER found */ | 
|  | 61 | dadapter = 1; | 
|  | 62 | memcpy(&_DAdapter, &DIDD_Table[x], sizeof(_DAdapter)); | 
|  | 63 | req.didd_notify.e.Req = 0; | 
|  | 64 | req.didd_notify.e.Rc = | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 65 | IDI_SYNC_REQ_DIDD_REGISTER_ADAPTER_NOTIFY; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | req.didd_notify.info.callback = (void *)didd_callback; | 
|  | 67 | req.didd_notify.info.context = NULL; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 68 | _DAdapter.request((ENTITY *)&req); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | if (req.didd_notify.e.Rc != 0xff) | 
|  | 70 | return (0); | 
|  | 71 | notify_handle = req.didd_notify.info.handle; | 
|  | 72 | } else if (DIDD_Table[x].type == IDI_DIMAINT) {	/* MAINT found */ | 
|  | 73 | DbgRegister("DIDD", DRIVERRELEASE_DIDD, DBG_DEFAULT); | 
|  | 74 | } | 
|  | 75 | } | 
|  | 76 | return (dadapter); | 
|  | 77 | } | 
|  | 78 |  | 
|  | 79 | /* | 
|  | 80 | * disconnect from didd | 
|  | 81 | */ | 
| hartleys | d739889 | 2012-04-24 12:56:03 +0000 | [diff] [blame] | 82 | static void __exit disconnect_didd(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | { | 
|  | 84 | IDI_SYNC_REQ req; | 
|  | 85 |  | 
|  | 86 | req.didd_notify.e.Req = 0; | 
|  | 87 | req.didd_notify.e.Rc = IDI_SYNC_REQ_DIDD_REMOVE_ADAPTER_NOTIFY; | 
|  | 88 | req.didd_notify.info.handle = notify_handle; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 89 | _DAdapter.request((ENTITY *)&req); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } | 
|  | 91 |  | 
|  | 92 | /* | 
|  | 93 | * init | 
|  | 94 | */ | 
| hartleys | d739889 | 2012-04-24 12:56:03 +0000 | [diff] [blame] | 95 | int __init diddfunc_init(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | { | 
|  | 97 | diva_didd_load_time_init(); | 
|  | 98 |  | 
|  | 99 | if (!connect_didd()) { | 
|  | 100 | DBG_ERR(("init: failed to connect to DIDD.")) | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 101 | diva_didd_load_time_finit(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | return (0); | 
|  | 103 | } | 
|  | 104 | return (1); | 
|  | 105 | } | 
|  | 106 |  | 
|  | 107 | /* | 
|  | 108 | * finit | 
|  | 109 | */ | 
| hartleys | d739889 | 2012-04-24 12:56:03 +0000 | [diff] [blame] | 110 | void __exit diddfunc_finit(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { | 
|  | 112 | DbgDeregister(); | 
|  | 113 | disconnect_didd(); | 
|  | 114 | diva_didd_load_time_finit(); | 
|  | 115 | } |