![]() |
|
|||
File indexing completed on 2025-05-11 08:23:48
0001 /* page_table.c 0002 * 0003 * The code submitted by Eric Vaitl <vaitl@viasat.com> for the MVME162 appears 0004 * to be for a uniprocessor implementation. The function that sets up the 0005 * page tables, page_table_init(), is not data driven. For all processors, it 0006 * sets up page tables to map virtual addresses from 0x20000 to 0x3FFFFF to 0007 * physical addresses 0x20000 to 0x3FFFFF. This presumably maps a subset of 0008 * a local 4 MB space, which is probably the amount of RAM on Eric Vailt's 0009 * MVME162. 0010 * 0011 * It is possible to set up the various bus bridges in the MVME167s to create 0012 * a flat physical address space across multiple boards, i.e., it is possible 0013 * for each MVME167 in a multiprocessor system to access a given memory 0014 * location using the same physical address, whether that location is in local 0015 * or VME space. Addres translation can be set up so that each virtual address 0016 * maps to its corresponding physical address, e.g. virtual address 0x12345678 0017 * is mapped to physical address 0x12345678. With this mapping, the MMU is 0018 * only used to control the caching modes for the various regions of memory. 0019 * Mapping the virtual addresses to their corresponding physical address makes 0020 * it unnecessary to map addresses under software control during the 0021 * initialization of RTEMS, before address translation is turned on. 0022 * 0023 * With the above approach, address translation may be set up either with the 0024 * transparent address translation registers, or with page tables. If page 0025 * tables are used, a more efficient use of page table space can be achieved 0026 * by sharing the page tables between processors. The entire page table tree 0027 * can be shared, or each processor can hold a private copy of the top nodes 0028 * which point to leaf nodes stored on individual processors. 0029 * 0030 * In this port, only the transparent address translation registers are used. 0031 * We map the entire virtual range from 0x0 to 0x7FFFFFFF to the identical 0032 * physical range 0x0 to 0x7FFFFFFF. We rely on the hardware to signal bus 0033 * errors if we address non-existent memory within this range. Our two 0034 * MVME167s are configured to exist at physical addresses 0x00800000 to 0035 * 0x00BFFFFF and 0x00C00000 to 0x00FFFFFF respectively. If jumper J1-4 is 0036 * installed, memory and cache control can be done by providing parameters 0037 * in NVRAM and jumpers J1-[5-7] are ignored. See the README for details. 0038 * If J1-4 is removed, behaviour defaults to the following. We map the space 0039 * from 0x0 to 0x7FFFFFFF as copyback, unless jumper J1-5 is removed, in which 0040 * case we map as writethrough. If jumper J1-7 is removed, the data cache is 0041 * NOT enabled. If jumper J1-6 is removed, the instruction cache is not enabled. 0042 * 0043 * Copyright (c) 1998, National Research Council of Canada 0044 */ 0045 0046 #include <bsp.h> 0047 #include <page_table.h> /* Nothing in here for us */ 0048 0049 /* 0050 * page_table_init 0051 * 0052 * Map the virtual range 0x00000000--0x7FFFFFFF to the physical range 0053 * 0x00000000--0x7FFFFFFF. Rely on the hardware to raise exceptions when 0054 * addressing non-existent memory. Use only the transparent translation 0055 * registers (for now). 0056 * 0057 * On all processors, the local virtual address range 0xFF000000--0xFFFFFFFF 0058 * is mapped to the physical address range 0xFF000000--0xFFFFFFFF as 0059 * caching disabled, serialized access. 0060 * 0061 * Output parameters: NONE 0062 * 0063 * Return values: NONE 0064 */ 0065 void page_table_init( void ) 0066 { 0067 unsigned char j1; /* State of J1 jumpers */ 0068 register unsigned long dtt0; /* Content of dtt0 */ 0069 register unsigned long cacr; /* Content of cacr */ 0070 0071 /* 0072 * Logical base addr = 0x00 map starting at 0x00000000 0073 * Logical address mask = 0x7F map up to 0x7FFFFFFF 0074 * E = 0b1 enable address translation 0075 * S-Field = 0b1X ignore FC2 when matching 0076 * U1, U0 = 0b00 user page attributes not used 0077 * CM = 0b01 cachable, copyback 0078 * W = 0b0 read/write access allowed 0079 */ 0080 dtt0 = 0x007FC020; 0081 0082 cacr = 0x00000000; /* Data and instruction cache off */ 0083 0084 /* Read the J1 header */ 0085 j1 = (unsigned char)(lcsr->vector_base & 0xFF); 0086 0087 if ( !(j1 & 0x10) ) { 0088 /* Jumper J1-4 is on, configure from NVRAM */ 0089 0090 if ( nvram->cache_mode & 0x01 ) 0091 cacr |= 0x80000000; 0092 0093 if ( nvram->cache_mode & 0x02 ) 0094 cacr |= 0x00008000; 0095 0096 if ( nvram->cache_mode ) 0097 dtt0 = ((nvram->cache_mode & 0x0C) << 3) | (dtt0 & 0xFFFFFF9F); 0098 } 0099 else { 0100 /* Configure according to other jumper settings */ 0101 0102 if ( !(j1 & 0x80) ) 0103 /* Jumper J1-7 if on, enable data caching */ 0104 cacr |= 0x80000000; 0105 0106 if ( !(j1 & 0x40) ) 0107 /* Jumper J1-6 if on, enable instruction caching */ 0108 cacr |= 0x00008000; 0109 0110 if ( j1 & 0x20 ) 0111 /* Jumper J1-5 is off, enable writethrough caching */ 0112 dtt0 &= 0xFFFFFF9F; 0113 } 0114 0115 /* do it ! */ 0116 __asm__ volatile("movec %0, %%tc\n\t" /* turn off paged address translation */ 0117 "movec %0, %%cacr\n\t" /* disable both caches */ 0118 "cinva %%bc\n\t" /* clear both caches */ 0119 "movec %1,%%dtt0\n\t" /* block address translation on */ 0120 "movec %1,%%itt0\n\t" 0121 "movec %2,%%dtt1\n\t" 0122 "movec %2,%%itt1\n\t" 0123 "movec %3,%%cacr" /* data cache on */ 0124 :: "d" (0), "d" (dtt0), "d" (0xFF00C040), "d" (cacr)); 0125 } 0126 0127 /* 0128 * page_table_teardown 0129 * 0130 * Turn off paging. Turn off the cache. Flush the cache. Tear down 0131 * the transparent translations. 0132 * 0133 * Input parameters: NONE 0134 * 0135 * Output parameters: NONE 0136 * 0137 * Return values: NONE 0138 */ 0139 void page_table_teardown( void ) 0140 { 0141 __asm__ volatile ("movec %0,%%tc\n\t" 0142 "movec %0,%%cacr\n\t" 0143 "cpusha %%bc\n\t" 0144 "movec %0,%%dtt0\n\t" 0145 "movec %0,%%itt0\n\t" 0146 "movec %0,%%dtt1\n\t" 0147 "movec %0,%%itt1" 0148 :: "d" (0) ); 0149 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |