From owner-freebsd-hackers Thu Jan 27 20:43:20 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mgo.iij.ad.jp (mgo.iij.ad.jp [202.232.15.6]) by hub.freebsd.org (Postfix) with ESMTP id D482915968 for ; Thu, 27 Jan 2000 20:43:15 -0800 (PST) (envelope-from shigeru@iij.ad.jp) Received: from ns.iij.ad.jp (root@ns.iij.ad.jp [192.168.2.8]) by mgo.iij.ad.jp (8.8.8/MGO1.0) with ESMTP id NAA15961; Fri, 28 Jan 2000 13:43:13 +0900 (JST) Received: from fs.iij.ad.jp (root@fs.iij.ad.jp [192.168.2.9]) by ns.iij.ad.jp (8.8.5/3.5Wpl7) with ESMTP id NAA02654; Fri, 28 Jan 2000 13:43:12 +0900 (JST) Received: from mercury.iij.ad.jp (mercury.iij.ad.jp [192.168.4.89]) by fs.iij.ad.jp (8.8.5/3.5Wpl7) with ESMTP id NAA26599; Fri, 28 Jan 2000 13:43:12 +0900 (JST) Received: from localhost (localhost [127.0.0.1]) by mercury.iij.ad.jp (8.9.3/3.5W) with ESMTP id NAA10124; Fri, 28 Jan 2000 13:43:11 +0900 (JST) To: imp@village.org Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: how to allocate an alined address for a device? In-Reply-To: Your message of "Tue, 18 Jan 2000 16:15:36 -0700" <200001182315.QAA20891@harmony.village.org> References: <200001182315.QAA20891@harmony.village.org> X-Mailer: Mew version 1.93b38 on XEmacs 21.2 (Shinjuku) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_Jan_28_13:42:12_2000_229)--" Content-Transfer-Encoding: 7bit Message-Id: <20000128134310D.shigeru@iij.ad.jp> Date: Fri, 28 Jan 2000 13:43:10 +0900 From: YAMAMOTO Shigeru X-Dispatcher: imput version 991025(IM133) Lines: 106 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG ----Next_Part(Fri_Jan_28_13:42:12_2000_229)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit >>>>> "Warner" == Warner Losh writes: Warner> In a cardbus system, one would force the alignment in the card bus Warner> bridge. It would reject those things that aren't aligned in a sane Warner> manner for cardbus. It would try again to get a different range, if Warner> possible, or would reject the attempt. I think it is no good to try again to get a different range. Because, a different system has a different free address range and a device dirver can not know where is a free address range. So I change rman_reserve_resource() in @src/sys/kern/subr_rman.c for we can allocate an aligned address. My idea is using high bits of flags. RF_ALIGN_XXX in aflags specifies an alignment request and an alignment size. Bad point of my idea is that we need to use a different bit for each an alignment size. This is a patch for @src/sys/kern/subr_rman.c (rev. 1.10) and @src/sys/sys/rman.h (rev. 1.5) Is my idea good or not? Thanks, ------- YAMAMOTO Shigeru Internet Initiative Japan Inc. Network Engineering Div. ----Next_Part(Fri_Jan_28_13:42:12_2000_229)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=align.diff --- kern/subr_rman.c.org Tue Nov 16 08:28:57 1999 +++ kern/subr_rman.c Thu Jan 27 02:33:03 2000 @@ -227,7 +227,17 @@ continue; } rstart = max(s->r_start, start); - rend = min(s->r_end, max(start + count, end)); + if (flags & RF_ALIGN_MASK) { + /* need to align an address */ + u_long aligned_rstart; + + aligned_rstart = (rstart & (~((u_long)(flags & RF_ALIGN_MASK)) + 1u)); + if ((rstart & (~(~((u_long)(flags & RF_ALIGN_MASK)) + 1u))) != 0) { + aligned_rstart += ((u_long)(flags & RF_ALIGN_MASK)); + } + 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); --- sys/rman.h.org Mon Jan 10 08:48:52 2000 +++ sys/rman.h Thu Jan 27 02:36:51 2000 @@ -57,14 +57,33 @@ struct rman *r_rm; /* resource manager from whence this came */ }; -#define RF_ALLOCATED 0x0001 /* resource has been reserved */ -#define RF_ACTIVE 0x0002 /* resource allocation has been activated */ -#define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */ -#define RF_TIMESHARE 0x0008 /* resource permits time-division sharing */ -#define RF_WANTED 0x0010 /* somebody is waiting for this resource */ -#define RF_FIRSTSHARE 0x0020 /* first in sharing list */ +#define RF_ALLOCATED 0x00000001 /* resource has been reserved */ +#define RF_ACTIVE 0x00000002 /* resource allocation has been activated */ +#define RF_SHAREABLE 0x00000004 /* resource permits contemporaneous sharing */ +#define RF_TIMESHARE 0x00000008 /* resource permits time-division sharing */ +#define RF_WANTED 0x00000010 /* somebody is waiting for this resource */ +#define RF_FIRSTSHARE 0x00000020 /* first in sharing list */ -#define RF_PCCARD_ATTR 0x10000 /* PCCARD attribute memory */ +#define RF_ALIGN_4K 0x00001000 /* require 4K byte address alignment */ +#define RF_ALIGN_8K 0x00002000 /* require 8K byte address alignment */ +#define RF_ALIGN_16K 0x00004000 /* require 16K byte address alignment */ +#define RF_ALIGN_32K 0x00008000 /* require 32K byte address alignment */ +#define RF_ALIGN_64K 0x00010000 /* require 64K byte address alignment */ +#define RF_ALIGN_128K 0x00020000 /* require 128K byte address alignment */ +#define RF_ALIGN_256K 0x00040000 /* require 256K byte address alignment */ +#define RF_ALIGN_512K 0x00080000 /* require 512K byte address alignment */ +#define RF_ALIGN_1M 0x00100000 /* require 1M byte address alignment */ +#define RF_ALIGN_2M 0x00200000 /* require 2M byte address alignment */ +#define RF_ALIGN_4M 0x00400000 /* require 4M byte address alignment */ +#define RF_ALIGN_8M 0x00800000 /* require 8M byte address alignment */ +#if 0 /* XXX Is there a device which requires more large address alignment? */ +#define RF_ALIGN_16M 0x01000000 /* require 16M byte address alignment */ +#define RF_ALIGN_32M 0x02000000 /* require 32M byte address alignment */ +#define RF_ALIGN_64M 0x04000000 /* require 64M byte address alignment */ +#define RF_ALIGN_128M 0x08000000 /* require 128M byte address alignment */ +#endif +#define RF_ALIGN_MASK 0x00FFF000 /* mask for RF_ALIGN_XX */ +#define RF_PCCARD_ATTR RF_ALIGN_4K /* PCCARD attribute memory */ enum rman_type { RMAN_UNINIT = 0, RMAN_GAUGE, RMAN_ARRAY }; ----Next_Part(Fri_Jan_28_13:42:12_2000_229)---- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message