Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Nov 2000 22:54:44 +0100
From:      Daniel Rock <D.Rock@t-online.de>
To:        Warner Losh <imp@village.org>
Cc:        current@FreeBSD.ORG, msmith@FreeBSD.ORG
Subject:   Re: ISA PnP resource allocation
Message-ID:  <3A11B4A4.6503FB73@t-online.de>
References:  <3A0B074D.4413FDB1@t-online.de> <200011122030.NAA00596@harmony.village.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Dies ist eine mehrteilige Nachricht im MIME-Format.
--------------EDAA6796BB99784501A2885F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Warner Losh schrieb:
> 
> In message <3A0B074D.4413FDB1@t-online.de> Daniel Rock writes:
> : I already filed a PR for this problem but my first solution was a real
> : hack (kern/21461).
> :
> : [another solution would be to introduce another flag for
> : rman_reserve_resource() not to search for alternate regions.
> 
> Would the alignment stuff I added for cardbus help any?

I think, my patch basically uses now the same alignment options from
the resource manager like cardbus does now.

I have cleaned up the code a little bit: Now the code uses the
rman_get_XXX() macros and also checks if the region returned is below the
end mark.

Daniel
--------------EDAA6796BB99784501A2885F
Content-Type: text/plain; charset=us-ascii;
 name="sys.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="sys.diff"

Index: sys/isa/isa_common.c
===================================================================
RCS file: /data/cvs/src/sys/isa/isa_common.c,v
retrieving revision 1.18
diff -u -r1.18 isa_common.c
--- sys/isa/isa_common.c	2000/07/12 00:42:08	1.18
+++ sys/isa/isa_common.c	2000/11/14 21:27:34
@@ -133,31 +133,30 @@
 	result->ic_nmem = config->ic_nmem;
 	for (i = 0; i < config->ic_nmem; i++) {
 		u_int32_t start, end, size, align;
-		for (start = config->ic_mem[i].ir_start,
-			     end = config->ic_mem[i].ir_end,
-			     size = config->ic_mem[i].ir_size,
-			     align = config->ic_mem[i].ir_align;
-		     start + size - 1 <= end;
-		     start += align) {
-			bus_set_resource(child, SYS_RES_MEMORY, i,
-					 start, size);
-			res[i] = bus_alloc_resource(child,
-						    SYS_RES_MEMORY, &i,
-						    0, ~0, 1, 0 /* !RF_ACTIVE */);
-			if (res[i]) {
-				result->ic_mem[i].ir_start = start;
-				result->ic_mem[i].ir_end = start + size - 1;
-				result->ic_mem[i].ir_size = size;
-				result->ic_mem[i].ir_align = align;
+
+		start = config->ic_mem[i].ir_start;
+		end = config->ic_mem[i].ir_end;
+		size = config->ic_mem[i].ir_size;
+		align = config->ic_mem[i].ir_align;
+		if(!align)
+			align = 1;
+		bus_set_resource(child, SYS_RES_MEMORY, i,
+				 start, size);
+		res[i] = bus_alloc_resource(child,
+					    SYS_RES_MEMORY, &i,
+					    0, ~0, 1,
+					    rman_make_alignment_flags(align));
+		if (res[i]) {
+			if(rman_get_start(res[i]) > end) {
+				success = 0;
 				break;
 			}
+			result->ic_mem[i].ir_start = rman_get_start(res[i]);
+			result->ic_mem[i].ir_end = rman_get_end(res[i]);
+			result->ic_mem[i].ir_size = rman_get_size(res[i]);
+			result->ic_mem[i].ir_align = align;
 		}
-
-		/*
-		 * If we didn't find a place for memory range i, then 
-		 * give up now.
-		 */
-		if (!res[i]) {
+		else {
 			success = 0;
 			break;
 		}
@@ -197,31 +196,31 @@
 	result->ic_nport = config->ic_nport;
 	for (i = 0; i < config->ic_nport; i++) {
 		u_int32_t start, end, size, align;
-		for (start = config->ic_port[i].ir_start,
-			     end = config->ic_port[i].ir_end,
-			     size = config->ic_port[i].ir_size,
-			     align = config->ic_port[i].ir_align;
-		     start + size - 1 <= end;
-		     start += align) {
-			bus_set_resource(child, SYS_RES_IOPORT, i,
-					 start, size);
-			res[i] = bus_alloc_resource(child,
-						    SYS_RES_IOPORT, &i,
-						    0, ~0, 1, 0 /* !RF_ACTIVE */);
-			if (res[i]) {
-				result->ic_port[i].ir_start = start;
-				result->ic_port[i].ir_end = start + size - 1;
-				result->ic_port[i].ir_size = size;
-				result->ic_port[i].ir_align = align;
+
+		start = config->ic_port[i].ir_start;
+		end = config->ic_port[i].ir_end;
+		size = config->ic_port[i].ir_size;
+		align = config->ic_port[i].ir_align;
+		if(!align)
+			align = 1;
+
+		bus_set_resource(child, SYS_RES_IOPORT, i,
+				 start, size);
+		res[i] = bus_alloc_resource(child,
+					    SYS_RES_IOPORT, &i,
+					    0, ~0, 1,
+					    rman_make_alignment_flags(align));
+		if (res[i]) {
+			if(rman_get_start(res[i]) > end) {
+				success = 0;
 				break;
 			}
+			result->ic_port[i].ir_start = rman_get_start(res[i]);
+			result->ic_port[i].ir_end = rman_get_end(res[i]);
+			result->ic_port[i].ir_size = rman_get_size(res[i]);
+			result->ic_port[i].ir_align = align;
 		}
-
-		/*
-		 * If we didn't find a place for port range i, then 
-		 * give up now.
-		 */
-		if (!res[i]) {
+		else {
 			success = 0;
 			break;
 		}

--------------EDAA6796BB99784501A2885F--



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A11B4A4.6503FB73>