source: rtems/c/src/lib/libcpu/powerpc/mpc6xx/mmu/bat.c @ d49389a

4.104.114.84.95
Last change on this file since d49389a was d49389a, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 20, 2003 at 10:07:22 PM

2003-02-20 Till Straumann <strauman@…>

PR 349/bsps

  • mpc6xx/exceptions/raw_exception.c, mpc6xx/mmu/bat.c, mpc6xx/mmu/pte121.c, shared/include/cpuIdent.c, shared/include/cpuIdent.h, shared/src/Makefile.am, shared/src/stack.c, shared/src/stackTrace.h, powerpc/registers.h:
    • undo improper 'fix' who broke mpc604r identification
    • fix: 7400 identification PVR value was wrong
    • enhance 'setdbat()' to switch OFF a given BAT if called with 0 size
    • fix: page table support bugfix
    • enhancement: provide routines to take and print stack trace snapshots
    • add definitions for HID1 and DABR SPRs
  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 * bat.c
3 *
4 *          This file contains the implementation of C function to
5 *          Instanciate 60x/7xx ppc Block Address Translation (BAT) registers.
6 *          More detailled information can be found on motorola
7 *          site and more precisely in the following book :
8 *
9 *              MPC750
10 *              Risc Microporcessor User's Manual
11 *              Mtorola REF : MPC750UM/AD 8/97
12 *
13 * Copyright (C) 1999  Eric Valette (valette@crf.canon.fr)
14 *                     Canon Centre Recherche France.
15 *
16 *  The license and distribution terms for this file may be
17 *  found in found in the file LICENSE in this distribution or at
18 *  http://www.OARcorp.com/rtems/license.html.
19 *
20 * $Id$
21 */
22
23#include <libcpu/bat.h>
24
25typedef union {                 /* BAT register values to be loaded */
26        BAT             bat;
27        unsigned int    word[2];
28}ubat;
29
30typedef struct batrange {               /* stores address ranges mapped by BATs */
31        unsigned long start;
32        unsigned long limit;
33        unsigned long phys;
34}batrange;
35
36batrange bat_addrs[4];
37
38void asm_setdbat0(unsigned int, unsigned int);
39void setdbat(int bat_index, unsigned long virt, unsigned long phys,
40       unsigned int size, int flags)
41{
42  unsigned int bl;
43  int wimgxpp;
44  ubat bat;
45
46  bl = (size >= (1<<17)) ? (size >> 17) - 1 : 0;
47  /* 603, 604, etc. */
48  wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
49                     | _PAGE_COHERENT | _PAGE_GUARDED);
50  wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX;
51  bat.word[0] = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */
52  bat.word[1] = phys | wimgxpp;
53  if (flags & _PAGE_USER)
54    bat.bat.batu.vp = 1;
55  bat_addrs[bat_index].start = virt;
56  bat_addrs[bat_index].limit = virt + (bl ? ((bl + 1) << 17) - 1 : 0);
57  bat_addrs[bat_index].phys = phys;
58  if ( 0 == bl ) {
59    /* size of 0 tells us to switch it off */
60        bat.bat.batu.vp = 0;
61        bat.bat.batu.vs = 0;
62  }
63  switch (bat_index) {
64  case 0 : asm_setdbat0(bat.word[0], bat.word[1]); break;
65  case 1 : asm_setdbat1(bat.word[0], bat.word[1]); break;
66  case 2 : asm_setdbat2(bat.word[0], bat.word[1]); break;
67  case 3 : asm_setdbat3(bat.word[0], bat.word[1]); break;
68  default: printk("bat.c : invalid BAT bat_index\n");
69  }
70}
71
Note: See TracBrowser for help on using the repository browser.