Change rman_manage_region() to actually honor the rm_start and rm_end

constraints on the rman and reject attempts to manage a region that is out
of range.
- Fix various places that set rm_end incorrectly (to ~0 or ~0u instead of
  ~0ul).
- To preserve existing behavior, change rman_init() to set rm_start and
  rm_end to allow managing the full range (0 to ~0ul) if they are not set by
  the caller when rman_init() is called.
This commit is contained in:
John Baldwin 2011-04-29 18:41:21 +00:00
parent 447552ca4c
commit b67d11bbcc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=221218
8 changed files with 13 additions and 9 deletions

View File

@ -138,10 +138,10 @@ nexus_attach(device_t dev)
{
mem_rman.rm_start = 0;
mem_rman.rm_end = ~0u;
mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory addresses";
if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0u))
if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0))
panic("nexus_probe mem_rman");
/*

View File

@ -206,7 +206,7 @@ fdtbus_attach(device_t dev)
* Mem-mapped I/O space rman.
*/
start = 0;
end = ~0u;
end = ~0ul;
sc->sc_mem.rm_start = start;
sc->sc_mem.rm_end = end;
sc->sc_mem.rm_type = RMAN_ARRAY;

View File

@ -174,7 +174,7 @@ nexus_probe(device_t dev)
panic("nexus_probe port_rman");
mem_rman.rm_start = 0;
mem_rman.rm_end = ~0u;
mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory addresses";
if (rman_init(&mem_rman)

View File

@ -138,6 +138,8 @@ rman_init(struct rman *rm)
mtx_init(&rman_mtx, "rman head", NULL, MTX_DEF);
}
if (rm->rm_start == 0 && rm->rm_end == 0)
rm->rm_end = ~0ul;
if (rm->rm_type == RMAN_UNINIT)
panic("rman_init");
if (rm->rm_type == RMAN_GAUGE)
@ -162,6 +164,8 @@ rman_manage_region(struct rman *rm, u_long start, u_long end)
DPRINTF(("rman_manage_region: <%s> request: start %#lx, end %#lx\n",
rm->rm_descr, start, end));
if (start < rm->rm_start || end > rm->rm_end)
return EINVAL;
r = int_alloc_resource(M_NOWAIT);
if (r == NULL)
return ENOMEM;

View File

@ -146,7 +146,7 @@ mainbus_probe(device_t dev)
panic("mainbus_probe port_rman");
mem_rman.rm_start = 0;
mem_rman.rm_end = ~0u;
mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory addresses";
if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0))

View File

@ -151,7 +151,7 @@ nexus_probe(device_t dev)
}
mem_rman.rm_start = 0;
mem_rman.rm_end = ~0u;
mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "Memory addresses";
if (rman_init(&mem_rman) != 0 ||

View File

@ -126,7 +126,7 @@ xlr_pci_init_resources(void)
panic("pci_init_resources irq_rman");
port_rman.rm_start = 0;
port_rman.rm_end = ~0u;
port_rman.rm_end = ~0ul;
port_rman.rm_type = RMAN_ARRAY;
port_rman.rm_descr = "I/O ports";
if (rman_init(&port_rman)
@ -134,7 +134,7 @@ xlr_pci_init_resources(void)
panic("pci_init_resources port_rman");
mem_rman.rm_start = 0;
mem_rman.rm_end = ~0u;
mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory";
if (rman_init(&mem_rman)

View File

@ -256,7 +256,7 @@ nexus_init_resources(void)
panic("nexus_init_resources port_rman");
mem_rman.rm_start = 0;
mem_rman.rm_end = ~0u;
mem_rman.rm_end = ~0ul;
mem_rman.rm_type = RMAN_ARRAY;
mem_rman.rm_descr = "I/O memory addresses";
if (rman_init(&mem_rman)