Linux Audio

Check our new training course

Loading...
v4.17
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef __ASM_SH_PAGE_H
  3#define __ASM_SH_PAGE_H
  4
  5/*
  6 * Copyright (C) 1999  Niibe Yutaka
  7 */
  8
  9#include <linux/const.h>
 10
 11/* PAGE_SHIFT determines the page size */
 12#if defined(CONFIG_PAGE_SIZE_4KB)
 13# define PAGE_SHIFT	12
 14#elif defined(CONFIG_PAGE_SIZE_8KB)
 15# define PAGE_SHIFT	13
 16#elif defined(CONFIG_PAGE_SIZE_16KB)
 17# define PAGE_SHIFT	14
 18#elif defined(CONFIG_PAGE_SIZE_64KB)
 19# define PAGE_SHIFT	16
 20#else
 21# error "Bogus kernel page size?"
 22#endif
 23
 24#define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
 25#define PAGE_MASK	(~(PAGE_SIZE-1))
 26#define PTE_MASK	PAGE_MASK
 27
 28#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
 29#define HPAGE_SHIFT	16
 30#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
 31#define HPAGE_SHIFT	18
 32#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
 33#define HPAGE_SHIFT	20
 34#elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
 35#define HPAGE_SHIFT	22
 36#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
 37#define HPAGE_SHIFT	26
 38#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512MB)
 39#define HPAGE_SHIFT	29
 40#endif
 41
 42#ifdef CONFIG_HUGETLB_PAGE
 43#define HPAGE_SIZE		(1UL << HPAGE_SHIFT)
 44#define HPAGE_MASK		(~(HPAGE_SIZE-1))
 45#define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT-PAGE_SHIFT)
 46#endif
 47
 48#ifndef __ASSEMBLY__
 49#include <asm/uncached.h>
 50
 51extern unsigned long shm_align_mask;
 52extern unsigned long max_low_pfn, min_low_pfn;
 53extern unsigned long memory_start, memory_end, memory_limit;
 54
 55static inline unsigned long
 56pages_do_alias(unsigned long addr1, unsigned long addr2)
 57{
 58	return (addr1 ^ addr2) & shm_align_mask;
 59}
 60
 61#define clear_page(page)	memset((void *)(page), 0, PAGE_SIZE)
 62extern void copy_page(void *to, void *from);
 63#define copy_user_page(to, from, vaddr, pg)  __copy_user(to, from, PAGE_SIZE)
 64
 65struct page;
 66struct vm_area_struct;
 67
 68extern void copy_user_highpage(struct page *to, struct page *from,
 69			       unsigned long vaddr, struct vm_area_struct *vma);
 70#define __HAVE_ARCH_COPY_USER_HIGHPAGE
 71extern void clear_user_highpage(struct page *page, unsigned long vaddr);
 72#define clear_user_highpage	clear_user_highpage
 73
 74/*
 75 * These are used to make use of C type-checking..
 76 */
 77#ifdef CONFIG_X2TLB
 78typedef struct { unsigned long pte_low, pte_high; } pte_t;
 79typedef struct { unsigned long long pgprot; } pgprot_t;
 80typedef struct { unsigned long long pgd; } pgd_t;
 81#define pte_val(x) \
 82	((x).pte_low | ((unsigned long long)(x).pte_high << 32))
 83#define __pte(x) \
 84	({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
 85#elif defined(CONFIG_SUPERH32)
 86typedef struct { unsigned long pte_low; } pte_t;
 87typedef struct { unsigned long pgprot; } pgprot_t;
 88typedef struct { unsigned long pgd; } pgd_t;
 89#define pte_val(x)	((x).pte_low)
 90#define __pte(x)	((pte_t) { (x) } )
 91#else
 92typedef struct { unsigned long long pte_low; } pte_t;
 93typedef struct { unsigned long long pgprot; } pgprot_t;
 94typedef struct { unsigned long pgd; } pgd_t;
 95#define pte_val(x)	((x).pte_low)
 96#define __pte(x)	((pte_t) { (x) } )
 97#endif
 98
 99#define pgd_val(x)	((x).pgd)
100#define pgprot_val(x)	((x).pgprot)
101
102#define __pgd(x) ((pgd_t) { (x) } )
103#define __pgprot(x)	((pgprot_t) { (x) } )
104
105typedef struct page *pgtable_t;
106
107#define pte_pgprot(x) __pgprot(pte_val(x) & PTE_FLAGS_MASK)
108
109#endif /* !__ASSEMBLY__ */
110
111/*
112 * __MEMORY_START and SIZE are the physical addresses and size of RAM.
113 */
114#define __MEMORY_START		CONFIG_MEMORY_START
115#define __MEMORY_SIZE		CONFIG_MEMORY_SIZE
116
117/*
118 * PHYSICAL_OFFSET is the offset in physical memory where the base
119 * of the kernel is loaded.
120 */
121#ifdef CONFIG_PHYSICAL_START
122#define PHYSICAL_OFFSET (CONFIG_PHYSICAL_START - __MEMORY_START)
123#else
124#define PHYSICAL_OFFSET 0
125#endif
126
127/*
128 * PAGE_OFFSET is the virtual address of the start of kernel address
129 * space.
130 */
131#define PAGE_OFFSET		CONFIG_PAGE_OFFSET
132
133/*
134 * Virtual to physical RAM address translation.
135 *
136 * In 29 bit mode, the physical offset of RAM from address 0 is visible in
137 * the kernel virtual address space, and thus we don't have to take
138 * this into account when translating. However in 32 bit mode this offset
139 * is not visible (it is part of the PMB mapping) and so needs to be
140 * added or subtracted as required.
141 */
142#ifdef CONFIG_PMB
143#define ___pa(x)	((x)-PAGE_OFFSET+__MEMORY_START)
144#define ___va(x)	((x)+PAGE_OFFSET-__MEMORY_START)
145#else
146#define ___pa(x)	((x)-PAGE_OFFSET)
147#define ___va(x)	((x)+PAGE_OFFSET)
148#endif
149
150#ifndef __ASSEMBLY__
151#define __pa(x)		___pa((unsigned long)x)
152#define __va(x)		(void *)___va((unsigned long)x)
153#endif /* !__ASSEMBLY__ */
154
155#ifdef CONFIG_UNCACHED_MAPPING
156#if defined(CONFIG_29BIT)
157#define UNCAC_ADDR(addr)	P2SEGADDR(addr)
158#define CAC_ADDR(addr)		P1SEGADDR(addr)
159#else
160#define UNCAC_ADDR(addr)	((addr) - PAGE_OFFSET + uncached_start)
161#define CAC_ADDR(addr)		((addr) - uncached_start + PAGE_OFFSET)
162#endif
163#else
164#define UNCAC_ADDR(addr)	((addr))
165#define CAC_ADDR(addr)		((addr))
166#endif
167
168#define pfn_to_kaddr(pfn)	__va((pfn) << PAGE_SHIFT)
169#define page_to_phys(page)	(page_to_pfn(page) << PAGE_SHIFT)
170
171/*
172 * PFN = physical frame number (ie PFN 0 == physical address 0)
173 * PFN_START is the PFN of the first page of RAM. By defining this we
174 * don't have struct page entries for the portion of address space
175 * between physical address 0 and the start of RAM.
176 */
177#define PFN_START		(__MEMORY_START >> PAGE_SHIFT)
178#define ARCH_PFN_OFFSET		(PFN_START)
179#define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
180#ifdef CONFIG_FLATMEM
181#define pfn_valid(pfn)		((pfn) >= min_low_pfn && (pfn) < max_low_pfn)
182#endif
183#define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
184
185#define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
186				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
187
188#include <asm-generic/memory_model.h>
189#include <asm-generic/getorder.h>
190
191/*
192 * Some drivers need to perform DMA into kmalloc'ed buffers
193 * and so we have to increase the kmalloc minalign for this.
194 */
195#define ARCH_DMA_MINALIGN	L1_CACHE_BYTES
196
197#ifdef CONFIG_SUPERH64
198/*
199 * While BYTES_PER_WORD == 4 on the current sh64 ABI, GCC will still
200 * happily generate {ld/st}.q pairs, requiring us to have 8-byte
201 * alignment to avoid traps. The kmalloc alignment is guaranteed by
202 * virtue of L1_CACHE_BYTES, requiring this to only be special cased
203 * for slab caches.
204 */
205#define ARCH_SLAB_MINALIGN	8
206#endif
207
208#endif /* __ASM_SH_PAGE_H */
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef __ASM_SH_PAGE_H
  3#define __ASM_SH_PAGE_H
  4
  5/*
  6 * Copyright (C) 1999  Niibe Yutaka
  7 */
  8
  9#include <linux/const.h>
 10
 11/* PAGE_SHIFT determines the page size */
 12#if defined(CONFIG_PAGE_SIZE_4KB)
 13# define PAGE_SHIFT	12
 14#elif defined(CONFIG_PAGE_SIZE_8KB)
 15# define PAGE_SHIFT	13
 16#elif defined(CONFIG_PAGE_SIZE_16KB)
 17# define PAGE_SHIFT	14
 18#elif defined(CONFIG_PAGE_SIZE_64KB)
 19# define PAGE_SHIFT	16
 20#else
 21# error "Bogus kernel page size?"
 22#endif
 23
 24#define PAGE_SIZE	(_AC(1, UL) << PAGE_SHIFT)
 25#define PAGE_MASK	(~(PAGE_SIZE-1))
 26#define PTE_MASK	PAGE_MASK
 27
 28#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
 29#define HPAGE_SHIFT	16
 30#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
 31#define HPAGE_SHIFT	18
 32#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
 33#define HPAGE_SHIFT	20
 34#elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
 35#define HPAGE_SHIFT	22
 36#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
 37#define HPAGE_SHIFT	26
 
 
 38#endif
 39
 40#ifdef CONFIG_HUGETLB_PAGE
 41#define HPAGE_SIZE		(1UL << HPAGE_SHIFT)
 42#define HPAGE_MASK		(~(HPAGE_SIZE-1))
 43#define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT-PAGE_SHIFT)
 44#endif
 45
 46#ifndef __ASSEMBLY__
 47#include <asm/uncached.h>
 48
 49extern unsigned long shm_align_mask;
 50extern unsigned long max_low_pfn, min_low_pfn;
 51extern unsigned long memory_start, memory_end, memory_limit;
 52
 53static inline unsigned long
 54pages_do_alias(unsigned long addr1, unsigned long addr2)
 55{
 56	return (addr1 ^ addr2) & shm_align_mask;
 57}
 58
 59#define clear_page(page)	memset((void *)(page), 0, PAGE_SIZE)
 60extern void copy_page(void *to, void *from);
 61#define copy_user_page(to, from, vaddr, pg)  __copy_user(to, from, PAGE_SIZE)
 62
 63struct page;
 64struct vm_area_struct;
 65
 66extern void copy_user_highpage(struct page *to, struct page *from,
 67			       unsigned long vaddr, struct vm_area_struct *vma);
 68#define __HAVE_ARCH_COPY_USER_HIGHPAGE
 69extern void clear_user_highpage(struct page *page, unsigned long vaddr);
 70#define clear_user_highpage	clear_user_highpage
 71
 72/*
 73 * These are used to make use of C type-checking..
 74 */
 75#ifdef CONFIG_X2TLB
 76typedef struct { unsigned long pte_low, pte_high; } pte_t;
 77typedef struct { unsigned long long pgprot; } pgprot_t;
 78typedef struct { unsigned long long pgd; } pgd_t;
 79#define pte_val(x) \
 80	((x).pte_low | ((unsigned long long)(x).pte_high << 32))
 81#define __pte(x) \
 82	({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
 83#else
 84typedef struct { unsigned long pte_low; } pte_t;
 85typedef struct { unsigned long pgprot; } pgprot_t;
 86typedef struct { unsigned long pgd; } pgd_t;
 87#define pte_val(x)	((x).pte_low)
 88#define __pte(x)	((pte_t) { (x) } )
 
 
 
 
 
 
 89#endif
 90
 91#define pgd_val(x)	((x).pgd)
 92#define pgprot_val(x)	((x).pgprot)
 93
 94#define __pgd(x) ((pgd_t) { (x) } )
 95#define __pgprot(x)	((pgprot_t) { (x) } )
 96
 97typedef struct page *pgtable_t;
 98
 99#define pte_pgprot(x) __pgprot(pte_val(x) & PTE_FLAGS_MASK)
100
101#endif /* !__ASSEMBLY__ */
102
103/*
104 * __MEMORY_START and SIZE are the physical addresses and size of RAM.
105 */
106#define __MEMORY_START		CONFIG_MEMORY_START
107#define __MEMORY_SIZE		CONFIG_MEMORY_SIZE
108
109/*
110 * PHYSICAL_OFFSET is the offset in physical memory where the base
111 * of the kernel is loaded.
112 */
113#ifdef CONFIG_PHYSICAL_START
114#define PHYSICAL_OFFSET (CONFIG_PHYSICAL_START - __MEMORY_START)
115#else
116#define PHYSICAL_OFFSET 0
117#endif
118
119/*
120 * PAGE_OFFSET is the virtual address of the start of kernel address
121 * space.
122 */
123#define PAGE_OFFSET		CONFIG_PAGE_OFFSET
124
125/*
126 * Virtual to physical RAM address translation.
127 *
128 * In 29 bit mode, the physical offset of RAM from address 0 is visible in
129 * the kernel virtual address space, and thus we don't have to take
130 * this into account when translating. However in 32 bit mode this offset
131 * is not visible (it is part of the PMB mapping) and so needs to be
132 * added or subtracted as required.
133 */
134#ifdef CONFIG_PMB
135#define ___pa(x)	((x)-PAGE_OFFSET+__MEMORY_START)
136#define ___va(x)	((x)+PAGE_OFFSET-__MEMORY_START)
137#else
138#define ___pa(x)	((x)-PAGE_OFFSET)
139#define ___va(x)	((x)+PAGE_OFFSET)
140#endif
141
142#ifndef __ASSEMBLY__
143#define __pa(x)		___pa((unsigned long)x)
144#define __va(x)		(void *)___va((unsigned long)x)
145#endif /* !__ASSEMBLY__ */
146
147#ifdef CONFIG_UNCACHED_MAPPING
148#if defined(CONFIG_29BIT)
149#define UNCAC_ADDR(addr)	P2SEGADDR(addr)
150#define CAC_ADDR(addr)		P1SEGADDR(addr)
151#else
152#define UNCAC_ADDR(addr)	((addr) - PAGE_OFFSET + uncached_start)
153#define CAC_ADDR(addr)		((addr) - uncached_start + PAGE_OFFSET)
154#endif
155#else
156#define UNCAC_ADDR(addr)	((addr))
157#define CAC_ADDR(addr)		((addr))
158#endif
159
160#define pfn_to_kaddr(pfn)	__va((pfn) << PAGE_SHIFT)
161#define page_to_phys(page)	(page_to_pfn(page) << PAGE_SHIFT)
162
163/*
164 * PFN = physical frame number (ie PFN 0 == physical address 0)
165 * PFN_START is the PFN of the first page of RAM. By defining this we
166 * don't have struct page entries for the portion of address space
167 * between physical address 0 and the start of RAM.
168 */
169#define PFN_START		(__MEMORY_START >> PAGE_SHIFT)
170#define ARCH_PFN_OFFSET		(PFN_START)
171#define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
172#ifdef CONFIG_FLATMEM
173#define pfn_valid(pfn)		((pfn) >= min_low_pfn && (pfn) < max_low_pfn)
174#endif
175#define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
176
 
 
 
177#include <asm-generic/memory_model.h>
178#include <asm-generic/getorder.h>
179
180/*
181 * Some drivers need to perform DMA into kmalloc'ed buffers
182 * and so we have to increase the kmalloc minalign for this.
183 */
184#define ARCH_DMA_MINALIGN	L1_CACHE_BYTES
 
 
 
 
 
 
 
 
 
 
 
185
186#endif /* __ASM_SH_PAGE_H */