Subversion Repositories HelenOS-historic

Rev

Rev 746 | Rev 748 | 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
747 jermar 3
 * Copyright (C) 2006 Jakub Vana
684 jermar 4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
8
 * are met:
9
 *
10
 * - Redistributions of source code must retain the above copyright
11
 *   notice, this list of conditions and the following disclaimer.
12
 * - Redistributions in binary form must reproduce the above copyright
13
 *   notice, this list of conditions and the following disclaimer in the
14
 *   documentation and/or other materials provided with the distribution.
15
 * - The name of the author may not be used to endorse or promote products
16
 *   derived from this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29
 
30
#include <arch/mm/page.h>
747 jermar 31
#include <genarch/mm/page_ht.h>
32
#include <mm/asid.h>
716 vana 33
#include <arch/types.h>
728 vana 34
#include <print.h>
684 jermar 35
#include <mm/page.h>
747 jermar 36
#include <mm/frame.h>
684 jermar 37
#include <config.h>
38
#include <panic.h>
746 jermar 39
#include <arch/asm.h>
747 jermar 40
#include <arch/barrier.h>
684 jermar 41
 
747 jermar 42
/** Initialize VHPT and region registers. */
43
static void set_vhpt_environment(void)
716 vana 44
{
747 jermar 45
	region_register rr;
46
	pta_register pta;	
47
	int i;
716 vana 48
 
747 jermar 49
	/*
50
	 * First set up kernel region register.
51
	 */
52
	rr.word = rr_read(VRN_KERNEL);
53
	rr.map.ve = 0;                  /* disable VHPT walker */
54
	rr.map.ps = PAGE_WIDTH;
55
	rr.map.rid = ASID_KERNEL;
56
	rr_write(VRN_KERNEL, rr.word);
57
	srlz_i();
58
	srlz_d();
716 vana 59
 
747 jermar 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;
728 vana 67
 
747 jermar 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
	}
726 jermar 74
 
715 vana 75
	/*
747 jermar 76
	 * Allocate VHPT and invalidate all its entries.
77
	 */
78
	page_ht = (pte_t *) frame_alloc(FRAME_KA, VHPT_WIDTH - FRAME_WIDTH, NULL);
79
	ht_invalidate_all();
715 vana 80
 
747 jermar 81
	/*
82
	 * Set up PTA register.
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;
89
	pta_write(pta.word);
90
	srlz_i();
91
	srlz_d();
92
}
728 vana 93
 
747 jermar 94
/** Initialize ia64 virtual address translation subsystem. */
684 jermar 95
void page_arch_init(void)
96
{
97
	page_operations = &page_ht_operations;
746 jermar 98
	pk_disable();
747 jermar 99
	set_vhpt_environment();
684 jermar 100
}