OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libcpu/] [powerpc/] [mpc6xx/] [mmu/] [bat.c] - Blame information for rev 507

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: bat.c,v 1.2 2001-09-27 12:01:25 chris Exp $
21
 */
22
 
23
#include <libcpu/bat.h>
24
 
25
typedef union {                 /* BAT register values to be loaded */
26
        BAT             bat;
27
        unsigned int    word[2];
28
}ubat;
29
 
30
typedef struct batrange {               /* stores address ranges mapped by BATs */
31
        unsigned long start;
32
        unsigned long limit;
33
        unsigned long phys;
34
}batrange;
35
 
36
batrange bat_addrs[4];
37
 
38
void setdbat(int bat_index, unsigned long virt, unsigned long phys,
39
       unsigned int size, int flags)
40
{
41
  unsigned int bl;
42
  int wimgxpp;
43
  ubat bat;
44
 
45
  bl = (size >> 17) - 1;
46
  /* 603, 604, etc. */
47
  wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
48
                     | _PAGE_COHERENT | _PAGE_GUARDED);
49
  wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX;
50
  bat.word[0] = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */
51
  bat.word[1] = phys | wimgxpp;
52
  if (flags & _PAGE_USER)
53
    bat.bat.batu.vp = 1;
54
  bat_addrs[bat_index].start = virt;
55
  bat_addrs[bat_index].limit = virt + ((bl + 1) << 17) - 1;
56
  bat_addrs[bat_index].phys = phys;
57
  switch (bat_index) {
58
  case 1 : asm_setdbat1(bat.word[0], bat.word[1]); break;
59
  case 2 : asm_setdbat2(bat.word[0], bat.word[1]); break;
60
  case 3 : asm_setdbat3(bat.word[0], bat.word[1]); break;
61
  default: printk("bat.c : invalid BAT bat_index\n");
62
  }
63
}
64
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.