FreeBSD/sys/dev/cardbus/cardbus_cis.c
/*
 * Read CIS bytes out of the config space.  We have to read it 4 bytes at a
 * time and do the usual mask and shift to return the bytes.  The standard
 * defines the byte order to be little endian.  pci_read_config converts it to
 * host byte order.  This is why we have no endian conversion functions: the
 * shifts wind up being endian neutral.  This is also why we avoid the obvious
 * memcpy optimization.
 */
Read CIS bytes out of the config space.  We have to read it 4 bytes at a
time and do the usual mask and shift to return the bytes.  The standard
defines the byte order to be little endian.  pci_read_config converts it to
host byte order.  This is why we have no endian conversion functions: the
shifts wind up being endian neutral.  This is also why we avoid the obvious
memcpy optimization.
Read CIS bytes out of the config space . We have to read it 4 bytes at a time and do the usual mask and shift to return the bytes . The standard defines the byte order to be little endian . pci_read_config converts it to host byte order . This is why we have no endian conversion functions : the shifts wind up being endian neutral . This is also why we avoid the obvious memcpy optimization .
static int
cardbus_read_tuple_conf(device_t cbdev, device_t child, uint32_t start,
    uint32_t *off, int *tupleid, int *len, uint8_t *tupledata)
{
	int i, j;
	uint32_t e;
	uint32_t loc;
	loc = start + *off;
	e = pci_read_config(child, loc & ~0x3, 4);
	e >>= 8 * (loc & 0x3);
	*len = 0;
	for (i = loc, j = -2; j < *len; j++, i++) {
		if ((i & 0x3) == 0)
			e = pci_read_config(child, i, 4);
		if (j == -2)
			*tupleid = 0xff & e;
		else if (j == -1)
			*len = 0xff & e;
		else
			tupledata[j] = 0xff & e;
		e >>= 8;
	}
	*off += *len + 2;
	return (0);
}
static int cardbus_read_tuple_conf ( device_t cbdev , device_t child , uint32_t start , uint32_t * off , int * tupleid , int * len , uint8_t * tupledata ) { int i , j ; uint32_t e ; uint32_t loc ; loc = start + * off ; e = pci_read_config ( child , loc & ~ 0x3 , 4 ) ; e >>= 8 * ( loc & 0x3 ) ; * len = 0 ; for ( i = loc , j = -2 ; j < * len ; j ++ , i ++ ) { if ( ( i & 0x3 ) == 0 ) e = pci_read_config ( child , i , 4 ) ; if ( j == -2 ) * tupleid = 0xff & e ; else if ( j == -1 ) * len = 0xff & e ; else tupledata [ j ] = 0xff & e ; e >>= 8 ; } * off += * len + 2 ; return ( 0 ) ; }
Read CIS bytes out of the config space.
Read CIS bytes out of the config space .