Changeset 50177dcd in mainline
- Timestamp:
- 2011-11-24T22:44:25Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9aed144
- Parents:
- 25c51c8
- Location:
- kernel/arch/sparc64/src/mm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/mm/sun4u/frame.c
r25c51c8 r50177dcd 41 41 #include <macros.h> 42 42 43 // TODO: remove me 43 44 uintptr_t last_frame = (uintptr_t) NULL; 44 45 … … 47 48 * Walk the memory map and create frame zones according to it. 48 49 */ 49 void frame_low_arch_init(void)50 static void frame_common_arch_init(bool low) 50 51 { 51 if (config.cpu_active == 1) { 52 unsigned int i; 52 unsigned int i; 53 54 for (i = 0; i < memmap.cnt; i++) { 55 uintptr_t base; 56 size_t size; 57 58 /* 59 * The memmap is created by HelenOS boot loader. 60 * It already contains no holes. 61 */ 62 63 /* To be safe, make the available zone possibly smaller */ 64 base = ALIGN_UP((uintptr_t) memmap.zones[i].start, FRAME_SIZE); 65 size = ALIGN_DOWN(memmap.zones[i].size - 66 (base - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE); 53 67 54 for (i = 0; i < memmap.cnt; i++) { 55 /* To be safe, make the available zone possibly smaller */ 56 uintptr_t new_start = ALIGN_UP((uintptr_t) memmap.zones[i].start, 57 FRAME_SIZE); 58 size_t new_size = ALIGN_DOWN(memmap.zones[i].size - 59 (new_start - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE); 60 61 /* 62 * The memmap is created by HelenOS boot loader. 63 * It already contains no holes. 64 */ 65 66 pfn_t confdata = ADDR2PFN(new_start); 67 68 // TODO: remove me 69 last_frame = max(last_frame, base + size); 70 71 if (!frame_adjust_zone_bounds(low, &base, &size)) 72 continue; 73 74 pfn_t confdata; 75 pfn_t pfn = ADDR2PFN(base); 76 size_t count = SIZE2FRAMES(size); 77 78 if (low) { 79 confdata = pfn; 68 80 if (confdata == ADDR2PFN(KA2PA(PFN2ADDR(0)))) 69 81 confdata = ADDR2PFN(KA2PA(PFN2ADDR(2))); 70 82 71 zone_create(ADDR2PFN(new_start), SIZE2FRAMES(new_size), 72 confdata, 0); 73 74 last_frame = max(last_frame, new_start + new_size); 83 zone_create(pfn, count, confdata, 84 ZONE_AVAILABLE | ZONE_LOWMEM); 85 } else { 86 confdata = zone_external_conf_alloc(count); 87 zone_create(pfn, count, confdata, 88 ZONE_AVAILABLE | ZONE_HIGHMEM); 75 89 } 90 } 76 91 77 /* 78 * On sparc64, physical memory can start on a non-zero address. 79 * The generic frame_init() only marks PFN 0 as not free, so we 80 * must mark the physically first frame not free explicitly 81 * here, no matter what is its address. 82 */ 83 frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1); 84 } 92 } 93 94 void frame_low_arch_init(void) 95 { 96 if (config.cpu_active > 1) 97 return; 98 99 frame_common_arch_init(true); 100 101 /* 102 * On sparc64, physical memory can start on a non-zero address. 103 * The generic frame_init() only marks PFN 0 as not free, so we 104 * must mark the physically first frame not free explicitly 105 * here, no matter what is its address. 106 */ 107 frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1); 85 108 86 109 end_of_identity = PA2KA(last_frame); … … 89 112 void frame_high_arch_init(void) 90 113 { 114 if (config.cpu_active > 1) 115 return; 116 117 frame_common_arch_init(false); 91 118 } 92 119 -
kernel/arch/sparc64/src/mm/sun4v/frame.c
r25c51c8 r50177dcd 45 45 * Walk the memory map and create frame zones according to it. 46 46 */ 47 void frame_low_arch_init(void)47 static void frame_common_arch_init(bool low) 48 48 { 49 if (config.cpu_active == 1) { 50 unsigned int i; 49 unsigned int i; 51 50 52 for (i = 0; i < memmap.cnt; i++) { 53 /* To be safe, make the available zone possibly smaller */ 54 uintptr_t new_start = ALIGN_UP((uintptr_t) memmap.zones[i].start, 55 FRAME_SIZE); 56 size_t new_size = ALIGN_DOWN(memmap.zones[i].size - 57 (new_start - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE); 58 59 /* 60 * The memmap is created by HelenOS boot loader. 61 * It already contains no holes. 62 */ 63 64 pfn_t confdata = ADDR2PFN(new_start); 65 51 for (i = 0; i < memmap.cnt; i++) { 52 uintptr_t base; 53 size_t size; 54 55 /* 56 * The memmap is created by HelenOS boot loader. 57 * It already contains no holes. 58 */ 59 60 /* To be safe, make the available zone possibly smaller */ 61 base = ALIGN_UP((uintptr_t) memmap.zones[i].start, FRAME_SIZE); 62 size = ALIGN_DOWN(memmap.zones[i].size - 63 (base - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE); 64 65 if (!frame_adjust_zone_bounds(low, &base, &size)) 66 continue; 67 68 pfn_t confdata; 69 pfn_t pfn = ADDR2PFN(base); 70 size_t count = SIZE2FRAMES(size); 71 72 if (low) { 73 confdata = pfn; 66 74 if (confdata == ADDR2PFN(KA2PA(PFN2ADDR(0)))) 67 75 confdata = ADDR2PFN(KA2PA(PFN2ADDR(2))); 68 76 69 zone_create(ADDR2PFN(new_start), SIZE2FRAMES(new_size), 70 confdata, 0); 77 zone_create(pfn, count, confdata, 78 ZONE_AVAILABLE | ZONE_LOWMEM); 79 } else { 80 confdata = zone_external_conf_alloc(count); 81 zone_create(pfn, count, confdata, 82 ZONE_AVAILABLE | ZONE_HIGHMEM); 71 83 } 84 } 72 85 73 /* 74 * On sparc64, physical memory can start on a non-zero address. 75 * The generic frame_init() only marks PFN 0 as not free, so we 76 * must mark the physically first frame not free explicitly 77 * here, no matter what is its address. 78 */ 79 frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1); 80 } 86 } 87 88 89 void frame_low_arch_init(void) 90 { 91 if (config.cpu_active > 1) 92 return; 93 94 frame_common_arch_init(true); 95 96 /* 97 * On sparc64, physical memory can start on a non-zero address. 98 * The generic frame_init() only marks PFN 0 as not free, so we 99 * must mark the physically first frame not free explicitly 100 * here, no matter what is its address. 101 */ 102 frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1); 81 103 } 82 104 83 105 void frame_high_arch_init(void) 84 106 { 107 if (config.cpu_active > 1) 108 return; 109 110 frame_common_arch_init(false); 85 111 } 86 112
Note:
See TracChangeset
for help on using the changeset viewer.