Finished constructor (hopefully) and header.
This commit is contained in:
parent
56539db9e9
commit
9d18451b26
2 changed files with 70 additions and 2 deletions
|
@ -132,8 +132,66 @@ ContFramePool::ContFramePool(unsigned long _base_frame_no,
|
|||
unsigned long _info_frame_no,
|
||||
unsigned long _n_info_frames)
|
||||
{
|
||||
// TODO: IMPLEMENTATION NEEEDED!
|
||||
assert(false);
|
||||
// Bitmap must fit in a single frame!
|
||||
// NOTE: In theory, we don't need to make the bitmap any larger,
|
||||
// since as stated in the instructions it is already big enough to
|
||||
// hold for 128MB of memory with one bit per frame, so should still
|
||||
// be enough for 64MB of memory with 2 bits per frame.
|
||||
assert(_n_frames <= FRAME_SIZE * 8);
|
||||
|
||||
base_frame_no = _base_frame_no;
|
||||
nframes = _n_frames;
|
||||
nFreeFrames = _n_frames;
|
||||
info_frame_no = _info_frame_no;
|
||||
n_info_frames = _n_info_frames;
|
||||
|
||||
// If _info_frame_no is zero then we keep management info in the first
|
||||
// frame(s), else we use the provided frame(s) to keep management info
|
||||
// NOTE: need a second check for the number of info frames specified, if any.
|
||||
if(info_frame_no == 0)
|
||||
{
|
||||
if(n_info_frames == 0)
|
||||
{
|
||||
bitmap = (unsigned char *) (base_frame_no * FRAME_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap = (unsigned char *) (base_frame_no * FRAME_SIZE * n_info_frames);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(n_info_frames == 0)
|
||||
{
|
||||
bitmap = (unsigned char *) (info_frame_no * FRAME_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap = (unsigned char *) (info_frame_no * FRAME_SIZE * n_info_frames);
|
||||
}
|
||||
}
|
||||
|
||||
// Number of frames must "fill" the bitmap!
|
||||
assert ((nframes % 8 ) == 0);
|
||||
|
||||
|
||||
// Everything ok. Proceed to mark all bits in the bitmap
|
||||
// NOTE: I don't think this needs to be changed...
|
||||
for(int i=0; i*8 < _n_frames; i++)
|
||||
{
|
||||
bitmap[i] = 0xFF;
|
||||
}
|
||||
|
||||
// Mark the first frame as being used if it is being used
|
||||
// NOTE: need to mark multiple frames if needed.
|
||||
unsigned long i = info_frame_no;
|
||||
while(i < (info_frame_no + n_info_frames))
|
||||
{
|
||||
bitmap[i*8] = 0x7F;
|
||||
nFreeFrames--;
|
||||
}
|
||||
|
||||
Console::puts("Frame Pool initialized\n");
|
||||
}
|
||||
|
||||
unsigned long ContFramePool::get_frames(unsigned int _n_frames)
|
||||
|
|
|
@ -43,6 +43,16 @@ class ContFramePool {
|
|||
private:
|
||||
/* -- DEFINE YOUR CONT FRAME POOL DATA STRUCTURE(s) HERE. */
|
||||
|
||||
unsigned char * bitmap; // Remember the bitmap here needs 2 bits per frame
|
||||
unsigned int nFreeFrames; //
|
||||
unsigned long base_frame_no; // Where does the frame pool start in phys mem?
|
||||
unsigned long nframes; // Size of the frame pool
|
||||
unsigned long info_frame_no; // Where do we store the management information?
|
||||
unsigned long n_info_frames; // Number of frames needed to store management info
|
||||
|
||||
void mark_inaccessible(unsigned long _frame_no); // Should be a frame marked as
|
||||
// a head, otherwise fails
|
||||
|
||||
public:
|
||||
|
||||
// The frame size is the same as the page size, duh...
|
||||
|
|
Reference in a new issue