FreeBSD/sys/dev/cfi/cfi_core.c
/*
 * Write the User/OEM 64-bit segment of the PR.
 * XXX should allow writing individual words/bytes
 */
Write the User/OEM 64-bit segment of the PR.
XXX should allow writing individual words/bytes
Write the User / OEM 64 - bit segment of the PR . XXX should allow writing individual words / bytes
int
cfi_intel_set_oem_pr(struct cfi_softc *sc, uint64_t id)
{
#ifdef CFI_ARMEDANDDANGEROUS
	register_t intr;
	int i, error;
	sbintime_t start;
#endif
	if (sc->sc_cmdset != CFI_VEND_INTEL_ECS)
		return EOPNOTSUPP;
	KASSERT(sc->sc_width == 2, ("sc_width %d", sc->sc_width));
#ifdef CFI_ARMEDANDDANGEROUS
	for (i = 7; i >= 4; i--, id >>= 16) {
		intr = intr_disable();
		start = sbinuptime();
		cfi_write(sc, 0, CFI_INTEL_PP_SETUP);
		cfi_put16(sc, CFI_INTEL_PR(i), id&0xffff);
		intr_restore(intr);
		error = cfi_wait_ready(sc, CFI_BCS_READ_STATUS, start,
		    CFI_TIMEOUT_WRITE);
		if (error)
			break;
	}
	cfi_write(sc, 0, CFI_BCS_READ_ARRAY);
	return error;
#else
	device_printf(sc->sc_dev, "%s: OEM PR not set, "
	    "CFI_ARMEDANDDANGEROUS not configured\n", __func__);
	return ENXIO;
#endif
}
int cfi_intel_set_oem_pr ( struct cfi_softc * sc , uint64_t id ) { #ifdef CFI_ARMEDANDDANGEROUS register_t intr ; int i , error ; sbintime_t start ; #endif if ( sc -> sc_cmdset != CFI_VEND_INTEL_ECS ) return EOPNOTSUPP ; KASSERT ( sc -> sc_width == 2 , ( " " , sc -> sc_width ) ) ; #ifdef CFI_ARMEDANDDANGEROUS for ( i = 7 ; i >= 4 ; i -- , id >>= 16 ) { intr = intr_disable ( ) ; start = sbinuptime ( ) ; cfi_write ( sc , 0 , CFI_INTEL_PP_SETUP ) ; cfi_put16 ( sc , CFI_INTEL_PR ( i ) , id & 0xffff ) ; intr_restore ( intr ) ; error = cfi_wait_ready ( sc , CFI_BCS_READ_STATUS , start , CFI_TIMEOUT_WRITE ) ; if ( error ) break ; } cfi_write ( sc , 0 , CFI_BCS_READ_ARRAY ) ; return error ; #else device_printf ( sc -> sc_dev , " " " \n " , __func__ ) ; return ENXIO ; #endif }
Write the User/OEM 64-bit segment of the PR.
Write the User / OEM 64 - bit segment of the PR .