Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Paul Mackerras 1997. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version |
| 7 | * 2 of the License, or (at your option) any later version. |
| 8 | */ |
| 9 | .text |
| 10 | |
| 11 | /* |
| 12 | * Use the BAT2 & 3 registers to map the 1st 16MB of RAM to |
| 13 | * the address given as the 1st argument. |
| 14 | */ |
| 15 | .globl setup_bats |
| 16 | setup_bats: |
| 17 | mfpvr 5 |
| 18 | rlwinm 5,5,16,16,31 /* r3 = 1 for 601, 4 for 604 */ |
| 19 | cmpwi 0,5,1 |
| 20 | li 0,0 |
| 21 | bne 4f |
| 22 | mtibatl 3,0 /* invalidate BAT first */ |
| 23 | ori 3,3,4 /* set up BAT registers for 601 */ |
| 24 | li 4,0x7f |
| 25 | mtibatu 2,3 |
| 26 | mtibatl 2,4 |
| 27 | oris 3,3,0x80 |
| 28 | oris 4,4,0x80 |
| 29 | mtibatu 3,3 |
| 30 | mtibatl 3,4 |
| 31 | b 5f |
| 32 | 4: mtdbatu 3,0 /* invalidate BATs first */ |
| 33 | mtibatu 3,0 |
| 34 | ori 3,3,0xff /* set up BAT registers for 604 */ |
| 35 | li 4,2 |
| 36 | mtdbatl 2,4 |
| 37 | mtdbatu 2,3 |
| 38 | mtibatl 2,4 |
| 39 | mtibatu 2,3 |
| 40 | oris 3,3,0x80 |
| 41 | oris 4,4,0x80 |
| 42 | mtdbatl 3,4 |
| 43 | mtdbatu 3,3 |
| 44 | mtibatl 3,4 |
| 45 | mtibatu 3,3 |
| 46 | 5: sync |
| 47 | isync |
| 48 | blr |
| 49 | |
| 50 | /* |
| 51 | * Flush the dcache and invalidate the icache for a range of addresses. |
| 52 | * |
| 53 | * flush_cache(addr, len) |
| 54 | */ |
| 55 | .global flush_cache |
| 56 | flush_cache: |
| 57 | addi 4,4,0x1f /* len = (len + 0x1f) / 0x20 */ |
| 58 | rlwinm. 4,4,27,5,31 |
| 59 | mtctr 4 |
| 60 | beqlr |
| 61 | 1: dcbf 0,3 |
| 62 | icbi 0,3 |
| 63 | addi 3,3,0x20 |
| 64 | bdnz 1b |
| 65 | sync |
| 66 | isync |
| 67 | blr |