/[rtmk]/rtmk/vm-syscall.c
ViewVC logotype

Diff of /rtmk/vm-syscall.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by jrydberg, Sun Feb 24 23:09:48 2002 UTC revision 1.7 by jrydberg, Wed Mar 6 00:55:01 2002 UTC
# Line 22  Foundation, Inc., 59 Temple Place - Suit Line 22  Foundation, Inc., 59 Temple Place - Suit
22  #include "tm.h"  #include "tm.h"
23  #include "task.h"  #include "task.h"
24  #include "trace.h"  #include "trace.h"
25    #include "ipc-port.h"
26    #include "host.h"
27    
28  #include "vm-object.h"  #include "vm-object.h"
29  #include "vm-page.h"  #include "vm-page.h"
30  #include "vm-fault.h"  #include "vm-fault.h"
31    #include "vm-pager.h"
32    
33  /* 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
34     false we try to map the object at *OFFSETP, otherwise the kernel     false we try to map the object at *ADDRESSP, otherwise the kernel
35     selects the location in the address space.  */     selects the location in the address space.  */
36  kern_return_t  kern_return_t
37  vm_map (struct task *task, struct vm_object *object, vm_offset_t *offsetp,  vm_map (struct task *task, vm_offset_t *addressp, vm_size_t size,
38          vm_size_t size, bool anywhere_p, vm_prot_t protection,          bool anywhere_p, struct ipc_port *memory_object,
39          vm_inherit_t inherit)          vm_offset_t offset, bool copy_p, vm_prot_t protection,
40            vm_prot_t max_protection, vm_inherit_t inherit)
41  {  {
42      struct vm_object *object;
43      struct vm_pager *pager;
44    kern_return_t kr;    kern_return_t kr;
45    
46    kr = vm_map_allocate (task->map, offsetp, size, object, protection,    size = vm_round_page (size);
47                          protection, inherit, anywhere_p);  
48      if (!task || (protection & ~VM_PROT_ALL)
49          || (max_protection & ~VM_PROT_ALL) || !size)
50        return KERN_INVALID_ARGUMENT;
51    
52      switch (inherit)
53        {
54        case VM_INHERIT_COPY:
55        case VM_INHERIT_SHARE:
56        case VM_INHERIT_NONE:
57          break;
58        default:
59          return KERN_INVALID_ARGUMENT;
60        }
61    
62      /* The priviledged host port is a backing storage for physical
63         memory.  It can not retain data though.  */
64      if (memory_object == master_host_port)
65        pager = & pager_host;
66      else if (memory_object)
67        pager = & pager_extern;
68      else
69        pager = default_pager;
70    
71      if (memory_object)
72        {
73          object = vm_object_enter (pager, memory_object, size, 0);
74          if (! object)
75            return KERN_INVALID_ARGUMENT;
76          object->pager_offset = offset;
77        }
78      else
79        object = vm_object_allocate (size);
80    
81      kr = vm_map_allocate (task->map, addressp, size, object, protection,
82                            max_protection, inherit, anywhere_p);
83    return kr;    return kr;
84  }  }
85    
# Line 52  vm_allocate (struct task *task, vm_size_ Line 93  vm_allocate (struct task *task, vm_size_
93    struct vm_object *object;    struct vm_object *object;
94    kern_return_t kr;    kern_return_t kr;
95    
96    #if 0
97    trace_printf ("vm allocate: task %p size %x offset %x anywhere %d",    trace_printf ("vm allocate: task %p size %x offset %x anywhere %d",
98                  task, size, *offsetp, anywhere_p);                  task, size, *offsetp, anywhere_p);
99    #endif
100    
101    object = vm_object_allocate (size);    object = vm_object_allocate (size);
102    if (object == 0)    if (object == 0)
103      return KERN_RESOURCE_SHORTAGE;      return KERN_RESOURCE_SHORTAGE;
104      size = vm_round_page (size);
105    
106    kr = vm_map_allocate (task->map, offsetp, size, object, VM_PROT_ALL,    kr = vm_map_allocate (task->map, offsetp, size, object, VM_PROT_ALL,
107                          VM_PROT_ALL, VM_INHERIT_COPY, anywhere_p);                          VM_PROT_ALL, VM_INHERIT_COPY, anywhere_p);
108    if (kr)    if (kr)
109      {      {
110        vm_object_destroy (object);        vm_object_deallocate (object);
111        return kr;        return kr;
112      }      }
113    return KERN_SUCCESS;    return KERN_SUCCESS;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26