Subversion Repositories HelenOS

Rev

Rev 746 | Rev 748 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 746 Rev 747
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2006 Jakub Jermar
2
 * Copyright (C) 2006 Jakub Jermar
-
 
3
 * Copyright (C) 2006 Jakub Vana
3
 * All rights reserved.
4
 * All rights reserved.
4
 *
5
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * are met:
Line 25... Line 26...
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * (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
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
 */
28
 
29
 
29
#include <arch/mm/page.h>
30
#include <arch/mm/page.h>
30
#include <arch/types.h>
-
 
31
#include <genarch/mm/page_ht.h>
31
#include <genarch/mm/page_ht.h>
-
 
32
#include <mm/asid.h>
-
 
33
#include <arch/types.h>
32
#include <print.h>
34
#include <print.h>
33
#include <mm/page.h>
35
#include <mm/page.h>
-
 
36
#include <mm/frame.h>
34
#include <config.h>
37
#include <config.h>
35
#include <panic.h>
38
#include <panic.h>
36
#include <arch/asm.h>
39
#include <arch/asm.h>
-
 
40
#include <arch/barrier.h>
37
 
41
 
38
__u64 thash(__u64 va);
42
/** Initialize VHPT and region registers. */
39
__u64 thash(__u64 va)
43
static void set_vhpt_environment(void)
40
{
-
 
41
    __u64 ret;
-
 
42
    asm
-
 
43
    (
-
 
44
        "thash %0=%1;;"
-
 
45
        :"=r"(ret)
-
 
46
        :"r" (va)
-
 
47
    );
-
 
48
   
-
 
49
    return ret;
-
 
50
}
-
 
51
 
-
 
52
__u64 ttag(__u64 va);
-
 
53
__u64 ttag(__u64 va)
-
 
54
{
44
{
55
    __u64 ret;
-
 
56
    asm
-
 
57
    (
-
 
58
        "ttag %0=%1;;"
-
 
59
        :"=r"(ret)
-
 
60
        :"r" (va)
-
 
61
    );
-
 
62
   
-
 
63
    return ret;
-
 
64
}
-
 
65
 
-
 
66
 
-
 
67
static void set_VHPT_environment(void)
-
 
68
{
-
 
69
   
-
 
70
 
-
 
71
    /*
-
 
72
    TODO:
-
 
73
    */
-
 
74
   
-
 
75
    int i;
-
 
76
   
-
 
77
    /* First set up REGION REGISTER 0 */
-
 
78
   
-
 
79
    region_register rr;
45
    region_register rr;
80
    rr.map.ve=0;                  /*Disable Walker*/
-
 
81
    rr.map.ps=PAGE_WIDTH;
46
    pta_register pta;  
82
    rr.map.rid=REGION_RID_MAIN;
47
    int i;
83
   
48
   
84
    asm
-
 
85
    (
49
    /*
86
        ";;\n"
-
 
87
        "srlz.i;;\n"
-
 
88
        "srlz.d;;\n"
-
 
89
        "{mov rr[r0]=%0};;\n"
50
     * First set up kernel region register.
90
        "srlz.i;;\n"
-
 
91
        "srlz.d;;\n"
-
 
92
        ";;\n"
-
 
93
        :
51
     */
94
        :"r"(rr.word)
52
    rr.word = rr_read(VRN_KERNEL);
95
    );
-
 
96
 
-
 
97
           
-
 
98
    /* And Invalidate the rest of REGION REGISTERS */
53
    rr.map.ve = 0;                  /* disable VHPT walker */
99
    for(i=1;i<REGION_REGISTERS;i++)
54
    rr.map.ps = PAGE_WIDTH;
100
    {
-
 
101
        rr.map.rid=REGION_RID_FIRST_INVALID+i-1;
55
    rr.map.rid = ASID_KERNEL;
102
        asm
-
 
103
        (
-
 
104
            ";;\n"
-
 
105
/*          "mov r8=%1;;\n"*/
-
 
106
/*          "mov rr[r8]=%0;;\n"*/
56
    rr_write(VRN_KERNEL, rr.word);
107
            "srlz.i;;\n"
-
 
108
            "srlz.d;;\n"
-
 
109
            "{mov rr[%1]=%0};;\n"
-
 
110
            "srlz.i;;\n"
57
    srlz_i();
111
            "srlz.d;;\n"
58
    srlz_d();
112
            :
-
 
113
            :"r"(rr.word),"r"(i)
-
 
114
            :"r8"
-
 
115
        );
-
 
116
    };
-
 
117
 
-
 
118
   
59
   
-
 
60
    /*
-
 
61
     * And invalidate the rest of region register.
-
 
62
     */
-
 
63
    for(i = 0; i < REGION_REGISTERS; i++) {
-
 
64
        /* skip kernel rr */
-
 
65
        if (i == VRN_KERNEL)
-
 
66
            continue;
-
 
67
   
-
 
68
        rr.word == rr_read(i);
-
 
69
        rr.map.rid = ASID_INVALID;
-
 
70
        rr_write(i, rr.word);
-
 
71
        srlz_i();
-
 
72
        srlz_d();
-
 
73
    }
119
 
74
 
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
   
75
    /*
126
    return ;
76
     * Allocate VHPT and invalidate all its entries.
127
   
77
     */
128
    printf("pta struct size:%d\n",sizeof(pta));
78
    page_ht = (pte_t *) frame_alloc(FRAME_KA, VHPT_WIDTH - FRAME_WIDTH, NULL);
-
 
79
    ht_invalidate_all();
129
   
80
   
130
    /*Write PTA*/
-
 
131
    asm
-
 
132
    (
81
    /*
133
        "mov cr8=%0;;"
82
     * Set up PTA register.
134
        :
83
     */
-
 
84
    pta.word = pta_read();
-
 
85
    pta.map.ve = 0;                   /* disable VHPT walker */
-
 
86
    pta.map.vf = 1;                   /* large entry format */
-
 
87
    pta.map.size = VHPT_WIDTH;
-
 
88
    pta.map.base = (__address) page_ht;
135
        :"r"(pta.word)
89
    pta_write(pta.word);
136
    ); 
90
    srlz_i();
137
    return ;
91
    srlz_d();
138
}  
92
}
139
 
-
 
140
 
93
 
-
 
94
/** Initialize ia64 virtual address translation subsystem. */
141
void page_arch_init(void)
95
void page_arch_init(void)
142
{
96
{
143
    page_operations = &page_ht_operations;
97
    page_operations = &page_ht_operations;
144
    pk_disable();
98
    pk_disable();
145
    set_VHPT_environment();
99
    set_vhpt_environment();
146
}
100
}