18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _M68K_PGTABLE_H 38c2ecf20Sopenharmony_ci#define _M68K_PGTABLE_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#if defined(CONFIG_SUN3) || defined(CONFIG_COLDFIRE) 78c2ecf20Sopenharmony_ci#include <asm-generic/pgtable-nopmd.h> 88c2ecf20Sopenharmony_ci#else 98c2ecf20Sopenharmony_ci#include <asm-generic/pgtable-nopud.h> 108c2ecf20Sopenharmony_ci#endif 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <asm/setup.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 158c2ecf20Sopenharmony_ci#include <asm/processor.h> 168c2ecf20Sopenharmony_ci#include <linux/sched.h> 178c2ecf20Sopenharmony_ci#include <linux/threads.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* 208c2ecf20Sopenharmony_ci * This file contains the functions and defines necessary to modify and use 218c2ecf20Sopenharmony_ci * the m68k page table tree. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include <asm/virtconvert.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* Certain architectures need to do special things when pte's 278c2ecf20Sopenharmony_ci * within a page table are directly modified. Thus, the following 288c2ecf20Sopenharmony_ci * hook is made available. 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci#define set_pte(pteptr, pteval) \ 318c2ecf20Sopenharmony_ci do{ \ 328c2ecf20Sopenharmony_ci *(pteptr) = (pteval); \ 338c2ecf20Sopenharmony_ci } while(0) 348c2ecf20Sopenharmony_ci#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* PMD_SHIFT determines the size of the area a second-level page table can map */ 388c2ecf20Sopenharmony_ci#if CONFIG_PGTABLE_LEVELS == 3 398c2ecf20Sopenharmony_ci#define PMD_SHIFT 18 408c2ecf20Sopenharmony_ci#endif 418c2ecf20Sopenharmony_ci#define PMD_SIZE (1UL << PMD_SHIFT) 428c2ecf20Sopenharmony_ci#define PMD_MASK (~(PMD_SIZE-1)) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* PGDIR_SHIFT determines what a third-level page table entry can map */ 458c2ecf20Sopenharmony_ci#ifdef CONFIG_SUN3 468c2ecf20Sopenharmony_ci#define PGDIR_SHIFT 17 478c2ecf20Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 488c2ecf20Sopenharmony_ci#define PGDIR_SHIFT 22 498c2ecf20Sopenharmony_ci#else 508c2ecf20Sopenharmony_ci#define PGDIR_SHIFT 25 518c2ecf20Sopenharmony_ci#endif 528c2ecf20Sopenharmony_ci#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 538c2ecf20Sopenharmony_ci#define PGDIR_MASK (~(PGDIR_SIZE-1)) 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci/* 568c2ecf20Sopenharmony_ci * entries per page directory level: the m68k is configured as three-level, 578c2ecf20Sopenharmony_ci * so we do have PMD level physically. 588c2ecf20Sopenharmony_ci */ 598c2ecf20Sopenharmony_ci#ifdef CONFIG_SUN3 608c2ecf20Sopenharmony_ci#define PTRS_PER_PTE 16 618c2ecf20Sopenharmony_ci#define __PAGETABLE_PMD_FOLDED 1 628c2ecf20Sopenharmony_ci#define PTRS_PER_PMD 1 638c2ecf20Sopenharmony_ci#define PTRS_PER_PGD 2048 648c2ecf20Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 658c2ecf20Sopenharmony_ci#define PTRS_PER_PTE 512 668c2ecf20Sopenharmony_ci#define __PAGETABLE_PMD_FOLDED 1 678c2ecf20Sopenharmony_ci#define PTRS_PER_PMD 1 688c2ecf20Sopenharmony_ci#define PTRS_PER_PGD 1024 698c2ecf20Sopenharmony_ci#else 708c2ecf20Sopenharmony_ci#define PTRS_PER_PTE 64 718c2ecf20Sopenharmony_ci#define PTRS_PER_PMD 128 728c2ecf20Sopenharmony_ci#define PTRS_PER_PGD 128 738c2ecf20Sopenharmony_ci#endif 748c2ecf20Sopenharmony_ci#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) 758c2ecf20Sopenharmony_ci#define FIRST_USER_ADDRESS 0UL 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* Virtual address region for use by kernel_map() */ 788c2ecf20Sopenharmony_ci#ifdef CONFIG_SUN3 798c2ecf20Sopenharmony_ci#define KMAP_START 0x0dc00000 808c2ecf20Sopenharmony_ci#define KMAP_END 0x0e000000 818c2ecf20Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 828c2ecf20Sopenharmony_ci#define KMAP_START 0xe0000000 838c2ecf20Sopenharmony_ci#define KMAP_END 0xf0000000 848c2ecf20Sopenharmony_ci#else 858c2ecf20Sopenharmony_ci#define KMAP_START 0xd0000000 868c2ecf20Sopenharmony_ci#define KMAP_END 0xf0000000 878c2ecf20Sopenharmony_ci#endif 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#ifdef CONFIG_SUN3 908c2ecf20Sopenharmony_ciextern unsigned long m68k_vmalloc_end; 918c2ecf20Sopenharmony_ci#define VMALLOC_START 0x0f800000 928c2ecf20Sopenharmony_ci#define VMALLOC_END m68k_vmalloc_end 938c2ecf20Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 948c2ecf20Sopenharmony_ci#define VMALLOC_START 0xd0000000 958c2ecf20Sopenharmony_ci#define VMALLOC_END 0xe0000000 968c2ecf20Sopenharmony_ci#else 978c2ecf20Sopenharmony_ci/* Just any arbitrary offset to the start of the vmalloc VM area: the 988c2ecf20Sopenharmony_ci * current 8MB value just means that there will be a 8MB "hole" after the 998c2ecf20Sopenharmony_ci * physical memory until the kernel virtual memory starts. That means that 1008c2ecf20Sopenharmony_ci * any out-of-bounds memory accesses will hopefully be caught. 1018c2ecf20Sopenharmony_ci * The vmalloc() routines leaves a hole of 4kB between each vmalloced 1028c2ecf20Sopenharmony_ci * area for the same reason. ;) 1038c2ecf20Sopenharmony_ci */ 1048c2ecf20Sopenharmony_ci#define VMALLOC_OFFSET (8*1024*1024) 1058c2ecf20Sopenharmony_ci#define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)) 1068c2ecf20Sopenharmony_ci#define VMALLOC_END KMAP_START 1078c2ecf20Sopenharmony_ci#endif 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* zero page used for uninitialized stuff */ 1108c2ecf20Sopenharmony_ciextern void *empty_zero_page; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* 1138c2ecf20Sopenharmony_ci * ZERO_PAGE is a global shared page that is always zero: used 1148c2ecf20Sopenharmony_ci * for zero-mapped memory areas etc.. 1158c2ecf20Sopenharmony_ci */ 1168c2ecf20Sopenharmony_ci#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci/* number of bits that fit into a memory pointer */ 1198c2ecf20Sopenharmony_ci#define BITS_PER_PTR (8*sizeof(unsigned long)) 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci/* to align the pointer to a pointer address */ 1228c2ecf20Sopenharmony_ci#define PTR_MASK (~(sizeof(void*)-1)) 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci/* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */ 1258c2ecf20Sopenharmony_ci/* 64-bit machines, beware! SRB. */ 1268c2ecf20Sopenharmony_ci#define SIZEOF_PTR_LOG2 2 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ciextern void kernel_set_cachemode(void *addr, unsigned long size, int cmode); 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci/* 1318c2ecf20Sopenharmony_ci * The m68k doesn't have any external MMU info: the kernel page 1328c2ecf20Sopenharmony_ci * tables contain all the necessary information. The Sun3 does, but 1338c2ecf20Sopenharmony_ci * they are updated on demand. 1348c2ecf20Sopenharmony_ci */ 1358c2ecf20Sopenharmony_cistatic inline void update_mmu_cache(struct vm_area_struct *vma, 1368c2ecf20Sopenharmony_ci unsigned long address, pte_t *ptep) 1378c2ecf20Sopenharmony_ci{ 1388c2ecf20Sopenharmony_ci} 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci#define kern_addr_valid(addr) (1) 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci/* MMU-specific headers */ 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci#ifdef CONFIG_SUN3 1478c2ecf20Sopenharmony_ci#include <asm/sun3_pgtable.h> 1488c2ecf20Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 1498c2ecf20Sopenharmony_ci#include <asm/mcf_pgtable.h> 1508c2ecf20Sopenharmony_ci#else 1518c2ecf20Sopenharmony_ci#include <asm/motorola_pgtable.h> 1528c2ecf20Sopenharmony_ci#endif 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 1558c2ecf20Sopenharmony_ci/* 1568c2ecf20Sopenharmony_ci * Macro to mark a page protection value as "uncacheable". 1578c2ecf20Sopenharmony_ci */ 1588c2ecf20Sopenharmony_ci#ifdef CONFIG_COLDFIRE 1598c2ecf20Sopenharmony_ci# define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | CF_PAGE_NOCACHE)) 1608c2ecf20Sopenharmony_ci#else 1618c2ecf20Sopenharmony_ci#ifdef SUN3_PAGE_NOCACHE 1628c2ecf20Sopenharmony_ci# define __SUN3_PAGE_NOCACHE SUN3_PAGE_NOCACHE 1638c2ecf20Sopenharmony_ci#else 1648c2ecf20Sopenharmony_ci# define __SUN3_PAGE_NOCACHE 0 1658c2ecf20Sopenharmony_ci#endif 1668c2ecf20Sopenharmony_ci#define pgprot_noncached(prot) \ 1678c2ecf20Sopenharmony_ci (MMU_IS_SUN3 \ 1688c2ecf20Sopenharmony_ci ? (__pgprot(pgprot_val(prot) | __SUN3_PAGE_NOCACHE)) \ 1698c2ecf20Sopenharmony_ci : ((MMU_IS_851 || MMU_IS_030) \ 1708c2ecf20Sopenharmony_ci ? (__pgprot(pgprot_val(prot) | _PAGE_NOCACHE030)) \ 1718c2ecf20Sopenharmony_ci : (MMU_IS_040 || MMU_IS_060) \ 1728c2ecf20Sopenharmony_ci ? (__pgprot((pgprot_val(prot) & _CACHEMASK040) | _PAGE_NOCACHE_S)) \ 1738c2ecf20Sopenharmony_ci : (prot))) 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_cipgprot_t pgprot_dmacoherent(pgprot_t prot); 1768c2ecf20Sopenharmony_ci#define pgprot_dmacoherent(prot) pgprot_dmacoherent(prot) 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci#endif /* CONFIG_COLDFIRE */ 1798c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci#endif /* _M68K_PGTABLE_H */ 182