From 0794c13d8ef9422cbd2529f617cbe16a220cfd49 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 12 Mar 2008 21:43:50 +0000 Subject: [PATCH] Minimize diffs with i686_mem.c: - A few whitespace changes I missed in the style(9) changes. - Move M_MEMDESC to mem.c. --- sys/amd64/amd64/amd64_mem.c | 10 ++++------ sys/amd64/amd64/mem.c | 5 +++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/amd64_mem.c b/sys/amd64/amd64/amd64_mem.c index 74407252e178..5874496a9baa 100644 --- a/sys/amd64/amd64/amd64_mem.c +++ b/sys/amd64/amd64/amd64_mem.c @@ -57,7 +57,7 @@ static char *mem_owner_bios = "BIOS"; #define mrvalid(base, len) \ ((!(base & ((1 << 12) - 1))) && /* base is multiple of 4k */ \ ((len) >= (1 << 12)) && /* length is >= 4k */ \ - powerof2((len)) && /* ... and power of two */ \ + powerof2((len)) && /* ... and power of two */ \ !((base) & ((len) - 1))) /* range is not discontiuous */ #define mrcopyflags(curr, new) \ @@ -110,11 +110,6 @@ static int amd64_mtrrtomrt[] = { #define MTRRTOMRTLEN (sizeof(amd64_mtrrtomrt) / sizeof(amd64_mtrrtomrt[0])) -/* - * Used in /dev/mem drivers and elsewhere - */ -MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors"); - static int amd64_mtrr2mrt(int val) { @@ -479,14 +474,17 @@ amd64_mrsetvariable(struct mem_range_softc *sc, struct mem_range_desc *mrd, /* Exact match? */ if ((curr_md->mr_base == mrd->mr_base) && (curr_md->mr_len == mrd->mr_len)) { + /* Whoops, owned by someone. */ if (curr_md->mr_flags & MDF_BUSY) return (EBUSY); + /* Check that we aren't doing something risky */ if (!(mrd->mr_flags & MDF_FORCE) && ((curr_md->mr_flags & MDF_ATTRMASK) == MDF_UNKNOWN)) return (EACCES); + /* Ok, just hijack this entry. */ free_md = curr_md; break; diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c index f3280d0dfc75..00f5a8e1a20b 100644 --- a/sys/amd64/amd64/mem.c +++ b/sys/amd64/amd64/mem.c @@ -67,6 +67,11 @@ __FBSDID("$FreeBSD$"); #include +/* + * Used in /dev/mem drivers and elsewhere + */ +MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors"); + /* ARGSUSED */ int memrw(struct cdev *dev, struct uio *uio, int flags)