Subversion Repositories HelenOS-historic

Rev

Rev 1425 | Rev 1494 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1425 Rev 1429
Line 51... Line 51...
51
 *
51
 *
52
 * @param id Task ID of the destination task.
52
 * @param id Task ID of the destination task.
53
 * @param pf Physical frame address of the starting frame.
53
 * @param pf Physical frame address of the starting frame.
54
 * @param vp Virtual page address of the starting page.
54
 * @param vp Virtual page address of the starting page.
55
 * @param pages Number of pages to map.
55
 * @param pages Number of pages to map.
56
 * @param writable If true, the mapping will be created writable.
56
 * @param flags Address space area flags for the mapping.
57
 *
57
 *
58
 * @return 0 on success, EPERM if the caller lacks capabilities to use this syscall,
58
 * @return 0 on success, EPERM if the caller lacks capabilities to use this syscall,
59
 *     ENOENT if there is no task matching the specified ID and ENOMEM if
59
 *     ENOENT if there is no task matching the specified ID and ENOMEM if
60
 *     there was a problem in creating address space area.
60
 *     there was a problem in creating address space area.
61
 */
61
 */
62
static int ddi_physmem_map(task_id_t id, __address pf, __address vp, count_t pages, bool writable)
62
static int ddi_physmem_map(task_id_t id, __address pf, __address vp, count_t pages, int flags)
63
{
63
{
64
    ipl_t ipl;
64
    ipl_t ipl;
65
    cap_t caps;
65
    cap_t caps;
66
    task_t *t;
66
    task_t *t;
67
    int flags;
-
 
68
    mem_backend_data_t backend_data;
67
    mem_backend_data_t backend_data;
69
 
68
 
70
    backend_data.base = pf;
69
    backend_data.base = pf;
71
    backend_data.frames = pages;
70
    backend_data.frames = pages;
72
   
71
   
Line 99... Line 98...
99
   
98
   
100
    /* Lock the task and release the lock protecting tasks_btree. */
99
    /* Lock the task and release the lock protecting tasks_btree. */
101
    spinlock_lock(&t->lock);
100
    spinlock_lock(&t->lock);
102
    spinlock_unlock(&tasks_lock);
101
    spinlock_unlock(&tasks_lock);
103
   
102
   
104
    flags = AS_AREA_READ;
-
 
105
    if (writable)
-
 
106
        flags |= AS_AREA_WRITE;
-
 
107
    if (!as_area_create(t->as, flags, pages * PAGE_SIZE, vp, AS_AREA_ATTR_NONE,
103
    if (!as_area_create(t->as, flags, pages * PAGE_SIZE, vp, AS_AREA_ATTR_NONE,
108
        &phys_backend, &backend_data)) {
104
        &phys_backend, &backend_data)) {
109
        /*
105
        /*
110
         * The address space area could not have been created.
106
         * The address space area could not have been created.
111
         * We report it using ENOMEM.
107
         * We report it using ENOMEM.
Line 193... Line 189...
193
    if (rc != 0)
189
    if (rc != 0)
194
        return (__native) rc;
190
        return (__native) rc;
195
       
191
       
196
    return (__native) ddi_physmem_map((task_id_t) arg.task_id, ALIGN_DOWN((__address) arg.phys_base, FRAME_SIZE),
192
    return (__native) ddi_physmem_map((task_id_t) arg.task_id, ALIGN_DOWN((__address) arg.phys_base, FRAME_SIZE),
197
                      ALIGN_DOWN((__address) arg.virt_base, PAGE_SIZE), (count_t) arg.pages,
193
                      ALIGN_DOWN((__address) arg.virt_base, PAGE_SIZE), (count_t) arg.pages,
198
                      (bool) arg.writable);
194
                      (int) arg.flags);
199
}
195
}
200
 
196
 
201
/** Wrapper for SYS_ENABLE_IOSPACE syscall.
197
/** Wrapper for SYS_ENABLE_IOSPACE syscall.
202
 *
198
 *
203
 * @param User space address of DDI argument structure.
199
 * @param User space address of DDI argument structure.