My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
page_table.c File Reference
#include <sw_types.h>
#include <sw_debug.h>
#include <sw_assert.h>
#include <sw_mem_functions.h>
#include <cache.h>
#include <cpu_mmu.h>
#include <page_table.h>
#include <mem_mng.h>
#include <global.h>
#include <sw_list.h>
#include <uart.h>
#include <sw_board.h>
#include <cpu_data.h>
#include <sw_buddy.h>
#include <unused.h>
#include <ptf.h>

Functions

u32 * get_secure_ptd (void)
 Get secure page table pointer. More...
 
void sw_seterrno (int x)
 
int mem_kunmap (va_t va, va_t size)
 
int mem_kmap (va_t va, pa_t pa, va_t size)
 
u32 * map_secure_page_table (void)
 Initialize page table entries. More...
 
int map_to_secure (pa_t phy_addr, va_t va_addr)
 
int __map_to_ns (pa_t phy_addr, va_t *va_addr)
 Create shared memory mapping between secure and non-secure kernel. More...
 
int ns_map (pa_t phy_addr, va_t *va_addr, pa_t size)
 Wrapper function for __map_to_ns. More...
 
int map_device (va_t va, pa_t pa, u32 size)
 Map devices. More...
 
int map_user_access_device (va_t va, pa_t pa, u32 size)
 Map user access devices. More...
 
int map_device_table (const struct devmap *dt)
 Map device table. More...
 
int map_user_access_device_table (const struct devmap *dt)
 Map User Access device table. More...
 
int map_secure_memory (va_t va, pa_t pa, u32 size, u32 ptf)
 Map a range of secure memory area. More...
 
int unmap_secure_memory (va_t va, u32 size)
 Unmap a range of secure memory area. More...
 
int map_nsmemsect_normal (va_t va, pa_t pa, u32 size)
 Map a range of non secure memory area as normal memory with attributes Outer and Inner write back, write allocate. More...
 
int unmap_nsmemsect_normal (va_t va, u32 size)
 Unmap a range of non secure memory area. More...
 
int map_section_entry (u32 *pgd, struct cpu_section *entry)
 Create a section map entry. More...
 
int map_ns_section_entry (u32 *pgd, struct cpu_section *entry)
 Map the non-secure memory in secure page table for shared memory access. More...
 
int unmap_section_entry (u32 *pgd, va_t va)
 
int unmap_ns_section_entry (u32 *pgd, va_t va)
 Unmap the shared section entry from secure page table. More...
 
int unmap_from_secure (va_t va_addr)
 
int __unmap_from_ns (va_t va_addr)
 Unmap the non-secure memory from secure page table. More...
 
int mem_ns_unmap (va_t va_addr, pa_t size)
 Wrapper function for __unmap_from_ns. More...
 
int page_ref_add (u32 l1_pte)
 Increment page table reference of shared memory. More...
 
int page_ref_release (u32 l1_pte)
 Decrement page table reference of shared memory. More...
 

Function Documentation

int __map_to_ns ( pa_t  phy_addr,
va_t *  va_addr 
)

Create shared memory mapping between secure and non-secure kernel.

This function creates the page table entry with ns bit set. So that this section of the non-secure memory act like a shared memory.

Parameters
phy_addrPhysical address of the non-secure memory
va_addrVirtual address of the shared memory
Returns
otz_return_t: OTZ_OK
OTZ_FAIL
int __unmap_from_ns ( va_t  va_addr)

Unmap the non-secure memory from secure page table.

This function unmaps the non-secure memory from secure page table. i.e. set 'NS' bit to zero

Parameters
va_addrVirtual address to be unmapped
Returns
otz_return_t: OTZ_OK
u32* get_secure_ptd ( void  )

Get secure page table pointer.

Returns the secure page table pointer.

This function returns the page table pointer

Returns
Pointer to the page table
int map_device ( va_t  va,
pa_t  pa,
u32  size 
)

Map devices.

This function assumes that the start address and size are section aligned.

Parameters
va: virtual address
pa: physical address
size: size
Returns
otz_return_t : OTZ_OK
OTZ_FAIL
int map_device_table ( const struct devmap dt)

Map device table.

