xref: /minix3/minix/servers/vm/vm.h (revision 63483e02e6a5924979f1c177070e18c56323a45c)
1433d6423SLionel Sambuc 
2433d6423SLionel Sambuc #ifndef _VM_H
3433d6423SLionel Sambuc #define _VM_H 1
4433d6423SLionel Sambuc 
5433d6423SLionel Sambuc #define _SYSTEM 1
6433d6423SLionel Sambuc 
7433d6423SLionel Sambuc /* Compile in asserts and custom sanity checks at all? */
8433d6423SLionel Sambuc #define SANITYCHECKS	0
9433d6423SLionel Sambuc #define CACHE_SANITY	0
10433d6423SLionel Sambuc #define VMSTATS		0
11433d6423SLionel Sambuc 
12433d6423SLionel Sambuc /* VM behaviour */
13433d6423SLionel Sambuc #define MEMPROTECT	0	/* Slab objects not mapped. Access with USE() */
14433d6423SLionel Sambuc #define JUNKFREE	0	/* Fill freed pages with junk */
15433d6423SLionel Sambuc 
16433d6423SLionel Sambuc #include <sys/errno.h>
17433d6423SLionel Sambuc 
18433d6423SLionel Sambuc #include "sanitycheck.h"
19433d6423SLionel Sambuc #include "region.h"
20433d6423SLionel Sambuc 
21433d6423SLionel Sambuc /* Memory flags to pt_allocmap() and alloc_mem(). */
22433d6423SLionel Sambuc #define PAF_CLEAR	0x01	/* Clear physical memory. */
23433d6423SLionel Sambuc #define PAF_CONTIG	0x02	/* Physically contiguous. */
24433d6423SLionel Sambuc #define PAF_ALIGN64K	0x04	/* Aligned to 64k boundary. */
25433d6423SLionel Sambuc #define PAF_LOWER16MB	0x08
26433d6423SLionel Sambuc #define PAF_LOWER1MB	0x10
27433d6423SLionel Sambuc #define PAF_ALIGN16K	0x40	/* Aligned to 16k boundary. */
28433d6423SLionel Sambuc 
29433d6423SLionel Sambuc #define MARK do { if(mark) { printf("%d\n", __LINE__); } } while(0)
30433d6423SLionel Sambuc 
31433d6423SLionel Sambuc /* special value for v in pt_allocmap */
32433d6423SLionel Sambuc #define AM_AUTO         ((u32_t) -1)
33433d6423SLionel Sambuc 
34433d6423SLionel Sambuc /* How noisy are we supposed to be? */
35433d6423SLionel Sambuc #define VERBOSE		0
36433d6423SLionel Sambuc #define LU_DEBUG	0
37433d6423SLionel Sambuc 
38433d6423SLionel Sambuc /* Minimum stack region size - 64MB. */
39433d6423SLionel Sambuc #define MINSTACKREGION	(64*1024*1024)
40433d6423SLionel Sambuc 
41433d6423SLionel Sambuc /* If so, this level: */
42433d6423SLionel Sambuc #define SCL_NONE	0	/* No sanity checks - assert()s only. */
43433d6423SLionel Sambuc #define SCL_TOP		1	/* Main loop and other high-level places. */
44433d6423SLionel Sambuc #define SCL_FUNCTIONS	2	/* Function entry/exit. */
45433d6423SLionel Sambuc #define SCL_DETAIL	3	/* Detailled steps. */
46433d6423SLionel Sambuc #define SCL_MAX		3	/* Highest value. */
47433d6423SLionel Sambuc 
48433d6423SLionel Sambuc /* Type of page allocations. */
49433d6423SLionel Sambuc #define VMP_SPARE	0
50433d6423SLionel Sambuc #define VMP_PAGETABLE	1
51433d6423SLionel Sambuc #define VMP_PAGEDIR	2
52433d6423SLionel Sambuc #define VMP_SLAB	3
53433d6423SLionel Sambuc #define VMP_CATEGORIES	4
54433d6423SLionel Sambuc 
55433d6423SLionel Sambuc /* Flags to pt_writemap(). */
56433d6423SLionel Sambuc #define WMF_OVERWRITE		0x01	/* Caller knows map may overwrite. */
57433d6423SLionel Sambuc #define WMF_WRITEFLAGSONLY	0x02	/* Copy physaddr and update flags. */
58433d6423SLionel Sambuc #define WMF_FREE		0x04	/* Free pages overwritten. */
59433d6423SLionel Sambuc #define WMF_VERIFY		0x08	/* Check pagetable contents. */
60433d6423SLionel Sambuc 
61433d6423SLionel Sambuc #define MAP_NONE	0xFFFFFFFE
62433d6423SLionel Sambuc #define NO_MEM ((phys_clicks) MAP_NONE)  /* returned by alloc_mem() with mem is up */
63433d6423SLionel Sambuc 
64433d6423SLionel Sambuc /* And what is the highest addressable piece of memory? */
65433d6423SLionel Sambuc #define VM_DATATOP	kernel_boot_info.user_end
6653398d73SCristiano Giuffrida 
67433d6423SLionel Sambuc #define VM_STACKTOP	kernel_boot_info.user_sp
68433d6423SLionel Sambuc 
6953398d73SCristiano Giuffrida /* Live update will work only with magic instrumentation. Live update requires
7053398d73SCristiano Giuffrida  * strict separation of regions within the process to succeed. Therefore,
7153398d73SCristiano Giuffrida  * apply this strict separation only if magic instrumentation is used.
7253398d73SCristiano Giuffrida  * Otherwise, do not place such limitations on processes.
7353398d73SCristiano Giuffrida  */
7453398d73SCristiano Giuffrida #ifdef _MINIX_MAGIC
7553398d73SCristiano Giuffrida #define VM_MMAPTOP	(VM_STACKTOP-DEFAULT_STACK_LIMIT)
7653398d73SCristiano Giuffrida #define VM_MMAPBASE	(VM_MMAPTOP/2)
7753398d73SCristiano Giuffrida #else
7853398d73SCristiano Giuffrida #define VM_MMAPTOP	VM_DATATOP
7953398d73SCristiano Giuffrida #define VM_MMAPBASE	VM_PAGE_SIZE
80433d6423SLionel Sambuc #endif
81433d6423SLionel Sambuc 
82*63483e02SCristiano Giuffrida extern char _end;
83*63483e02SCristiano Giuffrida #define VM_OWN_HEAPSTART ((vir_bytes) (&_end))
84*63483e02SCristiano Giuffrida #define VM_OWN_HEAPBASE   roundup(VM_OWN_HEAPSTART, VM_PAGE_SIZE)
85*63483e02SCristiano Giuffrida #define VM_OWN_MMAPBASE (VM_OWN_HEAPBASE+1024*1024*1024)
86*63483e02SCristiano Giuffrida #define VM_OWN_MMAPTOP   (VM_OWN_MMAPBASE+100 * 1024 * 1024)
87*63483e02SCristiano Giuffrida 
8853398d73SCristiano Giuffrida #endif
89