Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jan 2001 18:02:50 -0800 (PST)
From:      Richard Hodges <rh@matriplex.com>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   NEWBUS: multiple calls needed?
Message-ID:  <Pine.BSF.4.10.10101261750060.31475-100000@mail.matriplex.com>

next in thread | raw e-mail | index | archive | help
Hi, all!

I am writing a device driver for a device that has three separate
memory areas (plus a 256-byte IO block).  At first glance, it
would seem that the correct thing would be something like:

  for(x = 0; x < 3; x++) {
    device->mem[x] = bus_alloc_resource(dev, SYS_RES_MEMORY,
      &device->rid_mem[x], 0, ~0, 1, RF_ACTIVE);
    if(device->mem[x] == NULL)
      FAIL;
    device->bustag[x] = rman_get_bustag(device->mem[x]);
    device->bushandle[x] = rman_get_bushandle(device->mem[x]);
    device->virt_addr[x] = rman_get_virtual(device->mem[x]);
  }

The memory areas "appear" to be fixed relative to each other:
   mem1 == base + 0x000000  (size==0x200000)
   mem2 == base + 0x201000  (size==0x000100)
   mem3 == base + 0x203000  (size==0x000400)

So of course, it is tempting to wonder whether it is really neccessary
to allocate three newbus entities for them.  On the other hand, I have
to believe that the BIOS has already set the base and sizes of these
areas, and it would be a really bad idea to pretend that they are a
single (say 3-meg) resource.

I think I will just go ahead with allocating three separate resources
for them, but I would be very interested in other opinions.

Thanks,

-Richard

-------------------------------------------
   Richard Hodges   | Matriplex, inc.
      <title>       | 769 Basque Way
  rh@matriplex.com  | Carson City, NV 89706
    775-886-6477    | www.matriplex.com 



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?Pine.BSF.4.10.10101261750060.31475-100000>