Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci BUG FIX: calculate address line mask in pccbb_pc...



details:   https://anonhg.NetBSD.org/src/rev/7a170589d554
branches:  trunk
changeset: 503575:7a170589d554
user:      haya <haya%NetBSD.org@localhost>
date:      Fri Feb 09 10:41:50 2001 +0000

description:
BUG FIX: calculate address line mask in pccbb_pcmcia_io_alloc() when
start address is not set.

diffstat:

 sys/dev/pci/pccbb.c |  32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diffs (60 lines):

diff -r d4932f705296 -r 7a170589d554 sys/dev/pci/pccbb.c
--- a/sys/dev/pci/pccbb.c       Fri Feb 09 01:31:52 2001 +0000
+++ b/sys/dev/pci/pccbb.c       Fri Feb 09 10:41:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pccbb.c,v 1.56 2001/01/30 07:23:14 itohy Exp $ */
+/*     $NetBSD: pccbb.c,v 1.57 2001/02/09 10:41:50 haya Exp $  */
 
 /*
  * Copyright (c) 1998, 1999 and 2000
@@ -1927,6 +1927,7 @@
        int flags = 0;
        bus_space_tag_t iot;
        bus_space_handle_t ioh;
+       bus_addr_t mask;
 #if rbus
        rbus_tag_t rb;
 #endif
@@ -1934,6 +1935,32 @@
                align = size;          /* XXX: funny??? */
        }
 
+       if (start != 0) {
+               /* XXX: assume all card decode lower 10 bits by its hardware */
+               mask = 0x3ff;
+       } else {
+               /*
+                * calculate mask:
+                *  1. get the most significant bit of size (call it msb).
+                *  2. compare msb with the value of size.
+                *  3. if size is larger, shift msb left once.
+                *  4. obtain mask value to decrement msb.
+                */
+               bus_size_t size_tmp = size;
+               int shifts = 0;
+
+               mask = 1;
+               while (size_tmp) {
+                       ++shifts;
+                       size_tmp >>= 1;
+               }
+               mask = (1 << shifts);
+               if (mask < size) {
+                       mask <<= 1;
+               }
+               --mask;
+       }
+
        /* 
         * Allocate some arbitrary I/O space.
         */
@@ -1942,8 +1969,7 @@
 
 #if rbus
        rb = ((struct pccbb_softc *)(ph->ph_parent))->sc_rbus_iot;
-       /* XXX: I assume all card decode lower 10 bits by its hardware */
-       if (rbus_space_alloc(rb, start, size, 0x3ff, align, 0, &ioaddr, &ioh)) {
+       if (rbus_space_alloc(rb, start, size, mask, align, 0, &ioaddr, &ioh)) {
                return 1;
        }
 #else



Home | Main Index | Thread Index | Old Index