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:
parent
7f9b204636
commit
a4a64f2f0a
@ -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) {
|
if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
|
||||||
caddr_t vaddr = 0;
|
caddr_t vaddr = 0;
|
||||||
|
|
||||||
if (r->r_end < 1024 * 1024) {
|
if (rman_get_end(r) < 1024 * 1024) {
|
||||||
/*
|
/*
|
||||||
* The first 1Mb is mapped at KERNBASE.
|
* 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 {
|
} else {
|
||||||
u_int32_t paddr;
|
u_int32_t paddr;
|
||||||
u_int32_t psize;
|
u_int32_t psize;
|
||||||
u_int32_t poffs;
|
u_int32_t poffs;
|
||||||
|
|
||||||
paddr = r->r_start;
|
paddr = rman_get_start(r);
|
||||||
psize = r->r_end - r->r_start;
|
psize = rman_get_size(r);
|
||||||
|
|
||||||
poffs = paddr - trunc_page(paddr);
|
poffs = paddr - trunc_page(paddr);
|
||||||
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
|
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 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;
|
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);
|
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,
|
nexus_release_resource(device_t bus, device_t child, int type, int rid,
|
||||||
struct resource *r)
|
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);
|
int error = bus_deactivate_resource(child, type, rid, r);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
@ -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) {
|
if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
|
||||||
caddr_t vaddr = 0;
|
caddr_t vaddr = 0;
|
||||||
|
|
||||||
if (r->r_end < 1024 * 1024) {
|
if (rman_get_end(r) < 1024 * 1024) {
|
||||||
/*
|
/*
|
||||||
* The first 1Mb is mapped at KERNBASE.
|
* 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 {
|
} else {
|
||||||
u_int32_t paddr;
|
u_int32_t paddr;
|
||||||
u_int32_t psize;
|
u_int32_t psize;
|
||||||
u_int32_t poffs;
|
u_int32_t poffs;
|
||||||
|
|
||||||
paddr = r->r_start;
|
paddr = rman_get_start(r);
|
||||||
psize = r->r_end - r->r_start;
|
psize = rman_get_size(r);
|
||||||
|
|
||||||
poffs = paddr - trunc_page(paddr);
|
poffs = paddr - trunc_page(paddr);
|
||||||
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
|
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 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;
|
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);
|
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,
|
nexus_release_resource(device_t bus, device_t child, int type, int rid,
|
||||||
struct resource *r)
|
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);
|
int error = bus_deactivate_resource(child, type, rid, r);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
@ -746,8 +746,7 @@ agp_get_info(device_t dev, struct agp_info *info)
|
|||||||
info->ai_mode =
|
info->ai_mode =
|
||||||
pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4);
|
pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4);
|
||||||
info->ai_aperture_base = rman_get_start(sc->as_aperture);
|
info->ai_aperture_base = rman_get_start(sc->as_aperture);
|
||||||
info->ai_aperture_size = (rman_get_end(sc->as_aperture)
|
info->ai_aperture_size = rmang_get_size(sc->as_aperture);
|
||||||
- rman_get_start(sc->as_aperture)) + 1;
|
|
||||||
info->ai_memory_allowed = sc->as_maxmem;
|
info->ai_memory_allowed = sc->as_maxmem;
|
||||||
info->ai_memory_used = sc->as_allocated;
|
info->ai_memory_used = sc->as_allocated;
|
||||||
}
|
}
|
||||||
|
@ -1307,7 +1307,7 @@ pcic_activate_resource(device_t dev, device_t child, int type, int rid,
|
|||||||
bus_addr_t off;
|
bus_addr_t off;
|
||||||
struct pcic_handle *h = pcic_get_handle(dev, child);
|
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) {
|
switch (type) {
|
||||||
case SYS_RES_IOPORT:
|
case SYS_RES_IOPORT:
|
||||||
win = rid;
|
win = rid;
|
||||||
@ -1416,7 +1416,7 @@ pcic_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
|||||||
count, flags);
|
count, flags);
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
return r;
|
return r;
|
||||||
sz = rman_get_end(r) - rman_get_start(r) + 1;
|
sz = rman_get_size(r);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SYS_RES_IOPORT:
|
case SYS_RES_IOPORT:
|
||||||
err = pcic_chip_io_alloc(h, rman_get_start(r), sz, 0,
|
err = pcic_chip_io_alloc(h, rman_get_start(r), sz, 0,
|
||||||
|
@ -134,7 +134,7 @@ pcic_isa_bus_width_probe (device_t dev)
|
|||||||
struct resource *r;
|
struct resource *r;
|
||||||
|
|
||||||
base = rman_get_start(sc->port_res);
|
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;
|
iot = sc->iot;
|
||||||
ioh = sc->ioh;
|
ioh = sc->ioh;
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ pdq_eisa_attach (dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_addr = rman_get_start(mspace);
|
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_iobase = (pdq_bus_ioport_t) rman_get_start(io);
|
||||||
sc->sc_membase = (pdq_bus_memaddr_t) pmap_mapdev(m_addr, m_size);
|
sc->sc_membase = (pdq_bus_memaddr_t) pmap_mapdev(m_addr, m_size);
|
||||||
|
@ -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) {
|
if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
|
||||||
caddr_t vaddr = 0;
|
caddr_t vaddr = 0;
|
||||||
|
|
||||||
if (r->r_end < 1024 * 1024) {
|
if (rman_get_end(r) < 1024 * 1024) {
|
||||||
/*
|
/*
|
||||||
* The first 1Mb is mapped at KERNBASE.
|
* 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 {
|
} else {
|
||||||
u_int32_t paddr;
|
u_int32_t paddr;
|
||||||
u_int32_t psize;
|
u_int32_t psize;
|
||||||
u_int32_t poffs;
|
u_int32_t poffs;
|
||||||
|
|
||||||
paddr = r->r_start;
|
paddr = rman_get_start(r);
|
||||||
psize = r->r_end - r->r_start;
|
psize = rman_get_size(r);
|
||||||
|
|
||||||
poffs = paddr - trunc_page(paddr);
|
poffs = paddr - trunc_page(paddr);
|
||||||
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
|
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 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;
|
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);
|
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,
|
nexus_release_resource(device_t bus, device_t child, int type, int rid,
|
||||||
struct resource *r)
|
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);
|
int error = bus_deactivate_resource(child, type, rid, r);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
@ -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) {
|
if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
|
||||||
caddr_t vaddr = 0;
|
caddr_t vaddr = 0;
|
||||||
|
|
||||||
if (r->r_end < 1024 * 1024) {
|
if (rman_get_end(r) < 1024 * 1024) {
|
||||||
/*
|
/*
|
||||||
* The first 1Mb is mapped at KERNBASE.
|
* 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 {
|
} else {
|
||||||
u_int32_t paddr;
|
u_int32_t paddr;
|
||||||
u_int32_t psize;
|
u_int32_t psize;
|
||||||
u_int32_t poffs;
|
u_int32_t poffs;
|
||||||
|
|
||||||
paddr = r->r_start;
|
paddr = rman_get_start(r);
|
||||||
psize = r->r_end - r->r_start;
|
psize = rman_get_size(r);
|
||||||
|
|
||||||
poffs = paddr - trunc_page(paddr);
|
poffs = paddr - trunc_page(paddr);
|
||||||
vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
|
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 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;
|
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);
|
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,
|
nexus_release_resource(device_t bus, device_t child, int type, int rid,
|
||||||
struct resource *r)
|
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);
|
int error = bus_deactivate_resource(child, type, rid, r);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
@ -746,8 +746,7 @@ agp_get_info(device_t dev, struct agp_info *info)
|
|||||||
info->ai_mode =
|
info->ai_mode =
|
||||||
pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4);
|
pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4);
|
||||||
info->ai_aperture_base = rman_get_start(sc->as_aperture);
|
info->ai_aperture_base = rman_get_start(sc->as_aperture);
|
||||||
info->ai_aperture_size = (rman_get_end(sc->as_aperture)
|
info->ai_aperture_size = rmang_get_size(sc->as_aperture);
|
||||||
- rman_get_start(sc->as_aperture)) + 1;
|
|
||||||
info->ai_memory_allowed = sc->as_maxmem;
|
info->ai_memory_allowed = sc->as_maxmem;
|
||||||
info->ai_memory_used = sc->as_allocated;
|
info->ai_memory_used = sc->as_allocated;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user