22 |
#include "tm.h" |
#include "tm.h" |
23 |
#include "task.h" |
#include "task.h" |
24 |
|
|
25 |
|
#include "vm-object.h" |
26 |
|
|
27 |
/* Map OBJECT at into the address space of TASK. If ANYWHERE_P is |
/* Map OBJECT at into the address space of TASK. If ANYWHERE_P is |
28 |
false we try to map the object at *OFFSETP, otherwise the kernel |
false we try to map the object at *OFFSETP, otherwise the kernel |
39 |
protection, inherit, anywhere_p); |
protection, inherit, anywhere_p); |
40 |
return kr; |
return kr; |
41 |
} |
} |
42 |
|
|
43 |
|
|
44 |
|
/* Allocate SIZE bytes in the address space of TASK. If ANYWHERE_P is |
45 |
|
false, enter new object at *OFFSETP, otherwise use suitable location. */ |
46 |
|
|
47 |
|
kern_return_t |
48 |
|
vm_allocate (struct task *task, vm_size_t size, vm_offset_t *offsetp, |
49 |
|
bool anywhere_p) |
50 |
|
{ |
51 |
|
struct vm_object *object; |
52 |
|
kern_return_t kr; |
53 |
|
|
54 |
|
object = vm_object_allocate (size); |
55 |
|
if (object == 0) |
56 |
|
return KERN_RESOURCE_SHORTAGE; |
57 |
|
|
58 |
|
kr = vm_map_allocate (task->map, offsetp, size, object, VM_PROT_ALL, |
59 |
|
VM_PROT_ALL, VM_INHERIT_COPY, anywhere_p); |
60 |
|
if (kr) |
61 |
|
{ |
62 |
|
/* vm_object_deallocate (object); ??? */ |
63 |
|
return kr; |
64 |
|
} |
65 |
|
return KERN_SUCCESS; |
66 |
|
} |