summaryrefslogtreecommitdiff
path: root/minix/servers/vm/region.h
blob: 934ec79b6b9e676da7aeca0f8ead0227b0d60233 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

#ifndef _REGION_H
#define _REGION_H 1

#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/config.h>
#include <minix/const.h>
#include <minix/ds.h>
#include <minix/endpoint.h>
#include <minix/minlib.h>
#include <minix/type.h>
#include <minix/ipc.h>
#include <minix/sysutil.h>
#include <minix/syslib.h>
#include <minix/const.h>

#include "phys_region.h"
#include "memtype.h"
#include "vm.h"
#include "fdref.h"

struct phys_block {
#if SANITYCHECKS
	u32_t			seencount;
#endif
	phys_bytes		phys;	/* physical memory */

	/* first in list of phys_regions that reference this block */
	struct phys_region	*firstregion;	
	u8_t			refcount;	/* Refcount of these pages */
	u8_t			flags;
};

#define PBF_INCACHE		0x01

typedef struct vir_region {
	vir_bytes	vaddr;	/* virtual address, offset from pagetable */
	vir_bytes	length;	/* length in bytes */
	struct phys_region	**physblocks;
	u16_t		flags;
	struct vmproc *parent;	/* Process that owns this vir_region. */
	mem_type_t	*def_memtype; /* Default instantiated memory type. */
	int		remaps;
	int		id;     /* unique id */

	union {
		phys_bytes phys;	/* VR_DIRECT */
		struct {
			endpoint_t ep;
			vir_bytes vaddr;
			int id;
		} shared;
		struct phys_block *pb_cache;
		struct {
			int	inited;
			struct fdref	*fdref;
			u64_t	offset;
			u16_t	clearend;
		} file;
	} param;

	/* AVL fields */
	struct vir_region *lower, *higher;
	int		factor;
} region_t;

/* Mapping flags: */
#define VR_WRITABLE	0x001	/* Process may write here. */
#define VR_PHYS64K	0x004	/* Physical memory must be 64k aligned. */
#define VR_LOWER16MB	0x008
#define VR_LOWER1MB	0x010
#define VR_SHARED	0x040
#define VR_UNINITIALIZED 0x080	/* Do not clear after allocation  */

/* Mapping type: */
#define VR_ANON		0x100	/* Memory to be cleared and allocated */
#define VR_DIRECT	0x200	/* Mapped, but not managed by VM */
#define VR_PREALLOC_MAP	0x400   /* Preallocated map. */

/* map_page_region_flags */
#define MF_PREALLOC    0x01

#endif