-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Sorry, I have no idea how to add this or who needs it, but here is the code for free paging
var 4 start_pageList
var 4 hold_thisPage
---------------------------------Initialize Page List-------------------------
procedure 0 InitializePageList(4 fsp 4 pNum)
[4 iterator 4 fsp_next]{
fsp contains the address of the first free space
pNum is the number of pages total in the list
Page aligned, have to make some dead space
Add 1 to first twenty bits, then make last 12 bits 0
(= &fsp (>> fsp 12)) #push bits right
(= &fsp (+ fsp 1)) #increase the 13th bit
(= &fsp (<< fsp 12)) #push bits left
(= &start_pageList fsp) #Make page_head start where the free space pointer is
Loop through until we've reserved pNum pages
(= &iterator 1)
while((not(== iterator pNum))) {
(= &fsp_next (+ fsp 4096)) #fsp_next holds the next free page
(= fsp fsp_next) #first entry in fsp now contains the address of the next page
(= &fsp fsp_next) #fsp now holds the next page
(= &iterator (+ iterator 1))#Increment iterator/ We've added one more page
}
(= fsp 0) #Pointer is now at the last page, so make the first thing in that page 0 to signify that it's the last page
}
procedure 4 NextPage()[4 current_pointer]{
need to give a free page to the kernel and take it off the linked list. before giving it to the kernel need to wipe it.
(= ¤t_pointer start_pageList) #current_pointer has page to be given
(= &hold_thisPage start_pageList) #hold the page to be given
(= ¤t_pointer *(4)current_pointer) #second page in list given to current
(= &start_pageList current_pointer) #update new head of linked list
(= ¤t_pointer hold_thisPage) #current has page to be given
while((not(== current_pointer (+ hold_thisPage 4096)))){ #wipes the page to be given clean,
(= current_pointer 0)
(= ¤t_pointer (+ current_pointer 4))
}
return hold_thisPage
}
procedure 0 ReturnPage(4 p_add)[]{
get an address and add it back to the front of the linked list.
(= p_add start_pageList) #old head now points to added page
(= &start_pageList p_add) #update the head
}