wiki:kernel_vmem

Version 1 (modified by alain, 10 years ago) (diff)

--

Virtual to Physical Address Translation

The vmem.c and vmem.h files define the data structures used by the boot-loader and the kernel to implement the paged virtual memory.

[PageOutline?]

The page table initialisation is statically done by the boot-loader. There is one page table for each vspace defined in the mapping. When the architecture is clusterised (X_WIDTH > 1 or Y_WIDTH > 1), for each vspace, the page table is replicated in each cluster.

The virtual address format is 32 bits: structured in 3 fields:

11 9 12
IX1 IX2 OFFSET
  • The IX1 field is the index in the first level page table
  • The IX2 field is the index in the second level page table.
  • The |IX1|IX2| concatenation defines the VPN (Virtual Page Number).

Two page sizes are supported:

  • BPP : Big Physical Page / 2 Mbytes
  • SPP : Small Physical pages / 4 Kbytes

unsigned int _v2p_translate( page_table_t* pt, unsigned int vpn, unsigned int* ppn, unsigned int* flags )

This function makes a VPN to PPN translation, from the page table defined by the pt pointer . The MMU is supposed to be activated. It supports both small (4 Kbytes) & big (2 Mbytes) pages. It uses the address extension mechanism for physical addressing. Return 0 if success. Return 1 if PTE1 or PTE2 unmapped.