summaryrefslogtreecommitdiffstats
path: root/src/include/kernel/vmmmgr.H
blob: 49101feed4089122b16f550f982c84734fad3346 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef __KERNEL_VMMMGR_H
#define __KERNEL_VMMMGR_H

#include <limits.h>
#include <kernel/types.h>
#include <kernel/spinlock.H>

class VmmManager
{
    public:
        enum VMM_CONSTS
        {
            EIGHT_MEG = 8 * 1024 * 1024,

            FULL_MEM_SIZE = 1 * EIGHT_MEG,

            // put the Page Table at the end of our memory space
            PTSIZE = (1 << 18),
            HTABORG = (FULL_MEM_SIZE - PTSIZE),
        };

        enum ACCESS_TYPES
        {
            NO_USER_ACCESS,
            READ_O_ACCESS,
            NORMAL_ACCESS,
            CI_ACCESS,
            RO_EXE_ACCESS,
        };

        enum PID_ALLOCATIONS
        {
            LinearSpace = (FULL_MEM_SIZE / EIGHT_MEG) - 1,
            MMIOSpace = LinearSpace + 1,
            FirstPid,
        };

        static void init();
        static void init_slb();

        /**
         * @brief Responsible for handling PTE misses.
         *
         * @param[in] t - Task causing the page fault.
         * @param[in] effAddr - Effective address accessed to cause fault.
         *
         * @return true - PTE miss was successfully handled.
         *
         * If the PTE miss is not successfully handled, the exception
         * handler should collect debug information and kill the task.
         */
        static bool pteMiss(task_t* t, uint64_t effAddr);

        static void* mmioMap(void*, size_t);
        static int mmioUnmap(void*, size_t);


    protected:
        VmmManager();
        ~VmmManager() {};

    private:
        Spinlock lock;

        void initPTEs();
        void initSDR1();

        bool _pteMiss(task_t*, uint64_t);

};

#endif
OpenPOWER on IntegriCloud