1/*
2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors.
3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com>
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#ifndef _KERNEL_MEM_BITS_VM_H
10#define _KERNEL_MEM_BITS_VM_H
11
12#include <platform/generic/vmm/consts.h>
13#include <platform/generic/vmm/pde.h>
14#include <platform/generic/vmm/pte.h>
15
16#define pdir_t pdirectory_t
17#define VMM_TOTAL_PAGES_PER_TABLE VMM_PTE_COUNT
18#define VMM_TOTAL_TABLES_PER_DIRECTORY VMM_PDE_COUNT
19#define PDIR_SIZE sizeof(pdirectory_t)
20#define PTABLE_SIZE sizeof(ptable_t)
21#define IS_INDIVIDUAL_PER_DIR(index) (index < VMM_KERNEL_TABLES_START || (index == VMM_OFFSET_IN_DIRECTORY(pspace_zone.start)))
22
23enum PTABLE_LEVELS {
24 PTABLE_LV0 = 1,
25 PTABLE_LV1 = 2,
26 PTABLE_LV2 = 3,
27 PTABLE_LV3 = 4,
28};
29typedef enum PTABLE_LEVELS ptable_lv_t;
30
31typedef struct {
32 page_desc_t entities[VMM_PTE_COUNT];
33} ptable_t;
34
35typedef struct pdirectory {
36 table_desc_t entities[VMM_PDE_COUNT];
37} pdirectory_t;
38
39#endif // _KERNEL_MEM_BITS_VM_H