OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [mm0/] [mm/] [dev.c] - Blame information for rev 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Copyright (C) 2008 Bahadir Balban
3
 */
4
#include <l4/lib/list.h>
5
#include <vm_area.h>
6
#include <malloc/malloc.h>
7
#include <fs.h>
8
 
9
/*
10
 * This is yet unused, it is more of an anticipation
11
 * of how mmaped devices would be mapped with a pager.
12
 */
13
struct mmap_device {
14
        struct link page_list;  /* Dyn-allocated page list */
15
        unsigned long pfn_start;        /* Physical pfn start */
16
        unsigned long pfn_end;          /* Physical pfn end */
17
};
18
 
19
struct page *memdev_page_in(struct vm_object *vm_obj,
20
                            unsigned long pfn_offset)
21
{
22
        struct vm_file *f = vm_object_to_file(vm_obj);
23
        struct mmap_device *memdev = f->vnode->inode;
24
        struct page *page;
25
 
26
        /* Check if its within device boundary */
27
        if (pfn_offset >= memdev->pfn_end - memdev->pfn_start)
28
                return PTR_ERR(-1);
29
 
30
        /* Simply return the page if found */
31
        list_foreach_struct(page, &memdev->page_list, list)
32
                if (page->offset == pfn_offset)
33
                        return page;
34
 
35
        /* Otherwise allocate one of our own for that offset and return it */
36
        page = kzalloc(sizeof(struct page));
37
        link_init(&page->list);
38
        spin_lock_init(&page->lock);
39
        page->offset = pfn_offset;
40
        page->owner = vm_obj;
41
        list_insert(&page->list, &memdev->page_list);
42
 
43
        return page;
44
}
45
 
46
/* All mmapable devices are handled by this */
47
struct vm_pager memdev_pager = {
48
        .ops = {
49
                .page_in = memdev_page_in,
50
        },
51
};
52
 
53
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.