FreeBSD/contrib/pnpinfo/pnpinfo.c
/*
 * Dump all the information about configurations.
 */
Dump all the information about configurations.
Dump all the information about configurations .
void
dump_resdata(u_char *data, int csn)
{
    int i, large_len;
    u_char tag, *resinfo;
    DDB(printf("\nCard assigned CSN #%d\n", csn));
    printf("Vendor ID %c%c%c%02x%02x (0x%08x), Serial Number 0x%08x\n",
	    ((data[0] & 0x7c) >> 2) + 64,
	    (((data[0] & 0x03) << 3) | ((data[1] & 0xe0) >> 5)) + 64,
	    (data[1] & 0x1f) + 64, data[2], data[3],
	    *(int *)&(data[0]),
	    *(int *)&(data[4]));
    pnp_write(PNP_SET_CSN, csn); 
    outb(_PNP_ADDRESS, PNP_STATUS);
    for (i = 0; i < 1024; i++) {
	if (!get_resource_info(&tag, 1))
	    break;
	if (PNP_RES_TYPE(tag) == 0) {
	    resinfo = malloc(PNP_SRES_LEN(tag));
	    if (!get_resource_info(resinfo, PNP_SRES_LEN(tag)))
		break;
	    if (handle_small_res(resinfo, PNP_SRES_NUM(tag), PNP_SRES_LEN(tag)) == 1)
		break;
	    free(resinfo);
	} else {
	    u_char buf[2];
	    if (!get_resource_info((char *)buf, 2))
		break;
	    large_len = (buf[1] << 8) + buf[0];
	    resinfo = malloc(large_len);
	    if (!get_resource_info(resinfo, large_len))
		break;
	    handle_large_res(resinfo, PNP_LRES_NUM(tag), large_len);
	    free(resinfo);
	}
    }
    printf("Successfully got %d resources, %d logical fdevs\n", i,
	    logdevs);
    printf("-- card select # 0x%04x\n", pnp_read(PNP_SET_CSN));
    printf("\nCSN %c%c%c%02x%02x (0x%08x), Serial Number 0x%08x\n",
	    ((data[0] & 0x7c) >> 2) + 64,
	    (((data[0] & 0x03) << 3) | ((data[1] & 0xe0) >> 5)) + 64,
	    (data[1] & 0x1f) + 64, data[2], data[3],
	    *(int *)&(data[0]),
	    *(int *)&(data[4]));
    for (i=0; i<logdevs; i++) {
	int j;
	pnp_write(PNP_SET_LDN, i);
	printf("\nLogical device #%d\n", pnp_read(PNP_SET_LDN) );
	printf("IO: ");
	for (j=0; j<8; j++)
	    printf(" 0x%02x%02x", pnp_read(PNP_IO_BASE_HIGH(j)),
		pnp_read(PNP_IO_BASE_LOW(j)));
	printf("\nIRQ %d %d\n",
	    pnp_read(PNP_IRQ_LEVEL(0)), pnp_read(PNP_IRQ_LEVEL(1)) );
	printf("DMA %d %d\n",
	    pnp_read(PNP_DMA_CHANNEL(0)), pnp_read(PNP_DMA_CHANNEL(1)) );
	printf("IO range check 0x%02x activate 0x%02x\n",
	    pnp_read(PNP_IO_RANGE_CHECK), pnp_read(PNP_ACTIVATE) );
    }
}
void dump_resdata ( u_char * data , int csn ) { int i , large_len ; u_char tag , * resinfo ; DDB ( printf ( " \n \n " , csn ) ) ; printf ( " \n " , ( ( data [ 0 ] & 0x7c ) >> 2 ) + 64 , ( ( ( data [ 0 ] & 0x03 ) << 3 ) | ( ( data [ 1 ] & 0xe0 ) >> 5 ) ) + 64 , ( data [ 1 ] & 0x1f ) + 64 , data [ 2 ] , data [ 3 ] , * ( int * ) & ( data [ 0 ] ) , * ( int * ) & ( data [ 4 ] ) ) ; pnp_write ( PNP_SET_CSN , csn ) ; outb ( _PNP_ADDRESS , PNP_STATUS ) ; for ( i = 0 ; i < 1024 ; i ++ ) { if ( ! get_resource_info ( & tag , 1 ) ) break ; if ( PNP_RES_TYPE ( tag ) == 0 ) { resinfo = malloc ( PNP_SRES_LEN ( tag ) ) ; if ( ! get_resource_info ( resinfo , PNP_SRES_LEN ( tag ) ) ) break ; if ( handle_small_res ( resinfo , PNP_SRES_NUM ( tag ) , PNP_SRES_LEN ( tag ) ) == 1 ) break ; free ( resinfo ) ; } else { u_char buf [ 2 ] ; if ( ! get_resource_info ( ( char * ) buf , 2 ) ) break ; large_len = ( buf [ 1 ] << 8 ) + buf [ 0 ] ; resinfo = malloc ( large_len ) ; if ( ! get_resource_info ( resinfo , large_len ) ) break ; handle_large_res ( resinfo , PNP_LRES_NUM ( tag ) , large_len ) ; free ( resinfo ) ; } } printf ( " \n " , i , logdevs ) ; printf ( " \n " , pnp_read ( PNP_SET_CSN ) ) ; printf ( " \n \n " , ( ( data [ 0 ] & 0x7c ) >> 2 ) + 64 , ( ( ( data [ 0 ] & 0x03 ) << 3 ) | ( ( data [ 1 ] & 0xe0 ) >> 5 ) ) + 64 , ( data [ 1 ] & 0x1f ) + 64 , data [ 2 ] , data [ 3 ] , * ( int * ) & ( data [ 0 ] ) , * ( int * ) & ( data [ 4 ] ) ) ; for ( i = 0 ; i < logdevs ; i ++ ) { int j ; pnp_write ( PNP_SET_LDN , i ) ; printf ( " \n \n " , pnp_read ( PNP_SET_LDN ) ) ; printf ( " " ) ; for ( j = 0 ; j < 8 ; j ++ ) printf ( " " , pnp_read ( PNP_IO_BASE_HIGH ( j ) ) , pnp_read ( PNP_IO_BASE_LOW ( j ) ) ) ; printf ( " \n \n " , pnp_read ( PNP_IRQ_LEVEL ( 0 ) ) , pnp_read ( PNP_IRQ_LEVEL ( 1 ) ) ) ; printf ( " \n " , pnp_read ( PNP_DMA_CHANNEL ( 0 ) ) , pnp_read ( PNP_DMA_CHANNEL ( 1 ) ) ) ; printf ( " \n " , pnp_read ( PNP_IO_RANGE_CHECK ) , pnp_read ( PNP_ACTIVATE ) ) ; } }
Dump all the information about configurations.
Dump all the information about configurations .
/* Move this out of this function XXX */ /* Allows up to 1kb of Resource Info,  Should be plenty */ /* Handle small resouce data types */ /* Handle large resouce data types */