Date: Sat, 29 Jan 2000 11:06:15 -0700 From: Warner Losh <imp@village.org> To: YAMAMOTO Shigeru <shigeru@iij.ad.jp> Cc: dfr@nlsystems.com, freebsd-hackers@FreeBSD.ORG Subject: Re: how to allocate an alined address for a device? Message-ID: <200001291806.LAA07899@harmony.village.org> In-Reply-To: Your message of "Sat, 29 Jan 2000 22:24:54 %2B0900." <20000129222454T.shigeru@iij.ad.jp> References: <20000129222454T.shigeru@iij.ad.jp> <Pine.BSF.4.10.10001291105190.25770-100000@salmon.nlsystems.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <20000129222454T.shigeru@iij.ad.jp> YAMAMOTO Shigeru writes:
: + alignment_size = (1u << ((flags & RF_ALIGNMENT_MASK) >> RF_ALIGNMENT_SHIFT));
alignment_size = (1u << (RF_ALIGNMENT(flags)));
: + aligned_rstart = (rstart & (~alignment_size + 1u));
: + if ((rstart & (~(~alignment_size + 1u))) != 0) {
: + aligned_rstart += alignment_size;
: + }
: + rstart = aligned_rstart;
: + }
: + rend = min(s->r_end, max(max(start + count, end), rstart + count));
: #ifdef RMAN_DEBUG
: printf("truncated region: [%#lx, %#lx]; size %#lx (requested %#lx)\n",
: rstart, rend, (rend - rstart + 1), count);
: @@ -608,4 +620,19 @@
: rv = int_rman_release_resource(rm, r);
: simple_unlock(rm->rm_slock);
: return (rv);
: +}
I believe that this looks good.
: +u_int32_t
: +rman_make_alignment_flags(int size) {
: + int i;
: +
: + for (i = 0; i < 32 && size > 0x01; i ++) {
: + size = (size >> 1);
: + }
: +
: + if (i > 31) {
: + i = 0;
: + }
: +
: + return(RF_ALIGNMENT_LOG2(i));
: }
This could more simply be stated as RF_ALIGNMENT_LOG2(ffs(size)). I
don't think that it is really needed.
: +#define RF_PCCARD_ATTR 0x10000 /* PCCARD attribute memory */
Please leave this in. It doesn't have anything to do with the changes
you are making. Actually, I should remove it in an independent
commit. I'll do it a different way for the WaveGear Avaitor driver
I'm porting from NetBSD. Also for the XE driver.
: +#define RF_ALIGNMENT_SHIFT 10 /* alignment size bit starts bit 10 */
: +#define RF_ALIGNMENT_MASK (0x003F << RF_ALIGNMENT_SHIFT) /* resource address alignemnt size bit mask */
: +#define RF_ALIGNMENT_LOG2(x) ((x) << RF_ALIGNMENT_SHIFT)
You might want to add:
#define RF_ALIGNMENT(x) (((x) & RF_ALIGNMENT_MASK) >> RF_ALIGNMENT_SHIFT)
Warner
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001291806.LAA07899>
