Browse Source

Now known to work with an old Adaptec 1505 that I found lying around.

tags/v0.9.3
Michael Brown 19 years ago
parent
commit
c659a54f70
2 changed files with 53 additions and 24 deletions
  1. 52
    23
      src/drivers/bus/isapnp.c
  2. 1
    1
      src/include/isapnp.h

+ 52
- 23
src/drivers/bus/isapnp.c View File

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
 static inline void isapnp_write_address ( uint8_t address ) {
78
 static inline void isapnp_write_address ( uint8_t address ) {
69
 	outb ( address, ISAPNP_ADDRESS );
79
 	outb ( address, ISAPNP_ADDRESS );
70
 }
80
 }
254
 	uint8_t tag;
264
 	uint8_t tag;
255
 	uint16_t len;
265
 	uint16_t len;
256
 
266
 
267
+	DBG ( "ISAPnP read tag" );
257
 	do {
268
 	do {
258
 		tag = isapnp_peek_byte();
269
 		tag = isapnp_peek_byte();
259
 		if ( ISAPNP_IS_SMALL_TAG ( tag ) ) {
270
 		if ( ISAPNP_IS_SMALL_TAG ( tag ) ) {
263
 			len = isapnp_peek_byte() + ( isapnp_peek_byte() << 8 );
274
 			len = isapnp_peek_byte() + ( isapnp_peek_byte() << 8 );
264
 			tag = ISAPNP_LARGE_TAG_NAME ( tag );
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
 		if ( tag == wanted_tag ) {
278
 		if ( tag == wanted_tag ) {
268
 			isapnp_peek ( buf, len );
279
 			isapnp_peek ( buf, len );
280
+			DBG ( "\n" );
269
 			return 1;
281
 			return 1;
270
 		} else {
282
 		} else {
271
 			isapnp_peek ( NULL, len );
283
 			isapnp_peek ( NULL, len );
272
 		}
284
 		}
273
 	} while ( tag != ISAPNP_TAG_END );
285
 	} while ( tag != ISAPNP_TAG_END );
286
+	DBG ( "\n" );
274
 	return 0;
287
 	return 0;
275
 }
288
 }
276
 
289
 
333
 				isapnp_delay();
346
 				isapnp_delay();
334
 				data = ( data << 8 ) | isapnp_read_data ();
347
 				data = ( data << 8 ) | isapnp_read_data ();
335
 				isapnp_delay();
348
 				isapnp_delay();
349
+				byte >>= 1;
336
 				if ( data == 0x55aa ) {
350
 				if ( data == 0x55aa ) {
337
-					byte |= 1;
351
+					byte |= 0x80;
352
+					seen55aa = 1;
338
 				}
353
 				}
339
-				byte <<= 1;
340
 			}
354
 			}
341
 			( (char *) &identifier )[i] = byte;
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
 			break;
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
 		/* Give the device a CSN */
376
 		/* Give the device a CSN */
353
 		isapnp_max_csn++;
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
 		isapnp_write_csn ( isapnp_max_csn );
382
 		isapnp_write_csn ( isapnp_max_csn );
362
 		isapnp_delay();
383
 		isapnp_delay();
374
 	/* Return number of cards found */
395
 	/* Return number of cards found */
375
 	DBG ( "ISAPnP found %d cards at read port %hx\n",
396
 	DBG ( "ISAPnP found %d cards at read port %hx\n",
376
 	      isapnp_max_csn, isapnp_read_port );
397
 	      isapnp_max_csn, isapnp_read_port );
398
+
399
+	getchar();
400
+
377
 	return isapnp_max_csn;
401
 	return isapnp_max_csn;
378
 }
402
 }
379
 
403
 
406
  */
430
  */
407
 static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
431
 static int fill_isapnp_device ( struct isapnp_device *isapnp ) {
408
 	unsigned int i;
432
 	unsigned int i;
433
+	struct isapnp_identifier identifier;
409
 	struct isapnp_logdevid logdevid;
434
 	struct isapnp_logdevid logdevid;
410
 	
435
 	
411
 	/* Wake the card */
436
 	/* Wake the card */
413
 	isapnp_send_key ();
438
 	isapnp_send_key ();
414
 	isapnp_wake ( isapnp->csn );
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
 	/* Find the Logical Device ID tag corresponding to this device */
444
 	/* Find the Logical Device ID tag corresponding to this device */
420
 	for ( i = 0 ; i <= isapnp->logdev ; i++ ) {
445
 	for ( i = 0 ; i <= isapnp->logdev ; i++ ) {
421
 		if ( ! isapnp_find_tag ( ISAPNP_TAG_LOGDEVID,
446
 		if ( ! isapnp_find_tag ( ISAPNP_TAG_LOGDEVID,
422
 					 ( char * ) &logdevid ) ) {
447
 					 ( char * ) &logdevid ) ) {
423
 			/* No tag for this device */
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
 			return 0;
453
 			return 0;
425
 		}
454
 		}
426
 	}
455
 	}
427
 
456
 
428
-	/* Read information from identifier structure */
457
+	/* Read information from logdevid structure */
429
 	isapnp->vendor_id = logdevid.vendor_id;
458
 	isapnp->vendor_id = logdevid.vendor_id;
430
 	isapnp->prod_id = logdevid.prod_id;
459
 	isapnp->prod_id = logdevid.prod_id;
431
 
460
 
439
 	/* Return all cards to Wait for Key state */
468
 	/* Return all cards to Wait for Key state */
440
 	isapnp_wait_for_key ();
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
 	return 1;
477
 	return 1;
449
 }
478
 }

+ 1
- 1
src/include/isapnp.h View File

102
 #define ISAPNP_TAG_END			0x0F
102
 #define ISAPNP_TAG_END			0x0F
103
 /* Large tags */
103
 /* Large tags */
104
 #define ISAPNP_IS_LARGE_TAG(tag)	( ( (tag) & 0x80 ) )
104
 #define ISAPNP_IS_LARGE_TAG(tag)	( ( (tag) & 0x80 ) )
105
-#define ISAPNP_LARGE_TAG_NAME(tag)	( (tag) & 0x7f )
105
+#define ISAPNP_LARGE_TAG_NAME(tag)	(tag)
106
 #define ISAPNP_TAG_MEMRANGE		0x81
106
 #define ISAPNP_TAG_MEMRANGE		0x81
107
 #define ISAPNP_TAG_ANSISTR		0x82
107
 #define ISAPNP_TAG_ANSISTR		0x82
108
 #define ISAPNP_TAG_UNICODESTR		0x83
108
 #define ISAPNP_TAG_UNICODESTR		0x83

Loading…
Cancel
Save