162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * highmem.h: virtual kernel memory mappings for high memory
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Used in CONFIG_HIGHMEM systems for memory pages which
662306a36Sopenharmony_ci * are not addressable by direct kernel virtual addresses.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Copyright (C) 1999 Gerhard Wichert, Siemens AG
962306a36Sopenharmony_ci *		      Gerhard.Wichert@pdb.siemens.de
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci * Redesigned the x86 32-bit VM architecture to deal with
1362306a36Sopenharmony_ci * up to 16 Terrabyte physical memory. With current x86 CPUs
1462306a36Sopenharmony_ci * we now support up to 64 Gigabytes physical RAM.
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#ifndef _ASM_HIGHMEM_H
2062306a36Sopenharmony_ci#define _ASM_HIGHMEM_H
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#ifdef __KERNEL__
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#include <linux/interrupt.h>
2562306a36Sopenharmony_ci#include <linux/pgtable.h>
2662306a36Sopenharmony_ci#include <asm/vaddrs.h>
2762306a36Sopenharmony_ci#include <asm/pgtsrmmu.h>
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* declarations for highmem.c */
3062306a36Sopenharmony_ciextern unsigned long highstart_pfn, highend_pfn;
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#define kmap_prot __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE)
3362306a36Sopenharmony_ciextern pte_t *pkmap_page_table;
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/*
3662306a36Sopenharmony_ci * Right now we initialize only a single pte table. It can be extended
3762306a36Sopenharmony_ci * easily, subsequent pte tables have to be allocated in one physical
3862306a36Sopenharmony_ci * chunk of RAM.  Currently the simplest way to do this is to align the
3962306a36Sopenharmony_ci * pkmap region on a pagetable boundary (4MB).
4062306a36Sopenharmony_ci */
4162306a36Sopenharmony_ci#define LAST_PKMAP 1024
4262306a36Sopenharmony_ci#define PKMAP_SIZE (LAST_PKMAP << PAGE_SHIFT)
4362306a36Sopenharmony_ci#define PKMAP_BASE PMD_ALIGN(SRMMU_NOCACHE_VADDR + (SRMMU_MAX_NOCACHE_PAGES << PAGE_SHIFT))
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
4662306a36Sopenharmony_ci#define PKMAP_NR(virt)  ((virt - PKMAP_BASE) >> PAGE_SHIFT)
4762306a36Sopenharmony_ci#define PKMAP_ADDR(nr)  (PKMAP_BASE + ((nr) << PAGE_SHIFT))
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#define PKMAP_END (PKMAP_ADDR(LAST_PKMAP))
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#define flush_cache_kmaps()	flush_cache_all()
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci/* FIXME: Use __flush_*_one(vaddr) instead of flush_*_all() -- Anton */
5462306a36Sopenharmony_ci#define arch_kmap_local_pre_map(vaddr, pteval)	flush_cache_all()
5562306a36Sopenharmony_ci#define arch_kmap_local_pre_unmap(vaddr)	flush_cache_all()
5662306a36Sopenharmony_ci#define arch_kmap_local_post_map(vaddr, pteval)	flush_tlb_all()
5762306a36Sopenharmony_ci#define arch_kmap_local_post_unmap(vaddr)	flush_tlb_all()
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#endif /* __KERNEL__ */
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#endif /* _ASM_HIGHMEM_H */
62