2005-04-16 18:20:36 -04:00
|
|
|
#ifndef __ASM_SH_PAGE_H
|
|
|
|
#define __ASM_SH_PAGE_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 1999 Niibe Yutaka
|
|
|
|
*/
|
|
|
|
|
2007-11-30 03:52:53 -05:00
|
|
|
#include <linux/const.h>
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
/* PAGE_SHIFT determines the page size */
|
2006-11-20 00:30:26 -05:00
|
|
|
#if defined(CONFIG_PAGE_SIZE_4KB)
|
|
|
|
# define PAGE_SHIFT 12
|
|
|
|
#elif defined(CONFIG_PAGE_SIZE_8KB)
|
|
|
|
# define PAGE_SHIFT 13
|
2008-06-03 05:54:02 -04:00
|
|
|
#elif defined(CONFIG_PAGE_SIZE_16KB)
|
|
|
|
# define PAGE_SHIFT 14
|
2006-11-20 00:30:26 -05:00
|
|
|
#elif defined(CONFIG_PAGE_SIZE_64KB)
|
|
|
|
# define PAGE_SHIFT 16
|
|
|
|
#else
|
|
|
|
# error "Bogus kernel page size?"
|
|
|
|
#endif
|
2006-09-27 05:31:06 -04:00
|
|
|
|
2007-11-30 03:52:53 -05:00
|
|
|
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
|
2005-04-16 18:20:36 -04:00
|
|
|
#define PAGE_MASK (~(PAGE_SIZE-1))
|
|
|
|
#define PTE_MASK PAGE_MASK
|
|
|
|
|
|
|
|
#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
|
|
|
|
#define HPAGE_SHIFT 16
|
2006-11-20 00:30:26 -05:00
|
|
|
#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
|
|
|
|
#define HPAGE_SHIFT 18
|
2005-04-16 18:20:36 -04:00
|
|
|
#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
|
|
|
|
#define HPAGE_SHIFT 20
|
2006-11-20 00:30:26 -05:00
|
|
|
#elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
|
|
|
|
#define HPAGE_SHIFT 22
|
|
|
|
#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
|
|
|
|
#define HPAGE_SHIFT 26
|
2007-11-21 01:23:07 -05:00
|
|
|
#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512MB)
|
|
|
|
#define HPAGE_SHIFT 29
|
2005-04-16 18:20:36 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_HUGETLB_PAGE
|
|
|
|
#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
|
|
|
|
#define HPAGE_MASK (~(HPAGE_SIZE-1))
|
|
|
|
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2006-09-27 05:36:17 -04:00
|
|
|
extern unsigned long shm_align_mask;
|
2007-03-28 03:38:13 -04:00
|
|
|
extern unsigned long max_low_pfn, min_low_pfn;
|
2007-05-13 23:52:56 -04:00
|
|
|
extern unsigned long memory_start, memory_end;
|
2006-09-27 05:36:17 -04:00
|
|
|
|
2007-11-20 02:51:28 -05:00
|
|
|
extern void clear_page(void *to);
|
|
|
|
extern void copy_page(void *to, void *from);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2007-07-31 04:07:28 -04:00
|
|
|
#if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_MMU) && \
|
2008-02-13 06:14:10 -05:00
|
|
|
(defined(CONFIG_CPU_SH5) || defined(CONFIG_CPU_SH4) || \
|
|
|
|
defined(CONFIG_SH7705_CACHE_32KB))
|
2005-04-16 18:20:36 -04:00
|
|
|
struct page;
|
2007-11-05 02:12:32 -05:00
|
|
|
struct vm_area_struct;
|
2007-11-05 02:20:42 -05:00
|
|
|
extern void clear_user_page(void *to, unsigned long address, struct page *page);
|
2008-02-13 06:14:10 -05:00
|
|
|
extern void copy_user_page(void *to, void *from, unsigned long address,
|
|
|
|
struct page *page);
|
|
|
|
#if defined(CONFIG_CPU_SH4)
|
2007-11-05 02:12:32 -05:00
|
|
|
extern void copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long vaddr, struct vm_area_struct *vma);
|
|
|
|
#define __HAVE_ARCH_COPY_USER_HIGHPAGE
|
|
|
|
#endif
|
2007-07-31 04:07:28 -04:00
|
|
|
#else
|
2005-04-16 18:20:36 -04:00
|
|
|
#define clear_user_page(page, vaddr, pg) clear_page(page)
|
|
|
|
#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are used to make use of C type-checking..
|
|
|
|
*/
|
2006-11-20 00:30:26 -05:00
|
|
|
#ifdef CONFIG_X2TLB
|
|
|
|
typedef struct { unsigned long pte_low, pte_high; } pte_t;
|
|
|
|
typedef struct { unsigned long long pgprot; } pgprot_t;
|
2007-09-20 22:55:03 -04:00
|
|
|
typedef struct { unsigned long long pgd; } pgd_t;
|
2006-11-20 00:30:26 -05:00
|
|
|
#define pte_val(x) \
|
|
|
|
((x).pte_low | ((unsigned long long)(x).pte_high << 32))
|
|
|
|
#define __pte(x) \
|
|
|
|
({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
|
2007-11-19 04:26:19 -05:00
|
|
|
#elif defined(CONFIG_SUPERH32)
|
2006-11-20 00:30:26 -05:00
|
|
|
typedef struct { unsigned long pte_low; } pte_t;
|
2005-04-16 18:20:36 -04:00
|
|
|
typedef struct { unsigned long pgprot; } pgprot_t;
|
2007-09-20 22:55:03 -04:00
|
|
|
typedef struct { unsigned long pgd; } pgd_t;
|
2006-11-20 00:30:26 -05:00
|
|
|
#define pte_val(x) ((x).pte_low)
|
2007-11-19 04:26:19 -05:00
|
|
|
#define __pte(x) ((pte_t) { (x) } )
|
|
|
|
#else
|
|
|
|
typedef struct { unsigned long long pte_low; } pte_t;
|
|
|
|
typedef struct { unsigned long pgprot; } pgprot_t;
|
|
|
|
typedef struct { unsigned long pgd; } pgd_t;
|
|
|
|
#define pte_val(x) ((x).pte_low)
|
|
|
|
#define __pte(x) ((pte_t) { (x) } )
|
2006-11-20 00:30:26 -05:00
|
|
|
#endif
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
#define pgd_val(x) ((x).pgd)
|
|
|
|
#define pgprot_val(x) ((x).pgprot)
|
|
|
|
|
|
|
|
#define __pgd(x) ((pgd_t) { (x) } )
|
|
|
|
#define __pgprot(x) ((pgprot_t) { (x) } )
|
|
|
|
|
2008-02-08 07:22:04 -05:00
|
|
|
typedef struct page *pgtable_t;
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
|
2007-11-30 03:52:53 -05:00
|
|
|
/*
|
|
|
|
* __MEMORY_START and SIZE are the physical addresses and size of RAM.
|
|
|
|
*/
|
2005-04-16 18:20:36 -04:00
|
|
|
#define __MEMORY_START CONFIG_MEMORY_START
|
|
|
|
#define __MEMORY_SIZE CONFIG_MEMORY_SIZE
|
|
|
|
|
2007-11-30 03:52:53 -05:00
|
|
|
/*
|
|
|
|
* PAGE_OFFSET is the virtual address of the start of kernel address
|
|
|
|
* space.
|
|
|
|
*/
|
2006-09-27 04:19:13 -04:00
|
|
|
#define PAGE_OFFSET CONFIG_PAGE_OFFSET
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2007-11-30 03:52:53 -05:00
|
|
|
/*
|
|
|
|
* Virtual to physical RAM address translation.
|
|
|
|
*
|
|
|
|
* In 29 bit mode, the physical offset of RAM from address 0 is visible in
|
|
|
|
* the kernel virtual address space, and thus we don't have to take
|
|
|
|
* this into account when translating. However in 32 bit mode this offset
|
|
|
|
* is not visible (it is part of the PMB mapping) and so needs to be
|
|
|
|
* added or subtracted as required.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_32BIT
|
|
|
|
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET+__MEMORY_START)
|
|
|
|
#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET-__MEMORY_START))
|
|
|
|
#else
|
|
|
|
#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
|
|
|
|
#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
|
2007-03-28 03:38:13 -04:00
|
|
|
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2007-11-30 03:52:53 -05:00
|
|
|
/*
|
|
|
|
* PFN = physical frame number (ie PFN 0 == physical address 0)
|
|
|
|
* PFN_START is the PFN of the first page of RAM. By defining this we
|
|
|
|
* don't have struct page entries for the portion of address space
|
|
|
|
* between physical address 0 and the start of RAM.
|
|
|
|
*/
|
2005-04-16 18:20:36 -04:00
|
|
|
#define PFN_START (__MEMORY_START >> PAGE_SHIFT)
|
2006-09-08 12:47:34 -04:00
|
|
|
#define ARCH_PFN_OFFSET (PFN_START)
|
2005-04-16 18:20:36 -04:00
|
|
|
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
|
2007-05-23 04:40:56 -04:00
|
|
|
#ifdef CONFIG_FLATMEM
|
2007-03-28 03:38:13 -04:00
|
|
|
#define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_low_pfn)
|
2007-05-23 04:40:56 -04:00
|
|
|
#endif
|
2005-04-16 18:20:36 -04:00
|
|
|
#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
|
|
|
|
|
|
|
|
#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
|
|
|
|
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
|
|
|
|
|
2006-03-27 04:15:46 -05:00
|
|
|
#include <asm-generic/memory_model.h>
|
2005-09-03 18:54:30 -04:00
|
|
|
#include <asm-generic/page.h>
|
|
|
|
|
2006-09-27 05:33:49 -04:00
|
|
|
/* vDSO support */
|
|
|
|
#ifdef CONFIG_VSYSCALL
|
|
|
|
#define __HAVE_ARCH_GATE_AREA
|
|
|
|
#endif
|
|
|
|
|
2007-06-04 02:46:56 -04:00
|
|
|
/*
|
2007-11-27 01:57:30 -05:00
|
|
|
* Some drivers need to perform DMA into kmalloc'ed buffers
|
|
|
|
* and so we have to increase the kmalloc minalign for this.
|
2007-06-04 02:46:56 -04:00
|
|
|
*/
|
2007-11-27 01:57:30 -05:00
|
|
|
#define ARCH_KMALLOC_MINALIGN L1_CACHE_BYTES
|
2007-11-10 05:57:58 -05:00
|
|
|
|
2007-11-27 01:57:30 -05:00
|
|
|
#ifdef CONFIG_SUPERH64
|
2007-11-10 05:57:58 -05:00
|
|
|
/*
|
2007-11-27 01:57:30 -05:00
|
|
|
* While BYTES_PER_WORD == 4 on the current sh64 ABI, GCC will still
|
|
|
|
* happily generate {ld/st}.q pairs, requiring us to have 8-byte
|
|
|
|
* alignment to avoid traps. The kmalloc alignment is gauranteed by
|
|
|
|
* virtue of L1_CACHE_BYTES, requiring this to only be special cased
|
|
|
|
* for slab caches.
|
2007-11-10 05:57:58 -05:00
|
|
|
*/
|
|
|
|
#define ARCH_SLAB_MINALIGN 8
|
|
|
|
#endif
|
2007-06-04 02:46:56 -04:00
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
#endif /* __ASM_SH_PAGE_H */
|