mark_inaccessible should be finished. Initial skeleton for release_frames.
This commit is contained in:
parent
1c011508c1
commit
e655168599
1 changed files with 41 additions and 5 deletions
|
@ -259,7 +259,7 @@ unsigned long ContFramePool::get_frames(unsigned int _n_frames)
|
||||||
temp++;
|
temp++;
|
||||||
mask = 0x80;
|
mask = 0x80;
|
||||||
}
|
}
|
||||||
if((mask & bitmap[temp]) != 0 ^^ ((mask >> 1) & bitmap[temp]) != 0)
|
if((mask & bitmap[temp]) != 0 && ((mask >> 1) & bitmap[temp]) != 0)
|
||||||
{
|
{
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
@ -310,14 +310,50 @@ unsigned long ContFramePool::get_frames(unsigned int _n_frames)
|
||||||
void ContFramePool::mark_inaccessible(unsigned long _base_frame_no,
|
void ContFramePool::mark_inaccessible(unsigned long _base_frame_no,
|
||||||
unsigned long _n_frames)
|
unsigned long _n_frames)
|
||||||
{
|
{
|
||||||
// TODO: IMPLEMENTATION NEEEDED!
|
// Mark all frames in the range as being used.
|
||||||
assert(false);
|
int i ;
|
||||||
|
for(i = _base_frame_no; i < _base_frame_no + _n_frames; i++){
|
||||||
|
mark_inaccessible(i);
|
||||||
|
}
|
||||||
|
nFreeFrames -= _n_frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContFramePool::mark_inaccessible(unsigned long _frame_no)
|
||||||
|
{
|
||||||
|
// Let's first do a range check.
|
||||||
|
assert ((_frame_no >= base_frame_no) && (_frame_no < base_frame_no + nframes));
|
||||||
|
|
||||||
|
unsigned int bitmap_index = (_frame_no - base_frame_no) / 4;
|
||||||
|
unsigned char mask = 0x80 >> ((_frame_no - base_frame_no) % 4) * 2;
|
||||||
|
|
||||||
|
// Is the frame being used already?
|
||||||
|
assert(((bitmap[bitmap_index] & mask) != 0) && (bitmap[bitmap_index] & (mask >> 1)) != 0);
|
||||||
|
|
||||||
|
// Update bitmap
|
||||||
|
bitmap[bitmap_index] ^= mask;
|
||||||
|
bitmap[bitmap_index] ^= mask >> 1;
|
||||||
|
nFreeFrames--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ContFramePool::release_frames(unsigned long _first_frame_no)
|
void ContFramePool::release_frames(unsigned long _first_frame_no)
|
||||||
{
|
{
|
||||||
// TODO: IMPLEMENTATION NEEEDED!
|
|
||||||
assert(false);
|
// Find a way to find which pool has this frame.
|
||||||
|
|
||||||
|
unsigned int bitmap_index = (_first_frame_no - base_frame_no) / 4;
|
||||||
|
unsigned char mask = 0x80 >> ((_first_frame_no - base_frame_no) % 4) * 2;
|
||||||
|
|
||||||
|
if((bitmap[bitmap_index] & mask) != 0 && (bitmap[bitmap_index] & (mask >> 1)) != 0)
|
||||||
|
{
|
||||||
|
Console::puts("Error, Frame being released is not being used\n");
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bitmap[bitmap_index] ^= mask;
|
||||||
|
|
||||||
|
nFreeFrames++;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long ContFramePool::needed_info_frames(unsigned long _n_frames)
|
unsigned long ContFramePool::needed_info_frames(unsigned long _n_frames)
|
||||||
|
|
Reference in a new issue