^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) * highmem.h: virtual kernel memory mappings for high memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * PowerPC version, stolen from the i386 version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Used in CONFIG_HIGHMEM systems for memory pages which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * are not addressable by direct kernel virtual addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright (C) 1999 Gerhard Wichert, Siemens AG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Gerhard.Wichert@pdb.siemens.de
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Redesigned the x86 32-bit VM architecture to deal with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * up to 16 Terrabyte physical memory. With current x86 CPUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * we now support up to 64 Gigabytes physical RAM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
^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) #ifndef _ASM_HIGHMEM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define _ASM_HIGHMEM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <asm/kmap_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <asm/cacheflush.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <asm/fixmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) extern pte_t *kmap_pte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) extern pte_t *pkmap_page_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * Right now we initialize only a single pte table. It can be extended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * easily, subsequent pte tables have to be allocated in one physical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * chunk of RAM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * We use one full pte table with 4K pages. And with 16K/64K/256K pages pte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * table covers enough memory (32MB/512MB/2GB resp.), so that both FIXMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * and PKMAP can be placed in a single pte table. We use 512 pages for PKMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * in case of 16K/64K/256K page sizes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #ifdef CONFIG_PPC_4K_PAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define PKMAP_ORDER PTE_SHIFT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define PKMAP_ORDER 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define LAST_PKMAP (1 << PKMAP_ORDER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #ifndef CONFIG_PPC_4K_PAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define PKMAP_BASE (FIXADDR_START - PAGE_SIZE*(LAST_PKMAP + 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define PKMAP_BASE ((FIXADDR_START - PAGE_SIZE*(LAST_PKMAP + 1)) & PMD_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define LAST_PKMAP_MASK (LAST_PKMAP-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define PKMAP_NR(virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define flush_cache_kmaps() flush_cache_all()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #endif /* __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #endif /* _ASM_HIGHMEM_H */