Subversion Repositories HelenOS

Rev

Rev 728 | Rev 747 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
684 jermar 1
/*
2
 * Copyright (C) 2006 Jakub Jermar
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
 
29
#include <arch/mm/page.h>
716 vana 30
#include <arch/types.h>
684 jermar 31
#include <genarch/mm/page_ht.h>
728 vana 32
#include <print.h>
684 jermar 33
#include <mm/page.h>
34
#include <config.h>
35
#include <panic.h>
746 jermar 36
#include <arch/asm.h>
684 jermar 37
 
716 vana 38
__u64 thash(__u64 va);
39
__u64 thash(__u64 va)
40
{
41
    __u64 ret;
42
    asm
43
    (
44
        "thash %0=%1;;"
45
        :"=r"(ret)
46
        :"r" (va)
47
    );
48
 
49
    return ret;
50
}
715 vana 51
 
716 vana 52
__u64 ttag(__u64 va);
53
__u64 ttag(__u64 va)
54
{
55
    __u64 ret;
56
    asm
57
    (
58
        "ttag %0=%1;;"
59
        :"=r"(ret)
60
        :"r" (va)
61
    );
62
 
63
    return ret;
64
}
65
 
66
 
715 vana 67
static void set_VHPT_environment(void)
68
{
728 vana 69
 
726 jermar 70
 
715 vana 71
    /*
72
    TODO:
73
    */
74
 
75
    int i;
76
 
77
    /* First set up REGION REGISTER 0 */
78
 
79
    region_register rr;
80
    rr.map.ve=0;                  /*Disable Walker*/
81
    rr.map.ps=PAGE_WIDTH;
82
    rr.map.rid=REGION_RID_MAIN;
83
 
84
    asm
85
    (
728 vana 86
        ";;\n"
87
        "srlz.i;;\n"
88
        "srlz.d;;\n"
89
        "{mov rr[r0]=%0};;\n"
90
        "srlz.i;;\n"
91
        "srlz.d;;\n"
92
        ";;\n"
715 vana 93
        :
94
        :"r"(rr.word)
95
    );
728 vana 96
 
97
 
715 vana 98
    /* And Invalidate the rest of REGION REGISTERS */
99
    for(i=1;i<REGION_REGISTERS;i++)
100
    {
101
        rr.map.rid=REGION_RID_FIRST_INVALID+i-1;
102
        asm
103
        (
728 vana 104
            ";;\n"
105
/*          "mov r8=%1;;\n"*/
106
/*          "mov rr[r8]=%0;;\n"*/
107
            "srlz.i;;\n"
108
            "srlz.d;;\n"
109
            "{mov rr[%1]=%0};;\n"
110
            "srlz.i;;\n"
111
            "srlz.d;;\n"
715 vana 112
            :
113
            :"r"(rr.word),"r"(i)
114
            :"r8"
115
        );
116
    };
117
 
728 vana 118
 
119
 
715 vana 120
    PTA_register pta;
121
    pta.map.ve=0;                   /*Disable Walker*/
122
    pta.map.vf=1;                   /*Large entry format*/
123
    pta.map.size=VHPT_WIDTH;
124
    pta.map.base=VHPT_BASE;
125
 
728 vana 126
    return ;
715 vana 127
 
728 vana 128
    printf("pta struct size:%d\n",sizeof(pta));
129
 
715 vana 130
    /*Write PTA*/
131
    asm
132
    (
133
        "mov cr8=%0;;"
134
        :
135
        :"r"(pta.word)
136
    ); 
728 vana 137
    return ;
715 vana 138
}  
139
 
140
 
684 jermar 141
void page_arch_init(void)
142
{
143
    page_operations = &page_ht_operations;
746 jermar 144
    pk_disable();
715 vana 145
    set_VHPT_environment();
684 jermar 146
}