include: reduce default stack size
[minix.git] / servers / vm / mem_directphys.c
blob391f911a05f3e3411b6222517af5bac04845f7ea
2 /* This file implements the methods of direct physical mapping.
3 *
4 * A direct physical mapping is done by accepting the physical
5 * memory address and range from the caller and allowing direct
6 * access to it. Most significantly, no physical memory is allocated
7 * when it's mapped or freed when it's unmapped. E.g. device memory.
8 */
10 #include "vm.h"
12 /* These functions are static so as to not pollute the
13 * global namespace, and are accessed through their function
14 * pointers.
17 static int phys_reference(struct phys_region *pr);
18 static int phys_unreference(struct phys_region *pr);
19 static int phys_writable(struct phys_region *pr);
20 static int phys_pagefault(struct vmproc *vmp, struct vir_region *region,
21 struct phys_region *ph, int write);
22 static int phys_copy(struct vir_region *vr, struct vir_region *newvr);
24 struct mem_type mem_type_directphys = {
25 .name = "physical memory mapping",
26 .ev_reference = phys_reference,
27 .ev_copy = phys_copy,
28 .ev_unreference = phys_unreference,
29 .writable = phys_writable,
30 .ev_pagefault = phys_pagefault
33 static int phys_reference(struct phys_region *pr)
35 panic("%s", __FUNCTION__);
36 return OK;
39 static int phys_unreference(struct phys_region *pr)
41 return OK;
44 static int phys_pagefault(struct vmproc *vmp, struct vir_region *region,
45 struct phys_region *ph, int write)
47 phys_bytes arg = region->param.phys, phmem;
48 assert(arg != MAP_NONE);
49 assert(ph->ph->phys == MAP_NONE);
50 phmem = arg + ph->offset;
51 assert(phmem != MAP_NONE);
52 ph->ph->phys = phmem;
53 return OK;
56 static int phys_writable(struct phys_region *pr)
58 assert(pr->ph->refcount > 0);
59 return pr->ph->phys != MAP_NONE;
62 void phys_setphys(struct vir_region *vr, phys_bytes phys)
64 vr->param.phys = phys;
67 static int phys_copy(struct vir_region *vr, struct vir_region *newvr)
69 newvr->param.phys = vr->param.phys;
71 return OK;