^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #ifndef __ASM_CSKY_PAGE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #define __ASM_CSKY_PAGE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <asm/cache.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/const.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * PAGE_SHIFT determines the page size: 4KB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define PAGE_SHIFT 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define PAGE_MASK (~(PAGE_SIZE - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define THREAD_SIZE (PAGE_SIZE * 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define THREAD_MASK (~(THREAD_SIZE - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define THREAD_SHIFT (PAGE_SHIFT + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * For C-SKY "User-space:Kernel-space" is "2GB:2GB" fixed by hardware and there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * are two segment registers (MSA0 + MSA1) to mapping 512MB + 512MB physical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * address region. We use them mapping kernel 1GB direct-map address area and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * for more than 1GB of memory we use highmem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define PAGE_OFFSET 0x80000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define SSEG_SIZE 0x20000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define LOWMEM_LIMIT (SSEG_SIZE * 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define PHYS_OFFSET_OFFSET (CONFIG_DRAM_BASE & (SSEG_SIZE - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/pfn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) (void *)(kaddr) < high_memory)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) extern void *memset(void *dest, int c, size_t l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) extern void *memcpy(void *to, const void *from, size_t l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define clear_page(page) memset((page), 0, PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define phys_to_page(paddr) (pfn_to_page(PFN_DOWN(paddr)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #include <abi/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct vm_area_struct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) typedef struct { unsigned long pte_low; } pte_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define pte_val(x) ((x).pte_low)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) typedef struct { unsigned long pgd; } pgd_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) typedef struct { unsigned long pgprot; } pgprot_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) typedef struct page *pgtable_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define pgd_val(x) ((x).pgd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define pgprot_val(x) ((x).pgprot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define ptep_buddy(x) ((pte_t *)((unsigned long)(x) ^ sizeof(pte_t)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define __pte(x) ((pte_t) { (x) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define __pgd(x) ((pgd_t) { (x) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define __pgprot(x) ((pgprot_t) { (x) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) extern unsigned long va_pa_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define ARCH_PFN_OFFSET PFN_DOWN(va_pa_offset + PHYS_OFFSET_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + va_pa_offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - va_pa_offset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define MAP_NR(x) PFN_DOWN((unsigned long)(x) - PAGE_OFFSET - \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) PHYS_OFFSET_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define virt_to_page(x) (mem_map + MAP_NR(x))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define pfn_to_kaddr(x) __va(PFN_PHYS(x))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #include <asm-generic/memory_model.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #include <asm-generic/getorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #endif /* !__ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #endif /* __ASM_CSKY_PAGE_H */