diff options
author | msmith <msmith@FreeBSD.org> | 2000-01-18 02:13:27 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 2000-01-18 02:13:27 +0000 |
commit | cd58140a3f71225b489ba02bf78308d080ed6992 (patch) | |
tree | 037bfd115a6606d893a62263c5a2a263d038c806 | |
parent | 41c200930cdd2079853d2198feb1bd858ec26f1b (diff) | |
download | FreeBSD-src-cd58140a3f71225b489ba02bf78308d080ed6992.zip FreeBSD-src-cd58140a3f71225b489ba02bf78308d080ed6992.tar.gz |
Don't try to map memory resources into the kernel until they're actually
activated. Some of the things that get listed as "resources" aren't
necessarily suited for this.
(This shouldn't be a problem for any driver that correctly passes
RF_ACTIVE)
-rw-r--r-- | sys/amd64/amd64/legacy.c | 55 | ||||
-rw-r--r-- | sys/amd64/amd64/nexus.c | 55 | ||||
-rw-r--r-- | sys/i386/i386/legacy.c | 55 | ||||
-rw-r--r-- | sys/i386/i386/nexus.c | 55 |
4 files changed, 140 insertions, 80 deletions
diff --git a/sys/amd64/amd64/legacy.c b/sys/amd64/amd64/legacy.c index fda15bb..568085b 100644 --- a/sys/amd64/amd64/legacy.c +++ b/sys/amd64/amd64/legacy.c @@ -283,27 +283,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, return 0; if (type == SYS_RES_MEMORY) { - caddr_t vaddr = 0; - - if (rv->r_end < 1024 * 1024) { - /* - * The first 1Mb is mapped at KERNBASE. - */ - vaddr = (caddr_t)(uintptr_t)(KERNBASE + rv->r_start); - } else { - u_int32_t paddr; - u_int32_t psize; - u_int32_t poffs; - - paddr = rv->r_start; - psize = rv->r_end - rv->r_start; - - poffs = paddr - trunc_page(paddr); - vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs; - } - rman_set_virtual(rv, vaddr); rman_set_bustag(rv, I386_BUS_SPACE_MEM); - rman_set_bushandle(rv, (bus_space_handle_t) vaddr); } else if (type == SYS_RES_IOPORT) { rman_set_bustag(rv, I386_BUS_SPACE_IO); rman_set_bushandle(rv, rv->r_start); @@ -323,6 +303,31 @@ static int nexus_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + /* + * If this is a memory resource, map it into the kernel. + */ + if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) { + caddr_t vaddr = 0; + + if (r->r_end < 1024 * 1024) { + /* + * The first 1Mb is mapped at KERNBASE. + */ + vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start); + } else { + u_int32_t paddr; + u_int32_t psize; + u_int32_t poffs; + + paddr = r->r_start; + psize = r->r_end - r->r_start; + + poffs = paddr - trunc_page(paddr); + vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs; + } + rman_set_virtual(r, vaddr); + rman_set_bushandle(r, (bus_space_handle_t) vaddr); + } return (rman_activate_resource(r)); } @@ -330,6 +335,16 @@ static int nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + /* + * If this is a memory resource, unmap it. + */ + if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (rv->r_end >= 1024 * 1024)) { + u_int32_t psize; + + psize = r->r_end - r->r_start; + pmap_unmapdev(rman_get_virtual(r), psize); + } + return (rman_deactivate_resource(r)); } diff --git a/sys/amd64/amd64/nexus.c b/sys/amd64/amd64/nexus.c index fda15bb..568085b 100644 --- a/sys/amd64/amd64/nexus.c +++ b/sys/amd64/amd64/nexus.c @@ -283,27 +283,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, return 0; if (type == SYS_RES_MEMORY) { - caddr_t vaddr = 0; - - if (rv->r_end < 1024 * 1024) { - /* - * The first 1Mb is mapped at KERNBASE. - */ - vaddr = (caddr_t)(uintptr_t)(KERNBASE + rv->r_start); - } else { - u_int32_t paddr; - u_int32_t psize; - u_int32_t poffs; - - paddr = rv->r_start; - psize = rv->r_end - rv->r_start; - - poffs = paddr - trunc_page(paddr); - vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs; - } - rman_set_virtual(rv, vaddr); rman_set_bustag(rv, I386_BUS_SPACE_MEM); - rman_set_bushandle(rv, (bus_space_handle_t) vaddr); } else if (type == SYS_RES_IOPORT) { rman_set_bustag(rv, I386_BUS_SPACE_IO); rman_set_bushandle(rv, rv->r_start); @@ -323,6 +303,31 @@ static int nexus_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + /* + * If this is a memory resource, map it into the kernel. + */ + if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) { + caddr_t vaddr = 0; + + if (r->r_end < 1024 * 1024) { + /* + * The first 1Mb is mapped at KERNBASE. + */ + vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start); + } else { + u_int32_t paddr; + u_int32_t psize; + u_int32_t poffs; + + paddr = r->r_start; + psize = r->r_end - r->r_start; + + poffs = paddr - trunc_page(paddr); + vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs; + } + rman_set_virtual(r, vaddr); + rman_set_bushandle(r, (bus_space_handle_t) vaddr); + } return (rman_activate_resource(r)); } @@ -330,6 +335,16 @@ static int nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + /* + * If this is a memory resource, unmap it. + */ + if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (rv->r_end >= 1024 * 1024)) { + u_int32_t psize; + + psize = r->r_end - r->r_start; + pmap_unmapdev(rman_get_virtual(r), psize); + } + return (rman_deactivate_resource(r)); } diff --git a/sys/i386/i386/legacy.c b/sys/i386/i386/legacy.c index fda15bb..568085b 100644 --- a/sys/i386/i386/legacy.c +++ b/sys/i386/i386/legacy.c @@ -283,27 +283,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, return 0; if (type == SYS_RES_MEMORY) { - caddr_t vaddr = 0; - - if (rv->r_end < 1024 * 1024) { - /* - * The first 1Mb is mapped at KERNBASE. - */ - vaddr = (caddr_t)(uintptr_t)(KERNBASE + rv->r_start); - } else { - u_int32_t paddr; - u_int32_t psize; - u_int32_t poffs; - - paddr = rv->r_start; - psize = rv->r_end - rv->r_start; - - poffs = paddr - trunc_page(paddr); - vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs; - } - rman_set_virtual(rv, vaddr); rman_set_bustag(rv, I386_BUS_SPACE_MEM); - rman_set_bushandle(rv, (bus_space_handle_t) vaddr); } else if (type == SYS_RES_IOPORT) { rman_set_bustag(rv, I386_BUS_SPACE_IO); rman_set_bushandle(rv, rv->r_start); @@ -323,6 +303,31 @@ static int nexus_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + /* + * If this is a memory resource, map it into the kernel. + */ + if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) { + caddr_t vaddr = 0; + + if (r->r_end < 1024 * 1024) { + /* + * The first 1Mb is mapped at KERNBASE. + */ + vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start); + } else { + u_int32_t paddr; + u_int32_t psize; + u_int32_t poffs; + + paddr = r->r_start; + psize = r->r_end - r->r_start; + + poffs = paddr - trunc_page(paddr); + vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs; + } + rman_set_virtual(r, vaddr); + rman_set_bushandle(r, (bus_space_handle_t) vaddr); + } return (rman_activate_resource(r)); } @@ -330,6 +335,16 @@ static int nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + /* + * If this is a memory resource, unmap it. + */ + if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (rv->r_end >= 1024 * 1024)) { + u_int32_t psize; + + psize = r->r_end - r->r_start; + pmap_unmapdev(rman_get_virtual(r), psize); + } + return (rman_deactivate_resource(r)); } diff --git a/sys/i386/i386/nexus.c b/sys/i386/i386/nexus.c index fda15bb..568085b 100644 --- a/sys/i386/i386/nexus.c +++ b/sys/i386/i386/nexus.c @@ -283,27 +283,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, return 0; if (type == SYS_RES_MEMORY) { - caddr_t vaddr = 0; - - if (rv->r_end < 1024 * 1024) { - /* - * The first 1Mb is mapped at KERNBASE. - */ - vaddr = (caddr_t)(uintptr_t)(KERNBASE + rv->r_start); - } else { - u_int32_t paddr; - u_int32_t psize; - u_int32_t poffs; - - paddr = rv->r_start; - psize = rv->r_end - rv->r_start; - - poffs = paddr - trunc_page(paddr); - vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs; - } - rman_set_virtual(rv, vaddr); rman_set_bustag(rv, I386_BUS_SPACE_MEM); - rman_set_bushandle(rv, (bus_space_handle_t) vaddr); } else if (type == SYS_RES_IOPORT) { rman_set_bustag(rv, I386_BUS_SPACE_IO); rman_set_bushandle(rv, rv->r_start); @@ -323,6 +303,31 @@ static int nexus_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + /* + * If this is a memory resource, map it into the kernel. + */ + if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) { + caddr_t vaddr = 0; + + if (r->r_end < 1024 * 1024) { + /* + * The first 1Mb is mapped at KERNBASE. + */ + vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start); + } else { + u_int32_t paddr; + u_int32_t psize; + u_int32_t poffs; + + paddr = r->r_start; + psize = r->r_end - r->r_start; + + poffs = paddr - trunc_page(paddr); + vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs; + } + rman_set_virtual(r, vaddr); + rman_set_bushandle(r, (bus_space_handle_t) vaddr); + } return (rman_activate_resource(r)); } @@ -330,6 +335,16 @@ static int nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { + /* + * If this is a memory resource, unmap it. + */ + if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (rv->r_end >= 1024 * 1024)) { + u_int32_t psize; + + psize = r->r_end - r->r_start; + pmap_unmapdev(rman_get_virtual(r), psize); + } + return (rman_deactivate_resource(r)); } |