Sat Dec 17 19:34:07 2011 UTC ()
Allow defining a bus space with pbs_limit=0, which will have the effect to
create a space which ends with 0xffffffff.
This is needed, because pbs_limit=0xffffffff ends the space with 0xfffffffe.


(phx)
diff -r1.28 -r1.29 src/sys/arch/powerpc/powerpc/bus_space.c

cvs diff -r1.28 -r1.29 src/sys/arch/powerpc/powerpc/bus_space.c (expand / switch to unified diff)

--- src/sys/arch/powerpc/powerpc/bus_space.c 2011/06/30 00:53:00 1.28
+++ src/sys/arch/powerpc/powerpc/bus_space.c 2011/12/17 19:34:07 1.29
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bus_space.c,v 1.28 2011/06/30 00:53:00 matt Exp $ */ 1/* $NetBSD: bus_space.c,v 1.29 2011/12/17 19:34:07 phx Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.28 2011/06/30 00:53:00 matt Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.29 2011/12/17 19:34:07 phx Exp $");
35 35
36#define _POWERPC_BUS_SPACE_PRIVATE 36#define _POWERPC_BUS_SPACE_PRIVATE
37 37
38#include <sys/param.h> 38#include <sys/param.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/kernel.h> 40#include <sys/kernel.h>
41#include <sys/device.h> 41#include <sys/device.h>
42#include <sys/endian.h> 42#include <sys/endian.h>
43#include <sys/extent.h> 43#include <sys/extent.h>
44#include <sys/malloc.h> 44#include <sys/malloc.h>
45#include <sys/bus.h> 45#include <sys/bus.h>
46 46
47#include <uvm/uvm.h> 47#include <uvm/uvm.h>
@@ -516,27 +516,27 @@ memio_mmap(bus_space_tag_t t, bus_addr_t @@ -516,27 +516,27 @@ memio_mmap(bus_space_tag_t t, bus_addr_t
516 return ret; 516 return ret;
517} 517}
518 518
519int 519int
520memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags, 520memio_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
521 bus_space_handle_t *bshp) 521 bus_space_handle_t *bshp)
522{ 522{
523 int error; 523 int error;
524 paddr_t pa; 524 paddr_t pa;
525 525
526 size = _BUS_SPACE_STRIDE(t, size); 526 size = _BUS_SPACE_STRIDE(t, size);
527 bpa = _BUS_SPACE_STRIDE(t, bpa); 527 bpa = _BUS_SPACE_STRIDE(t, bpa);
528 528
529 if (bpa + size > t->pbs_limit) { 529 if (t->pbs_limit != 0 && bpa + size > t->pbs_limit) {
530#ifdef DEBUG 530#ifdef DEBUG
531 printf("bus_space_map(%p[%x:%x], %#x, %#x) failed: EINVAL\n", 531 printf("bus_space_map(%p[%x:%x], %#x, %#x) failed: EINVAL\n",
532 t, t->pbs_base, t->pbs_limit, bpa, size); 532 t, t->pbs_base, t->pbs_limit, bpa, size);
533#endif 533#endif
534 return (EINVAL); 534 return (EINVAL);
535 } 535 }
536 536
537 /* 537 /*
538 * Can't map I/O space as linear. 538 * Can't map I/O space as linear.
539 */ 539 */
540 if ((flags & BUS_SPACE_MAP_LINEAR) && 540 if ((flags & BUS_SPACE_MAP_LINEAR) &&
541 (t->pbs_flags & _BUS_SPACE_IO_TYPE)) { 541 (t->pbs_flags & _BUS_SPACE_IO_TYPE)) {
542 return (EOPNOTSUPP); 542 return (EOPNOTSUPP);
@@ -692,27 +692,27 @@ memio_alloc(bus_space_tag_t t, bus_addr_ @@ -692,27 +692,27 @@ memio_alloc(bus_space_tag_t t, bus_addr_
692 bus_size_t size, bus_size_t alignment, bus_size_t boundary, 692 bus_size_t size, bus_size_t alignment, bus_size_t boundary,
693 int flags, bus_addr_t *bpap, bus_space_handle_t *bshp) 693 int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
694{ 694{
695 u_long bpa; 695 u_long bpa;
696 paddr_t pa; 696 paddr_t pa;
697 int error; 697 int error;
698 698
699 size = _BUS_SPACE_STRIDE(t, size); 699 size = _BUS_SPACE_STRIDE(t, size);
700 rstart = _BUS_SPACE_STRIDE(t, rstart); 700 rstart = _BUS_SPACE_STRIDE(t, rstart);
701 701
702 if (t->pbs_extent == NULL) 702 if (t->pbs_extent == NULL)
703 return ENOMEM; 703 return ENOMEM;
704 704
705 if (rstart + size > t->pbs_limit) { 705 if (t->pbs_limit != 0 && rstart + size > t->pbs_limit) {
706#ifdef DEBUG 706#ifdef DEBUG
707 printf("%s(%p[%x:%x], %#x, %#x) failed: EINVAL\n", 707 printf("%s(%p[%x:%x], %#x, %#x) failed: EINVAL\n",
708 __func__, t, t->pbs_base, t->pbs_limit, rstart, size); 708 __func__, t, t->pbs_base, t->pbs_limit, rstart, size);
709#endif 709#endif
710 return (EINVAL); 710 return (EINVAL);
711 } 711 }
712 712
713 /* 713 /*
714 * Can't map I/O space as linear. 714 * Can't map I/O space as linear.
715 */ 715 */
716 if ((flags & BUS_SPACE_MAP_LINEAR) && 716 if ((flags & BUS_SPACE_MAP_LINEAR) &&
717 (t->pbs_flags & _BUS_SPACE_IO_TYPE)) 717 (t->pbs_flags & _BUS_SPACE_IO_TYPE))
718 return (EOPNOTSUPP); 718 return (EOPNOTSUPP);