Parameters
dtpointer to array of device mappings Array has to terminated with zero.
Returns
otz_return_t: OTZ_OK
OTZ_FAIL
int map_ns_section_entry ( u32 *  pgd,
struct cpu_section entry 
)

Map the non-secure memory in secure page table for shared memory access.

This function creates the section mapping with 'NS' bit set to create a shared memory access.

Parameters
pgdPointer to page table
entryPointer to section entry
Returns
otz_return_t: OTZ_OK
OTZ_FAIL
int map_nsmemsect_normal ( va_t  va,
pa_t  pa,
u32  size 
)

Map a range of non secure memory area as normal memory with attributes Outer and Inner write back, write allocate.

This function assumes that the start address and size are section aligned.

Parameters
vavirtual address
paphysical address
sizesize
Returns
otz_return_t: OTZ_OK
OTZ_FAIL
int map_section_entry ( u32 *  pgd,
struct cpu_section entry 
)

Create a section map entry.

This function creates section map entry in supplied page table

Parameters
pgdPointer to page table
entryPointer to section entry
Returns
otz_return_t: OTZ_OK
OTZ_FAIL
int map_secure_memory ( va_t  va,
pa_t  pa,
u32  size,
u32  ptf 
)

Map a range of secure memory area.

Map a range of secure memory.

This function assumes that the start address and size are section aligned.

Parameters
va: virtual address
pa: physical address
size: size
ptf: page table flag
Returns
otz_return_t : OTZ_OK
OTZ_FAIL
u32* map_secure_page_table ( void  )

Initialize page table entries.

This function creates the initial page table entries for secure kernel

Returns
Pointer to the page table
int map_to_secure ( pa_t  phy_addr,
va_t  va_addr 
)
Parameters
phy_addr
va_addr
Returns
int map_user_access_device ( va_t  va,
pa_t  pa,
u32  size 
)

Map user access devices.

This function assumes that the start address and size are section aligned.

Parameters
va: virtual address
pa: physical address
size: size
Returns
otz_return_t : OTZ_OK
OTZ_FAIL
int map_user_access_device_table ( const struct devmap dt)

Map User Access device table.

Parameters
dtpointer to array of device mappings Array has to terminated with zero.
Returns
otz_return_t: OTZ_OK
OTZ_FAIL
int mem_kmap ( va_t  va,
pa_t  pa,
va_t  size 
)
int mem_kunmap ( va_t  va,
va_t  size 
)
int mem_ns_unmap ( va_t  va_addr,
pa_t  size 
)

Wrapper function for __unmap_from_ns.

Parameters
va_addr
Returns
int ns_map ( pa_t  phy_addr,
va_t *  va_addr,
pa_t  size 
)

Wrapper function for __map_to_ns.

Parameters
phy_addr
va_addr
Returns
int page_ref_add ( u32  l1_pte)

Increment page table reference of shared memory.

This function increment the reference count of mapped shared memory

Parameters
l1_ptePage table entry
Returns
otz_return_t: OTZ_OK
OTZ_FAIL
int page_ref_release ( u32  l1_pte)

Decrement page table reference of shared memory.

This function decrement the reference count of mapped shared memory

Parameters
l1_ptePage table entry
Returns
otz_return_t: OTZ_OK
OTZ_FAIL
void sw_seterrno ( int  x)
int unmap_from_secure ( va_t  va_addr)
Parameters
va_addr
Returns
int unmap_ns_section_entry ( u32 *  pgd,
va_t  va 
)

Unmap the shared section entry from secure page table.

This function unmaps the secure memory section from secure page table. i.e. set 'NS' bit to zero

Parameters
pgdPointer to page table
vaVirtual address to be unmapped
Returns
otz_return_t: OTZ_OK
int unmap_nsmemsect_normal ( va_t  va,
u32  size 
)

Unmap a range of non secure memory area.

This function assumes that the start address and size are section aligned.

Parameters
vavirtual address
sizesize
Returns
otz_return_t: OTZ_OK
OTZ_FAIL
int unmap_section_entry ( u32 *  pgd,
va_t  va 
)
Parameters
pgd
va
Returns
int unmap_secure_memory ( va_t  va,
u32  size 
)

Unmap a range of secure memory area.

This function assumes that the start address and size are section aligned.

Parameters
vavirtual address
sizesize
Returns
otz_return_t: OTZ_OK
OTZ_FAIL