Changeset c520034 in mainline for kernel/generic/src/mm/frame.c
- Timestamp:
- 2011-12-31T18:19:35Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 295f658, 77c2b02, 96cd5b4
- Parents:
- 852052d (diff), 22f0561 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/frame.c
r852052d rc520034 240 240 NO_TRACE static bool zone_can_alloc(zone_t *zone, uint8_t order) 241 241 { 242 return ( zone_flags_available(zone->flags)243 &&buddy_system_can_alloc(zone->buddy_system, order));242 return ((zone->flags & ZONE_AVAILABLE) && 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 ( (zones.info[i].flags & flags) == flags) {267 if (ZONE_FLAGS_MATCH(zones.info[i].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_available(zone->flags));462 ASSERT(zone->flags & ZONE_AVAILABLE); 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_available(zone->flags));492 ASSERT(zone->flags & ZONE_AVAILABLE); 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_available(zone->flags));520 ASSERT(zone->flags & ZONE_AVAILABLE); 521 521 522 522 frame_t *frame = zone_get_frame(zone, frame_idx); … … 549 549 buddy_system_t *buddy) 550 550 { 551 ASSERT(zone _flags_available(zones.info[z1].flags));552 ASSERT(zone _flags_available(zones.info[z2].flags));551 ASSERT(zones.info[z1].flags & ZONE_AVAILABLE); 552 ASSERT(zones.info[z2].flags & ZONE_AVAILABLE); 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 _flags_available(zones.info[znum].flags));647 ASSERT(zones.info[znum].flags & ZONE_AVAILABLE); 648 648 649 649 size_t cframes = SIZE2FRAMES(zone_conf_size(count)); … … 681 681 size_t count) 682 682 { 683 ASSERT(zone _flags_available(zones.info[znum].flags));683 ASSERT(zones.info[znum].flags & ZONE_AVAILABLE); 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) 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)) { 725 if ((z1 >= zones.count) || (z2 >= zones.count) || (z2 - z1 != 1) || 726 (zones.info[z1].flags != zones.info[z2].flags)) { 730 727 ret = false; 731 728 goto errout; … … 828 825 zone->buddy_system = buddy; 829 826 830 if ( zone_flags_available(flags)) {827 if (flags & ZONE_AVAILABLE) { 831 828 /* 832 829 * Compute order for buddy system and initialize … … 865 862 { 866 863 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, FRAME_LOWMEM)); 867 873 } 868 874 … … 888 894 irq_spinlock_lock(&zones.lock, true); 889 895 890 if ( zone_flags_available(flags)) { /* Create available zone */896 if (flags & ZONE_AVAILABLE) { /* Create available zone */ 891 897 /* Theoretically we could have NULL here, practically make sure 892 898 * nobody tries to do that. If some platform requires, remove … … 894 900 */ 895 901 ASSERT(confframe != ADDR2PFN((uintptr_t ) NULL)); 902 903 /* Update the known end of physical memory. */ 904 config.physmem_end = max(config.physmem_end, PFN2ADDR(start + count)); 896 905 897 906 /* If confframe is supposed to be inside our zone, then make sure … … 1232 1241 1233 1242 /* Tell the architecture to create some memory */ 1234 frame_ arch_init();1243 frame_low_arch_init(); 1235 1244 if (config.cpu_active == 1) { 1236 1245 frame_mark_unavailable(ADDR2PFN(KA2PA(config.base)), … … 1255 1264 frame_mark_unavailable(0, 1); 1256 1265 } 1266 frame_high_arch_init(); 1267 } 1268 1269 /** Adjust bounds of physical memory region according to low/high memory split. 1270 * 1271 * @param low[in] If true, the adujstment is performed to make the region 1272 * fit in the low memory. Otherwise the adjustment is 1273 * performed to make the region fit in the high memory. 1274 * @param basep[inout] Pointer to a variable which contains the region's base 1275 * address and which may receive the adjusted base address. 1276 * @param sizep[inout] Pointer to a variable which contains the region's size 1277 * and which may receive the adjusted size. 1278 * @retun True if the region still exists even after the 1279 * adjustment, false otherwise. 1280 */ 1281 bool frame_adjust_zone_bounds(bool low, uintptr_t *basep, size_t *sizep) 1282 { 1283 uintptr_t limit = config.identity_size; 1284 1285 if (low) { 1286 if (*basep > limit) 1287 return false; 1288 if (*basep + *sizep > limit) 1289 *sizep = limit - *basep; 1290 } else { 1291 if (*basep + *sizep <= limit) 1292 return false; 1293 if (*basep <= limit) { 1294 *sizep -= limit - *basep; 1295 *basep = limit; 1296 } 1297 } 1298 return true; 1257 1299 } 1258 1300 … … 1293 1335 *total += (uint64_t) FRAMES2SIZE(zones.info[i].count); 1294 1336 1295 if (zone _flags_available(zones.info[i].flags)) {1337 if (zones.info[i].flags & ZONE_AVAILABLE) { 1296 1338 *busy += (uint64_t) FRAMES2SIZE(zones.info[i].busy_count); 1297 1339 *free += (uint64_t) FRAMES2SIZE(zones.info[i].free_count); … … 1344 1386 irq_spinlock_unlock(&zones.lock, true); 1345 1387 1346 bool available = zone_flags_available(flags);1388 bool available = ((flags & ZONE_AVAILABLE) != 0); 1347 1389 1348 1390 printf("%-4zu", i); … … 1356 1398 #endif 1357 1399 1358 printf(" %12zu %c%c%c ", count, 1359 available ? 'A' : ' ', 1360 (flags & ZONE_RESERVED) ? 'R' : ' ', 1361 (flags & ZONE_FIRMWARE) ? 'F' : ' '); 1400 printf(" %12zu %c%c%c%c%c ", count, 1401 available ? 'A' : '-', 1402 (flags & ZONE_RESERVED) ? 'R' : '-', 1403 (flags & ZONE_FIRMWARE) ? 'F' : '-', 1404 (flags & ZONE_LOWMEM) ? 'L' : '-', 1405 (flags & ZONE_HIGHMEM) ? 'H' : '-'); 1362 1406 1363 1407 if (available) … … 1401 1445 irq_spinlock_unlock(&zones.lock, true); 1402 1446 1403 bool available = zone_flags_available(flags);1447 bool available = ((flags & ZONE_AVAILABLE) != 0); 1404 1448 1405 1449 uint64_t size; … … 1411 1455 printf("Zone size: %zu frames (%" PRIu64 " %s)\n", count, 1412 1456 size, size_suffix); 1413 printf("Zone flags: %c%c%c\n", 1414 available ? 'A' : ' ', 1415 (flags & ZONE_RESERVED) ? 'R' : ' ', 1416 (flags & ZONE_FIRMWARE) ? 'F' : ' '); 1457 printf("Zone flags: %c%c%c%c%c\n", 1458 available ? 'A' : '-', 1459 (flags & ZONE_RESERVED) ? 'R' : '-', 1460 (flags & ZONE_FIRMWARE) ? 'F' : '-', 1461 (flags & ZONE_LOWMEM) ? 'L' : '-', 1462 (flags & ZONE_HIGHMEM) ? 'H' : '-'); 1417 1463 1418 1464 if (available) {
Note:
See TracChangeset
for help on using the changeset viewer.