Changeset e6c4b94 in mainline
- Timestamp:
- 2011-11-16T19:52:33Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fadb07a
- Parents:
- 19c8030
- Location:
- kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/mm/frame.c
r19c8030 re6c4b94 88 88 89 89 zone_create(ADDR2PFN(config.identity_size), frames, conf, 90 ZONE_AVAILABLE );90 ZONE_AVAILABLE | ZONE_HIGHMEM); 91 91 } 92 92 -
kernel/generic/include/mm/frame.h
r19c8030 re6c4b94 50 50 typedef uint8_t frame_flags_t; 51 51 52 #define FRAME_NONE 0x0 52 53 /** Convert the frame address to kernel VA. */ 53 54 #define FRAME_KA 0x1 … … 60 61 /** Allocate a frame which can be identity-mapped. */ 61 62 #define FRAME_LOWMEM 0x10 63 /** Allocate a frame which cannot be identity-mapped. */ 64 #define FRAME_HIGHMEM 0x20 62 65 63 66 typedef uint8_t zone_flags_t; 64 67 68 #define ZONE_NONE 0x0 65 69 /** Available zone (free for allocation) */ 66 #define ZONE_AVAILABLE 0x 070 #define ZONE_AVAILABLE 0x1 67 71 /** Zone is reserved (not available for allocation) */ 68 #define ZONE_RESERVED 0x 872 #define ZONE_RESERVED 0x2 69 73 /** Zone is used by firmware (not available for allocation) */ 70 #define ZONE_FIRMWARE 0x 1074 #define ZONE_FIRMWARE 0x4 71 75 /** Zone contains memory that can be identity-mapped */ 72 #define ZONE_LOWMEM 0x20 76 #define ZONE_LOWMEM 0x8 77 /** Zone contains memory that cannot be identity-mapped */ 78 #define ZONE_HIGHMEM 0x10 73 79 74 #define FRAME_TO_ZONE_FLAGS(ff) (((ff) & FRAME_LOWMEM) ? ZONE_LOWMEM : 0) 80 /** Mask of zone bits that must be matched exactly. */ 81 #define ZONE_EF_MASK 0x7 82 83 #define FRAME_TO_ZONE_FLAGS(ff) \ 84 ((((ff) & FRAME_LOWMEM) ? ZONE_LOWMEM : \ 85 (((ff) & FRAME_HIGHMEM) ? ZONE_HIGHMEM : ZONE_NONE)) | \ 86 (ZONE_AVAILABLE | ZONE_LOWMEM | ZONE_HIGHMEM)) 87 88 #define ZONE_FLAGS_MATCH(zf, f) \ 89 (((((zf) & ZONE_EF_MASK)) == ((f) & ZONE_EF_MASK)) && \ 90 (((zf) & ~ZONE_EF_MASK) & (f))) 75 91 76 92 typedef struct { … … 131 147 } 132 148 133 NO_TRACE static inline bool zone_flags_available(zone_flags_t flags)134 {135 return ((flags & (ZONE_RESERVED | ZONE_FIRMWARE)) == 0);136 }137 138 149 #define IS_BUDDY_ORDER_OK(index, order) \ 139 150 ((~(((sysarg_t) -1) << (order)) & (index)) == 0) -
kernel/generic/src/mm/frame.c
r19c8030 re6c4b94 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 … … 897 894 irq_spinlock_lock(&zones.lock, true); 898 895 899 if ( zone_flags_available(flags)) { /* Create available zone */896 if (flags & ZONE_AVAILABLE) { /* Create available zone */ 900 897 /* Theoretically we could have NULL here, practically make sure 901 898 * nobody tries to do that. If some platform requires, remove … … 1303 1300 *total += (uint64_t) FRAMES2SIZE(zones.info[i].count); 1304 1301 1305 if (zone _flags_available(zones.info[i].flags)) {1302 if (zones.info[i].flags & ZONE_AVAILABLE) { 1306 1303 *busy += (uint64_t) FRAMES2SIZE(zones.info[i].busy_count); 1307 1304 *free += (uint64_t) FRAMES2SIZE(zones.info[i].free_count); … … 1354 1351 irq_spinlock_unlock(&zones.lock, true); 1355 1352 1356 bool available = zone_flags_available(flags);1353 bool available = ((flags & ZONE_AVAILABLE) != 0); 1357 1354 1358 1355 printf("%-4zu", i); … … 1366 1363 #endif 1367 1364 1368 printf(" %12zu %c%c%c ", count, 1369 available ? 'A' : ' ', 1370 (flags & ZONE_RESERVED) ? 'R' : ' ', 1371 (flags & ZONE_FIRMWARE) ? 'F' : ' '); 1365 printf(" %12zu %c%c%c%c%c ", count, 1366 available ? 'A' : '-', 1367 (flags & ZONE_RESERVED) ? 'R' : '-', 1368 (flags & ZONE_FIRMWARE) ? 'F' : '-', 1369 (flags & ZONE_LOWMEM) ? 'L' : '-', 1370 (flags & ZONE_HIGHMEM) ? 'H' : '-'); 1372 1371 1373 1372 if (available) … … 1411 1410 irq_spinlock_unlock(&zones.lock, true); 1412 1411 1413 bool available = zone_flags_available(flags);1412 bool available = ((flags & ZONE_AVAILABLE) != 0); 1414 1413 1415 1414 uint64_t size; … … 1421 1420 printf("Zone size: %zu frames (%" PRIu64 " %s)\n", count, 1422 1421 size, size_suffix); 1423 printf("Zone flags: %c%c%c\n", 1424 available ? 'A' : ' ', 1425 (flags & ZONE_RESERVED) ? 'R' : ' ', 1426 (flags & ZONE_FIRMWARE) ? 'F' : ' '); 1422 printf("Zone flags: %c%c%c%c%c\n", 1423 available ? 'A' : '-', 1424 (flags & ZONE_RESERVED) ? 'R' : '-', 1425 (flags & ZONE_FIRMWARE) ? 'F' : '-', 1426 (flags & ZONE_LOWMEM) ? 'L' : '-', 1427 (flags & ZONE_HIGHMEM) ? 'H' : '-'); 1427 1428 1428 1429 if (available) {
Note:
See TracChangeset
for help on using the changeset viewer.