114cf11afSPaul Mackerras /* 214cf11afSPaul Mackerras * Declarations of procedures and variables shared between files 314cf11afSPaul Mackerras * in arch/ppc/mm/. 414cf11afSPaul Mackerras * 514cf11afSPaul Mackerras * Derived from arch/ppc/mm/init.c: 614cf11afSPaul Mackerras * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 714cf11afSPaul Mackerras * 814cf11afSPaul Mackerras * Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au) 914cf11afSPaul Mackerras * and Cort Dougan (PReP) (cort@cs.nmt.edu) 1014cf11afSPaul Mackerras * Copyright (C) 1996 Paul Mackerras 1114cf11afSPaul Mackerras * 1214cf11afSPaul Mackerras * Derived from "arch/i386/mm/init.c" 1314cf11afSPaul Mackerras * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 1414cf11afSPaul Mackerras * 1514cf11afSPaul Mackerras * This program is free software; you can redistribute it and/or 1614cf11afSPaul Mackerras * modify it under the terms of the GNU General Public License 1714cf11afSPaul Mackerras * as published by the Free Software Foundation; either version 1814cf11afSPaul Mackerras * 2 of the License, or (at your option) any later version. 1914cf11afSPaul Mackerras * 2014cf11afSPaul Mackerras */ 2162102307SDavid Gibson #include <linux/mm.h> 2214cf11afSPaul Mackerras #include <asm/tlbflush.h> 2314cf11afSPaul Mackerras #include <asm/mmu.h> 2414cf11afSPaul Mackerras 252a4aca11SBenjamin Herrenschmidt #ifdef CONFIG_PPC_MMU_NOHASH 262a4aca11SBenjamin Herrenschmidt 272a4aca11SBenjamin Herrenschmidt /* 282a4aca11SBenjamin Herrenschmidt * On 40x and 8xx, we directly inline tlbia and tlbivax 292a4aca11SBenjamin Herrenschmidt */ 302a4aca11SBenjamin Herrenschmidt #if defined(CONFIG_40x) || defined(CONFIG_8xx) 312a4aca11SBenjamin Herrenschmidt static inline void _tlbil_all(void) 322a4aca11SBenjamin Herrenschmidt { 334a082682SBenjamin Herrenschmidt asm volatile ("sync; tlbia; isync" : : : "memory"); 342a4aca11SBenjamin Herrenschmidt } 352a4aca11SBenjamin Herrenschmidt static inline void _tlbil_pid(unsigned int pid) 362a4aca11SBenjamin Herrenschmidt { 374a082682SBenjamin Herrenschmidt asm volatile ("sync; tlbia; isync" : : : "memory"); 382a4aca11SBenjamin Herrenschmidt } 39d4e167daSBenjamin Herrenschmidt #define _tlbil_pid_noind(pid) _tlbil_pid(pid) 40d4e167daSBenjamin Herrenschmidt 412a4aca11SBenjamin Herrenschmidt #else /* CONFIG_40x || CONFIG_8xx */ 422a4aca11SBenjamin Herrenschmidt extern void _tlbil_all(void); 432a4aca11SBenjamin Herrenschmidt extern void _tlbil_pid(unsigned int pid); 4425d21ad6SBenjamin Herrenschmidt #ifdef CONFIG_PPC_BOOK3E 4525d21ad6SBenjamin Herrenschmidt extern void _tlbil_pid_noind(unsigned int pid); 4625d21ad6SBenjamin Herrenschmidt #else 47d4e167daSBenjamin Herrenschmidt #define _tlbil_pid_noind(pid) _tlbil_pid(pid) 4825d21ad6SBenjamin Herrenschmidt #endif 492a4aca11SBenjamin Herrenschmidt #endif /* !(CONFIG_40x || CONFIG_8xx) */ 502a4aca11SBenjamin Herrenschmidt 512a4aca11SBenjamin Herrenschmidt /* 522a4aca11SBenjamin Herrenschmidt * On 8xx, we directly inline tlbie, on others, it's extern 532a4aca11SBenjamin Herrenschmidt */ 542a4aca11SBenjamin Herrenschmidt #ifdef CONFIG_8xx 55d4e167daSBenjamin Herrenschmidt static inline void _tlbil_va(unsigned long address, unsigned int pid, 56d4e167daSBenjamin Herrenschmidt unsigned int tsize, unsigned int ind) 572a4aca11SBenjamin Herrenschmidt { 584a082682SBenjamin Herrenschmidt asm volatile ("tlbie %0; sync" : : "r" (address) : "memory"); 592a4aca11SBenjamin Herrenschmidt } 6025d21ad6SBenjamin Herrenschmidt #elif defined(CONFIG_PPC_BOOK3E) 6125d21ad6SBenjamin Herrenschmidt extern void _tlbil_va(unsigned long address, unsigned int pid, 6225d21ad6SBenjamin Herrenschmidt unsigned int tsize, unsigned int ind); 6325d21ad6SBenjamin Herrenschmidt #else 64d4e167daSBenjamin Herrenschmidt extern void __tlbil_va(unsigned long address, unsigned int pid); 65d4e167daSBenjamin Herrenschmidt static inline void _tlbil_va(unsigned long address, unsigned int pid, 66d4e167daSBenjamin Herrenschmidt unsigned int tsize, unsigned int ind) 67d4e167daSBenjamin Herrenschmidt { 68d4e167daSBenjamin Herrenschmidt __tlbil_va(address, pid); 69d4e167daSBenjamin Herrenschmidt } 70b823982cSPaul Bolle #endif /* CONFIG_8xx */ 712a4aca11SBenjamin Herrenschmidt 72e7f75ad0SDave Kleikamp #if defined(CONFIG_PPC_BOOK3E) || defined(CONFIG_PPC_47x) 7325d21ad6SBenjamin Herrenschmidt extern void _tlbivax_bcast(unsigned long address, unsigned int pid, 7425d21ad6SBenjamin Herrenschmidt unsigned int tsize, unsigned int ind); 7525d21ad6SBenjamin Herrenschmidt #else 76d4e167daSBenjamin Herrenschmidt static inline void _tlbivax_bcast(unsigned long address, unsigned int pid, 77d4e167daSBenjamin Herrenschmidt unsigned int tsize, unsigned int ind) 782a4aca11SBenjamin Herrenschmidt { 792a4aca11SBenjamin Herrenschmidt BUG(); 802a4aca11SBenjamin Herrenschmidt } 8125d21ad6SBenjamin Herrenschmidt #endif 822a4aca11SBenjamin Herrenschmidt 832a4aca11SBenjamin Herrenschmidt #else /* CONFIG_PPC_MMU_NOHASH */ 842a4aca11SBenjamin Herrenschmidt 85ee4f2ea4SBenjamin Herrenschmidt extern void hash_preload(struct mm_struct *mm, unsigned long ea, 86ee4f2ea4SBenjamin Herrenschmidt unsigned long access, unsigned long trap); 87ee4f2ea4SBenjamin Herrenschmidt 88ee4f2ea4SBenjamin Herrenschmidt 892a4aca11SBenjamin Herrenschmidt extern void _tlbie(unsigned long address); 902a4aca11SBenjamin Herrenschmidt extern void _tlbia(void); 912a4aca11SBenjamin Herrenschmidt 922a4aca11SBenjamin Herrenschmidt #endif /* CONFIG_PPC_MMU_NOHASH */ 932a4aca11SBenjamin Herrenschmidt 94ab1f9dacSPaul Mackerras #ifdef CONFIG_PPC32 9519f5465eSTrent Piepho 9614cf11afSPaul Mackerras extern void mapin_ram(void); 9714cf11afSPaul Mackerras extern int map_page(unsigned long va, phys_addr_t pa, int flags); 987c5c4325SBecky Bruce extern void setbat(int index, unsigned long virt, phys_addr_t phys, 995dd4e4f6SMichael Ellerman unsigned int size, pgprot_t prot); 10014cf11afSPaul Mackerras 10114cf11afSPaul Mackerras extern int __map_without_bats; 102c5df7f77SAlbert Herranz extern int __allow_ioremap_reserved; 10314cf11afSPaul Mackerras extern unsigned long ioremap_base; 10414cf11afSPaul Mackerras extern unsigned int rtas_data, rtas_size; 10514cf11afSPaul Mackerras 1068e561e7eSDavid Gibson struct hash_pte; 1078e561e7eSDavid Gibson extern struct hash_pte *Hash, *Hash_end; 10814cf11afSPaul Mackerras extern unsigned long Hash_size, Hash_mask; 10932a74949SBenjamin Herrenschmidt 11032a74949SBenjamin Herrenschmidt #endif /* CONFIG_PPC32 */ 11132a74949SBenjamin Herrenschmidt 11232a74949SBenjamin Herrenschmidt #ifdef CONFIG_PPC64 11332a74949SBenjamin Herrenschmidt extern int map_kernel_page(unsigned long ea, unsigned long pa, int flags); 11432a74949SBenjamin Herrenschmidt #endif /* CONFIG_PPC64 */ 115ab1f9dacSPaul Mackerras 116800fc3eeSDavid Gibson extern unsigned long ioremap_bot; 117ab1f9dacSPaul Mackerras extern unsigned long __max_low_memory; 11809b5e63fSKumar Gala extern phys_addr_t __initial_memory_limit_addr; 1192bf3016fSStefan Roese extern phys_addr_t total_memory; 1202bf3016fSStefan Roese extern phys_addr_t total_lowmem; 12199c62dd7SKumar Gala extern phys_addr_t memstart_addr; 122d7917ba7SKumar Gala extern phys_addr_t lowmem_end_addr; 12314cf11afSPaul Mackerras 124de32400dSAlbert Herranz #ifdef CONFIG_WII 125de32400dSAlbert Herranz extern unsigned long wii_hole_start; 126de32400dSAlbert Herranz extern unsigned long wii_hole_size; 127de32400dSAlbert Herranz 128de32400dSAlbert Herranz extern unsigned long wii_mmu_mapin_mem2(unsigned long top); 129de32400dSAlbert Herranz extern void wii_memory_fixups(void); 130de32400dSAlbert Herranz #endif 131de32400dSAlbert Herranz 13214cf11afSPaul Mackerras /* ...and now those things that may be slightly different between processor 13314cf11afSPaul Mackerras * architectures. -- Dan 13414cf11afSPaul Mackerras */ 13514cf11afSPaul Mackerras #if defined(CONFIG_8xx) 13614cf11afSPaul Mackerras #define MMU_init_hw() do { } while(0) 137ae4cec47SStephen Rothwell #define mmu_mapin_ram(top) (0UL) 13814cf11afSPaul Mackerras 13914cf11afSPaul Mackerras #elif defined(CONFIG_4xx) 14014cf11afSPaul Mackerras extern void MMU_init_hw(void); 141ae4cec47SStephen Rothwell extern unsigned long mmu_mapin_ram(unsigned long top); 14214cf11afSPaul Mackerras 14355fd766bSKumar Gala #elif defined(CONFIG_PPC_FSL_BOOK3E) 14455fd766bSKumar Gala extern unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx); 1451dc91c3eSKumar Gala extern unsigned long calc_cam_sz(unsigned long ram, unsigned long virt, 1461dc91c3eSKumar Gala phys_addr_t phys); 14755fd766bSKumar Gala #ifdef CONFIG_PPC32 14814cf11afSPaul Mackerras extern void MMU_init_hw(void); 149ae4cec47SStephen Rothwell extern unsigned long mmu_mapin_ram(unsigned long top); 15014cf11afSPaul Mackerras extern void adjust_total_lowmem(void); 15178a235efSKevin Hao extern int switch_to_as1(void); 1520be7d969SKevin Hao extern void restore_to_as0(int esel, int offset, void *dt_ptr, int bootcpu); 15355fd766bSKumar Gala #endif 15478f62237SKumar Gala extern void loadcam_entry(unsigned int index); 155*d9e1831aSScott Wood extern void loadcam_multi(int first_idx, int num, int tmp_idx); 15614cf11afSPaul Mackerras 15778f62237SKumar Gala struct tlbcam { 15878f62237SKumar Gala u32 MAS0; 15978f62237SKumar Gala u32 MAS1; 16078f62237SKumar Gala unsigned long MAS2; 16178f62237SKumar Gala u32 MAS3; 16278f62237SKumar Gala u32 MAS7; 16378f62237SKumar Gala }; 164ab1f9dacSPaul Mackerras #elif defined(CONFIG_PPC32) 165ab1f9dacSPaul Mackerras /* anything 32-bit except 4xx or 8xx */ 16614cf11afSPaul Mackerras extern void MMU_init_hw(void); 167de32400dSAlbert Herranz extern unsigned long mmu_mapin_ram(unsigned long top); 16814cf11afSPaul Mackerras #endif 169