MCPcopy Create free account
hub / github.com/F-Stack/f-stack / insert_region

Function insert_region

freebsd/kern/subr_physmem.c:276–308  ·  view source on GitHub ↗

* Insertion-sort a new entry into a regions list; sorted by start address. */

Source from the content-addressed store, hash-verified

274 * Insertion-sort a new entry into a regions list; sorted by start address.
275 */
276static size_t
277insert_region(struct region *regions, size_t rcnt, vm_paddr_t addr,
278 vm_size_t size, uint32_t flags)
279{
280 size_t i;
281 struct region *ep, *rp;
282
283 ep = regions + rcnt;
284 for (i = 0, rp = regions; i < rcnt; ++i, ++rp) {
285 if (rp->addr == addr && rp->size == size) /* Pure dup. */
286 return (rcnt);
287 if (flags == rp->flags) {
288 if (addr + size == rp->addr) {
289 rp->addr = addr;
290 rp->size += size;
291 return (rcnt);
292 } else if (rp->addr + rp->size == addr) {
293 rp->size += size;
294 return (rcnt);
295 }
296 }
297 if (addr < rp->addr) {
298 bcopy(rp, rp + 1, (ep - rp) * sizeof(*rp));
299 break;
300 }
301 }
302 rp->addr = addr;
303 rp->size = size;
304 rp->flags = flags;
305 rcnt++;
306
307 return (rcnt);
308}
309
310/*
311 * Add a hardware memory region.

Callers 2

physmem_hardware_regionFunction · 0.85
physmem_exclude_regionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected