HelenOS sources
This source file includes following definitions.
- set_ptl0_addr
- set_ptl1_addr
- set_ptl3_addr
#ifndef KERN_arm32_PAGE_H_
#define KERN_arm32_PAGE_H_
#include <arch/mm/frame.h>
#include <mm/mm.h>
#include <arch/exception.h>
#include <barrier.h>
#include <arch/barrier.h>
#include <arch/cp15.h>
#include <trace.h>
#define PAGE_WIDTH FRAME_WIDTH
#define PAGE_SIZE FRAME_SIZE
#if (defined MACHINE_beagleboardxm) || (defined MACHINE_beaglebone)
#ifndef __ASSEMBLER__
# define KA2PA(x) ((uintptr_t) (x))
# define PA2KA(x) ((uintptr_t) (x))
#else
# define KA2PA(x) (x)
# define PA2KA(x) (x)
#endif
#else
#ifndef __ASSEMBLER__
# define KA2PA(x) (((uintptr_t) (x)) - 0x80000000)
# define PA2KA(x) (((uintptr_t) (x)) + 0x80000000)
#else
# define KA2PA(x) ((x) - 0x80000000)
# define PA2KA(x) ((x) + 0x80000000)
#endif
#endif
#define PTL0_ENTRIES_ARCH (1 << 12)
#define PTL1_ENTRIES_ARCH 0
#define PTL2_ENTRIES_ARCH 0
#define PTL3_ENTRIES_ARCH (1 << 8)
#define PTL0_FRAMES_ARCH 4
#define PTL1_FRAMES_ARCH 1
#define PTL2_FRAMES_ARCH 1
#define PTL3_FRAMES_ARCH 1
#define PTL0_INDEX_ARCH(vaddr) (((vaddr) >> 20) & 0xfff)
#define PTL1_INDEX_ARCH(vaddr) 0
#define PTL2_INDEX_ARCH(vaddr) 0
#define PTL3_INDEX_ARCH(vaddr) (((vaddr) >> 12) & 0x0ff)
#define GET_PTL1_ADDRESS_ARCH(ptl0, i) \
((pte_t *) ((((pte_t *)(ptl0))[(i)].l0).coarse_table_addr << 10))
#define GET_PTL2_ADDRESS_ARCH(ptl1, i) \
(ptl1)
#define GET_PTL3_ADDRESS_ARCH(ptl2, i) \
(ptl2)
#define GET_FRAME_ADDRESS_ARCH(ptl3, i) \
((uintptr_t) ((((pte_t *)(ptl3))[(i)].l1).frame_base_addr << 12))
#define SET_PTL0_ADDRESS_ARCH(ptl0) \
set_ptl0_addr((pte_t *) (ptl0))
#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \
set_ptl1_addr((pte_t*) (ptl0), i, a)
#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \
set_ptl3_addr((pte_t*) (ptl3), i, a)
#define GET_PTL1_FLAGS_ARCH(ptl0, i) \
get_pt_level0_flags((pte_t *) (ptl0), (size_t) (i))
#define GET_PTL2_FLAGS_ARCH(ptl1, i) \
PAGE_PRESENT
#define GET_PTL3_FLAGS_ARCH(ptl2, i) \
PAGE_PRESENT
#define GET_FRAME_FLAGS_ARCH(ptl3, i) \
get_pt_level1_flags((pte_t *) (ptl3), (size_t) (i))
#define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \
set_pt_level0_flags((pte_t *) (ptl0), (size_t) (i), (x))
#define SET_PTL2_FLAGS_ARCH(ptl1, i, x)
#define SET_PTL3_FLAGS_ARCH(ptl2, i, x)
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \
set_pt_level1_flags((pte_t *) (ptl3), (size_t) (i), (x))
#define SET_PTL1_PRESENT_ARCH(ptl0, i) \
set_pt_level0_present((pte_t *) (ptl0), (size_t) (i))
#define SET_PTL2_PRESENT_ARCH(ptl1, i)
#define SET_PTL3_PRESENT_ARCH(ptl2, i)
#define SET_FRAME_PRESENT_ARCH(ptl3, i) \
set_pt_level1_present((pte_t *) (ptl3), (size_t) (i))
#define pt_coherence(page) pt_coherence_m(page, 1)
#if defined(PROCESSOR_ARCH_armv6) | defined(PROCESSOR_ARCH_armv7_a)
#include "page_armv6.h"
#elif defined(PROCESSOR_ARCH_armv4) | defined(PROCESSOR_ARCH_armv5)
#include "page_armv4.h"
#else
#error "Unsupported architecture"
#endif
_NO_TRACE static inline void set_ptl0_addr(pte_t *pt)
{
uint32_t val = (uint32_t)pt & TTBR_ADDR_MASK;
#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
val |= TTBR_RGN_WBWA_CACHE | TTBR_C_FLAG;
#endif
TTBR0_write(val);
#if defined(PROCESSOR_ARCH_armv6) || defined(PROCESSOR_ARCH_armv7_a)
BPIALL_write(0);
#endif
}
_NO_TRACE static inline void set_ptl1_addr(pte_t *pt, size_t i, uintptr_t address)
{
pt[i].l0.coarse_table_addr = address >> 10;
pt_coherence(&pt[i].l0);
}
_NO_TRACE static inline void set_ptl3_addr(pte_t *pt, size_t i, uintptr_t address)
{
pt[i].l1.frame_base_addr = address >> 12;
pt_coherence(&pt[i].l1);
}
#endif
HelenOS homepage, sources at GitHub