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

4.104.114.84.95
Last change on this file since cebb89b was cebb89b, checked in by Joel Sherrill <joel.sherrill@…>, on 10/31/02 at 20:12:46

2002-10-31 Joel Sherrill <joel@…>

  • mpc6xx/clock/c_clock.c, mpc6xx/exceptions/raw_exception.c, mpc6xx/mmu/bat.c: Removed warnings.
  • Property mode set to 100644
File size: 1.9 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 >> 17) - 1;
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 + 1) << 17) - 1;
57  bat_addrs[bat_index].phys = phys;
58  switch (bat_index) {
59  case 0 : asm_setdbat0(bat.word[0], bat.word[1]); break;
60  case 1 : asm_setdbat1(bat.word[0], bat.word[1]); break;
61  case 2 : asm_setdbat2(bat.word[0], bat.word[1]); break;
62  case 3 : asm_setdbat3(bat.word[0], bat.word[1]); break;
63  default: printk("bat.c : invalid BAT bat_index\n");
64  }
65}
66
Note: See TracBrowser for help on using the repository browser.