Subversion Repositories HelenOS-historic

Rev

Rev 1 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 68
Line 69... Line 69...
69
                frames = config.memory_size / FRAME_SIZE;
69
                frames = config.memory_size / FRAME_SIZE;
70
                frame_bitmap_octets = frames / 8 + (frames % 8 > 0);
70
                frame_bitmap_octets = frames / 8 + (frames % 8 > 0);
71
 
71
 
72
                frame_bitmap = (__u8 *) malloc(frame_bitmap_octets);
72
                frame_bitmap = (__u8 *) malloc(frame_bitmap_octets);
73
                if (!frame_bitmap)
73
                if (!frame_bitmap)
74
                        panic(PANIC "malloc/frame_bitmap\n");
74
                        panic("malloc/frame_bitmap\n");
75
 
75
 
76
                /*
76
                /*
77
                 * Mark all frames free.
77
                 * Mark all frames free.
78
                 */
78
                 */
79
                memsetb((__address) frame_bitmap, frame_bitmap_octets, 0);
79
                memsetb((__address) frame_bitmap, frame_bitmap_octets, 0);
Line 142... Line 142...
142
                cpu_priority_restore(pri);
142
                cpu_priority_restore(pri);
143
                if (flags & FRAME_KA) return PA2KA(i*FRAME_SIZE);
143
                if (flags & FRAME_KA) return PA2KA(i*FRAME_SIZE);
144
                return i*FRAME_SIZE;
144
                return i*FRAME_SIZE;
145
            }
145
            }
146
        }
146
        }
147
        panic(PANIC "frames_free inconsistent (%d)\n", frames_free);
147
        panic("frames_free inconsistent (%d)\n", frames_free);
148
    }
148
    }
149
    spinlock_unlock(&framelock);
149
    spinlock_unlock(&framelock);
150
    cpu_priority_restore(pri);
150
    cpu_priority_restore(pri);
151
 
151
 
152
    if (flags & FRAME_PANIC)
152
    if (flags & FRAME_PANIC)
153
        panic(PANIC "unable to allocate frame\n");
153
        panic("unable to allocate frame\n");
154
       
154
       
155
    /* TODO: implement sleeping logic here */
155
    /* TODO: implement sleeping logic here */
156
    panic(PANIC "sleep not supported\n");
156
    panic("sleep not supported\n");
157
   
157
   
158
    goto loop;
158
    goto loop;
159
}
159
}
160
 
160
 
161
/*
161
/*
Line 193... Line 193...
193
                 * It is still necessary to increment frames_free.
193
                 * It is still necessary to increment frames_free.
194
                 */
194
                 */
195
                 frames_free++;
195
                 frames_free++;
196
            }  
196
            }  
197
        }
197
        }
198
        else panic(PANIC "frame_free: frame already free\n");
198
        else panic("frame_free: frame already free\n");
199
    }
199
    }
200
    else panic(PANIC "frame_free: frame number too big\n");
200
    else panic("frame_free: frame number too big\n");
201
   
201
   
202
    spinlock_unlock(&framelock);
202
    spinlock_unlock(&framelock);
203
    cpu_priority_restore(pri);
203
    cpu_priority_restore(pri);
204
}
204
}
205
 
205