physmem: Add physmem_excluded to query if a region is excluded

In order to safely reuse excluded memory when it's reserved for special
purpose, we need to test whether or not the memory has been reserved
early in boot. physmem_excluded will return true when the entire range
is excluded, false otherwise.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2022-10-05 21:55:26 -06:00
parent ecb167daf7
commit deb1e3b719
2 changed files with 15 additions and 0 deletions

View File

@ -483,6 +483,20 @@ physmem_avail(vm_paddr_t *avail, size_t maxavail)
return (regions_to_avail(avail, EXFLAG_NOALLOC, maxavail, 0, NULL, NULL));
}
bool
physmem_excluded(vm_paddr_t pa, vm_size_t sz)
{
const struct region *exp;
size_t exi;
for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) {
if (pa < exp->addr || pa + sz > exp->addr + exp->size)
continue;
return (true);
}
return (false);
}
#ifdef _KERNEL
/*
* Process all the regions added earlier into the global avail lists.

View File

@ -54,6 +54,7 @@ void physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags);
size_t physmem_avail(vm_paddr_t *avail, size_t maxavail);
void physmem_init_kernel_globals(void);
void physmem_print_tables(void);
bool physmem_excluded(vm_paddr_t pa, vm_size_t sz);
/*
* Convenience routines for FDT.