Add pci_mapreg_submap(): This function is pci_mapreg_map() with two
additional arguments, offset and maxsize. This new functionality eases handling certain tasks within the direct rendering manager, though I hope others will also find it useful. pci_mapreg_map() is now merely a wrapper around pci_mapreg_submap(); the latter contains all of the code from the former. ok christos@
This commit is contained in:
parent
fd9755072f
commit
c7921652a6
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pci_map.c,v 1.23 2008/04/28 20:23:55 martin Exp $ */
|
||||
/* $NetBSD: pci_map.c,v 1.24 2008/07/22 04:52:19 bjs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pci_map.c,v 1.23 2008/04/28 20:23:55 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: pci_map.c,v 1.24 2008/07/22 04:52:19 bjs Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -270,6 +270,15 @@ int
|
|||
pci_mapreg_map(struct pci_attach_args *pa, int reg, pcireg_t type,
|
||||
int busflags, bus_space_tag_t *tagp, bus_space_handle_t *handlep,
|
||||
bus_addr_t *basep, bus_size_t *sizep)
|
||||
{
|
||||
return pci_mapreg_submap(pa, reg, type, busflags, 0, 0, tagp,
|
||||
handlep, basep, sizep);
|
||||
}
|
||||
|
||||
int
|
||||
pci_mapreg_submap(struct pci_attach_args *pa, int reg, pcireg_t type,
|
||||
int busflags, bus_size_t maxsize, bus_size_t offset, bus_space_tag_t *tagp,
|
||||
bus_space_handle_t *handlep, bus_addr_t *basep, bus_size_t *sizep)
|
||||
{
|
||||
bus_space_tag_t tag;
|
||||
bus_space_handle_t handle;
|
||||
|
@ -304,7 +313,17 @@ pci_mapreg_map(struct pci_attach_args *pa, int reg, pcireg_t type,
|
|||
splx(s);
|
||||
}
|
||||
|
||||
if (bus_space_map(tag, base, size, busflags | flags, &handle))
|
||||
/* If we're called with maxsize/offset of 0, behave like
|
||||
* pci_mapreg_map.
|
||||
*/
|
||||
|
||||
maxsize = (maxsize && offset) ? maxsize : size;
|
||||
base += offset;
|
||||
|
||||
if ((maxsize < size && offset + maxsize <= size) || offset != 0)
|
||||
return (1);
|
||||
|
||||
if (bus_space_map(tag, base, maxsize, busflags | flags, &handle))
|
||||
return (1);
|
||||
|
||||
if (tagp != 0)
|
||||
|
@ -314,7 +333,7 @@ pci_mapreg_map(struct pci_attach_args *pa, int reg, pcireg_t type,
|
|||
if (basep != 0)
|
||||
*basep = base;
|
||||
if (sizep != 0)
|
||||
*sizep = size;
|
||||
*sizep = maxsize;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pcivar.h,v 1.82 2008/05/30 19:26:35 ad Exp $ */
|
||||
/* $NetBSD: pcivar.h,v 1.83 2008/07/22 04:52:19 bjs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -198,6 +198,9 @@ int pci_mapreg_info(pci_chipset_tag_t, pcitag_t, int, pcireg_t,
|
|||
int pci_mapreg_map(struct pci_attach_args *, int, pcireg_t, int,
|
||||
bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *,
|
||||
bus_size_t *);
|
||||
int pci_mapreg_submap(struct pci_attach_args *, int, pcireg_t, int,
|
||||
bus_size_t, bus_size_t, bus_space_tag_t *, bus_space_handle_t *,
|
||||
bus_addr_t *, bus_size_t *);
|
||||
|
||||
int pci_find_rom(struct pci_attach_args *, bus_space_tag_t, bus_space_handle_t,
|
||||
int, bus_space_handle_t *, bus_size_t *);
|
||||
|
|
Loading…
Reference in New Issue