Use appropriate resource management accessors instead of directly

referencing structure members.

Use rman_get_size() instead of end - start + 1.
This commit is contained in:
Matthew N. Dodd 2000-10-18 00:09:26 +00:00
parent 7f9b204636
commit a4a64f2f0a
9 changed files with 38 additions and 36 deletions

View File

@ -472,18 +472,18 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid,
if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
caddr_t vaddr = 0;
if (r->r_end < 1024 * 1024) {
if (rman_get_end(r) < 1024 * 1024) {
/*
* The first 1Mb is mapped at KERNBASE.
*/
vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start);
vaddr = (caddr_t)(uintptr_t)(KERNBASE + rman_get_start(r));
} else {
u_int32_t paddr;
u_int32_t psize;
u_int32_t poffs;
paddr = r->r_start;
psize = r->r_end - r->r_start;
paddr = rman_get_start(r);
psize = rman_get_size(r);
poffs = paddr - trunc_page(paddr);
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
@ -511,10 +511,11 @@ nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
/*
* If this is a memory resource, unmap it.
*/
if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (r->r_end >= 1024 * 1024)) {
if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) &&
(rman_get_end(r) >= 1024 * 1024)) {
u_int32_t psize;
psize = r->r_end - r->r_start;
psize = rman_get_size(r);
pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize);
}
@ -525,7 +526,7 @@ static int
nexus_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
if (r->r_flags & RF_ACTIVE) {
if (rman_get_flags(r) & RF_ACTIVE) {
int error = bus_deactivate_resource(child, type, rid, r);
if (error)
return error;

View File

@ -472,18 +472,18 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid,
if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
caddr_t vaddr = 0;
if (r->r_end < 1024 * 1024) {
if (rman_get_end(r) < 1024 * 1024) {
/*
* The first 1Mb is mapped at KERNBASE.
*/
vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start);
vaddr = (caddr_t)(uintptr_t)(KERNBASE + rman_get_start(r));
} else {
u_int32_t paddr;
u_int32_t psize;
u_int32_t poffs;
paddr = r->r_start;
psize = r->r_end - r->r_start;
paddr = rman_get_start(r);
psize = rman_get_size(r);
poffs = paddr - trunc_page(paddr);
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
@ -511,10 +511,11 @@ nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
/*
* If this is a memory resource, unmap it.
*/
if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (r->r_end >= 1024 * 1024)) {
if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) &&
(rman_get_end(r) >= 1024 * 1024)) {
u_int32_t psize;
psize = r->r_end - r->r_start;
psize = rman_get_size(r);
pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize);
}
@ -525,7 +526,7 @@ static int
nexus_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
if (r->r_flags & RF_ACTIVE) {
if (rman_get_flags(r) & RF_ACTIVE) {
int error = bus_deactivate_resource(child, type, rid, r);
if (error)
return error;

View File

@ -746,8 +746,7 @@ agp_get_info(device_t dev, struct agp_info *info)
info->ai_mode =
pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4);
info->ai_aperture_base = rman_get_start(sc->as_aperture);
info->ai_aperture_size = (rman_get_end(sc->as_aperture)
- rman_get_start(sc->as_aperture)) + 1;
info->ai_aperture_size = rmang_get_size(sc->as_aperture);
info->ai_memory_allowed = sc->as_maxmem;
info->ai_memory_used = sc->as_allocated;
}

View File

