xref: /minix/minix/include/minix/vm.h (revision 9f988b79)
1 /* Prototypes and definitions for VM interface. */
2 
3 #ifndef _MINIX_VM_H
4 #define _MINIX_VM_H
5 
6 #include <sys/types.h>
7 #include <minix/endpoint.h>
8 
9 int vm_exit(endpoint_t ep);
10 int vm_fork(endpoint_t ep, int slotno, endpoint_t *child_ep);
11 int vm_getrusage(endpoint_t endpt, void *addr, int children);
12 int vm_willexit(endpoint_t ep);
13 int vm_adddma(endpoint_t proc_e, phys_bytes start, phys_bytes size);
14 int vm_deldma(endpoint_t proc_e, phys_bytes start, phys_bytes size);
15 int vm_getdma(endpoint_t *procp, phys_bytes *basep, phys_bytes *sizep);
16 void *vm_map_phys(endpoint_t who, void *physaddr, size_t len);
17 int vm_unmap_phys(endpoint_t who, void *vaddr, size_t len);
18 
19 int vm_notify_sig(endpoint_t ep, endpoint_t ipc_ep);
20 int vm_set_priv(endpoint_t ep, void *buf, int sys_proc);
21 int vm_update(endpoint_t src_e, endpoint_t dst_e, int flags);
22 int vm_memctl(endpoint_t ep, int req, void** addr, size_t *len);
23 int vm_prepare(endpoint_t src_e, endpoint_t dst_e, int flags);
24 int vm_query_exit(endpoint_t *endpt);
25 int vm_watch_exit(endpoint_t ep);
26 int minix_vfs_mmap(endpoint_t who, off_t offset, size_t len,
27         dev_t dev, ino_t ino, int fd, u32_t vaddr, u16_t clearend, u16_t
28 	flags);
29 
30 void *minix_mmap_for(endpoint_t forwhom,
31         void *addr, size_t len, int prot, int flags, int fd, off_t offset);
32 int minix_vfs_mmap(endpoint_t who, off_t offset, size_t len,
33         dev_t dev, ino_t ino, int fd, u32_t vaddr, u16_t clearend,
34         u16_t flags);
35 
36 /* minix vfs mmap flags */
37 #define MVM_WRITABLE	0x8000
38 
39 /* VM kernel request types. */
40 #define VMPTYPE_NONE		0
41 #define VMPTYPE_CHECK		1
42 
43 struct vm_stats_info {
44   unsigned int vsi_pagesize;	/* page size */
45   unsigned long vsi_total;	/* total number of memory pages */
46   unsigned long vsi_free;	/* number of free pages */
47   unsigned long vsi_largest;	/* largest number of consecutive free pages */
48   unsigned long vsi_cached;	/* number of pages cached for file systems */
49 };
50 
51 struct vm_usage_info {
52   vir_bytes vui_total;		/* total amount of process memory */
53   vir_bytes vui_common;		/* part of memory mapped in more than once */
54   vir_bytes vui_shared;		/* shared (non-COW) part of common memory */
55 };
56 
57 struct vm_region_info {
58   vir_bytes vri_addr;		/* base address of region */
59   vir_bytes vri_length;		/* length of region */
60   int vri_prot;			/* protection flags (PROT_) */
61   int vri_flags;		/* memory flags (subset of MAP_) */
62 };
63 
64 #define MAX_VRI_COUNT	64	/* max. number of regions provided at once */
65 
66 int vm_info_stats(struct vm_stats_info *vfi);
67 int vm_info_usage(endpoint_t who, struct vm_usage_info *vui);
68 int vm_info_region(endpoint_t who, struct vm_region_info *vri, int
69 	count, vir_bytes *next);
70 int vm_procctl_clear(endpoint_t ep);
71 int vm_procctl_handlemem(endpoint_t ep, vir_bytes m1, vir_bytes m2, int wr);
72 
73 int vm_set_cacheblock(void *block, dev_t dev, off_t dev_offset,
74         ino_t ino, off_t ino_offset, u32_t *flags, int blocksize,
75         int setflags);
76 void *vm_map_cacheblock(dev_t dev, off_t dev_offset,
77         ino_t ino, off_t ino_offset, u32_t *flags, int blocksize);
78 int vm_forget_cacheblock(dev_t dev, off_t dev_offset, int blocksize);
79 int vm_clear_cache(dev_t dev);
80 
81 /* flags for vm cache functions */
82 #define VMMC_FLAGS_LOCKED	0x01	/* someone is updating the flags; don't read/write */
83 #define VMMC_DIRTY		0x02	/* dirty buffer and it may not be evicted */
84 #define VMMC_EVICTED		0x04	/* VM has evicted the buffer and it's invalid */
85 #define VMMC_BLOCK_LOCKED	0x08	/* client is using it and it may not be evicted */
86 
87 /* special inode number for vm cache functions */
88 #define VMC_NO_INODE		0	/* to reference a disk block, no associated file */
89 
90 /* setflags for vm_set_cacheblock, also used internally in VM */
91 #define VMSF_ONCE		0x01	/* discard block after one-time use */
92 
93 #endif /* _MINIX_VM_H */
94 
95