Commit 7c5c4325 authored by Becky Bruce's avatar Becky Bruce Committed by Paul Mackerras

powerpc: Change BAT code to use phys_addr_t

Currently, the physical address is an unsigned long, but it should
be phys_addr_t in set_bat, [v/p]_mapped_by_bat.  Also, create a
macro that can convert a large physical address into the correct
format for programming the BAT registers.
Signed-off-by: default avatarBecky Bruce <becky.bruce@freescale.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent bf2737f7
...@@ -29,7 +29,7 @@ extern void hash_preload(struct mm_struct *mm, unsigned long ea, ...@@ -29,7 +29,7 @@ extern void hash_preload(struct mm_struct *mm, unsigned long ea,
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC32
extern void mapin_ram(void); extern void mapin_ram(void);
extern int map_page(unsigned long va, phys_addr_t pa, int flags); extern int map_page(unsigned long va, phys_addr_t pa, int flags);
extern void setbat(int index, unsigned long virt, unsigned long phys, extern void setbat(int index, unsigned long virt, phys_addr_t phys,
unsigned int size, int flags); unsigned int size, int flags);
extern void settlbcam(int index, unsigned long virt, phys_addr_t phys, extern void settlbcam(int index, unsigned long virt, phys_addr_t phys,
unsigned int size, int flags, unsigned int pid); unsigned int size, int flags, unsigned int pid);
......
...@@ -53,9 +53,9 @@ extern void hash_page_sync(void); ...@@ -53,9 +53,9 @@ extern void hash_page_sync(void);
#endif #endif
#ifdef HAVE_BATS #ifdef HAVE_BATS
extern unsigned long v_mapped_by_bats(unsigned long va); extern phys_addr_t v_mapped_by_bats(unsigned long va);
extern unsigned long p_mapped_by_bats(unsigned long pa); extern unsigned long p_mapped_by_bats(phys_addr_t pa);
void setbat(int index, unsigned long virt, unsigned long phys, void setbat(int index, unsigned long virt, phys_addr_t phys,
unsigned int size, int flags); unsigned int size, int flags);
#else /* !HAVE_BATS */ #else /* !HAVE_BATS */
......
...@@ -46,13 +46,13 @@ union ubat { /* BAT register values to be loaded */ ...@@ -46,13 +46,13 @@ union ubat { /* BAT register values to be loaded */
struct batrange { /* stores address ranges mapped by BATs */ struct batrange { /* stores address ranges mapped by BATs */
unsigned long start; unsigned long start;
unsigned long limit; unsigned long limit;
unsigned long phys; phys_addr_t phys;
} bat_addrs[8]; } bat_addrs[8];
/* /*
* Return PA for this VA if it is mapped by a BAT, or 0 * Return PA for this VA if it is mapped by a BAT, or 0
*/ */
unsigned long v_mapped_by_bats(unsigned long va) phys_addr_t v_mapped_by_bats(unsigned long va)
{ {
int b; int b;
for (b = 0; b < 4; ++b) for (b = 0; b < 4; ++b)
...@@ -64,7 +64,7 @@ unsigned long v_mapped_by_bats(unsigned long va) ...@@ -64,7 +64,7 @@ unsigned long v_mapped_by_bats(unsigned long va)
/* /*
* Return VA for a given PA or 0 if not mapped * Return VA for a given PA or 0 if not mapped
*/ */
unsigned long p_mapped_by_bats(unsigned long pa) unsigned long p_mapped_by_bats(phys_addr_t pa)
{ {
int b; int b;
for (b = 0; b < 4; ++b) for (b = 0; b < 4; ++b)
...@@ -119,7 +119,7 @@ unsigned long __init mmu_mapin_ram(void) ...@@ -119,7 +119,7 @@ unsigned long __init mmu_mapin_ram(void)
* The parameters are not checked; in particular size must be a power * The parameters are not checked; in particular size must be a power
* of 2 between 128k and 256M. * of 2 between 128k and 256M.
*/ */
void __init setbat(int index, unsigned long virt, unsigned long phys, void __init setbat(int index, unsigned long virt, phys_addr_t phys,
unsigned int size, int flags) unsigned int size, int flags)
{ {
unsigned int bl; unsigned int bl;
...@@ -138,7 +138,7 @@ void __init setbat(int index, unsigned long virt, unsigned long phys, ...@@ -138,7 +138,7 @@ void __init setbat(int index, unsigned long virt, unsigned long phys,
| _PAGE_COHERENT | _PAGE_GUARDED); | _PAGE_COHERENT | _PAGE_GUARDED);
wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX; wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX;
bat[1].word[0] = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */ bat[1].word[0] = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */
bat[1].word[1] = phys | wimgxpp; bat[1].word[1] = BAT_PHYS_ADDR(phys) | wimgxpp;
#ifndef CONFIG_KGDB /* want user access for breakpoints */ #ifndef CONFIG_KGDB /* want user access for breakpoints */
if (flags & _PAGE_USER) if (flags & _PAGE_USER)
#endif #endif
......
...@@ -28,6 +28,15 @@ ...@@ -28,6 +28,15 @@
#define BPP_RW 0x02 /* Read/write */ #define BPP_RW 0x02 /* Read/write */
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
/* Contort a phys_addr_t into the right format/bits for a BAT */
#ifdef CONFIG_PHYS_64BIT
#define BAT_PHYS_ADDR(x) ((u32)((x & 0x00000000fffe0000ULL) | \
((x & 0x0000000e00000000ULL) >> 24) | \
((x & 0x0000000100000000ULL) >> 30)))
#else
#define BAT_PHYS_ADDR(x) (x)
#endif
struct ppc_bat { struct ppc_bat {
struct { struct {
unsigned long bepi:15; /* Effective page index (virtual address) */ unsigned long bepi:15; /* Effective page index (virtual address) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment