![]() |
|
|||
File indexing completed on 2025-05-11 08:23:58
0001 #include <sys/param.h> 0002 #include <rtems.h> 0003 #include <libcpu/mmu.h> 0004 #include <rtems/bspIo.h> 0005 #include <libcpu/pte121.h> 0006 0007 /* Default setup of the page tables. This is a weak 0008 * alias, so applications may easily override this 0009 * default setup. 0010 * 0011 * NOTE: while it is possible to change the individual 0012 * mappings, the page table itself MUST be 0013 * allocated at the top of the physical memory! 0014 * bspstart.c RELIES on this. 0015 * Also, the 'setup' routine must reduce 0016 * *pmemsize by the size of the page table. 0017 */ 0018 /* to align the pointer to the (next) page boundary */ 0019 #define PAGE_ALIGN(addr) (((addr) + PAGE_MASK) & ~PAGE_MASK) 0020 0021 0022 /* 0023 * Authorship 0024 * ---------- 0025 * This software was created by 0026 * Till Straumann <strauman@slac.stanford.edu>, 4/2002, 0027 * Stanford Linear Accelerator Center, Stanford University. 0028 * 0029 * Acknowledgement of sponsorship 0030 * ------------------------------ 0031 * This software was produced by 0032 * the Stanford Linear Accelerator Center, Stanford University, 0033 * under Contract DE-AC03-76SFO0515 with the Department of Energy. 0034 * 0035 * Government disclaimer of liability 0036 * ---------------------------------- 0037 * Neither the United States nor the United States Department of Energy, 0038 * nor any of their employees, makes any warranty, express or implied, or 0039 * assumes any legal liability or responsibility for the accuracy, 0040 * completeness, or usefulness of any data, apparatus, product, or process 0041 * disclosed, or represents that its use would not infringe privately owned 0042 * rights. 0043 * 0044 * Stanford disclaimer of liability 0045 * -------------------------------- 0046 * Stanford University makes no representations or warranties, express or 0047 * implied, nor assumes any liability for the use of this software. 0048 * 0049 * Stanford disclaimer of copyright 0050 * -------------------------------- 0051 * Stanford University, owner of the copyright, hereby disclaims its 0052 * copyright and all other rights in this software. Hence, anyone may 0053 * freely use it for any purpose without restriction. 0054 * 0055 * Maintenance of notices 0056 * ---------------------- 0057 * In the interest of clarity regarding the origin and status of this 0058 * SLAC software, this and all the preceding Stanford University notices 0059 * are to remain affixed to any copy or derivative of this software made 0060 * or distributed by the recipient and are to be affixed to any copy of 0061 * software made or distributed by the recipient that contains a copy or 0062 * derivative of this software. 0063 * 0064 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 0065 */ 0066 0067 Triv121PgTbl __BSP_default_pgtbl_setup(unsigned int *pmemsize); 0068 Triv121PgTbl BSP_pgtbl_setup(unsigned int *) 0069 __attribute__ (( weak, alias("__BSP_default_pgtbl_setup") )); 0070 0071 /* get those from the linker script. 0072 * NOTE THAT THE CORRECTNESS OF THE LINKER SCRIPT IS CRUCIAL 0073 */ 0074 extern unsigned long __DATA_START__[], _etext[]; 0075 0076 Triv121PgTbl 0077 __BSP_default_pgtbl_setup(unsigned int *pmemsize) 0078 { 0079 Triv121PgTbl pt; 0080 unsigned ldPtSize,tmp; 0081 0082 /* Allocate a page table large enough to map 0083 * the entire physical memory. We put the page 0084 * table at the top of the physical memory. 0085 */ 0086 0087 /* get minimal size (log base 2) of PT for 0088 * this board's memory 0089 */ 0090 ldPtSize = triv121PgTblLdMinSize(*pmemsize); 0091 ldPtSize++; /* double this amount -- then why? */ 0092 0093 /* allocate the page table at the top of the physical 0094 * memory - THIS IS NOT AN OPTION - bspstart.c RELIES 0095 * ON THIS LAYOUT! (the size, however may be changed) 0096 */ 0097 if ( (pt = triv121PgTblInit(*pmemsize - (1<<ldPtSize), ldPtSize)) ) { 0098 /* map text and RO data read-only */ 0099 tmp = triv121PgTblMap( 0100 pt, 0101 TRIV121_121_VSID, 0102 0, 0103 (PAGE_ALIGN((unsigned long)_etext) - 0) >> PG_SHIFT, 0104 0, /* WIMG */ 0105 TRIV121_PP_RO_PAGE); 0106 if (TRIV121_MAP_SUCCESS != tmp) { 0107 printk("Unable to map page index %i; reverting to BAT0\n", 0108 tmp); 0109 pt = 0; 0110 } else { 0111 /* map the rest (without the page table itself) RW */ 0112 tmp = triv121PgTblMap( 0113 pt, 0114 TRIV121_121_VSID, 0115 (unsigned long)__DATA_START__, 0116 (*pmemsize - (1<<ldPtSize) - (unsigned long)__DATA_START__ )>> PG_SHIFT, 0117 0, /* WIMG */ 0118 TRIV121_PP_RW_PAGE); 0119 if (TRIV121_MAP_SUCCESS != tmp) { 0120 printk("Unable to map page index %i; reverting to BAT0\n", 0121 tmp); 0122 pt = 0; 0123 } 0124 } 0125 } else { 0126 printk("WARNING: unable to allocate page table, keeping DBAT0\n"); 0127 } 0128 if (pt) { 0129 #ifdef SHOW_MORE_INIT_SETTINGS 0130 printk("Setting up page table mappings; protecting text/read-only data from write access\n"); 0131 #endif 0132 /* SUCCESS; reduce available memory by size of the page table */ 0133 *pmemsize -= (1<<ldPtSize); 0134 } 0135 return pt; 0136 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |