[acc25ee] | 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 | |
---|
| 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 | |
---|
[cebb89b] | 38 | void asm_setdbat0(unsigned int, unsigned int); |
---|
[acc25ee] | 39 | void 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) { |
---|
[c1f00ca] | 59 | case 0 : asm_setdbat0(bat.word[0], bat.word[1]); break; |
---|
[acc25ee] | 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 | |
---|