|
@@ -65,6 +65,16 @@ static uint16_t isapnp_max_csn;
|
65
|
65
|
*
|
66
|
66
|
*/
|
67
|
67
|
|
|
68
|
+#define ISAPNP_CARD_ID_FMT "ID %hx:%hx (\"%s\") serial %x"
|
|
69
|
+#define ISAPNP_CARD_ID_DATA(identifier) \
|
|
70
|
+ (identifier)->vendor_id, (identifier)->prod_id, \
|
|
71
|
+ isa_id_string ( (identifier)->vendor_id, (identifier)->prod_id ), \
|
|
72
|
+ (identifier)->serial
|
|
73
|
+#define ISAPNP_DEV_ID_FMT "ID %hx:%hx (\"%s\")"
|
|
74
|
+#define ISAPNP_DEV_ID_DATA(isapnp) \
|
|
75
|
+ (isapnp)->vendor_id, (isapnp)->prod_id, \
|
|
76
|
+ isa_id_string ( (isapnp)->vendor_id, (isapnp)->prod_id )
|
|
77
|
+
|
68
|
78
|
static inline void isapnp_write_address ( uint8_t address ) {
|
69
|
79
|
outb ( address, ISAPNP_ADDRESS );
|
70
|
80
|
}
|
|
@@ -254,6 +264,7 @@ static int isapnp_find_tag ( uint8_t wanted_tag, uint8_t *buf ) {
|
254
|
264
|
uint8_t tag;
|
255
|
265
|
uint16_t len;
|
256
|
266
|
|
|
267
|
+ DBG ( "ISAPnP read tag" );
|
257
|
268
|
do {
|
258
|
269
|
tag = isapnp_peek_byte();
|
259
|
270
|
if ( ISAPNP_IS_SMALL_TAG ( tag ) ) {
|
|
@@ -263,14 +274,16 @@ static int isapnp_find_tag ( uint8_t wanted_tag, uint8_t *buf ) {
|
263
|
274
|
len = isapnp_peek_byte() + ( isapnp_peek_byte() << 8 );
|
264
|
275
|
tag = ISAPNP_LARGE_TAG_NAME ( tag );
|
265
|
276
|
}
|
266
|
|
- DBG ( "ISAPnP read tag %hhx len %hhx\n", tag, len );
|
|
277
|
+ DBG ( " %hhx (%hhx)", tag, len );
|
267
|
278
|
if ( tag == wanted_tag ) {
|
268
|
279
|
isapnp_peek ( buf, len );
|
|
280
|
+ DBG ( "\n" );
|
269
|
281
|
return 1;
|
270
|
282
|
} else {
|
271
|
283
|
isapnp_peek ( NULL, len );
|
272
|
284
|
}
|
273
|
285
|
} while ( tag != ISAPNP_TAG_END );
|
|
286
|
+ DBG ( "\n" );
|
274
|
287
|
return 0;
|
275
|
288
|
}
|
276
|
289
|
|
|
@@ -333,30 +346,38 @@ static int isapnp_try_isolate ( void ) {
|
333
|
346
|
isapnp_delay();
|
334
|
347
|
data = ( data << 8 ) | isapnp_read_data ();
|
335
|
348
|
isapnp_delay();
|
|
349
|
+ byte >>= 1;
|
336
|
350
|
if ( data == 0x55aa ) {
|
337
|
|
- byte |= 1;
|
|
351
|
+ byte |= 0x80;
|
|
352
|
+ seen55aa = 1;
|
338
|
353
|
}
|
339
|
|
- byte <<= 1;
|
340
|
354
|
}
|
341
|
355
|
( (char *) &identifier )[i] = byte;
|
342
|
|
- if ( byte ) {
|
343
|
|
- seen55aa = 1;
|
344
|
|
- }
|
345
|
356
|
}
|
346
|
357
|
|
347
|
|
- /* If we didn't see a valid ISAPnP device, stop here */
|
348
|
|
- if ( ( ! seen55aa ) ||
|
349
|
|
- ( identifier.checksum != isapnp_checksum (&identifier) ) )
|
|
358
|
+ /* If we didn't see any 55aa patterns, stop here */
|
|
359
|
+ if ( ! seen55aa ) {
|
|
360
|
+ DBG ( "ISAPnP saw %s signs of life\n",
|
|
361
|
+ isapnp_max_csn ? "no futher" : "no" );
|
350
|
362
|
break;
|
|
363
|
+ }
|
|
364
|
+
|
|
365
|
+ /* If the checksum was invalid stop here */
|
|
366
|
+ if ( identifier.checksum != isapnp_checksum ( &identifier) ) {
|
|
367
|
+ DBG ( "ISAPnP found malformed card "
|
|
368
|
+ ISAPNP_CARD_ID_FMT "\n with checksum %hhx "
|
|
369
|
+ "(should be %hhx), abandoning isolation\n",
|
|
370
|
+ ISAPNP_CARD_ID_DATA ( &identifier ),
|
|
371
|
+ identifier.checksum,
|
|
372
|
+ isapnp_checksum ( &identifier) );
|
|
373
|
+ /* break; */
|
|
374
|
+ }
|
351
|
375
|
|
352
|
376
|
/* Give the device a CSN */
|
353
|
377
|
isapnp_max_csn++;
|
354
|
|
- DBG ( "ISAPnP isolation found card %hhx ID %hx:%hx (\"%s\") "
|
355
|
|
- "serial %x checksum %hhx, assigning CSN %hhx\n",
|
356
|
|
- identifier.vendor_id, identifier.prod_id,
|
357
|
|
- isa_id_string ( identifier.vendor_id,
|
358
|
|
- identifier.prod_id ),
|
359
|
|
- identifier.serial, identifier.checksum, isapnp_max_csn );
|
|
378
|
+ DBG ( "ISAPnP found card " ISAPNP_CARD_ID_FMT
|
|
379
|
+ ", assigning CSN %hhx\n",
|
|
380
|
+ ISAPNP_CARD_ID_DATA ( &identifier ), isapnp_max_csn );
|
360
|
381
|
|
361
|
382
|
isapnp_write_csn ( isapnp_max_csn );
|
362
|
383
|
isapnp_delay();
|
|
@@ -374,6 +395,9 @@ static int isapnp_try_isolate ( void ) {
|
374
|
395
|
/* Return number of cards found */
|
375
|
396
|
DBG ( "ISAPnP found %d cards at read port %hx\n",
|
376
|
397
|
isapnp_max_csn, isapnp_read_port );
|
|
398
|
+
|
|
399
|
+ getchar();
|
|
400
|
+
|
377
|
401
|
return isapnp_max_csn;
|
378
|
402
|
}
|
379
|
403
|
|
|
@@ -406,6 +430,7 @@ static void isapnp_isolate ( void ) {
|
406
|
430
|
*/
|
407
|
431
|
static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
|
408
|
432
|
unsigned int i;
|
|
433
|
+ struct isapnp_identifier identifier;
|
409
|
434
|
struct isapnp_logdevid logdevid;
|
410
|
435
|
|
411
|
436
|
/* Wake the card */
|
|
@@ -413,19 +438,23 @@ static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
|
413
|
438
|
isapnp_send_key ();
|
414
|
439
|
isapnp_wake ( isapnp->csn );
|
415
|
440
|
|
416
|
|
- /* Skip past the card identifier */
|
417
|
|
- isapnp_peek ( NULL, sizeof ( struct isapnp_identifier ) );
|
|
441
|
+ /* Read the card identifier */
|
|
442
|
+ isapnp_peek ( ( char * ) &identifier, sizeof ( identifier ) );
|
418
|
443
|
|
419
|
444
|
/* Find the Logical Device ID tag corresponding to this device */
|
420
|
445
|
for ( i = 0 ; i <= isapnp->logdev ; i++ ) {
|
421
|
446
|
if ( ! isapnp_find_tag ( ISAPNP_TAG_LOGDEVID,
|
422
|
447
|
( char * ) &logdevid ) ) {
|
423
|
448
|
/* No tag for this device */
|
|
449
|
+ DBG ( "ISAPnP found no device %hhx.%hhx on "
|
|
450
|
+ "card " ISAPNP_CARD_ID_FMT "\n",
|
|
451
|
+ isapnp->csn, isapnp->logdev,
|
|
452
|
+ ISAPNP_CARD_ID_DATA ( &identifier ) );
|
424
|
453
|
return 0;
|
425
|
454
|
}
|
426
|
455
|
}
|
427
|
456
|
|
428
|
|
- /* Read information from identifier structure */
|
|
457
|
+ /* Read information from logdevid structure */
|
429
|
458
|
isapnp->vendor_id = logdevid.vendor_id;
|
430
|
459
|
isapnp->prod_id = logdevid.prod_id;
|
431
|
460
|
|
|
@@ -439,11 +468,11 @@ static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
|
439
|
468
|
/* Return all cards to Wait for Key state */
|
440
|
469
|
isapnp_wait_for_key ();
|
441
|
470
|
|
442
|
|
- DBG ( "ISAPnP found device %hhx.%hhx ID %hx:%hx (\"%s\"), "
|
443
|
|
- "base %hx irq %d\n",
|
444
|
|
- isapnp->csn, isapnp->logdev, isapnp->vendor_id, isapnp->prod_id,
|
445
|
|
- isa_id_string ( isapnp->vendor_id, isapnp->prod_id ),
|
446
|
|
- isapnp->ioaddr, isapnp->irqno );
|
|
471
|
+ DBG ( "ISAPnP found device %hhx.%hhx " ISAPNP_DEV_ID_FMT
|
|
472
|
+ ", base %hx irq %d\n", isapnp->csn, isapnp->logdev,
|
|
473
|
+ ISAPNP_DEV_ID_DATA ( isapnp ), isapnp->ioaddr, isapnp->irqno );
|
|
474
|
+ DBG ( " on card " ISAPNP_CARD_ID_FMT "\n",
|
|
475
|
+ ISAPNP_CARD_ID_DATA ( &identifier ) );
|
447
|
476
|
|
448
|
477
|
return 1;
|
449
|
478
|
}
|