Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / minix / vm.h @ 13

History | View | Annotate | Download (3.86 KB)

1 13 up20180614
/* 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_set_priv(endpoint_t ep, void *buf, int sys_proc);
20
int vm_update(endpoint_t src_e, endpoint_t dst_e, int flags);
21
int vm_memctl(endpoint_t ep, int req, void** addr, size_t *len);
22
int vm_prepare(endpoint_t src_e, endpoint_t dst_e, int flags);
23
int minix_vfs_mmap(endpoint_t who, off_t offset, size_t len,
24
        dev_t dev, ino_t ino, int fd, u32_t vaddr, u16_t clearend, u16_t
25
        flags);
26
27
void *minix_mmap_for(endpoint_t forwhom,
28
        void *addr, size_t len, int prot, int flags, int fd, off_t offset);
29
int minix_vfs_mmap(endpoint_t who, off_t offset, size_t len,
30
        dev_t dev, ino_t ino, int fd, u32_t vaddr, u16_t clearend,
31
        u16_t flags);
32
33
/* minix vfs mmap flags */
34
#define MVM_WRITABLE        0x8000
35
36
/* VM kernel request types. */
37
#define VMPTYPE_NONE                0
38
#define VMPTYPE_CHECK                1
39
40
struct vm_stats_info {
41
  unsigned int vsi_pagesize;        /* page size */
42
  unsigned long vsi_total;        /* total number of memory pages */
43
  unsigned long vsi_free;        /* number of free pages */
44
  unsigned long vsi_largest;        /* largest number of consecutive free pages */
45
  unsigned long vsi_cached;        /* number of pages cached for file systems */
46
};
47
48
struct vm_usage_info {
49
  vir_bytes vui_total;                /* total amount of mapped process memory */
50
  vir_bytes vui_common;                /* part of memory mapped in more than once */
51
  vir_bytes vui_shared;                /* shared (non-COW) part of common memory */
52
  vir_bytes vui_virtual;        /* total size of virtual address space */
53
  vir_bytes vui_mvirtual;        /* idem but minus unmapped stack pages */
54
  uint64_t vui_maxrss;                /* maximum resident set size (in KB) */
55
  uint64_t vui_minflt;                /* minor page faults */
56
  uint64_t vui_majflt;                /* major page faults */
57
};
58
59
struct vm_region_info {
60
  vir_bytes vri_addr;                /* base address of region */
61
  vir_bytes vri_length;                /* length of region */
62
  int vri_prot;                        /* protection flags (PROT_) */
63
  int vri_flags;                /* memory flags (subset of MAP_) */
64
};
65
66
#define MAX_VRI_COUNT        64        /* max. number of regions provided at once */
67
68
int vm_info_stats(struct vm_stats_info *vfi);
69
int vm_info_usage(endpoint_t who, struct vm_usage_info *vui);
70
int vm_info_region(endpoint_t who, struct vm_region_info *vri, int
71
        count, vir_bytes *next);
72
int vm_procctl_clear(endpoint_t ep);
73
int vm_procctl_handlemem(endpoint_t ep, vir_bytes m1, vir_bytes m2, int wr);
74
75
int vm_set_cacheblock(void *block, dev_t dev, off_t dev_offset,
76
        ino_t ino, off_t ino_offset, u32_t *flags, int blocksize,
77
        int setflags);
78
void *vm_map_cacheblock(dev_t dev, off_t dev_offset,
79
        ino_t ino, off_t ino_offset, u32_t *flags, int blocksize);
80
int vm_forget_cacheblock(dev_t dev, off_t dev_offset, int blocksize);
81
int vm_clear_cache(dev_t dev);
82
83
/* flags for vm cache functions */
84
#define VMMC_FLAGS_LOCKED        0x01        /* someone is updating the flags; don't read/write */
85
#define VMMC_DIRTY                0x02        /* dirty buffer and it may not be evicted */
86
#define VMMC_EVICTED                0x04        /* VM has evicted the buffer and it's invalid */
87
#define VMMC_BLOCK_LOCKED        0x08        /* client is using it and it may not be evicted */
88
89
/* special inode number for vm cache functions */
90
#define VMC_NO_INODE                0        /* to reference a disk block, no associated file */
91
92
/* setflags for vm_set_cacheblock, also used internally in VM */
93
#define VMSF_ONCE                0x01        /* discard block after one-time use */
94
95
#endif /* _MINIX_VM_H */