Changes in kernel/generic/src/mm/frame.c [2cc7f16:818fffe] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/frame.c
r2cc7f16 r818fffe 240 240 NO_TRACE static bool zone_can_alloc(zone_t *zone, uint8_t order) 241 241 { 242 return ( (zone->flags & ZONE_AVAILABLE) &&243 buddy_system_can_alloc(zone->buddy_system, order));242 return (zone_flags_available(zone->flags) 243 && buddy_system_can_alloc(zone->buddy_system, order)); 244 244 } 245 245 … … 265 265 * Check whether the zone meets the search criteria. 266 266 */ 267 if ( ZONE_FLAGS_MATCH(zones.info[i].flags, flags)) {267 if ((zones.info[i].flags & flags) == flags) { 268 268 /* 269 269 * Check if the zone has 2^order frames area available. … … 460 460 NO_TRACE static pfn_t zone_frame_alloc(zone_t *zone, uint8_t order) 461 461 { 462 ASSERT(zone ->flags & ZONE_AVAILABLE);462 ASSERT(zone_flags_available(zone->flags)); 463 463 464 464 /* Allocate frames from zone buddy system */ … … 490 490 NO_TRACE static size_t zone_frame_free(zone_t *zone, size_t frame_idx) 491 491 { 492 ASSERT(zone ->flags & ZONE_AVAILABLE);492 ASSERT(zone_flags_available(zone->flags)); 493 493 494 494 frame_t *frame = &zone->frames[frame_idx]; … … 518 518 NO_TRACE static void zone_mark_unavailable(zone_t *zone, size_t frame_idx) 519 519 { 520 ASSERT(zone ->flags & ZONE_AVAILABLE);520 ASSERT(zone_flags_available(zone->flags)); 521 521 522 522 frame_t *frame = zone_get_frame(zone, frame_idx); … … 549 549 buddy_system_t *buddy) 550 550 { 551 ASSERT(zone s.info[z1].flags & ZONE_AVAILABLE);552 ASSERT(zone s.info[z2].flags & ZONE_AVAILABLE);551 ASSERT(zone_flags_available(zones.info[z1].flags)); 552 ASSERT(zone_flags_available(zones.info[z2].flags)); 553 553 ASSERT(zones.info[z1].flags == zones.info[z2].flags); 554 554 ASSERT(zones.info[z1].base < zones.info[z2].base); … … 645 645 NO_TRACE static void return_config_frames(size_t znum, pfn_t pfn, size_t count) 646 646 { 647 ASSERT(zone s.info[znum].flags & ZONE_AVAILABLE);647 ASSERT(zone_flags_available(zones.info[znum].flags)); 648 648 649 649 size_t cframes = SIZE2FRAMES(zone_conf_size(count)); … … 681 681 size_t count) 682 682 { 683 ASSERT(zone s.info[znum].flags & ZONE_AVAILABLE);683 ASSERT(zone_flags_available(zones.info[znum].flags)); 684 684 ASSERT(frame_idx + count < zones.info[znum].count); 685 685 … … 723 723 * set of flags 724 724 */ 725 if ((z1 >= zones.count) || (z2 >= zones.count) || (z2 - z1 != 1) || 726 (zones.info[z1].flags != zones.info[z2].flags)) { 725 if ((z1 >= zones.count) || (z2 >= zones.count) 726 || (z2 - z1 != 1) 727 || (!zone_flags_available(zones.info[z1].flags)) 728 || (!zone_flags_available(zones.info[z2].flags)) 729 || (zones.info[z1].flags != zones.info[z2].flags)) { 727 730 ret = false; 728 731 goto errout; … … 825 828 zone->buddy_system = buddy; 826 829 827 if ( flags & ZONE_AVAILABLE) {830 if (zone_flags_available(flags)) { 828 831 /* 829 832 * Compute order for buddy system and initialize … … 862 865 { 863 866 return (count * sizeof(frame_t) + buddy_conf_size(fnzb(count))); 864 }865 866 /** Allocate external configuration frames from low memory. */867 pfn_t zone_external_conf_alloc(size_t count)868 {869 size_t size = zone_conf_size(count);870 size_t order = ispwr2(size) ? fnzb(size) : (fnzb(size) + 1);871 872 return ADDR2PFN((uintptr_t) frame_alloc(order - FRAME_WIDTH,873 FRAME_LOWMEM | FRAME_ATOMIC));874 867 } 875 868 … … 895 888 irq_spinlock_lock(&zones.lock, true); 896 889 897 if ( flags & ZONE_AVAILABLE) { /* Create available zone */890 if (zone_flags_available(flags)) { /* Create available zone */ 898 891 /* Theoretically we could have NULL here, practically make sure 899 892 * nobody tries to do that. If some platform requires, remove … … 901 894 */ 902 895 ASSERT(confframe != ADDR2PFN((uintptr_t ) NULL)); 903 904 /* Update the known end of physical memory. */905 config.physmem_end = max(config.physmem_end, PFN2ADDR(start + count));906 896 907 897 /* If confframe is supposed to be inside our zone, then make sure … … 924 914 for (i = 0; i < init.cnt; i++) 925 915 if (overlaps(addr, PFN2ADDR(confcount), 926 init.tasks[i].paddr,916 KA2PA(init.tasks[i].addr), 927 917 init.tasks[i].size)) { 928 918 overlap = true; … … 1242 1232 1243 1233 /* Tell the architecture to create some memory */ 1244 frame_ low_arch_init();1234 frame_arch_init(); 1245 1235 if (config.cpu_active == 1) { 1246 1236 frame_mark_unavailable(ADDR2PFN(KA2PA(config.base)), … … 1251 1241 size_t i; 1252 1242 for (i = 0; i < init.cnt; i++) { 1253 pfn_t pfn = ADDR2PFN( init.tasks[i].paddr);1243 pfn_t pfn = ADDR2PFN(KA2PA(init.tasks[i].addr)); 1254 1244 frame_mark_unavailable(pfn, 1255 1245 SIZE2FRAMES(init.tasks[i].size)); … … 1265 1255 frame_mark_unavailable(0, 1); 1266 1256 } 1267 frame_high_arch_init();1268 }1269 1270 /** Adjust bounds of physical memory region according to low/high memory split.1271 *1272 * @param low[in] If true, the adjustment is performed to make the region1273 * fit in the low memory. Otherwise the adjustment is1274 * performed to make the region fit in the high memory.1275 * @param basep[inout] Pointer to a variable which contains the region's base1276 * address and which may receive the adjusted base address.1277 * @param sizep[inout] Pointer to a variable which contains the region's size1278 * and which may receive the adjusted size.1279 * @retun True if the region still exists even after the1280 * adjustment, false otherwise.1281 */1282 bool frame_adjust_zone_bounds(bool low, uintptr_t *basep, size_t *sizep)1283 {1284 uintptr_t limit = KA2PA(config.identity_base) + config.identity_size;1285 1286 if (low) {1287 if (*basep > limit)1288 return false;1289 if (*basep + *sizep > limit)1290 *sizep = limit - *basep;1291 } else {1292 if (*basep + *sizep <= limit)1293 return false;1294 if (*basep <= limit) {1295 *sizep -= limit - *basep;1296 *basep = limit;1297 }1298 }1299 return true;1300 1257 } 1301 1258 … … 1336 1293 *total += (uint64_t) FRAMES2SIZE(zones.info[i].count); 1337 1294 1338 if (zone s.info[i].flags & ZONE_AVAILABLE) {1295 if (zone_flags_available(zones.info[i].flags)) { 1339 1296 *busy += (uint64_t) FRAMES2SIZE(zones.info[i].busy_count); 1340 1297 *free += (uint64_t) FRAMES2SIZE(zones.info[i].free_count); … … 1387 1344 irq_spinlock_unlock(&zones.lock, true); 1388 1345 1389 bool available = ((flags & ZONE_AVAILABLE) != 0);1346 bool available = zone_flags_available(flags); 1390 1347 1391 1348 printf("%-4zu", i); … … 1399 1356 #endif 1400 1357 1401 printf(" %12zu %c%c%c%c%c ", count, 1402 available ? 'A' : '-', 1403 (flags & ZONE_RESERVED) ? 'R' : '-', 1404 (flags & ZONE_FIRMWARE) ? 'F' : '-', 1405 (flags & ZONE_LOWMEM) ? 'L' : '-', 1406 (flags & ZONE_HIGHMEM) ? 'H' : '-'); 1358 printf(" %12zu %c%c%c ", count, 1359 available ? 'A' : ' ', 1360 (flags & ZONE_RESERVED) ? 'R' : ' ', 1361 (flags & ZONE_FIRMWARE) ? 'F' : ' '); 1407 1362 1408 1363 if (available) … … 1446 1401 irq_spinlock_unlock(&zones.lock, true); 1447 1402 1448 bool available = ((flags & ZONE_AVAILABLE) != 0);1403 bool available = zone_flags_available(flags); 1449 1404 1450 1405 uint64_t size; … … 1456 1411 printf("Zone size: %zu frames (%" PRIu64 " %s)\n", count, 1457 1412 size, size_suffix); 1458 printf("Zone flags: %c%c%c%c%c\n", 1459 available ? 'A' : '-', 1460 (flags & ZONE_RESERVED) ? 'R' : '-', 1461 (flags & ZONE_FIRMWARE) ? 'F' : '-', 1462 (flags & ZONE_LOWMEM) ? 'L' : '-', 1463 (flags & ZONE_HIGHMEM) ? 'H' : '-'); 1413 printf("Zone flags: %c%c%c\n", 1414 available ? 'A' : ' ', 1415 (flags & ZONE_RESERVED) ? 'R' : ' ', 1416 (flags & ZONE_FIRMWARE) ? 'F' : ' '); 1464 1417 1465 1418 if (available) {
Note:
See TracChangeset
for help on using the changeset viewer.