FreeBSD/sys/dev/pci/pci.c
/* Perform early EHCI takeover from SMM. */
Perform early EHCI takeover from SMM.
Perform early EHCI takeover from SMM .
static void
ehci_early_takeover(device_t self)
{
	struct resource *res;
	uint32_t cparams;
	uint32_t eec;
	uint8_t eecp;
	uint8_t bios_sem;
	uint8_t offs;
	int rid;
	int i;
	rid = PCIR_BAR(0);
	res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE);
	if (res == NULL)
		return;
	cparams = bus_read_4(res, EHCI_HCCPARAMS);
	for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
	    eecp = EHCI_EECP_NEXT(eec)) {
		eec = pci_read_config(self, eecp, 4);
		if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP) {
			continue;
		}
		bios_sem = pci_read_config(self, eecp +
		    EHCI_LEGSUP_BIOS_SEM, 1);
		if (bios_sem == 0) {
			continue;
		}
		if (bootverbose)
			printf("ehci early: "
			    "SMM active, request owner change\n");
		pci_write_config(self, eecp + EHCI_LEGSUP_OS_SEM, 1, 1);
		for (i = 0; (i < 100) && (bios_sem != 0); i++) {
			DELAY(1000);
			bios_sem = pci_read_config(self, eecp +
			    EHCI_LEGSUP_BIOS_SEM, 1);
		}
		if (bios_sem != 0) {
			if (bootverbose)
				printf("ehci early: "
				    "SMM does not respond\n");
		}
		offs = EHCI_CAPLENGTH(bus_read_4(res, EHCI_CAPLEN_HCIVERSION));
		bus_write_4(res, offs + EHCI_USBINTR, 0);
	}
	bus_release_resource(self, SYS_RES_MEMORY, rid, res);
}
static void ehci_early_takeover ( device_t self ) { struct resource * res ; uint32_t cparams ; uint32_t eec ; uint8_t eecp ; uint8_t bios_sem ; uint8_t offs ; int rid ; int i ; rid = PCIR_BAR ( 0 ) ; res = bus_alloc_resource_any ( self , SYS_RES_MEMORY , & rid , RF_ACTIVE ) ; if ( res == NULL ) return ; cparams = bus_read_4 ( res , EHCI_HCCPARAMS ) ; for ( eecp = EHCI_HCC_EECP ( cparams ) ; eecp != 0 ; eecp = EHCI_EECP_NEXT ( eec ) ) { eec = pci_read_config ( self , eecp , 4 ) ; if ( EHCI_EECP_ID ( eec ) != EHCI_EC_LEGSUP ) { continue ; } bios_sem = pci_read_config ( self , eecp + EHCI_LEGSUP_BIOS_SEM , 1 ) ; if ( bios_sem == 0 ) { continue ; } if ( bootverbose ) printf ( " " " \n " ) ; pci_write_config ( self , eecp + EHCI_LEGSUP_OS_SEM , 1 , 1 ) ; for ( i = 0 ; ( i < 100 ) && ( bios_sem != 0 ) ; i ++ ) { DELAY ( 1000 ) ; bios_sem = pci_read_config ( self , eecp + EHCI_LEGSUP_BIOS_SEM , 1 ) ; } if ( bios_sem != 0 ) { if ( bootverbose ) printf ( " " " \n " ) ; } offs = EHCI_CAPLENGTH ( bus_read_4 ( res , EHCI_CAPLEN_HCIVERSION ) ) ; bus_write_4 ( res , offs + EHCI_USBINTR , 0 ) ; } bus_release_resource ( self , SYS_RES_MEMORY , rid , res ) ; }
Perform early EHCI takeover from SMM.
Perform early EHCI takeover from SMM .
/* Synchronise with the BIOS if it owns the controller. */ /* Disable interrupts */