Squash commits for public release
This commit is contained in:
42
kernel/include/mem/bits/mmu.h
Normal file
42
kernel/include/mem/bits/mmu.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _KERNEL_MEM_BITS_MMU_H
|
||||
#define _KERNEL_MEM_BITS_MMU_H
|
||||
|
||||
#include <libkern/types.h>
|
||||
|
||||
enum MMU_FLAGS {
|
||||
MMU_FLAG_PERM_WRITE = (1 << 0),
|
||||
MMU_FLAG_PERM_READ = (1 << 1),
|
||||
MMU_FLAG_PERM_EXEC = (1 << 2),
|
||||
MMU_FLAG_UNCACHED = (1 << 3),
|
||||
MMU_FLAG_NONPRIV = (1 << 4),
|
||||
MMU_FLAG_INVALID = (1 << 5),
|
||||
MMU_FLAG_COW = (1 << 6), // TODO: Remove this flag.
|
||||
MMU_FLAG_HUGE_PAGE = (1 << 7),
|
||||
MMU_FLAG_DEVICE = MMU_FLAG_PERM_READ | MMU_FLAG_PERM_WRITE | MMU_FLAG_UNCACHED,
|
||||
};
|
||||
typedef uint32_t mmu_flags_t;
|
||||
|
||||
enum MMU_PF_INFO_FLAGS {
|
||||
MMU_PF_INFO_ON_NOT_PRESENT = (1 << 0),
|
||||
MMU_PF_INFO_ON_WRITE = (1 << 1),
|
||||
MMU_PF_INFO_ON_NONPRIV_ACCESS = (1 << 2),
|
||||
MMU_PF_INFO_SECURITY_VIOLATION = (1 << 3),
|
||||
};
|
||||
typedef uint32_t mmu_pf_info_flags_t;
|
||||
|
||||
enum PTABLE_LEVELS {
|
||||
PTABLE_LV0 = 0,
|
||||
PTABLE_LV1 = 1,
|
||||
PTABLE_LV2 = 2,
|
||||
PTABLE_LV3 = 3,
|
||||
};
|
||||
typedef enum PTABLE_LEVELS ptable_lv_t;
|
||||
|
||||
enum PTABLE_ENTITY_STATES {
|
||||
PTABLE_ENTITY_PRESENT,
|
||||
PTABLE_ENTITY_INVALID,
|
||||
PTABLE_ENTITY_ALLOC, // For arm32 pspace, other targets never return this state.
|
||||
};
|
||||
typedef uint32_t ptable_state_t;
|
||||
|
||||
#endif // _KERNEL_MEM_BITS_MMU_H
|
||||
10
kernel/include/mem/bits/swap.h
Normal file
10
kernel/include/mem/bits/swap.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef _KERNEL_MEM_BITS_SWAP_H
|
||||
#define _KERNEL_MEM_BITS_SWAP_H
|
||||
|
||||
enum SWAP_TYPE {
|
||||
SWAP_TO_DEV,
|
||||
SWAP_DROP,
|
||||
SWAP_NOT_ALLOWED,
|
||||
};
|
||||
|
||||
#endif // _KERNEL_MEM_BITS_SWAP_H
|
||||
68
kernel/include/mem/bits/vm.h
Normal file
68
kernel/include/mem/bits/vm.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef _KERNEL_MEM_BITS_VM_H
|
||||
#define _KERNEL_MEM_BITS_VM_H
|
||||
|
||||
#include <libkern/types.h>
|
||||
#include <mem/bits/mmu.h>
|
||||
#include <platform/generic/vmm/consts.h>
|
||||
#include <platform/generic/vmm/mmu.h>
|
||||
|
||||
#ifndef VMM_LV2_ENTITY_COUNT
|
||||
#define VMM_LV2_ENTITY_COUNT (1)
|
||||
#endif
|
||||
|
||||
#ifndef VMM_LV3_ENTITY_COUNT
|
||||
#define VMM_LV3_ENTITY_COUNT (1)
|
||||
#endif
|
||||
|
||||
#ifndef PTABLE_LV2_VADDR_OFFSET
|
||||
#define PTABLE_LV2_VADDR_OFFSET (32)
|
||||
#endif
|
||||
|
||||
#ifndef PTABLE_LV3_VADDR_OFFSET
|
||||
#define PTABLE_LV3_VADDR_OFFSET (32)
|
||||
#endif
|
||||
|
||||
#define PTABLE_ENTITY_COUNT(lv) (ptable_entity_count_at_level[lv])
|
||||
#define PTABLE_SIZE(lv) (ptable_size_at_level[lv])
|
||||
#define IS_INDIVIDUAL_PER_DIR(index) (index < PTABLE_TOP_KERNEL_OFFSET || (index == VMM_OFFSET_IN_DIRECTORY(pspace_zone.start)))
|
||||
|
||||
typedef struct {
|
||||
ptable_entity_t entities[1];
|
||||
} ptable_t;
|
||||
|
||||
static const size_t ptable_entity_count_at_level[] = {
|
||||
[PTABLE_LV0] = VMM_LV0_ENTITY_COUNT,
|
||||
[PTABLE_LV1] = VMM_LV1_ENTITY_COUNT,
|
||||
[PTABLE_LV2] = VMM_LV2_ENTITY_COUNT,
|
||||
[PTABLE_LV3] = VMM_LV3_ENTITY_COUNT,
|
||||
};
|
||||
|
||||
static const size_t ptable_size_at_level[] = {
|
||||
[PTABLE_LV0] = VMM_LV0_ENTITY_COUNT * sizeof(ptable_entity_t),
|
||||
[PTABLE_LV1] = VMM_LV1_ENTITY_COUNT * sizeof(ptable_entity_t),
|
||||
[PTABLE_LV2] = VMM_LV2_ENTITY_COUNT * sizeof(ptable_entity_t),
|
||||
[PTABLE_LV3] = VMM_LV3_ENTITY_COUNT * sizeof(ptable_entity_t),
|
||||
};
|
||||
|
||||
static const size_t ptable_entity_vaddr_offset_at_level[] = {
|
||||
[PTABLE_LV0] = PTABLE_LV0_VADDR_OFFSET,
|
||||
[PTABLE_LV1] = PTABLE_LV1_VADDR_OFFSET,
|
||||
[PTABLE_LV2] = PTABLE_LV2_VADDR_OFFSET,
|
||||
[PTABLE_LV3] = PTABLE_LV3_VADDR_OFFSET,
|
||||
};
|
||||
|
||||
#define VM_VADDR_OFFSET_AT_LEVEL(vaddr, lv) ((vaddr >> ptable_entity_vaddr_offset_at_level[lv]) % ptable_entity_count_at_level[lv])
|
||||
|
||||
static inline ptable_lv_t lower_level(ptable_lv_t lv)
|
||||
{
|
||||
ASSERT(lv != PTABLE_LV0);
|
||||
return lv - 1;
|
||||
}
|
||||
|
||||
static inline ptable_lv_t upper_level(ptable_lv_t lv)
|
||||
{
|
||||
ASSERT(lv != PTABLE_LV_TOP);
|
||||
return lv + 1;
|
||||
}
|
||||
|
||||
#endif // _KERNEL_MEM_BITS_VM_H
|
||||
18
kernel/include/mem/bits/zone.h
Normal file
18
kernel/include/mem/bits/zone.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _KERNEL_MEM_BITS_ZONE_H
|
||||
#define _KERNEL_MEM_BITS_ZONE_H
|
||||
|
||||
#include <mem/bits/mmu.h>
|
||||
|
||||
enum ZONE_TYPES {
|
||||
ZONE_TYPE_NULL = 0x0,
|
||||
ZONE_TYPE_CODE = 0x1,
|
||||
ZONE_TYPE_DATA = 0x2,
|
||||
ZONE_TYPE_STACK = 0x4,
|
||||
ZONE_TYPE_BSS = 0x8,
|
||||
ZONE_TYPE_DEVICE = 0x10,
|
||||
ZONE_TYPE_MAPPED = 0x20,
|
||||
ZONE_TYPE_MAPPED_FILE_PRIVATLY = 0x40,
|
||||
ZONE_TYPE_MAPPED_FILE_SHAREDLY = 0x80,
|
||||
};
|
||||
|
||||
#endif // _KERNEL_MEM_BITS_ZONE_H
|
||||
Reference in New Issue
Block a user