Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free paging #1

Open
ClapClapSnap opened this issue May 13, 2014 · 0 comments
Open

Free paging #1

ClapClapSnap opened this issue May 13, 2014 · 0 comments

Comments

@ClapClapSnap
Copy link

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.

(= &current_pointer start_pageList) #current_pointer has page to be given
(= &hold_thisPage start_pageList) #hold the page to be given
(= &current_pointer *(4)current_pointer) #second page in list given to current
(= &start_pageList current_pointer) #update new head of linked list
(= &current_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)
(= &current_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

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant