Changeset a7a1063 in mainline for src/mm/frame.c
- Timestamp:
- 2005-06-07T00:41:39Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d896525
- Parents:
- b0bf501
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mm/frame.c
rb0bf501 ra7a1063 49 49 count_t frame_bitmap_octets; 50 50 51 /*52 * This is for kernel address space frames (allocated with FRAME_KA).53 * Their addresses may not interfere with user address space.54 */55 __u8 *frame_kernel_bitmap;56 count_t kernel_frames;57 count_t kernel_frames_free;58 59 51 static spinlock_t framelock; 60 52 … … 78 70 memsetb((__address) frame_bitmap, frame_bitmap_octets, 0); 79 71 frames_free = frames; 80 81 /*82 * Will be properly set up by architecture dependent frame init.83 */84 frame_kernel_bitmap = NULL;85 kernel_frames_free = 0;86 kernel_frames = 0;87 72 } 88 73 89 74 /* 90 * No frame allocations/reservations 75 * No frame allocations/reservations prior this point. 91 76 */ 92 77 … … 109 94 int i; 110 95 pri_t pri; 111 __u8 **frame_bitmap_ptr = &frame_bitmap;112 count_t *frames_ptr = &frames, *frames_free_ptr = &frames_free;113 114 if (flags & FRAME_KA) {115 frame_bitmap_ptr = &frame_kernel_bitmap;116 frames_ptr = &kernel_frames;117 frames_free_ptr = &kernel_frames_free;118 }119 96 120 97 loop: 121 98 pri = cpu_priority_high(); 122 99 spinlock_lock(&framelock); 123 if ( *frames_free_ptr) {124 for (i=0; i < *frames_ptr; i++) {100 if (frames_free) { 101 for (i=0; i < frames; i++) { 125 102 int m, n; 126 103 … … 128 105 n = i % 8; 129 106 130 if (((*frame_bitmap_ptr)[m] & (1<<n)) == 0) { 131 (*frame_bitmap_ptr)[m] |= (1<<n); 132 *frames_free_ptr--; 133 if (flags & FRAME_KA) { 134 /* 135 * frames_free_ptr points to kernel_frames_free 136 * It is still necessary to decrement frames_free. 137 */ 138 frames_free--; 139 } 107 if ((frame_bitmap[m] & (1<<n)) == 0) { 108 frame_bitmap[m] |= (1<<n); 109 frames_free--; 140 110 spinlock_unlock(&framelock); 141 111 cpu_priority_restore(pri); … … 165 135 pri_t pri; 166 136 __u32 frame; 167 count_t *frames_free_ptr = &frames_free, *frames_ptr = &frames;168 __u8 **frame_bitmap_ptr = &frame_bitmap;169 170 if (IS_KA(addr)) {171 frames_free_ptr = &kernel_frames_free;172 frame_bitmap_ptr = &frame_kernel_bitmap;173 }174 137 175 138 pri = cpu_priority_high(); … … 178 141 frame = IS_KA(addr) ? KA2PA(addr) : addr; 179 142 frame /= FRAME_SIZE; 180 if (frame < *frames_ptr) {143 if (frame < frames) { 181 144 int m, n; 182 145 … … 184 147 n = frame % 8; 185 148 186 if ((*frame_bitmap_ptr)[m] & (1<<n)) { 187 (*frame_bitmap_ptr)[m] &= ~(1<<n); 188 *frames_free_ptr++; 189 if (IS_KA(addr)) { 190 /* 191 * frames_free_ptr points to kernel_frames_free 192 * It is still necessary to increment frames_free. 193 */ 194 frames_free++; 195 } 149 if (frame_bitmap[m] & (1<<n)) { 150 frame_bitmap[m] &= ~(1<<n); 151 frames_free++; 196 152 } 197 153 else panic("frame already free\n"); … … 211 167 pri_t pri; 212 168 __u32 frame; 213 count_t *frames_ptr = &frames, *frames_free_ptr = &frames_free;214 __u8 **frame_bitmap_ptr = &frame_bitmap;215 169 216 170 pri = cpu_priority_high(); … … 218 172 frame = IS_KA(addr) ? KA2PA(addr) : addr; 219 173 frame /= FRAME_SIZE; 220 if (frame < *frames_ptr) {174 if (frame < frames) { 221 175 int m, n; 222 176 … … 224 178 n = frame % 8; 225 179 226 if (((*frame_bitmap_ptr)[m] & (1<<n)) == 0) { 227 (*frame_bitmap_ptr)[m] |= (1<<n); 228 *frames_free_ptr--; 229 if (IS_KA(addr)) { 230 /* 231 * frames_free_ptr points to kernel_frames_free 232 * It is still necessary to decrement frames_free. 233 */ 234 frames_free--; 235 } 180 if ((frame_bitmap[m] & (1<<n)) == 0) { 181 frame_bitmap[m] |= (1<<n); 182 frames_free--; 236 183 } 237 184 }
Note:
See TracChangeset
for help on using the changeset viewer.