1 |
30 |
unneback |
/* page_table.c
|
2 |
|
|
*
|
3 |
|
|
* The code submitted by Eric Vaitl <vaitl@viasat.com> for the MVME162 appears
|
4 |
|
|
* to be for a uniprocessor implementation. The function that sets up the
|
5 |
|
|
* page tables, page_table_init(), is not data driven. For all processors, it
|
6 |
|
|
* sets up page tables to map virtual addresses from 0x20000 to 0x3FFFFF to
|
7 |
|
|
* physical addresses 0x20000 to 0x3FFFFF. This presumably maps a subset of
|
8 |
|
|
* a local 4 MB space, which is probably the amount of RAM on Eric Vailt's
|
9 |
|
|
* MVME162.
|
10 |
|
|
*
|
11 |
|
|
* It is possible to set up the various bus bridges in the MVME167s to create
|
12 |
|
|
* a flat physical address space across multiple boards, i.e., it is possible
|
13 |
|
|
* for each MVME167 in a multiprocessor system to access a given memory
|
14 |
|
|
* location using the same physical address, whether that location is in local
|
15 |
|
|
* or VME space. Addres translation can be set up so that each virtual address
|
16 |
|
|
* maps to its corresponding physical address, e.g. virtual address 0x12345678
|
17 |
|
|
* is mapped to physical address 0x12345678. With this mapping, the MMU is
|
18 |
|
|
* only used to control the caching modes for the various regions of memory.
|
19 |
|
|
* Mapping the virtual addresses to their corresponding physical address makes
|
20 |
|
|
* it unnecessary to map addresses under software control during the
|
21 |
|
|
* initialization of RTEMS, before address translation is turned on.
|
22 |
|
|
*
|
23 |
|
|
* With the above approach, address translation may be set up either with the
|
24 |
|
|
* transparent address translation registers, or with page tables. If page
|
25 |
|
|
* tables are used, a more efficient use of page table space can be achieved
|
26 |
|
|
* by sharing the page tables between processors. The entire page table tree
|
27 |
|
|
* can be shared, or each processor can hold a private copy of the top nodes
|
28 |
|
|
* which point to leaf nodes stored on individual processors.
|
29 |
|
|
*
|
30 |
|
|
* In this port, only the transparent address translation registers are used.
|
31 |
|
|
* We map the entire virtual range from 0x0 to 0x7FFFFFFF to the identical
|
32 |
|
|
* physical range 0x0 to 0x7FFFFFFF. We rely on the hardware to signal bus
|
33 |
|
|
* errors if we address non-existent memory within this range. Our two
|
34 |
|
|
* MVME167s are configured to exist at physical addresses 0x00800000 to
|
35 |
|
|
* 0x00BFFFFF and 0x00C00000 to 0x00FFFFFF respectively. We map the space
|
36 |
|
|
* from 0x0 to 0x7FFFFFFF as copyback, unless jumper J1-5 is removed, in
|
37 |
|
|
* which case we map as writethrough. If jumper J1-7 is removed, the data
|
38 |
|
|
* cache is NOT enabled. If jumper J1-6 is removed, the instruction cache
|
39 |
|
|
* is not enabled.
|
40 |
|
|
*
|
41 |
|
|
* Copyright (c) 1998, National Research Council of Canada
|
42 |
|
|
*
|
43 |
|
|
* $Id: page_table.c,v 1.2 2001-09-27 12:00:20 chris Exp $
|
44 |
|
|
*/
|
45 |
|
|
|
46 |
|
|
#include <bsp.h>
|
47 |
|
|
#include <page_table.h> /* Nothing in here for us */
|
48 |
|
|
|
49 |
|
|
/*
|
50 |
|
|
* page_table_init
|
51 |
|
|
*
|
52 |
|
|
* Map the virtual range 0x00000000--0x7FFFFFFF to the physical range
|
53 |
|
|
* 0x00000000--0x7FFFFFFF. Rely on the hardware to raise exceptions when
|
54 |
|
|
* addressing non-existent memory. Use only the transparent translation
|
55 |
|
|
* registers (for now).
|
56 |
|
|
*
|
57 |
|
|
* On all processors, the local virtual address range 0xFF000000--0xFFFFFFFF
|
58 |
|
|
* is mapped to the physical address range 0xFF000000--0xFFFFFFFF as
|
59 |
|
|
* caching disabled, serialized access.
|
60 |
|
|
*
|
61 |
|
|
* Input parameters:
|
62 |
|
|
* config_table - ignored for now
|
63 |
|
|
*
|
64 |
|
|
* Output parameters: NONE
|
65 |
|
|
*
|
66 |
|
|
* Return values: NONE
|
67 |
|
|
*/
|
68 |
|
|
void page_table_init(
|
69 |
|
|
rtems_configuration_table *config_table
|
70 |
|
|
)
|
71 |
|
|
{
|
72 |
|
|
unsigned char j1; /* State of J1 jumpers */
|
73 |
|
|
register unsigned long dtt0; /* Content of dtt0 */
|
74 |
|
|
register unsigned long cacr; /* Content of cacr */
|
75 |
|
|
|
76 |
|
|
/*
|
77 |
|
|
* Logical base addr = 0x00 map starting at 0x00000000
|
78 |
|
|
* Logical address mask = 0x7F map up to 0x7FFFFFFF
|
79 |
|
|
* E = 0b1 enable address translation
|
80 |
|
|
* S-Field = 0b1X ignore FC2 when matching
|
81 |
|
|
* U1, U0 = 0b00 user page attributes not used
|
82 |
|
|
* CM = 0b01 cachable, copyback
|
83 |
|
|
* W = 0b0 read/write access allowed
|
84 |
|
|
*/
|
85 |
|
|
dtt0 = 0x007FC020;
|
86 |
|
|
|
87 |
|
|
cacr = 0x80008000; /* Data and instruction cache on */
|
88 |
|
|
|
89 |
|
|
/* Read the J1 header */
|
90 |
|
|
j1 = (unsigned char)(lcsr->vector_base & 0xFF);
|
91 |
|
|
|
92 |
|
|
if ( j1 & 0x80 )
|
93 |
|
|
/* Jumper J1-7 if off, disable data caching */
|
94 |
|
|
cacr &= 0x7FFFFFFF;
|
95 |
|
|
|
96 |
|
|
if ( j1 & 0x40 )
|
97 |
|
|
/* Jumper J1-6 if off, disable instruction caching */
|
98 |
|
|
cacr &= 0xFFFF7FFF;
|
99 |
|
|
|
100 |
|
|
if ( j1 & 0x20 )
|
101 |
|
|
/* Jumper J1-5 is off, enable writethrough caching */
|
102 |
|
|
dtt0 &= 0xFFFFFF9F;
|
103 |
|
|
|
104 |
|
|
/* do it ! */
|
105 |
|
|
asm volatile("movec %0, %%tc /* turn off paged address translation */
|
106 |
|
|
movec %0, %%cacr /* disable both caches */
|
107 |
|
|
cinva %%bc /* clear both caches */
|
108 |
|
|
movec %1,%%dtt0 /* block address translation on */
|
109 |
|
|
movec %1,%%itt0
|
110 |
|
|
movec %2,%%dtt1
|
111 |
|
|
movec %2,%%itt1
|
112 |
|
|
movec %3,%%cacr" /* data cache on */
|
113 |
|
|
:: "d" (0), "d" (dtt0), "d" (0xFF00C040), "d" (cacr));
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
/*
|
118 |
|
|
* page_table_teardown
|
119 |
|
|
*
|
120 |
|
|
* Turn off paging. Turn off the cache. Flush the cache. Tear down
|
121 |
|
|
* the transparent translations.
|
122 |
|
|
*
|
123 |
|
|
* Input parameters: NONE
|
124 |
|
|
*
|
125 |
|
|
* Output parameters: NONE
|
126 |
|
|
*
|
127 |
|
|
* Return values: NONE
|
128 |
|
|
*/
|
129 |
|
|
void page_table_teardown( void )
|
130 |
|
|
{
|
131 |
|
|
asm volatile ("movec %0,%%tc
|
132 |
|
|
movec %0,%%cacr
|
133 |
|
|
cpusha %%bc
|
134 |
|
|
movec %0,%%dtt0
|
135 |
|
|
movec %0,%%itt0
|
136 |
|
|
movec %0,%%dtt1
|
137 |
|
|
movec %0,%%itt1"
|
138 |
|
|
:: "d" (0) );
|
139 |
|
|
}
|