mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-17 17:10:26 -05:00
Pull asm-generic updates from Arnd Bergmann:
"These are a number of unrelated cleanups, generally simplifying the
architecture specific header files:
- A series from Al Viro simplifies asm/vga.h, after it turns out that
most of it can be generalized.
- A series from Julian Vetter adds a common version of
memcpy_{to,from}io() and memset_io() and changes most architectures
to use that instead of their own implementation
- A series from Niklas Schnelle concludes his work to make PC style
inb()/outb() optional
- Nicolas Pitre contributes improvements for the generic do_div()
helper
- Christoph Hellwig adds a generic version of page_to_phys() and
phys_to_page(), replacing the slightly different architecture
specific definitions.
- Uwe Kleine-Koenig has a minor cleanup for ioctl definitions"
* tag 'asm-generic-3.13' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: (24 commits)
empty include/asm-generic/vga.h
sparc: get rid of asm/vga.h
asm/vga.h: don't bother with scr_mem{cpy,move}v() unless we need to
vt_buffer.h: get rid of dead code in default scr_...() instances
tty: serial: export serial_8250_warn_need_ioport
lib/iomem_copy: fix kerneldoc format style
hexagon: simplify asm/io.h for !HAS_IOPORT
loongarch: Use new fallback IO memcpy/memset
csky: Use new fallback IO memcpy/memset
arm64: Use new fallback IO memcpy/memset
New implementation for IO memcpy and IO memset
watchdog: Add HAS_IOPORT dependency for SBC8360 and SBC7240
__arch_xprod64(): make __always_inline when optimizing for performance
ARM: div64: improve __arch_xprod_64()
asm-generic/div64: optimize/simplify __div64_const32()
lib/math/test_div64: add some edge cases relevant to __div64_const32()
asm-generic: add an optional pfn_valid check to page_to_phys
asm-generic: provide generic page_to_phys and phys_to_page implementations
asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n
tty: serial: handle HAS_IOPORT dependencies
...
135 lines
3.6 KiB
C
135 lines
3.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Page management definitions for the Hexagon architecture
|
|
*
|
|
* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
|
|
*/
|
|
|
|
#ifndef _ASM_PAGE_H
|
|
#define _ASM_PAGE_H
|
|
|
|
#include <linux/const.h>
|
|
|
|
/* This is probably not the most graceful way to handle this. */
|
|
|
|
#ifdef CONFIG_PAGE_SIZE_4KB
|
|
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_4KB
|
|
#endif
|
|
|
|
#ifdef CONFIG_PAGE_SIZE_16KB
|
|
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_16KB
|
|
#endif
|
|
|
|
#ifdef CONFIG_PAGE_SIZE_64KB
|
|
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_64KB
|
|
#endif
|
|
|
|
#ifdef CONFIG_PAGE_SIZE_256KB
|
|
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_256KB
|
|
#endif
|
|
|
|
#ifdef CONFIG_PAGE_SIZE_1MB
|
|
#define HEXAGON_L1_PTE_SIZE __HVM_PDE_S_1MB
|
|
#endif
|
|
|
|
/*
|
|
* These should be defined in hugetlb.h, but apparently not.
|
|
* "Huge" for us should be 4MB or 16MB, which are both represented
|
|
* in L1 PTE's. Right now, it's set up for 4MB.
|
|
*/
|
|
#ifdef CONFIG_HUGETLB_PAGE
|
|
#define HPAGE_SHIFT 22
|
|
#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
|
|
#define HPAGE_MASK (~(HPAGE_SIZE-1))
|
|
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
|
|
#define HVM_HUGEPAGE_SIZE 0x5
|
|
#endif
|
|
|
|
#include <vdso/page.h>
|
|
|
|
#ifdef __KERNEL__
|
|
#ifndef __ASSEMBLY__
|
|
|
|
/*
|
|
* This is for PFN_DOWN, which mm.h needs. Seems the right place to pull it in.
|
|
*/
|
|
#include <linux/pfn.h>
|
|
|
|
/*
|
|
* We implement a two-level architecture-specific page table structure.
|
|
* Null intermediate page table level (pmd, pud) definitions will come from
|
|
* asm-generic/pagetable-nopmd.h and asm-generic/pagetable-nopud.h
|
|
*/
|
|
typedef struct { unsigned long pte; } pte_t;
|
|
typedef struct { unsigned long pgd; } pgd_t;
|
|
typedef struct { unsigned long pgprot; } pgprot_t;
|
|
typedef struct page *pgtable_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) })
|
|
|
|
/* Needed for PAGE_OFFSET used in the macro right below */
|
|
#include <asm/mem-layout.h>
|
|
|
|
/*
|
|
* We need a __pa and a __va routine for kernel space.
|
|
* MIPS says they're only used during mem_init.
|
|
* also, check if we need a PHYS_OFFSET.
|
|
*/
|
|
#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
|
|
#define __va(x) ((void *)((unsigned long)(x) - PHYS_OFFSET + PAGE_OFFSET))
|
|
|
|
/* The "page frame" descriptor is defined in linux/mm.h */
|
|
struct page;
|
|
|
|
/* Returns page frame descriptor for virtual address. */
|
|
#define virt_to_page(kaddr) pfn_to_page(PFN_DOWN(__pa(kaddr)))
|
|
|
|
/* Default vm area behavior is non-executable. */
|
|
#define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
|
|
|
|
#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
|
|
|
|
/* Need to not use a define for linesize; may move this to another file. */
|
|
static inline void clear_page(void *page)
|
|
{
|
|
/* This can only be done on pages with L1 WB cache */
|
|
asm volatile(
|
|
" loop0(1f,%1);\n"
|
|
"1: { dczeroa(%0);\n"
|
|
" %0 = add(%0,#32); }:endloop0\n"
|
|
: "+r" (page)
|
|
: "r" (PAGE_SIZE/32)
|
|
: "lc0", "sa0", "memory"
|
|
);
|
|
}
|
|
|
|
#define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
|
|
|
|
/*
|
|
* Under assumption that kernel always "sees" user map...
|
|
*/
|
|
#define clear_user_page(page, vaddr, pg) clear_page(page)
|
|
#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
|
|
|
|
static inline unsigned long virt_to_pfn(const void *kaddr)
|
|
{
|
|
return __pa(kaddr) >> PAGE_SHIFT;
|
|
}
|
|
|
|
#define page_to_virt(page) __va(page_to_phys(page))
|
|
|
|
#include <asm/mem-layout.h>
|
|
#include <asm-generic/memory_model.h>
|
|
/* XXX Todo: implement assembly-optimized version of getorder. */
|
|
#include <asm-generic/getorder.h>
|
|
|
|
#endif /* ifdef __ASSEMBLY__ */
|
|
#endif /* ifdef __KERNEL__ */
|
|
|
|
#endif
|