source: rtems/c/src/lib/libbsp/m68k/mvme167/startup/page_table.c @ a9e5e74

4.115
Last change on this file since a9e5e74 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/*  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. If jumper J1-4 is
36 *  installed, memory and cache control can be done by providing parameters
37 *  in NVRAM and jumpers J1-[5-7] are ignored. See the README for details.
38 *  If J1-4 is removed, behaviour defaults to the following. We map the space
39 *  from 0x0 to 0x7FFFFFFF as copyback, unless jumper J1-5 is removed, in which
40 *  case we map as writethrough. If jumper J1-7 is removed, the data cache is
41 *  NOT enabled. If jumper J1-6 is removed, the instruction cache is not enabled.
42 *
43 *  Copyright (c) 1998, National Research Council of Canada
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 */
68void 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 = 0x00000000;              /* Data and instruction cache off */
88
89  /* Read the J1 header */
90  j1 = (unsigned char)(lcsr->vector_base & 0xFF);
91
92  if ( !(j1 & 0x10) ) {
93        /* Jumper J1-4 is on, configure from NVRAM */
94
95        if ( nvram->cache_mode & 0x01 )
96                cacr |= 0x80000000;
97
98        if ( nvram->cache_mode & 0x02 )
99                cacr |= 0x00008000;
100
101        if ( nvram->cache_mode )
102                dtt0 = ((nvram->cache_mode & 0x0C) << 3) | (dtt0 & 0xFFFFFF9F);
103  }
104        else {
105                /* Configure according to other jumper settings */
106
107          if ( !(j1 & 0x80) )
108          /* Jumper J1-7 if on, enable data caching */
109                cacr |= 0x80000000;
110
111          if ( !(j1 & 0x40) )
112            /* Jumper J1-6 if on, enable instruction caching */
113            cacr |= 0x00008000;
114
115          if ( j1 & 0x20 )
116            /* Jumper J1-5 is off, enable writethrough caching */
117            dtt0 &= 0xFFFFFF9F;
118        }
119
120  /* do it ! */
121  __asm__ volatile("movec %0, %%tc\n\t"    /* turn off paged address translation */
122               "movec %0, %%cacr\n\t"  /* disable both caches */
123               "cinva %%bc\n\t"        /* clear both caches */
124               "movec %1,%%dtt0\n\t"   /* block address translation on */
125               "movec %1,%%itt0\n\t"
126               "movec %2,%%dtt1\n\t"
127               "movec %2,%%itt1\n\t"
128               "movec %3,%%cacr"       /* data cache on */
129          :: "d" (0), "d" (dtt0), "d" (0xFF00C040), "d" (cacr));
130}
131
132/*
133 *  page_table_teardown
134 *
135 *  Turn off paging. Turn off the cache. Flush the cache. Tear down
136 *  the transparent translations.
137 *
138 *  Input parameters: NONE
139 *
140 *  Output parameters: NONE
141 *
142 *  Return values: NONE
143 */
144void page_table_teardown( void )
145{
146  __asm__ volatile ("movec %0,%%tc\n\t"
147                "movec %0,%%cacr\n\t"
148                "cpusha %%bc\n\t"
149                "movec %0,%%dtt0\n\t"
150                "movec %0,%%itt0\n\t"
151                "movec %0,%%dtt1\n\t"
152                "movec %0,%%itt1"
153    :: "d" (0) );
154}
Note: See TracBrowser for help on using the repository browser.