HelenOS sources
This source file includes following definitions.
- thash
- ttag
- rr_read
- rr_write
- pta_read
- pta_write
#ifndef KERN_ia64_PAGE_H_
#define KERN_ia64_PAGE_H_
#include <arch/mm/frame.h>
#include <arch/register.h>
#ifndef __ASSEMBLER__
#include <assert.h>
#endif
#define PAGE_SIZE FRAME_SIZE
#define PAGE_WIDTH FRAME_WIDTH
#define KERNEL_PAGE_WIDTH 28
#define PPN_SHIFT 12
#define VRN_SHIFT 61
#define VRN_MASK (7ULL << VRN_SHIFT)
#define VA2VRN(va) ((va) >> VRN_SHIFT)
#ifdef __ASSEMBLER__
#define VRN_KERNEL 7
#else
#define VRN_KERNEL 7ULL
#endif
#define REGION_REGISTERS 8
#define KA2PA(x) (((uintptr_t) (x)) - (VRN_KERNEL << VRN_SHIFT))
#define PA2KA(x) (((uintptr_t) (x)) + (VRN_KERNEL << VRN_SHIFT))
#define VHPT_WIDTH 20
#define VHPT_SIZE (1 << VHPT_WIDTH)
#define PTA_BASE_SHIFT 15
#define MA_WRITEBACK 0x00
#define MA_UNCACHEABLE 0x04
#define PL_KERNEL PSR_CPL_KERNEL
#define PL_USER PSR_CPL_USER
#define AR_READ 0x00
#define AR_EXECUTE 0x01
#define AR_WRITE 0x02
#ifndef __ASSEMBLER__
#include <arch/mm/as.h>
#include <arch/mm/frame.h>
#include <arch/interrupt.h>
#include <barrier.h>
#include <arch/mm/asid.h>
#include <typedefs.h>
#include <debug.h>
struct vhpt_tag_info {
unsigned long long tag : 63;
unsigned int ti : 1;
} __attribute__((packed));
union vhpt_tag {
struct vhpt_tag_info tag_info;
unsigned tag_word;
};
struct vhpt_entry_present {
unsigned int p : 1;
unsigned int : 1;
unsigned int ma : 3;
unsigned int a : 1;
unsigned int d : 1;
unsigned int pl : 2;
unsigned int ar : 3;
unsigned long long ppn : 38;
unsigned int : 2;
unsigned int ed : 1;
unsigned int ig1 : 11;
unsigned int : 2;
unsigned int ps : 6;
unsigned int key : 24;
unsigned int : 32;
union vhpt_tag tag;
uint64_t ig3 : 64;
} __attribute__((packed));
struct vhpt_entry_not_present {
unsigned int p : 1;
unsigned long long ig0 : 52;
unsigned int ig1 : 11;
unsigned int : 2;
unsigned int ps : 6;
unsigned long long ig2 : 56;
union vhpt_tag tag;
uint64_t ig3 : 64;
} __attribute__((packed));
typedef union {
struct vhpt_entry_present present;
struct vhpt_entry_not_present not_present;
uint64_t word[4];
} vhpt_entry_t;
struct region_register_map {
unsigned int ve : 1;
unsigned int : 1;
unsigned int ps : 6;
unsigned int rid : 24;
unsigned int : 32;
} __attribute__((packed));
typedef union {
struct region_register_map map;
unsigned long long word;
} region_register_t;
struct pta_register_map {
unsigned int ve : 1;
unsigned int : 1;
unsigned int size : 6;
unsigned int vf : 1;
unsigned int : 6;
unsigned long long base : 49;
} __attribute__((packed));
typedef union pta_register {
struct pta_register_map map;
uint64_t word;
} pta_register_t;
_NO_TRACE static inline uint64_t thash(uint64_t va)
{
uint64_t ret;
asm volatile (
"thash %[ret] = %[va]\n"
: [ret] "=r" (ret)
: [va] "r" (va)
);
return ret;
}
_NO_TRACE static inline uint64_t ttag(uint64_t va)
{
uint64_t ret;
asm volatile (
"ttag %[ret] = %[va]\n"
: [ret] "=r" (ret)
: [va] "r" (va)
);
return ret;
}
_NO_TRACE static inline uint64_t rr_read(size_t i)
{
uint64_t ret;
assert(i < REGION_REGISTERS);
asm volatile (
"mov %[ret] = rr[%[index]]\n"
: [ret] "=r" (ret)
: [index] "r" (i << VRN_SHIFT)
);
return ret;
}
_NO_TRACE static inline void rr_write(size_t i, uint64_t v)
{
assert(i < REGION_REGISTERS);
asm volatile (
"mov rr[%[index]] = %[value]\n"
:: [index] "r" (i << VRN_SHIFT),
[value] "r" (v)
);
}
_NO_TRACE static inline uint64_t pta_read(void)
{
uint64_t ret;
asm volatile (
"mov %[ret] = cr.pta\n"
: [ret] "=r" (ret)
);
return ret;
}
_NO_TRACE static inline void pta_write(uint64_t v)
{
asm volatile (
"mov cr.pta = %[value]\n"
:: [value] "r" (v)
);
}
extern void page_arch_init(void);
extern vhpt_entry_t *vhpt_hash(uintptr_t page, asid_t asid);
extern bool vhpt_compare(uintptr_t page, asid_t asid, vhpt_entry_t *v);
extern void vhpt_set_record(vhpt_entry_t *v, uintptr_t page, asid_t asid, uintptr_t frame, int flags);
#endif
#endif
HelenOS homepage, sources at GitHub