]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/hwinfo/src/hd/isdn.c
Kleiner netter neuer Versuch.
[people/pmueller/ipfire-2.x.git] / src / hwinfo / src / hd / isdn.c
CommitLineData
a6316ce4
MT
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4
5#include "hd.h"
6#include "hd_int.h"
7#include "isdn.h"
8
9#undef ISDN_TEST
10
11/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
12 * identify isdn cards
13 *
14 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15 */
16
17#ifndef LIBHD_TINY
18
19#if !defined(__s390__) && !defined(__s390x__) && !defined(__alpha__)
20
21void hd_scan_isdn(hd_data_t *hd_data)
22{
23 hd_t *hd;
24 cdb_isdn_card *cic;
25
26 if(!hd_probe_feature(hd_data, pr_isdn)) return;
27
28 hd_data->module = mod_isdn;
29
30 /* some clean-up */
31 remove_hd_entries(hd_data);
32
33 PROGRESS(1, 0, "list");
34
35#ifdef ISDN_TEST
36 {
37 hd_res_t *res;
38
39 hd = add_hd_entry(hd_data, __LINE__, 0);
40 hd->bus.id = bus_isa;
41 hd->base_class.id = bc_isdn;
42 hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x3005);
43 hd->device.id = MAKE_ID(TAG_SPECIAL, 0x0500); // type, subtype
44 res = add_res_entry(&hd->res, new_mem(sizeof *res));
45 res->io.type = res_io;
46 res->io.enabled = 1;
47 res->io.base = 0x0300;
48 res->io.access = acc_rw;
49
50 hd = add_hd_entry(hd_data, __LINE__, 0);
51 hd->bus.id = bus_isa;
52 hd->base_class.id = bc_isdn;
53 hd->vendor.id = MAKE_ID(TAG_EISA, 0x1593);
54 hd->device.id = MAKE_ID(TAG_EISA, 0x0133); // type, subtype
55 res = add_res_entry(&hd->res, new_mem(sizeof *res));
56 res->io.type = res_io;
57 res->io.enabled = 1;
58 res->io.base = 0x0240;
59 res->io.access = acc_rw;
60 res = add_res_entry(&hd->res, new_mem(sizeof *res));
61 res->irq.type = res_irq;
62 res->irq.enabled = 1;
63 res->irq.base = 99;
64
65 hd = add_hd_entry(hd_data, __LINE__, 0);
66 hd->bus.id = bus_isa;
67 hd->base_class.id = bc_isdn;
68 hd->vendor.id = MAKE_ID(TAG_EISA, 0x0e98);
69 hd->device.id = MAKE_ID(TAG_EISA, 0x0000); // type, subtype
70 res = add_res_entry(&hd->res, new_mem(sizeof *res));
71 res->io.type = res_io;
72 res->io.enabled = 1;
73 res->io.base = 0x0180;
74 res->io.access = acc_rw;
75 res = add_res_entry(&hd->res, new_mem(sizeof *res));
76 res->io.type = res_io;
77 res->io.enabled = 1;
78 res->io.base = 0x0540;
79 res->io.access = acc_rw;
80 res = add_res_entry(&hd->res, new_mem(sizeof *res));
81 res->irq.type = res_irq;
82 res->irq.enabled = 1;
83 res->irq.base = 77;
84
85 hd = add_hd_entry(hd_data, __LINE__, 0);
86 hd->bus.id = bus_pci;
87 hd->base_class.id = bc_isdn;
88 hd->vendor.id = MAKE_ID(TAG_PCI, 0x1244);
89 hd->device.id = MAKE_ID(TAG_PCI, 0x0a00); // type, subtype
90 res = add_res_entry(&hd->res, new_mem(sizeof *res));
91 res->io.type = res_io;
92 res->io.enabled = 1;
93 res->io.base = 0xe000;
94 res->io.access = acc_rw;
95
96 hd = add_hd_entry(hd_data, __LINE__, 0);
97 hd->bus.id = bus_isa;
98 hd->base_class.id = bc_isdn;
99 hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x3001);
100 hd->device.id = MAKE_ID(TAG_SPECIAL, 0x0100); // type, subtype
101 res = add_res_entry(&hd->res, new_mem(sizeof *res));
102 res->io.type = res_io;
103 res->io.enabled = 1;
104 res->io.base = 0xe80;
105 res->io.access = acc_rw;
106
107 hd = add_hd_entry(hd_data, __LINE__, 0);
108 hd->bus.id = bus_isa;
109 hd->base_class.id = bc_isdn;
110 hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x3000);
111 hd->device.id = MAKE_ID(TAG_SPECIAL, 0x1a00); // type, subtype
112 res = add_res_entry(&hd->res, new_mem(sizeof *res));
113 res->io.type = res_io;
114 res->io.enabled = 1;
115 res->io.base = 0x400;
116 res->io.access = acc_rw;
117
118
119 }
120#endif
121
122 for(hd = hd_data->hd; hd; hd = hd->next) {
123 if((cic = get_isdn_info(hd))) {
124 hd->base_class.id = bc_isdn;
125 hd->sub_class.id = 0;
126 free_mem(cic);
127 }
128 }
129
130
131}
132
133cdb_isdn_card *get_isdn_info(hd_t *hd)
134{
135 cdb_isdn_card *cic0, *cic;
136 unsigned u0, u1;
137
138 if(hd->bus.id == bus_pci ||
139 hd->bus.id == bus_isa ||
140 hd->bus.id == bus_usb ||
141 hd->bus.id == bus_pcmcia ||
142 hd->bus.id == bus_cardbus) {
143
144 cic = NULL;
145 u0 = ID_VALUE(hd->vendor.id);
146 if(
147 hd->bus.id == bus_isa &&
148 ID_TAG(hd->vendor.id) == TAG_SPECIAL &&
149 u0 >= 0x3000 && u0 <= 0x3006 &&
150 ID_TAG(hd->device.id) == TAG_SPECIAL
151 ) {
152 u0 = ID_VALUE(hd->device.id);
153 cic = hd_cdbisdn_get_card_from_type(u0 >> 8, u0 & 0xff);
154 }
155
156 if(
157 hd->bus.id == bus_isa &&
158 ID_TAG(hd->vendor.id) == TAG_EISA &&
159 ID_TAG(hd->device.id) == TAG_EISA
160 ) {
161 u0 = ID_VALUE(hd->vendor.id);
162 u1 = ID_VALUE(hd->device.id);
163 cic = hd_cdbisdn_get_card_from_id(((u0 & 0xff) << 8) + ((u0 >> 8) & 0xff),
164 ((u1 & 0xff) << 8) + ((u1 >> 8) & 0xff),
165 0xffff,0xffff);
166 }
167
168 if(hd->bus.id == bus_pci) {
169 cic = hd_cdbisdn_get_card_from_id(ID_VALUE(hd->vendor.id), ID_VALUE(hd->device.id),
170 ID_VALUE(hd->sub_vendor.id), ID_VALUE(hd->sub_device.id));
171 }
172
173 if(hd->bus.id == bus_usb &&
174 ID_TAG(hd->vendor.id) == TAG_USB &&
175 ID_TAG(hd->device.id) == TAG_USB) {
176
177 if (hd->revision.id == 0 && hd->revision.name) {
178 /* the revision is usually saved as string (1.00) */
179 sscanf(hd->revision.name, "%x.%x", &u1, &u0);
180 u0 = u0 | u1 << 8;
181 } else
182 u0 = ID_VALUE(hd->revision.id);
183
184 cic = hd_cdbisdn_get_card_from_id(ID_VALUE(hd->vendor.id), ID_VALUE(hd->device.id),
185 u0, 0xffff);
186 if (!cic) /* to get cards without revision info in database */
187 cic = hd_cdbisdn_get_card_from_id(ID_VALUE(hd->vendor.id), ID_VALUE(hd->device.id),
188 0xffff, 0xffff);
189 }
190
191 if((hd->bus.id == bus_pcmcia || hd->bus.id == bus_cardbus) &&
192 (hd->base_class.id == bc_network || hd->base_class.id == bc_isdn)) {
193 if (hd->drivers && hd->drivers->str) {
194 if (0 == strcmp(hd->drivers->str, "teles_cs")) {
195 cic = hd_cdbisdn_get_card_from_type(8, 0);
196 } else if (0 == strcmp(hd->drivers->str, "sedlbauer_cs")) {
197 cic = hd_cdbisdn_get_card_from_type(22, 2);
198 } else if (0 == strcmp(hd->drivers->str, "avma1_cs")) {
199 cic = hd_cdbisdn_get_card_from_type(26, 0);
200 } else if (0 == strcmp(hd->drivers->str, "fcpcmcia_cs")) {
201 cic = hd_cdbisdn_get_card_from_type(8002, 5);
202 } else if (0 == strcmp(hd->drivers->str, "elsa_cs")) {
203 cic = hd_cdbisdn_get_card_from_type(10, 11);
204 } else if (0 == strcmp(hd->drivers->str, "avm_cs")) {
205 cic = hd_cdbisdn_get_card_from_type(8001, 2);
206 }
207 }
208 }
209
210 if (cic && cic->Class && strcmp(cic->Class, "DSL")) {
211 cic0 = new_mem(sizeof *cic0);
212 memcpy(cic0, cic, sizeof *cic0);
213 return cic0;
214 }
215 }
216 return NULL;
217}
218
219void hd_scan_dsl(hd_data_t *hd_data)
220{
221 hd_t *hd;
222 cdb_isdn_card *cic;
223
224 if(!hd_probe_feature(hd_data, pr_isdn)) return;
225
226 hd_data->module = mod_dsl;
227
228 /* some clean-up */
229 remove_hd_entries(hd_data);
230
231 PROGRESS(1, 0, "list");
232
233#ifdef DSL_TEST
234 {
235 hd_res_t *res;
236
237 hd = add_hd_entry(hd_data, __LINE__, 0);
238 hd->bus.id = bus_pci;
239 hd->base_class.id = bc_dsl;
240 hd->vendor.id = MAKE_ID(TAG_SPECIAL, 0x1244);
241 hd->device.id = MAKE_ID(TAG_SPECIAL, 0x2700); // type, subtype
242
243 }
244#endif
245
246 for(hd = hd_data->hd; hd; hd = hd->next) {
247 if((cic = get_dsl_info(hd))) {
248 free_mem(cic);
249 }
250 }
251
252
253}
254
255cdb_isdn_card *get_dsl_info(hd_t *hd)
256{
257 cdb_isdn_card *cic0, *cic;
258 cdb_isdn_vario *civ;
259 unsigned u0, u1;
260
261 if(hd->bus.id == bus_pci ||
262 hd->bus.id == bus_usb) {
263
264 cic = NULL;
265
266 if(hd->bus.id == bus_pci) {
267 cic = hd_cdbisdn_get_card_from_id(ID_VALUE(hd->vendor.id), ID_VALUE(hd->device.id),
268 ID_VALUE(hd->sub_vendor.id), ID_VALUE(hd->sub_device.id));
269 }
270
271 if(hd->bus.id == bus_usb &&
272 ID_TAG(hd->vendor.id) == TAG_USB &&
273 ID_TAG(hd->device.id) == TAG_USB) {
274
275 if (hd->revision.id == 0 && hd->revision.name) {
276 /* the revision is usually saved as string (1.00) */
277 sscanf(hd->revision.name, "%x.%x", &u1, &u0);
278 u0 = u0 | u1 << 8;
279 } else
280 u0 = ID_VALUE(hd->revision.id);
281
282 cic = hd_cdbisdn_get_card_from_id(ID_VALUE(hd->vendor.id), ID_VALUE(hd->device.id),
283 u0, 0xffff);
284 if (!cic) /* to get cards without revision info in database */
285 cic = hd_cdbisdn_get_card_from_id(ID_VALUE(hd->vendor.id), ID_VALUE(hd->device.id),
286 0xffff, 0xffff);
287 }
288
289 if (cic && cic->Class && !strcmp(cic->Class, "DSL")) {
290 hd->base_class.id = bc_dsl;
291 hd->sub_class.id = sc_dsl_unknown;
292 civ = hd_cdbisdn_get_vario(cic->vario);
293 if (civ && civ->interface) {
294 if (0 == strncmp(civ->interface, "CAPI20", 6)) {
295 hd->sub_class.id = sc_dsl_capi;
296 } else if (0 == strncmp(civ->interface, "pppoe", 5)) {
297 hd->sub_class.id = sc_dsl_pppoe;
298 }
299 }
300 cic0 = new_mem(sizeof *cic0);
301 memcpy(cic0, cic, sizeof *cic0);
302 return cic0;
303 }
304 }
305 return NULL;
306}
307
308#endif /* !defined(__s390__) && !defined(__s390x__) && !defined(__alpha__) */
309
310#endif /* !defined(LIBHD_TINY) */
311