Library Pip.Model.MMU


Summary

Memory Management Unit : the specification of the translation of virtual memory addresses to physical addresses
The 'comparePageToNull' returns true if the given page is equal to the fixed default page (null)
The 'getIndexOfAddr' function returns the index of va that corresponds to l
Definition getIndexOfAddr (va : vaddr) (l : level) : LLI index:=
  ret ( nth ((length va) - (l + 2)) va defaultIndex ).

Definition readPhyEntry (paddr : page) (idx : index) : LLI page :=
  perform s := get in
  let entry := lookup paddr idx s.(memory) beqPage beqIndex in
  match entry with
  | Some (PE a) ⇒ ret a.(pa)
  | Some _undefined 9
  | Noneundefined 8
  end.

Definition readPresent (paddr : page) (idx : index) : LLI bool:=
perform s := get in
let entry := lookup paddr idx s.(memory) beqPage beqIndex in
match entry with
  | Some (PE a) ⇒ ret a.(present)
  | Some _undefined 18
  | Noneundefined 17
end.

Definition readAccessible (paddr : page) (idx : index) : LLI bool:=
perform s := get in
let entry := lookup paddr idx s.(memory) beqPage beqIndex in
match entry with
  | Some (PE a) ⇒ ret a.(user)
  | Some _undefined 12
  | Noneundefined 11
end.

The 'getTableAddrAux' returns the reference to the last page table
Fixpoint translateAux timeout (pd : page) (va : vaddr) (l : level) :=
  match timeout with
  | 0 ⇒ getDefaultPage
  |S timeout1
  perform isFstLevel := MALInternal.Level.eqb l fstLevel in
    if isFstLevel
    then ret pd
    else
      perform idx := getIndexOfAddr va l in
      perform addr := readPhyEntry pd idx in
      perform isNull := comparePageToNull addr in
      if isNull then getDefaultPage else
      perform p := MALInternal.Level.pred l in
      translateAux timeout1 addr va p
  end .

The 'translate'