static void frame_common_arch_init(bool low) { unsigned int i; for (i = 0; i < bootinfo->memmap_items; i++) { if (bootinfo->memmap[i].type != MEMMAP_FREE_MEM) continue; uintptr_t base = bootinfo->memmap[i].base; size_t size = bootinfo->memmap[i].size; uintptr_t abase = ALIGN_UP(base, FRAME_SIZE); if (size > FRAME_SIZE) size -= abase - base; if (!frame_adjust_zone_bounds(low, &abase, &size)) continue; if (size > MIN_ZONE_SIZE) { pfn_t pfn = ADDR2PFN(abase); size_t count = SIZE2FRAMES(size); if (low) { zone_create(pfn, count, max(MINCONF, pfn), ZONE_AVAILABLE | ZONE_LOWMEM); } else { pfn_t conf = zone_external_conf_alloc(count); if (conf != 0) zone_create(pfn, count, conf, ZONE_AVAILABLE | ZONE_HIGHMEM); } } } }
static void frame_common_arch_init(bool low) { uintptr_t base; size_t size; machine_get_memory_extents(&base, &size); base = ALIGN_UP(base, FRAME_SIZE); size = ALIGN_DOWN(size, FRAME_SIZE); if (!frame_adjust_zone_bounds(low, &base, &size)) return; if (low) { zone_create(ADDR2PFN(base), SIZE2FRAMES(size), BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, ZONE_AVAILABLE | ZONE_LOWMEM); } else { pfn_t conf = zone_external_conf_alloc(SIZE2FRAMES(size)); if (conf != 0) zone_create(ADDR2PFN(base), SIZE2FRAMES(size), conf, ZONE_AVAILABLE | ZONE_HIGHMEM); } }
/** Create memory zones according to information stored in memmap. * * Walk the memory map and create frame zones according to it. */ static void frame_common_arch_init(bool low) { unsigned int i; for (i = 0; i < memmap.cnt; i++) { uintptr_t base; size_t size; /* * The memmap is created by HelenOS boot loader. * It already contains no holes. */ /* To be safe, make the available zone possibly smaller */ base = ALIGN_UP((uintptr_t) memmap.zones[i].start, FRAME_SIZE); size = ALIGN_DOWN(memmap.zones[i].size - (base - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE); if (!frame_adjust_zone_bounds(low, &base, &size)) continue; pfn_t confdata; pfn_t pfn = ADDR2PFN(base); size_t count = SIZE2FRAMES(size); if (low) { confdata = pfn; if (confdata == ADDR2PFN(KA2PA(PFN2ADDR(0)))) confdata = ADDR2PFN(KA2PA(PFN2ADDR(2))); zone_create(pfn, count, confdata, ZONE_AVAILABLE | ZONE_LOWMEM); } else { confdata = zone_external_conf_alloc(count); if (confdata != 0) zone_create(pfn, count, confdata, ZONE_AVAILABLE | ZONE_HIGHMEM); } } }
/** * Lookup zone by name. * */ zone_type* zonelist_lookup_zone_by_name(zonelist_type* zonelist, const char* name, ldns_rr_class klass) { zone_type* zone = NULL; zone_type* result = NULL; if (zonelist && zonelist->zones && name && klass) { zone = zone_create((char*) name, klass); if (!zone) { ods_log_error("[%s] unable to lookup zone %s: " "zone_create() failed", zl_str, name); /* result stays NULL */ } else { result = zonelist_lookup_zone(zonelist, zone); zone_cleanup(zone); } } return result; }