18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Memory layout definitions for the Hexagon architecture
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _ASM_HEXAGON_MEM_LAYOUT_H
98c2ecf20Sopenharmony_ci#define _ASM_HEXAGON_MEM_LAYOUT_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/const.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/*
148c2ecf20Sopenharmony_ci * Have to do this for ginormous numbers, else they get printed as
158c2ecf20Sopenharmony_ci * negative numbers, which the linker no likey when you try to
168c2ecf20Sopenharmony_ci * assign it to the location counter.
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define PAGE_OFFSET			_AC(0xc0000000, UL)
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/*
228c2ecf20Sopenharmony_ci * Compiling for a platform that needs a crazy physical offset
238c2ecf20Sopenharmony_ci * (like if the memory starts at 1GB and up) means we need
248c2ecf20Sopenharmony_ci * an actual PHYS_OFFSET.  Should be set up in head.S.
258c2ecf20Sopenharmony_ci */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#ifdef CONFIG_HEXAGON_PHYS_OFFSET
288c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
298c2ecf20Sopenharmony_ciextern unsigned long	__phys_offset;
308c2ecf20Sopenharmony_ci#endif
318c2ecf20Sopenharmony_ci#define PHYS_OFFSET	__phys_offset
328c2ecf20Sopenharmony_ci#endif
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#ifndef PHYS_OFFSET
358c2ecf20Sopenharmony_ci#define PHYS_OFFSET	0
368c2ecf20Sopenharmony_ci#endif
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define PHYS_PFN_OFFSET	(PHYS_OFFSET >> PAGE_SHIFT)
398c2ecf20Sopenharmony_ci#define ARCH_PFN_OFFSET	PHYS_PFN_OFFSET
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define TASK_SIZE			(PAGE_OFFSET)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*  not sure how these are used yet  */
448c2ecf20Sopenharmony_ci#define STACK_TOP			TASK_SIZE
458c2ecf20Sopenharmony_ci#define STACK_TOP_MAX			TASK_SIZE
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
488c2ecf20Sopenharmony_cienum fixed_addresses {
498c2ecf20Sopenharmony_ci	FIX_KMAP_BEGIN,
508c2ecf20Sopenharmony_ci	FIX_KMAP_END,  /*  check for per-cpuism  */
518c2ecf20Sopenharmony_ci	__end_of_fixed_addresses
528c2ecf20Sopenharmony_ci};
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define MIN_KERNEL_SEG (PAGE_OFFSET >> PGDIR_SHIFT)   /* L1 shift is 22 bits */
558c2ecf20Sopenharmony_ciextern int max_kernel_seg;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/*
588c2ecf20Sopenharmony_ci * Start of vmalloc virtual address space for kernel;
598c2ecf20Sopenharmony_ci * supposed to be based on the amount of physical memory available
608c2ecf20Sopenharmony_ci */
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define VMALLOC_START ((unsigned long) __va(high_memory + VMALLOC_OFFSET))
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/* Gap between physical ram and vmalloc space for guard purposes. */
658c2ecf20Sopenharmony_ci#define VMALLOC_OFFSET PAGE_SIZE
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci/*
688c2ecf20Sopenharmony_ci * Create the space between VMALLOC_START and FIXADDR_TOP backwards
698c2ecf20Sopenharmony_ci * from the ... "top".
708c2ecf20Sopenharmony_ci *
718c2ecf20Sopenharmony_ci * Permanent IO mappings will live at 0xfexx_xxxx
728c2ecf20Sopenharmony_ci * Hypervisor occupies the last 16MB page at 0xffxxxxxx
738c2ecf20Sopenharmony_ci */
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define FIXADDR_TOP     0xfe000000
768c2ecf20Sopenharmony_ci#define FIXADDR_SIZE    (__end_of_fixed_addresses << PAGE_SHIFT)
778c2ecf20Sopenharmony_ci#define FIXADDR_START   (FIXADDR_TOP - FIXADDR_SIZE)
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/*
808c2ecf20Sopenharmony_ci * "permanent kernel mappings", defined as long-lasting mappings of
818c2ecf20Sopenharmony_ci * high-memory page frames into the kernel address space.
828c2ecf20Sopenharmony_ci */
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define LAST_PKMAP	PTRS_PER_PTE
858c2ecf20Sopenharmony_ci#define LAST_PKMAP_MASK	(LAST_PKMAP - 1)
868c2ecf20Sopenharmony_ci#define PKMAP_NR(virt)	((virt - PKMAP_BASE) >> PAGE_SHIFT)
878c2ecf20Sopenharmony_ci#define PKMAP_ADDR(nr)	(PKMAP_BASE + ((nr) << PAGE_SHIFT))
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/*
908c2ecf20Sopenharmony_ci * To the "left" of the fixed map space is the kmap space
918c2ecf20Sopenharmony_ci *
928c2ecf20Sopenharmony_ci * "Permanent Kernel Mappings"; fancy (or less fancy) PTE table
938c2ecf20Sopenharmony_ci * that looks like it's actually walked.
948c2ecf20Sopenharmony_ci * Need to check the alignment/shift usage; some archs use
958c2ecf20Sopenharmony_ci * PMD_MASK on this value
968c2ecf20Sopenharmony_ci */
978c2ecf20Sopenharmony_ci#define PKMAP_BASE (FIXADDR_START-PAGE_SIZE*LAST_PKMAP)
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci/*
1008c2ecf20Sopenharmony_ci * 2 pages of guard gap between where vmalloc area ends
1018c2ecf20Sopenharmony_ci * and pkmap_base begins.
1028c2ecf20Sopenharmony_ci */
1038c2ecf20Sopenharmony_ci#define VMALLOC_END (PKMAP_BASE-PAGE_SIZE*2)
1048c2ecf20Sopenharmony_ci#endif /*  !__ASSEMBLY__  */
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#endif /* _ASM_HEXAGON_MEM_LAYOUT_H */
108