18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * highmem.h: virtual kernel memory mappings for high memory
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Used in CONFIG_HIGHMEM systems for memory pages which
68c2ecf20Sopenharmony_ci * are not addressable by direct kernel virtual addresses.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Copyright (C) 1999 Gerhard Wichert, Siemens AG
98c2ecf20Sopenharmony_ci *		      Gerhard.Wichert@pdb.siemens.de
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Redesigned the x86 32-bit VM architecture to deal with
138c2ecf20Sopenharmony_ci * up to 16 Terabyte physical memory. With current x86 CPUs
148c2ecf20Sopenharmony_ci * we now support up to 64 Gigabytes physical RAM.
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci#ifndef _ASM_HIGHMEM_H
198c2ecf20Sopenharmony_ci#define _ASM_HIGHMEM_H
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#ifdef __KERNEL__
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include <linux/init.h>
248c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
258c2ecf20Sopenharmony_ci#include <linux/uaccess.h>
268c2ecf20Sopenharmony_ci#include <asm/fixmap.h>
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciextern pte_t *kmap_pte;
298c2ecf20Sopenharmony_ciextern pte_t *pkmap_page_table;
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/*
328c2ecf20Sopenharmony_ci * Right now we initialize only a single pte table. It can be extended
338c2ecf20Sopenharmony_ci * easily, subsequent pte tables have to be allocated in one physical
348c2ecf20Sopenharmony_ci * chunk of RAM.
358c2ecf20Sopenharmony_ci */
368c2ecf20Sopenharmony_ci/*
378c2ecf20Sopenharmony_ci * We use one full pte table with 4K pages. And with 16K/64K/256K pages pte
388c2ecf20Sopenharmony_ci * table covers enough memory (32MB/512MB/2GB resp.), so that both FIXMAP
398c2ecf20Sopenharmony_ci * and PKMAP can be placed in a single pte table. We use 512 pages for PKMAP
408c2ecf20Sopenharmony_ci * in case of 16K/64K/256K page sizes.
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define PKMAP_ORDER	PTE_SHIFT
448c2ecf20Sopenharmony_ci#define LAST_PKMAP	(1 << PKMAP_ORDER)
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define PKMAP_BASE	((FIXADDR_START - PAGE_SIZE * (LAST_PKMAP + 1)) \
478c2ecf20Sopenharmony_ci								& PMD_MASK)
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define LAST_PKMAP_MASK	(LAST_PKMAP - 1)
508c2ecf20Sopenharmony_ci#define PKMAP_NR(virt)  ((virt - PKMAP_BASE) >> PAGE_SHIFT)
518c2ecf20Sopenharmony_ci#define PKMAP_ADDR(nr)  (PKMAP_BASE + ((nr) << PAGE_SHIFT))
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define flush_cache_kmaps()	{ flush_icache(); flush_dcache(); }
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#endif /* _ASM_HIGHMEM_H */
58