19a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel/*
29a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * include/asm-xtensa/mman.h
39a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel *
49a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * Xtensa Processor memory-manager definitions
59a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel *
69a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * This file is subject to the terms and conditions of the GNU General Public
79a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * License.  See the file "COPYING" in the main directory of this archive
89a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * for more details.
99a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel *
109a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * Copyright (C) 1995 by Ralf Baechle
119a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * Copyright (C) 2001 - 2005 Tensilica Inc.
129a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel */
139a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
149a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#ifndef _XTENSA_MMAN_H
159a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define _XTENSA_MMAN_H
169a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
179a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel/*
189a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * Protections are chosen from these bits, OR'd together.  The
199a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * implementation does not necessarily support PROT_EXEC or PROT_WRITE
209a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * without PROT_READ.  The only guarantees are that no writing will be
219a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * allowed without PROT_WRITE and no access will be allowed for PROT_NONE.
229a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel */
239a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
249a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define PROT_NONE	0x0		/* page can not be accessed */
259a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define PROT_READ	0x1		/* page can be read */
269a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define PROT_WRITE	0x2		/* page can be written */
279a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define PROT_EXEC	0x4		/* page can be executed */
289a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
299a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define PROT_SEM	0x10		/* page may be used for atomic ops */
309a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
319a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end fo growsup vma */
329a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
339a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel/*
349a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * Flags for mmap
359a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel */
369a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_SHARED	0x001		/* Share changes */
379a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_PRIVATE	0x002		/* Changes are private */
389a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_TYPE	0x00f		/* Mask for type of mapping */
399a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_FIXED	0x010		/* Interpret addr exactly */
409a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
419a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel/* not used by linux, but here to make sure we don't clash with ABI defines */
429a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_RENAME	0x020		/* Assign page to file */
439a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_AUTOGROW	0x040		/* File may grow by writing */
449a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_LOCAL	0x080		/* Copy on fork/sproc */
459a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_AUTORSRV	0x100		/* Logical swap reserved on demand */
469a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
479a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel/* These are linux-specific */
489a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_NORESERVE	0x0400		/* don't check for reservations */
499a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_ANONYMOUS	0x0800		/* don't use a file */
509a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_GROWSDOWN	0x1000		/* stack-like segment */
519a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_DENYWRITE	0x2000		/* ETXTBSY */
529a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_EXECUTABLE	0x4000		/* mark it as an executable */
539a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_LOCKED	0x8000		/* pages are locked */
549a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
559a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MAP_NONBLOCK	0x20000		/* do not block on IO */
5690f72aa58bbf076b68e289fbd71eb829bc505923Arnd Bergmann#define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
5790f72aa58bbf076b68e289fbd71eb829bc505923Arnd Bergmann#define MAP_HUGETLB	0x80000		/* create a huge page mapping */
589a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
599a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel/*
609a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * Flags for msync
619a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel */
629a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MS_ASYNC	0x0001		/* sync memory asynchronously */
639a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MS_INVALIDATE	0x0002		/* invalidate mappings & caches */
649a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MS_SYNC		0x0004		/* synchronous memory sync */
659a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
669a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel/*
679a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel * Flags for mlockall
689a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel */
699a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MCL_CURRENT	1		/* lock all current mappings */
709a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#define MCL_FUTURE	2		/* lock all future mappings */
719a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
725f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin#define MADV_NORMAL	0		/* no further special treatment */
735f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin#define MADV_RANDOM	1		/* expect random page references */
745f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin#define MADV_SEQUENTIAL	2		/* expect sequential page references */
755f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin#define MADV_WILLNEED	3		/* will need these pages */
765f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin#define MADV_DONTNEED	4		/* don't need these pages */
775f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin
785f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin/* common parameters: try to keep these consistent across architectures */
795f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin#define MADV_REMOVE	9		/* remove these pages & resources */
805f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin#define MADV_DONTFORK	10		/* don't inherit across fork */
815f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin#define MADV_DOFORK	11		/* do inherit across fork */
829a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
83d19f352484467a5e518639ddff0554669c10ffabHugh Dickins#define MADV_MERGEABLE   12		/* KSM may merge identical pages */
84d19f352484467a5e518639ddff0554669c10ffabHugh Dickins#define MADV_UNMERGEABLE 13		/* KSM may not merge identical pages */
85d19f352484467a5e518639ddff0554669c10ffabHugh Dickins
86a826e422420b461a6247137c292ff83c4800354aAndrea Arcangeli#define MADV_HUGEPAGE	14		/* Worth backing with hugepages */
871ddd6db43a08cba56c7ee920800980862086f1c3Andrea Arcangeli#define MADV_NOHUGEPAGE	15		/* Not worth backing with hugepages */
88a826e422420b461a6247137c292ff83c4800354aAndrea Arcangeli
89accb61fe7bb0f5c2a4102239e4981650f9048519Jason Baron#define MADV_DONTDUMP   16		/* Explicity exclude from the core dump,
90accb61fe7bb0f5c2a4102239e4981650f9048519Jason Baron					   overrides the coredump filter bits */
91accb61fe7bb0f5c2a4102239e4981650f9048519Jason Baron#define MADV_DODUMP	17		/* Clear the MADV_NODUMP flag */
92accb61fe7bb0f5c2a4102239e4981650f9048519Jason Baron
939a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel/* compatibility flags */
945f6164f3092832e0d9b12eed52e09a76bf39c64aMichael S. Tsirkin#define MAP_FILE	0
959a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel
9642d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen/*
9742d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen * When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size.
9842d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen * This gives us 6 bits, which is enough until someone invents 128 bit address
9942d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen * spaces.
10042d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen *
10142d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen * Assume these are all power of twos.
10242d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen * When 0 use the default page size.
10342d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen */
10442d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen#define MAP_HUGE_SHIFT	26
10542d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen#define MAP_HUGE_MASK	0x3f
10642d7395feb56f0655cd8b68e06fc6063823449f8Andi Kleen
1079a8fd5589902153a134111ed7a40f9cca1f83254Chris Zankel#endif /* _XTENSA_MMAN_H */
108