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

4.104.11
Last change on this file since 27e966f was 27e966f, checked in by Till Straumann <strauman@…>, on Oct 20, 2009 at 5:52:20 PM

2009-10-20 Till Straumann <strauman@…>

  • shared/startup/pgtbl_setup.c: Fixed compiler warnings (added prototypes to function declarations etc.)
  • Property mode set to 100644
File size: 4.4 KB
Line 
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
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 */ 
65
66Triv121PgTbl
67BSP_pgtbl_setup(unsigned int *) __attribute__ (( weak, alias("__BSP_default_pgtbl_setup") ));
68
69/* get those from the linker script.
70 * NOTE THAT THE CORRECTNESS OF THE LINKER SCRIPT IS CRUCIAL
71 */
72extern unsigned long __DATA_START__[], _etext[];
73
74Triv121PgTbl
75__BSP_default_pgtbl_setup(unsigned int *pmemsize)
76{
77Triv121PgTbl    pt;
78unsigned                ldPtSize,tmp;
79
80  /* Allocate a page table large enough to map
81   * the entire physical memory. We put the page
82   * table at the top of the physical memory.
83   */
84
85  /* get minimal size (log base 2) of PT for
86   * this board's memory
87   */
88  ldPtSize = triv121PgTblLdMinSize(*pmemsize);
89  ldPtSize++; /* double this amount -- then why? */
90
91  /* allocate the page table at the top of the physical
92   * memory - THIS IS NOT AN OPTION - bspstart.c RELIES
93   * ON THIS LAYOUT! (the size, however may be changed)
94   */
95  if ( (pt = triv121PgTblInit(*pmemsize - (1<<ldPtSize), ldPtSize)) ) {
96        /* map text and RO data read-only */
97        tmp = triv121PgTblMap(
98                                                pt,
99                                                TRIV121_121_VSID,
100                                                0,
101                                                (PAGE_ALIGN((unsigned long)_etext) - 0) >> PG_SHIFT,
102                                                0, /* WIMG */
103                                                TRIV121_PP_RO_PAGE);
104        if (TRIV121_MAP_SUCCESS != tmp) {
105                printk("Unable to map page index %i; reverting to BAT0\n",
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,
113                                                (unsigned long)__DATA_START__,
114                                                (*pmemsize - (1<<ldPtSize) -  (unsigned long)__DATA_START__ )>> PG_SHIFT,
115                                                0, /* WIMG */
116                                                TRIV121_PP_RW_PAGE);
117                if (TRIV121_MAP_SUCCESS != tmp) {
118                        printk("Unable to map page index %i; reverting to BAT0\n",
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.