17.01.2014 Views

The holy bible of SWEB - Institute of Applied Information Processing ...

The holy bible of SWEB - Institute of Applied Information Processing ...

The holy bible of SWEB - Institute of Applied Information Processing ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.4. INTERFACE & CLASSES CHAPTER 3. VM, PROTECTION AND PAGING<br />

uint32<br />

returns the next free physical page number<br />

getFreePhysicalPage(uint32 type); and marks that page as used. It takes<br />

one parameter "type", which should be either<br />

PAGE_USERSPACE, that is the default, or<br />

PAGE_KERNEL. Note that the type set in the<br />

PageManager does not influence the User/Supervisor<br />

Flag in the Page-Directory.<br />

void freePage(uint32 page_number); marks one physical page identified by its<br />

page_number as free, if it was marked as used<br />

in user or kernel context.<br />

void startUsingSyncMechanism(); to be called after initialising the KernelMemoryManager<br />

and before starting Interrupts to ensure<br />

Mutual Exclusion<br />

Table 3.6: PageManager Interface<br />

3.4.3 Implementation<br />

1 /∗∗<br />

2 ∗ @ f i l e PageManager . cpp<br />

3 ∗/<br />

4<br />

5 #include "mm/PageManager .h"<br />

6 #include "mm/new.h"<br />

7 #include " paging−definitions .h"<br />

8 #include " arch_panic .h"<br />

9 #include "ArchCommon.h"<br />

10 #include "ArchMemory.h"<br />

11 #include " debug_bochs .h"<br />

12 #include " console/kprintf .h"<br />

13 #include " ArchInterrupts .h"<br />

14 #include " assert .h"<br />

15<br />

16 PageManager∗ PageManager : : instance_ =0;<br />

17<br />

18 extern void∗ kernel_end_address ;<br />

19<br />

20 void PageManager : : createPageManager ( )<br />

21 {<br />

22 i f ( instance_ )<br />

23 return ;<br />

24<br />

25 instance_ = new PageManager ( ) ;<br />

26 }<br />

27<br />

28 PageManager : : PageManager ( )<br />

29 {<br />

30 number_<strong>of</strong>_pages_ = 0;<br />

31 lowest_unreserved_page_ = 256; //physical memory

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!