@ -1307,7 +1307,7 @@ pcic_activate_resource(device_t dev, device_t child, int type, int rid,
bus_addr_t off;
struct pcic_handle *h = pcic_get_handle(dev, child);
sz = rman_get_end(r) - rman_get_start(r) + 1;
sz = rman_get_size(r);
switch (type) {
case SYS_RES_IOPORT:
win = rid;
@ -1416,7 +1416,7 @@ pcic_alloc_resource(device_t dev, device_t child, int type, int *rid,
count, flags);
if (r == NULL)
return r;
sz = rman_get_end(r) - rman_get_start(r) + 1;
sz = rman_get_size(r);
switch (type) {
case SYS_RES_IOPORT:
err = pcic_chip_io_alloc(h, rman_get_start(r), sz, 0,

View File

@ -134,7 +134,7 @@ pcic_isa_bus_width_probe (device_t dev)
struct resource *r;
base = rman_get_start(sc->port_res);
length = rman_get_end(sc->port_res) - rman_get_end(sc->port_res) + 1;
length = rman_get_size(sc->port_res);
iot = sc->iot;
ioh = sc->ioh;

View File

@ -204,7 +204,7 @@ pdq_eisa_attach (dev)
}
m_addr = rman_get_start(mspace);
m_size = (rman_get_end(mspace) - rman_get_start(mspace)) + 1;
m_size = rman_get_size(mspace);
sc->sc_iobase = (pdq_bus_ioport_t) rman_get_start(io);
sc->sc_membase = (pdq_bus_memaddr_t) pmap_mapdev(m_addr, m_size);

View File

@ -472,18 +472,18 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid,
if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
caddr_t vaddr = 0;
if (r->r_end < 1024 * 1024) {
if (rman_get_end(r) < 1024 * 1024) {
/*
* The first 1Mb is mapped at KERNBASE.
*/
vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start);
vaddr = (caddr_t)(uintptr_t)(KERNBASE + rman_get_start(r));
} else {
u_int32_t paddr;
u_int32_t psize;
u_int32_t poffs;
paddr = r->r_start;
psize = r->r_end - r->r_start;
paddr = rman_get_start(r);
psize = rman_get_size(r);
poffs = paddr - trunc_page(paddr);
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
@ -511,10 +511,11 @@ nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
/*
* If this is a memory resource, unmap it.
*/
if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (r->r_end >= 1024 * 1024)) {
if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) &&
(rman_get_end(r) >= 1024 * 1024)) {
u_int32_t psize;
psize = r->r_end - r->r_start;
psize = rman_get_size(r);
pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize);
}
@ -525,7 +526,7 @@ static int
nexus_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
if (r->r_flags & RF_ACTIVE) {
if (rman_get_flags(r) & RF_ACTIVE) {
int error = bus_deactivate_resource(child, type, rid, r);
if (error)
return error;

View File

@ -472,18 +472,18 @@ nexus_activate_resource(device_t bus, device_t child, int type, int rid,
if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
caddr_t vaddr = 0;
if (r->r_end < 1024 * 1024) {
if (rman_get_end(r) < 1024 * 1024) {
/*
* The first 1Mb is mapped at KERNBASE.
*/
vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start);
vaddr = (caddr_t)(uintptr_t)(KERNBASE + rman_get_start(r));
} else {
u_int32_t paddr;
u_int32_t psize;
u_int32_t poffs;
paddr = r->r_start;
psize = r->r_end - r->r_start;
paddr = rman_get_start(r);
psize = rman_get_size(r);
poffs = paddr - trunc_page(paddr);
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
@ -511,10 +511,11 @@ nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
/*
* If this is a memory resource, unmap it.
*/
if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (r->r_end >= 1024 * 1024)) {
if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) &&
(rman_get_end(r) >= 1024 * 1024)) {
u_int32_t psize;
psize = r->r_end - r->r_start;
psize = rman_get_size(r);
pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize);
}
@ -525,7 +526,7 @@ static int
nexus_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
if (r->r_flags & RF_ACTIVE) {
if (rman_get_flags(r) & RF_ACTIVE) {
int error = bus_deactivate_resource(child, type, rid, r);
if (error)
return error;

View File

@ -746,8 +746,7 @@ agp_get_info(device_t dev, struct agp_info *info)
info->ai_mode =
pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4);
info->ai_aperture_base = rman_get_start(sc->as_aperture);
info->ai_aperture_size = (rman_get_end(sc->as_aperture)
- rman_get_start(sc->as_aperture)) + 1;
info->ai_aperture_size = rmang_get_size(sc->as_aperture);
info->ai_memory_allowed = sc->as_maxmem;
info->ai_memory_used = sc->as_allocated;
}