FreeBSD/sys/i386/i386/i686_mem.c
/*
 * Handle requests to set memory range attributes by manipulating MTRRs.
 */
Handle requests to set memory range attributes by manipulating MTRRs.
Handle requests to set memory range attributes by manipulating MTRRs .
static int
i686_mrset(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg)
{
	struct mem_range_desc *targ;
	int error = 0;
	switch(*arg) {
	case MEMRANGE_SET_UPDATE:
		if (!mrvalid(mrd->mr_base, mrd->mr_len) ||
		    i686_mtrrtype(mrd->mr_flags) == -1)
			return (EINVAL);
#define	FIXTOP	((MTRR_N64K * 0x10000) + (MTRR_N16K * 0x4000) + (MTRR_N4K * 0x1000))
		if ((sc->mr_cap & MR686_FIXMTRR) &&
		    ((mrd->mr_base + mrd->mr_len) <= FIXTOP)) {
			if ((error = i686_mrsetlow(sc, mrd, arg)) != 0)
				return (error);
		} else {
			if ((error = i686_mrsetvariable(sc, mrd, arg)) != 0)
				return (error);
		}
		break;
	case MEMRANGE_SET_REMOVE:
		if ((targ = mem_range_match(sc, mrd)) == NULL)
			return (ENOENT);
		if (targ->mr_flags & MDF_FIXACTIVE)
			return (EPERM);
		if (targ->mr_flags & MDF_BUSY)
			return (EBUSY);
		targ->mr_flags &= ~MDF_ACTIVE;
		targ->mr_owner[0] = 0;
		break;
	default:
		return (EOPNOTSUPP);
	}
	i686_mrstore(sc);
	i686_mrfetch(sc);
	return (0);
}
static int i686_mrset ( struct mem_range_softc * sc , struct mem_range_desc * mrd , int * arg ) { struct mem_range_desc * targ ; int error = 0 ; switch ( * arg ) { case MEMRANGE_SET_UPDATE : if ( ! mrvalid ( mrd -> mr_base , mrd -> mr_len ) || i686_mtrrtype ( mrd -> mr_flags ) == -1 ) return ( EINVAL ) ; #define FIXTOP 	((MTRR_N64K * 0x10000) + (MTRR_N16K * 0x4000) + (MTRR_N4K * 0x1000)) if ( ( sc -> mr_cap & MR686_FIXMTRR ) && ( ( mrd -> mr_base + mrd -> mr_len ) <= FIXTOP ) ) { if ( ( error = i686_mrsetlow ( sc , mrd , arg ) ) != 0 ) return ( error ) ; } else { if ( ( error = i686_mrsetvariable ( sc , mrd , arg ) ) != 0 ) return ( error ) ; } break ; case MEMRANGE_SET_REMOVE : if ( ( targ = mem_range_match ( sc , mrd ) ) == NULL ) return ( ENOENT ) ; if ( targ -> mr_flags & MDF_FIXACTIVE ) return ( EPERM ) ; if ( targ -> mr_flags & MDF_BUSY ) return ( EBUSY ) ; targ -> mr_flags &= ~ MDF_ACTIVE ; targ -> mr_owner [ 0 ] = 0 ; break ; default : return ( EOPNOTSUPP ) ; } i686_mrstore ( sc ) ; i686_mrfetch ( sc ) ; return ( 0 ) ; }
Handle requests to set memory range attributes by manipulating MTRRs.
Handle requests to set memory range attributes by manipulating MTRRs .
/*
		 * Make sure that what's being asked for is even
		 * possible at all.
		 */ /* Are the "low memory" conditions applicable? */ /* It's time to play with variable MTRRs. */ /* Update the hardware. */ /* Refetch to see where we're at. */