FreeBSD/sys/dev/pci/pci.c
/* extract header type specific config data */
extract header type specific config data
extract header type specific config data
static void
pci_hdrtypedata(device_t pcib, int b, int s, int f, pcicfgregs *cfg)
{
#define	REG(n, w)	PCIB_READ_CONFIG(pcib, b, s, f, n, w)
	switch (cfg->hdrtype & PCIM_HDRTYPE) {
	case PCIM_HDRTYPE_NORMAL:
		cfg->subvendor      = REG(PCIR_SUBVEND_0, 2);
		cfg->subdevice      = REG(PCIR_SUBDEV_0, 2);
		cfg->mingnt         = REG(PCIR_MINGNT, 1);
		cfg->maxlat         = REG(PCIR_MAXLAT, 1);
		cfg->nummaps	    = PCI_MAXMAPS_0;
		break;
	case PCIM_HDRTYPE_BRIDGE:
		cfg->bridge.br_seclat = REG(PCIR_SECLAT_1, 1);
		cfg->bridge.br_subbus = REG(PCIR_SUBBUS_1, 1);
		cfg->bridge.br_secbus = REG(PCIR_SECBUS_1, 1);
		cfg->bridge.br_pribus = REG(PCIR_PRIBUS_1, 1);
		cfg->bridge.br_control = REG(PCIR_BRIDGECTL_1, 2);
		cfg->nummaps	    = PCI_MAXMAPS_1;
		break;
	case PCIM_HDRTYPE_CARDBUS:
		cfg->bridge.br_seclat = REG(PCIR_SECLAT_2, 1);
		cfg->bridge.br_subbus = REG(PCIR_SUBBUS_2, 1);
		cfg->bridge.br_secbus = REG(PCIR_SECBUS_2, 1);
		cfg->bridge.br_pribus = REG(PCIR_PRIBUS_2, 1);
		cfg->bridge.br_control = REG(PCIR_BRIDGECTL_2, 2);
		cfg->subvendor      = REG(PCIR_SUBVEND_2, 2);
		cfg->subdevice      = REG(PCIR_SUBDEV_2, 2);
		cfg->nummaps	    = PCI_MAXMAPS_2;
		break;
	}
#undef REG
}
static void pci_hdrtypedata ( device_t pcib , int b , int s , int f , pcicfgregs * cfg ) { #define REG ( n , w ) 	PCIB_READ_CONFIG(pcib, b, s, f, n, w) switch ( cfg -> hdrtype & PCIM_HDRTYPE ) { case PCIM_HDRTYPE_NORMAL : cfg -> subvendor = REG ( PCIR_SUBVEND_0 , 2 ) ; cfg -> subdevice = REG ( PCIR_SUBDEV_0 , 2 ) ; cfg -> mingnt = REG ( PCIR_MINGNT , 1 ) ; cfg -> maxlat = REG ( PCIR_MAXLAT , 1 ) ; cfg -> nummaps = PCI_MAXMAPS_0 ; break ; case PCIM_HDRTYPE_BRIDGE : cfg -> bridge . br_seclat = REG ( PCIR_SECLAT_1 , 1 ) ; cfg -> bridge . br_subbus = REG ( PCIR_SUBBUS_1 , 1 ) ; cfg -> bridge . br_secbus = REG ( PCIR_SECBUS_1 , 1 ) ; cfg -> bridge . br_pribus = REG ( PCIR_PRIBUS_1 , 1 ) ; cfg -> bridge . br_control = REG ( PCIR_BRIDGECTL_1 , 2 ) ; cfg -> nummaps = PCI_MAXMAPS_1 ; break ; case PCIM_HDRTYPE_CARDBUS : cfg -> bridge . br_seclat = REG ( PCIR_SECLAT_2 , 1 ) ; cfg -> bridge . br_subbus = REG ( PCIR_SUBBUS_2 , 1 ) ; cfg -> bridge . br_secbus = REG ( PCIR_SECBUS_2 , 1 ) ; cfg -> bridge . br_pribus = REG ( PCIR_PRIBUS_2 , 1 ) ; cfg -> bridge . br_control = REG ( PCIR_BRIDGECTL_2 , 2 ) ; cfg -> subvendor = REG ( PCIR_SUBVEND_2 , 2 ) ; cfg -> subdevice = REG ( PCIR_SUBDEV_2 , 2 ) ; cfg -> nummaps = PCI_MAXMAPS_2 ; break ; } #undef  REG }
extract header type specific config data
extract header type specific config data