162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2015 Synopsys, Inc. (www.synopsys.com)
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef _ASM_HIGHMEM_H
762306a36Sopenharmony_ci#define _ASM_HIGHMEM_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifdef CONFIG_HIGHMEM
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <uapi/asm/page.h>
1262306a36Sopenharmony_ci#include <asm/kmap_size.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#define FIXMAP_SIZE		PGDIR_SIZE
1562306a36Sopenharmony_ci#define PKMAP_SIZE		PGDIR_SIZE
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/* start after vmalloc area */
1862306a36Sopenharmony_ci#define FIXMAP_BASE		(PAGE_OFFSET - FIXMAP_SIZE - PKMAP_SIZE)
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define FIX_KMAP_SLOTS		(KM_MAX_IDX * NR_CPUS)
2162306a36Sopenharmony_ci#define FIX_KMAP_BEGIN		(0UL)
2262306a36Sopenharmony_ci#define FIX_KMAP_END		((FIX_KMAP_BEGIN + FIX_KMAP_SLOTS) - 1)
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define FIXADDR_TOP		(FIXMAP_BASE + (FIX_KMAP_END << PAGE_SHIFT))
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/*
2762306a36Sopenharmony_ci * This should be converted to the asm-generic version, but of course this
2862306a36Sopenharmony_ci * is needlessly different from all other architectures. Sigh - tglx
2962306a36Sopenharmony_ci */
3062306a36Sopenharmony_ci#define __fix_to_virt(x)	(FIXADDR_TOP - ((x) << PAGE_SHIFT))
3162306a36Sopenharmony_ci#define __virt_to_fix(x)	(((FIXADDR_TOP - ((x) & PAGE_MASK))) >> PAGE_SHIFT)
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* start after fixmap area */
3462306a36Sopenharmony_ci#define PKMAP_BASE		(FIXMAP_BASE + FIXMAP_SIZE)
3562306a36Sopenharmony_ci#define LAST_PKMAP		(PKMAP_SIZE >> PAGE_SHIFT)
3662306a36Sopenharmony_ci#define LAST_PKMAP_MASK		(LAST_PKMAP - 1)
3762306a36Sopenharmony_ci#define PKMAP_ADDR(nr)		(PKMAP_BASE + ((nr) << PAGE_SHIFT))
3862306a36Sopenharmony_ci#define PKMAP_NR(virt)		(((virt) - PKMAP_BASE) >> PAGE_SHIFT)
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#include <asm/cacheflush.h>
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciextern void kmap_init(void);
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define arch_kmap_local_post_unmap(vaddr)			\
4562306a36Sopenharmony_ci	local_flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE)
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_cistatic inline void flush_cache_kmaps(void)
4862306a36Sopenharmony_ci{
4962306a36Sopenharmony_ci	flush_cache_all();
5062306a36Sopenharmony_ci}
5162306a36Sopenharmony_ci#endif
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#endif
54