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

4.104.114.84.9
Last change on this file since 073b310 was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on Apr 21, 2004 at 4:01:48 PM

Remove duplicate white lines.

  • Property mode set to 100644
File size: 2.6 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/* Author: Till Straumann, <strauman@slac.stanford.edu>, 4/2002 */
22
23Triv121PgTbl
24BSP_pgtbl_setup(unsigned long) __attribute__ (( weak, alias("__BSP_default_pgtbl_setup") ));
25
26Triv121PgTbl
27__BSP_default_pgtbl_setup(unsigned int *pmemsize)
28{
29Triv121PgTbl    pt;
30unsigned                ldPtSize,tmp;
31
32  /* Allocate a page table large enough to map
33   * the entire physical memory. We put the page
34   * table at the top of the physical memory.
35   */
36
37  /* get minimal size (log base 2) of PT for
38   * this board's memory
39   */
40  ldPtSize = triv121PgTblLdMinSize(*pmemsize);
41  ldPtSize++; /* double this amount -- then why? */
42
43  /* allocate the page table at the top of the physical
44   * memory - THIS IS NOT AN OPTION - bspstart.c RELIES
45   * ON THIS LAYOUT! (the size, however may be changed)
46   */
47  if ( (pt = triv121PgTblInit(*pmemsize - (1<<ldPtSize), ldPtSize)) ) {
48        /* get those from the linker script.
49         * NOTE THAT THE CORRECTNESS OF THE LINKER SCRIPT IS CRUCIAL
50         */
51        extern unsigned long __DATA_START__[], _etext[];
52
53        /* map text and RO data read-only */
54        tmp = triv121PgTblMap(
55                                                pt,
56                                                TRIV121_121_VSID,
57                                                0,
58                                                (PAGE_ALIGN((unsigned long)_etext) - 0) >> PG_SHIFT,
59                                                0, /* WIMG */
60                                                TRIV121_PP_RO_PAGE);
61        if (TRIV121_MAP_SUCCESS != tmp) {
62                printk("Unable to map page index %i; reverting to BAT0\n",
63                                tmp);
64                pt = 0;
65        } else {
66                /* map the rest (without the page table itself) RW */
67                tmp = triv121PgTblMap(
68                                                pt,
69                                                TRIV121_121_VSID,
70                                                (unsigned long)__DATA_START__,
71                                                (*pmemsize - (1<<ldPtSize) -  (unsigned long)__DATA_START__ )>> PG_SHIFT,
72                                                0, /* WIMG */
73                                                TRIV121_PP_RW_PAGE);
74                if (TRIV121_MAP_SUCCESS != tmp) {
75                        printk("Unable to map page index %i; reverting to BAT0\n",
76                                        tmp);
77                        pt = 0;
78                }
79        }
80  } else {
81        printk("WARNING: unable to allocate page table, keeping DBAT0\n");
82  }
83  if (pt) {
84#ifdef SHOW_MORE_INIT_SETTINGS
85        printk("Setting up page table mappings; protecting text/read-only data from write access\n");
86#endif
87        /* SUCCESS; reduce available memory by size of the page table */
88        *pmemsize -= (1<<ldPtSize);
89  }
90  return pt;
91}
Note: See TracBrowser for help on using the repository browser.