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/mmu.h> 2314cf11afSPaul Mackerras 242a4aca11SBenjamin Herrenschmidt #ifdef CONFIG_PPC_MMU_NOHASH 25cf4a6085SChristophe Leroy #include <asm/trace.h> 262a4aca11SBenjamin Herrenschmidt 272a4aca11SBenjamin Herrenschmidt /* 282a4aca11SBenjamin Herrenschmidt * On 40x and 8xx, we directly inline tlbia and tlbivax 292a4aca11SBenjamin Herrenschmidt */ 30968159c0SChristophe Leroy #if defined(CONFIG_40x) || defined(CONFIG_PPC_8xx) 312a4aca11SBenjamin Herrenschmidt static inline void _tlbil_all(void) 322a4aca11SBenjamin Herrenschmidt { 334a082682SBenjamin Herrenschmidt asm volatile ("sync; tlbia; isync" : : : "memory"); 348114c36eSChristophe Leroy trace_tlbia(MMU_NO_CONTEXT); 352a4aca11SBenjamin Herrenschmidt } 362a4aca11SBenjamin Herrenschmidt static inline void _tlbil_pid(unsigned int pid) 372a4aca11SBenjamin Herrenschmidt { 384a082682SBenjamin Herrenschmidt asm volatile ("sync; tlbia; isync" : : : "memory"); 398114c36eSChristophe Leroy trace_tlbia(pid); 402a4aca11SBenjamin Herrenschmidt } 41d4e167daSBenjamin Herrenschmidt #define _tlbil_pid_noind(pid) _tlbil_pid(pid) 42d4e167daSBenjamin Herrenschmidt 43968159c0SChristophe Leroy #else /* CONFIG_40x || CONFIG_PPC_8xx */ 442a4aca11SBenjamin Herrenschmidt extern void _tlbil_all(void); 452a4aca11SBenjamin Herrenschmidt extern void _tlbil_pid(unsigned int pid); 4625d21ad6SBenjamin Herrenschmidt #ifdef CONFIG_PPC_BOOK3E 4725d21ad6SBenjamin Herrenschmidt extern void _tlbil_pid_noind(unsigned int pid); 4825d21ad6SBenjamin Herrenschmidt #else 49d4e167daSBenjamin Herrenschmidt #define _tlbil_pid_noind(pid) _tlbil_pid(pid) 5025d21ad6SBenjamin Herrenschmidt #endif 51968159c0SChristophe Leroy #endif /* !(CONFIG_40x || CONFIG_PPC_8xx) */ 522a4aca11SBenjamin Herrenschmidt 532a4aca11SBenjamin Herrenschmidt /* 542a4aca11SBenjamin Herrenschmidt * On 8xx, we directly inline tlbie, on others, it's extern 552a4aca11SBenjamin Herrenschmidt */ 56968159c0SChristophe Leroy #ifdef CONFIG_PPC_8xx 57d4e167daSBenjamin Herrenschmidt static inline void _tlbil_va(unsigned long address, unsigned int pid, 58d4e167daSBenjamin Herrenschmidt unsigned int tsize, unsigned int ind) 592a4aca11SBenjamin Herrenschmidt { 604a082682SBenjamin Herrenschmidt asm volatile ("tlbie %0; sync" : : "r" (address) : "memory"); 61cf4a6085SChristophe Leroy trace_tlbie(0, 0, address, pid, 0, 0, 0); 622a4aca11SBenjamin Herrenschmidt } 6325d21ad6SBenjamin Herrenschmidt #elif defined(CONFIG_PPC_BOOK3E) 6425d21ad6SBenjamin Herrenschmidt extern void _tlbil_va(unsigned long address, unsigned int pid, 6525d21ad6SBenjamin Herrenschmidt unsigned int tsize, unsigned int ind); 6625d21ad6SBenjamin Herrenschmidt #else 67d4e167daSBenjamin Herrenschmidt extern void __tlbil_va(unsigned long address, unsigned int pid); 68d4e167daSBenjamin Herrenschmidt static inline void _tlbil_va(unsigned long address, unsigned int pid, 69d4e167daSBenjamin Herrenschmidt unsigned int tsize, unsigned int ind) 70d4e167daSBenjamin Herrenschmidt { 71d4e167daSBenjamin Herrenschmidt __tlbil_va(address, pid); 72d4e167daSBenjamin Herrenschmidt } 73968159c0SChristophe Leroy #endif /* CONFIG_PPC_8xx */ 742a4aca11SBenjamin Herrenschmidt 75e7f75ad0SDave Kleikamp #if defined(CONFIG_PPC_BOOK3E) || defined(CONFIG_PPC_47x) 7625d21ad6SBenjamin Herrenschmidt extern void _tlbivax_bcast(unsigned long address, unsigned int pid, 7725d21ad6SBenjamin Herrenschmidt unsigned int tsize, unsigned int ind); 7825d21ad6SBenjamin Herrenschmidt #else 79d4e167daSBenjamin Herrenschmidt static inline void _tlbivax_bcast(unsigned long address, unsigned int pid, 80d4e167daSBenjamin Herrenschmidt unsigned int tsize, unsigned int ind) 812a4aca11SBenjamin Herrenschmidt { 822a4aca11SBenjamin Herrenschmidt BUG(); 832a4aca11SBenjamin Herrenschmidt } 8425d21ad6SBenjamin Herrenschmidt #endif 852a4aca11SBenjamin Herrenschmidt 862a4aca11SBenjamin Herrenschmidt #else /* CONFIG_PPC_MMU_NOHASH */ 872a4aca11SBenjamin Herrenschmidt 88ee4f2ea4SBenjamin Herrenschmidt extern void hash_preload(struct mm_struct *mm, unsigned long ea, 8934eb138eSChristophe Leroy bool is_exec, unsigned long trap); 90ee4f2ea4SBenjamin Herrenschmidt 91ee4f2ea4SBenjamin Herrenschmidt 922a4aca11SBenjamin Herrenschmidt extern void _tlbie(unsigned long address); 932a4aca11SBenjamin Herrenschmidt extern void _tlbia(void); 942a4aca11SBenjamin Herrenschmidt 952a4aca11SBenjamin Herrenschmidt #endif /* CONFIG_PPC_MMU_NOHASH */ 962a4aca11SBenjamin Herrenschmidt 97ab1f9dacSPaul Mackerras #ifdef CONFIG_PPC32 9819f5465eSTrent Piepho 9914cf11afSPaul Mackerras extern void mapin_ram(void); 1007c5c4325SBecky Bruce extern void setbat(int index, unsigned long virt, phys_addr_t phys, 1015dd4e4f6SMichael Ellerman unsigned int size, pgprot_t prot); 10214cf11afSPaul Mackerras 10314cf11afSPaul Mackerras extern int __map_without_bats; 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 112800fc3eeSDavid Gibson extern unsigned long ioremap_bot; 113ab1f9dacSPaul Mackerras extern unsigned long __max_low_memory; 11409b5e63fSKumar Gala extern phys_addr_t __initial_memory_limit_addr; 1152bf3016fSStefan Roese extern phys_addr_t total_memory; 1162bf3016fSStefan Roese extern phys_addr_t total_lowmem; 11799c62dd7SKumar Gala extern phys_addr_t memstart_addr; 118d7917ba7SKumar Gala extern phys_addr_t lowmem_end_addr; 11914cf11afSPaul Mackerras 120de32400dSAlbert Herranz #ifdef CONFIG_WII 121de32400dSAlbert Herranz extern unsigned long wii_hole_start; 122de32400dSAlbert Herranz extern unsigned long wii_hole_size; 123de32400dSAlbert Herranz 124de32400dSAlbert Herranz extern unsigned long wii_mmu_mapin_mem2(unsigned long top); 125de32400dSAlbert Herranz extern void wii_memory_fixups(void); 126de32400dSAlbert Herranz #endif 127de32400dSAlbert Herranz 12814cf11afSPaul Mackerras /* ...and now those things that may be slightly different between processor 12914cf11afSPaul Mackerras * architectures. -- Dan 13014cf11afSPaul Mackerras */ 131a372acfaSChristophe Leroy #ifdef CONFIG_PPC32 13214cf11afSPaul Mackerras extern void MMU_init_hw(void); 133*14e609d6SChristophe Leroy unsigned long mmu_mapin_ram(unsigned long base, unsigned long top); 134a372acfaSChristophe Leroy #endif 13514cf11afSPaul Mackerras 136a372acfaSChristophe Leroy #ifdef CONFIG_PPC_FSL_BOOK3E 137eba5de8dSScott Wood extern unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx, 138eba5de8dSScott Wood bool dryrun); 1391dc91c3eSKumar Gala extern unsigned long calc_cam_sz(unsigned long ram, unsigned long virt, 1401dc91c3eSKumar Gala phys_addr_t phys); 14155fd766bSKumar Gala #ifdef CONFIG_PPC32 14214cf11afSPaul Mackerras extern void adjust_total_lowmem(void); 14378a235efSKevin Hao extern int switch_to_as1(void); 1440be7d969SKevin Hao extern void restore_to_as0(int esel, int offset, void *dt_ptr, int bootcpu); 14555fd766bSKumar Gala #endif 14678f62237SKumar Gala extern void loadcam_entry(unsigned int index); 147d9e1831aSScott Wood extern void loadcam_multi(int first_idx, int num, int tmp_idx); 14814cf11afSPaul Mackerras 14978f62237SKumar Gala struct tlbcam { 15078f62237SKumar Gala u32 MAS0; 15178f62237SKumar Gala u32 MAS1; 15278f62237SKumar Gala unsigned long MAS2; 15378f62237SKumar Gala u32 MAS3; 15478f62237SKumar Gala u32 MAS7; 15578f62237SKumar Gala }; 15614cf11afSPaul Mackerras #endif 1573084cdb7SChristophe Leroy 158d7cceda9SChristophe Leroy #if defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_FSL_BOOKE) || defined(CONFIG_PPC_8xx) 1593084cdb7SChristophe Leroy /* 6xx have BATS */ 1603084cdb7SChristophe Leroy /* FSL_BOOKE have TLBCAM */ 1614badd43aSChristophe Leroy /* 8xx have LTLB */ 1623084cdb7SChristophe Leroy phys_addr_t v_block_mapped(unsigned long va); 1633084cdb7SChristophe Leroy unsigned long p_block_mapped(phys_addr_t pa); 1643084cdb7SChristophe Leroy #else 1653084cdb7SChristophe Leroy static inline phys_addr_t v_block_mapped(unsigned long va) { return 0; } 1663084cdb7SChristophe Leroy static inline unsigned long p_block_mapped(phys_addr_t pa) { return 0; } 1673084cdb7SChristophe Leroy #endif 168