source: rtems/c/src/lib/libbsp/powerpc/shared/startup/pgtbl_setup.c @ f774fc06

4.104.114.84.95
Last change on this file since f774fc06 was f774fc06, checked in by Till Straumann <strauman@…>, on 01/17/07 at 05:45:14

2007-01-16 Till Straumann <strauman@…>

  • ep1a/vme/vmeconfig.c, mvme5500/pci/pcifinddevice.c,
  • mvme5500/startup/pgtbl_activate.c, mvme5500/vectors/bspException.h,
  • mvme5500/vectors/exceptionhandler.c, mvme5500/vme/VME.h,
  • mvme5500/vme/vmeconfig.c, score603e/vme/vmeconfig.c, shared/pci/pcifinddevice.c,
  • shared/startup/pgtbl_activate.c, shared/startup/pgtbl_setup.c,
  • shared/startup/probeMemEnd.c, shared/startup/sbrk.c, shared/vme/VME.h,
  • shared/vme/VMEConfig.h, shared/vme/vme_universe.c, shared/vme/vmeconfig.c: Added SLAC/Stanford Authorship Note / Copyright + Liability Disclaimer.
  • Property mode set to 100644
File size: 4.4 KB
RevLine 
[ea29ba6]1/* $Id$ */
2
3#include <rtems.h>
4#include <libcpu/mmu.h>
5#include <libcpu/page.h>
6#include <rtems/bspIo.h>
7#include <libcpu/pte121.h>
8
9/* Default setup of the page tables. This is a weak
10 * alias, so applications may easily override this
11 * default setup.
12 *
13 * NOTE: while it is possible to change the individual
14 *       mappings, the page table itself MUST be
15 *       allocated at the top of the physical memory!
16 *       bspstart.c RELIES on this.
17 *       Also, the 'setup' routine must reduce
18 *       *pmemsize by the size of the page table.
19 */
20
[f774fc06]21/*
22 * Authorship
23 * ----------
24 * This software was created by
25 *     Till Straumann <strauman@slac.stanford.edu>, 4/2002,
26 *         Stanford Linear Accelerator Center, Stanford University.
27 *
28 * Acknowledgement of sponsorship
29 * ------------------------------
30 * This software was produced by
31 *     the Stanford Linear Accelerator Center, Stanford University,
32 *         under Contract DE-AC03-76SFO0515 with the Department of Energy.
33 *
34 * Government disclaimer of liability
35 * ----------------------------------
36 * Neither the United States nor the United States Department of Energy,
37 * nor any of their employees, makes any warranty, express or implied, or
38 * assumes any legal liability or responsibility for the accuracy,
39 * completeness, or usefulness of any data, apparatus, product, or process
40 * disclosed, or represents that its use would not infringe privately owned
41 * rights.
42 *
43 * Stanford disclaimer of liability
44 * --------------------------------
45 * Stanford University makes no representations or warranties, express or
46 * implied, nor assumes any liability for the use of this software.
47 *
48 * Stanford disclaimer of copyright
49 * --------------------------------
50 * Stanford University, owner of the copyright, hereby disclaims its
51 * copyright and all other rights in this software.  Hence, anyone may
52 * freely use it for any purpose without restriction. 
53 *
54 * Maintenance of notices
55 * ----------------------
56 * In the interest of clarity regarding the origin and status of this
57 * SLAC software, this and all the preceding Stanford University notices
58 * are to remain affixed to any copy or derivative of this software made
59 * or distributed by the recipient and are to be affixed to any copy of
60 * software made or distributed by the recipient that contains a copy or
61 * derivative of this software.
62 *
63 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
64 */
[ea29ba6]65
66Triv121PgTbl
67BSP_pgtbl_setup(unsigned long) __attribute__ (( weak, alias("__BSP_default_pgtbl_setup") ));
68
69Triv121PgTbl
70__BSP_default_pgtbl_setup(unsigned int *pmemsize)
71{
72Triv121PgTbl    pt;
73unsigned                ldPtSize,tmp;
74
75  /* Allocate a page table large enough to map
76   * the entire physical memory. We put the page
77   * table at the top of the physical memory.
78   */
79
80  /* get minimal size (log base 2) of PT for
81   * this board's memory
82   */
83  ldPtSize = triv121PgTblLdMinSize(*pmemsize);
84  ldPtSize++; /* double this amount -- then why? */
85
86  /* allocate the page table at the top of the physical
87   * memory - THIS IS NOT AN OPTION - bspstart.c RELIES
88   * ON THIS LAYOUT! (the size, however may be changed)
89   */
90  if ( (pt = triv121PgTblInit(*pmemsize - (1<<ldPtSize), ldPtSize)) ) {
91        /* get those from the linker script.
92         * NOTE THAT THE CORRECTNESS OF THE LINKER SCRIPT IS CRUCIAL
93         */
[64f8ae4]94        extern unsigned long __DATA_START__[], _etext[];
[ea29ba6]95
96        /* map text and RO data read-only */
97        tmp = triv121PgTblMap(
98                                                pt,
99                                                TRIV121_121_VSID,
100                                                0,
[64f8ae4]101                                                (PAGE_ALIGN((unsigned long)_etext) - 0) >> PG_SHIFT,
[ea29ba6]102                                                0, /* WIMG */
103                                                TRIV121_PP_RO_PAGE);
104        if (TRIV121_MAP_SUCCESS != tmp) {
[6128a4a]105                printk("Unable to map page index %i; reverting to BAT0\n",
[ea29ba6]106                                tmp);
107                pt = 0;
108        } else {
109                /* map the rest (without the page table itself) RW */
110                tmp = triv121PgTblMap(
111                                                pt,
112                                                TRIV121_121_VSID,
[64f8ae4]113                                                (unsigned long)__DATA_START__,
114                                                (*pmemsize - (1<<ldPtSize) -  (unsigned long)__DATA_START__ )>> PG_SHIFT,
[ea29ba6]115                                                0, /* WIMG */
116                                                TRIV121_PP_RW_PAGE);
117                if (TRIV121_MAP_SUCCESS != tmp) {
[6128a4a]118                        printk("Unable to map page index %i; reverting to BAT0\n",
[ea29ba6]119                                        tmp);
120                        pt = 0;
121                }
122        }
123  } else {
124        printk("WARNING: unable to allocate page table, keeping DBAT0\n");
125  }
126  if (pt) {
127#ifdef SHOW_MORE_INIT_SETTINGS
128        printk("Setting up page table mappings; protecting text/read-only data from write access\n");
129#endif
130        /* SUCCESS; reduce available memory by size of the page table */
131        *pmemsize -= (1<<ldPtSize);
132  }
133  return pt;
134}
Note: See TracBrowser for help on using the repository browser.