162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _M68K_PGTABLE_H 362306a36Sopenharmony_ci#define _M68K_PGTABLE_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#if defined(CONFIG_SUN3) || defined(CONFIG_COLDFIRE) 762306a36Sopenharmony_ci#include <asm-generic/pgtable-nopmd.h> 862306a36Sopenharmony_ci#else 962306a36Sopenharmony_ci#include <asm-generic/pgtable-nopud.h> 1062306a36Sopenharmony_ci#endif 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <asm/setup.h> 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 1562306a36Sopenharmony_ci#include <asm/processor.h> 1662306a36Sopenharmony_ci#include <linux/sched.h> 1762306a36Sopenharmony_ci#include <linux/threads.h> 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci/* 2062306a36Sopenharmony_ci * This file contains the functions and defines necessary to modify and use 2162306a36Sopenharmony_ci * the m68k page table tree. 2262306a36Sopenharmony_ci */ 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#include <asm/virtconvert.h> 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* Certain architectures need to do special things when pte's 2762306a36Sopenharmony_ci * within a page table are directly modified. Thus, the following 2862306a36Sopenharmony_ci * hook is made available. 2962306a36Sopenharmony_ci */ 3062306a36Sopenharmony_ci#define set_pte(pteptr, pteval) \ 3162306a36Sopenharmony_ci do{ \ 3262306a36Sopenharmony_ci *(pteptr) = (pteval); \ 3362306a36Sopenharmony_ci } while(0) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* PMD_SHIFT determines the size of the area a second-level page table can map */ 3662306a36Sopenharmony_ci#if CONFIG_PGTABLE_LEVELS == 3 3762306a36Sopenharmony_ci#define PMD_SHIFT 18 3862306a36Sopenharmony_ci#endif 3962306a36Sopenharmony_ci#define PMD_SIZE (1UL << PMD_SHIFT) 4062306a36Sopenharmony_ci#define PMD_MASK (~(PMD_SIZE-1)) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* PGDIR_SHIFT determines what a third-level page table entry can map */ 4362306a36Sopenharmony_ci#ifdef CONFIG_SUN3 4462306a36Sopenharmony_ci#define PGDIR_SHIFT 17 4562306a36Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 4662306a36Sopenharmony_ci#define PGDIR_SHIFT 22 4762306a36Sopenharmony_ci#else 4862306a36Sopenharmony_ci#define PGDIR_SHIFT 25 4962306a36Sopenharmony_ci#endif 5062306a36Sopenharmony_ci#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 5162306a36Sopenharmony_ci#define PGDIR_MASK (~(PGDIR_SIZE-1)) 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci/* 5462306a36Sopenharmony_ci * entries per page directory level: the m68k is configured as three-level, 5562306a36Sopenharmony_ci * so we do have PMD level physically. 5662306a36Sopenharmony_ci */ 5762306a36Sopenharmony_ci#ifdef CONFIG_SUN3 5862306a36Sopenharmony_ci#define PTRS_PER_PTE 16 5962306a36Sopenharmony_ci#define __PAGETABLE_PMD_FOLDED 1 6062306a36Sopenharmony_ci#define PTRS_PER_PMD 1 6162306a36Sopenharmony_ci#define PTRS_PER_PGD 2048 6262306a36Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 6362306a36Sopenharmony_ci#define PTRS_PER_PTE 512 6462306a36Sopenharmony_ci#define __PAGETABLE_PMD_FOLDED 1 6562306a36Sopenharmony_ci#define PTRS_PER_PMD 1 6662306a36Sopenharmony_ci#define PTRS_PER_PGD 1024 6762306a36Sopenharmony_ci#else 6862306a36Sopenharmony_ci#define PTRS_PER_PTE 64 6962306a36Sopenharmony_ci#define PTRS_PER_PMD 128 7062306a36Sopenharmony_ci#define PTRS_PER_PGD 128 7162306a36Sopenharmony_ci#endif 7262306a36Sopenharmony_ci#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/* Virtual address region for use by kernel_map() */ 7562306a36Sopenharmony_ci#ifdef CONFIG_SUN3 7662306a36Sopenharmony_ci#define KMAP_START 0x0dc00000 7762306a36Sopenharmony_ci#define KMAP_END 0x0e000000 7862306a36Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 7962306a36Sopenharmony_ci#define KMAP_START 0xe0000000 8062306a36Sopenharmony_ci#define KMAP_END 0xf0000000 8162306a36Sopenharmony_ci#elif defined(CONFIG_VIRT) 8262306a36Sopenharmony_ci#define KMAP_START 0xdf000000 8362306a36Sopenharmony_ci#define KMAP_END 0xff000000 8462306a36Sopenharmony_ci#else 8562306a36Sopenharmony_ci#define KMAP_START 0xd0000000 8662306a36Sopenharmony_ci#define KMAP_END 0xf0000000 8762306a36Sopenharmony_ci#endif 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci#ifdef CONFIG_SUN3 9062306a36Sopenharmony_ciextern unsigned long m68k_vmalloc_end; 9162306a36Sopenharmony_ci#define VMALLOC_START 0x0f800000 9262306a36Sopenharmony_ci#define VMALLOC_END m68k_vmalloc_end 9362306a36Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 9462306a36Sopenharmony_ci#define VMALLOC_START 0xd0000000 9562306a36Sopenharmony_ci#define VMALLOC_END 0xe0000000 9662306a36Sopenharmony_ci#elif defined(CONFIG_VIRT) 9762306a36Sopenharmony_ci#define VMALLOC_OFFSET PAGE_SIZE 9862306a36Sopenharmony_ci#define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)) 9962306a36Sopenharmony_ci#define VMALLOC_END KMAP_START 10062306a36Sopenharmony_ci#else 10162306a36Sopenharmony_ci/* Just any arbitrary offset to the start of the vmalloc VM area: the 10262306a36Sopenharmony_ci * current 8MB value just means that there will be a 8MB "hole" after the 10362306a36Sopenharmony_ci * physical memory until the kernel virtual memory starts. That means that 10462306a36Sopenharmony_ci * any out-of-bounds memory accesses will hopefully be caught. 10562306a36Sopenharmony_ci * The vmalloc() routines leaves a hole of 4kB between each vmalloced 10662306a36Sopenharmony_ci * area for the same reason. ;) 10762306a36Sopenharmony_ci */ 10862306a36Sopenharmony_ci#define VMALLOC_OFFSET (8*1024*1024) 10962306a36Sopenharmony_ci#define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)) 11062306a36Sopenharmony_ci#define VMALLOC_END KMAP_START 11162306a36Sopenharmony_ci#endif 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci/* zero page used for uninitialized stuff */ 11462306a36Sopenharmony_ciextern void *empty_zero_page; 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci/* 11762306a36Sopenharmony_ci * ZERO_PAGE is a global shared page that is always zero: used 11862306a36Sopenharmony_ci * for zero-mapped memory areas etc.. 11962306a36Sopenharmony_ci */ 12062306a36Sopenharmony_ci#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci/* number of bits that fit into a memory pointer */ 12362306a36Sopenharmony_ci#define BITS_PER_PTR (8*sizeof(unsigned long)) 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* to align the pointer to a pointer address */ 12662306a36Sopenharmony_ci#define PTR_MASK (~(sizeof(void*)-1)) 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci/* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */ 12962306a36Sopenharmony_ci/* 64-bit machines, beware! SRB. */ 13062306a36Sopenharmony_ci#define SIZEOF_PTR_LOG2 2 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ciextern void kernel_set_cachemode(void *addr, unsigned long size, int cmode); 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci/* 13562306a36Sopenharmony_ci * The m68k doesn't have any external MMU info: the kernel page 13662306a36Sopenharmony_ci * tables contain all the necessary information. The Sun3 does, but 13762306a36Sopenharmony_ci * they are updated on demand. 13862306a36Sopenharmony_ci */ 13962306a36Sopenharmony_cistatic inline void update_mmu_cache_range(struct vm_fault *vmf, 14062306a36Sopenharmony_ci struct vm_area_struct *vma, unsigned long address, 14162306a36Sopenharmony_ci pte_t *ptep, unsigned int nr) 14262306a36Sopenharmony_ci{ 14362306a36Sopenharmony_ci} 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci#define update_mmu_cache(vma, addr, ptep) \ 14662306a36Sopenharmony_ci update_mmu_cache_range(NULL, vma, addr, ptep, 1) 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci/* MMU-specific headers */ 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci#ifdef CONFIG_SUN3 15362306a36Sopenharmony_ci#include <asm/sun3_pgtable.h> 15462306a36Sopenharmony_ci#elif defined(CONFIG_COLDFIRE) 15562306a36Sopenharmony_ci#include <asm/mcf_pgtable.h> 15662306a36Sopenharmony_ci#else 15762306a36Sopenharmony_ci#include <asm/motorola_pgtable.h> 15862306a36Sopenharmony_ci#endif 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 16162306a36Sopenharmony_ci/* 16262306a36Sopenharmony_ci * Macro to mark a page protection value as "uncacheable". 16362306a36Sopenharmony_ci */ 16462306a36Sopenharmony_ci#ifdef CONFIG_COLDFIRE 16562306a36Sopenharmony_ci# define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | CF_PAGE_NOCACHE)) 16662306a36Sopenharmony_ci#else 16762306a36Sopenharmony_ci#ifdef SUN3_PAGE_NOCACHE 16862306a36Sopenharmony_ci# define __SUN3_PAGE_NOCACHE SUN3_PAGE_NOCACHE 16962306a36Sopenharmony_ci#else 17062306a36Sopenharmony_ci# define __SUN3_PAGE_NOCACHE 0 17162306a36Sopenharmony_ci#endif 17262306a36Sopenharmony_ci#define pgprot_noncached(prot) \ 17362306a36Sopenharmony_ci (MMU_IS_SUN3 \ 17462306a36Sopenharmony_ci ? (__pgprot(pgprot_val(prot) | __SUN3_PAGE_NOCACHE)) \ 17562306a36Sopenharmony_ci : ((MMU_IS_851 || MMU_IS_030) \ 17662306a36Sopenharmony_ci ? (__pgprot(pgprot_val(prot) | _PAGE_NOCACHE030)) \ 17762306a36Sopenharmony_ci : (MMU_IS_040 || MMU_IS_060) \ 17862306a36Sopenharmony_ci ? (__pgprot((pgprot_val(prot) & _CACHEMASK040) | _PAGE_NOCACHE_S)) \ 17962306a36Sopenharmony_ci : (prot))) 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_cipgprot_t pgprot_dmacoherent(pgprot_t prot); 18262306a36Sopenharmony_ci#define pgprot_dmacoherent(prot) pgprot_dmacoherent(prot) 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci#endif /* CONFIG_COLDFIRE */ 18562306a36Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci#endif /* _M68K_PGTABLE_H */ 188