2005-06-23 22:01:26 -07:00
|
|
|
/*
|
2007-08-06 23:12:24 -07:00
|
|
|
* include/asm-xtensa/page.h
|
2005-06-23 22:01:26 -07:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
2007-08-06 23:12:24 -07:00
|
|
|
* Copyright (C) 2001 - 2007 Tensilica Inc.
|
2005-06-23 22:01:26 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _XTENSA_PAGE_H
|
|
|
|
#define _XTENSA_PAGE_H
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#include <asm/processor.h>
|
2007-08-06 23:12:24 -07:00
|
|
|
#include <asm/types.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fixed TLB translations in the processor.
|
|
|
|
*/
|
2005-06-23 22:01:26 -07:00
|
|
|
|
2006-12-10 03:18:48 -07:00
|
|
|
#define XCHAL_KSEG_CACHED_VADDR 0xd0000000
|
|
|
|
#define XCHAL_KSEG_BYPASS_VADDR 0xd8000000
|
|
|
|
#define XCHAL_KSEG_PADDR 0x00000000
|
|
|
|
#define XCHAL_KSEG_SIZE 0x08000000
|
|
|
|
|
2005-06-23 22:01:26 -07:00
|
|
|
/*
|
|
|
|
* PAGE_SHIFT determines the page size
|
|
|
|
* PAGE_ALIGN(x) aligns the pointer to the (next) page boundary
|
|
|
|
*/
|
|
|
|
|
2006-12-10 03:18:48 -07:00
|
|
|
#define PAGE_SHIFT 12
|
2007-08-06 23:12:24 -07:00
|
|
|
#define PAGE_SIZE (__XTENSA_UL_CONST(1) << PAGE_SHIFT)
|
2005-06-23 22:01:26 -07:00
|
|
|
#define PAGE_MASK (~(PAGE_SIZE-1))
|
|
|
|
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE - 1) & PAGE_MASK)
|
|
|
|
|
|
|
|
#define PAGE_OFFSET XCHAL_KSEG_CACHED_VADDR
|
2007-08-06 23:12:24 -07:00
|
|
|
#define MAX_MEM_PFN XCHAL_KSEG_SIZE
|
|
|
|
#define PGTABLE_START 0x80000000
|
2005-06-23 22:01:26 -07:00
|
|
|
|
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
|
|
|
|
#define __pgprot(x) (x)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are used to make use of C type-checking..
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct { unsigned long pte; } pte_t; /* page table entry */
|
|
|
|
typedef struct { unsigned long pgd; } pgd_t; /* PGD table entry */
|
|
|
|
typedef struct { unsigned long pgprot; } pgprot_t;
|
|
|
|
|
|
|
|
#define pte_val(x) ((x).pte)
|
|
|
|
#define pgd_val(x) ((x).pgd)
|
|
|
|
#define pgprot_val(x) ((x).pgprot)
|
|
|
|
|
|
|
|
#define __pte(x) ((pte_t) { (x) } )
|
|
|
|
#define __pgd(x) ((pgd_t) { (x) } )
|
|
|
|
#define __pgprot(x) ((pgprot_t) { (x) } )
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pure 2^n version of get_order
|
2007-08-06 23:12:24 -07:00
|
|
|
* Use 'nsau' instructions if supported by the processor or the generic version.
|
2005-06-23 22:01:26 -07:00
|
|
|
*/
|
|
|
|
|
2007-08-06 23:12:24 -07:00
|
|
|
#if XCHAL_HAVE_NSA
|
|
|
|
|
|
|
|
static inline __attribute_const__ int get_order(unsigned long size)
|
2005-06-23 22:01:26 -07:00
|
|
|
{
|
2007-08-06 23:12:24 -07:00
|
|
|
int lz;
|
|
|
|
asm ("nsau %0, %1" : "=r" (lz) : "r" ((size - 1) >> PAGE_SHIFT));
|
|
|
|
return 32 - lz;
|
2005-06-23 22:01:26 -07:00
|
|
|
}
|
|
|
|
|
2007-08-06 23:12:24 -07:00
|
|
|
#else
|
|
|
|
|
|
|
|
# include <asm-generic/page.h>
|
|
|
|
|
|
|
|
#endif
|
2005-06-23 22:01:26 -07:00
|
|
|
|
|
|
|
struct page;
|
|
|
|
extern void clear_page(void *page);
|
|
|
|
extern void copy_page(void *to, void *from);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have cache aliasing and writeback caches, we might have to do
|
|
|
|
* some extra work
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if (DCACHE_WAY_SIZE > PAGE_SIZE)
|
|
|
|
void clear_user_page(void *addr, unsigned long vaddr, struct page* page);
|
|
|
|
void copy_user_page(void *to,void* from,unsigned long vaddr,struct page* page);
|
|
|
|
#else
|
|
|
|
# define clear_user_page(page,vaddr,pg) clear_page(page)
|
|
|
|
# define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This handles the memory map. We handle pages at
|
|
|
|
* XCHAL_KSEG_CACHED_VADDR for kernels with 32 bit address space.
|
|
|
|
* These macros are for conversion of kernel address, not user
|
|
|
|
* addresses.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
|
|
|
|
#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
|
|
|
|
#define pfn_valid(pfn) ((unsigned long)pfn < max_mapnr)
|
2006-03-27 02:15:52 -07:00
|
|
|
#ifdef CONFIG_DISCONTIGMEM
|
2005-06-23 22:01:26 -07:00
|
|
|
# error CONFIG_DISCONTIGMEM not supported
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
|
|
|
|
#define page_to_virt(page) __va(page_to_pfn(page) << PAGE_SHIFT)
|
|
|
|
#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
|
|
|
|
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
|
|
|
|
|
|
|
|
#define WANT_PAGE_VIRTUAL
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
|
|
|
|
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
|
|
|
|
|
2006-03-27 02:15:52 -07:00
|
|
|
#include <asm-generic/memory_model.h>
|
2007-05-31 17:47:01 -07:00
|
|
|
#endif /* __KERNEL__ */
|
2005-06-23 22:01:26 -07:00
|
|
|
#endif /* _XTENSA_PAGE_H */
|