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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [mm0/] [lib/] [vaddr.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * This module allocates an unused virtual address range for shm segments.
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 */
6
#include <lib/bit.h>
7
#include <l4/macros.h>
8
#include <l4/types.h>
9
#include INC_GLUE(memory.h)
10
#include <lib/vaddr.h>
11
#include <stdio.h>
12
#include <memory.h>
13
 
14
void vaddr_pool_init(struct id_pool *pool, unsigned long start, unsigned long end)
15
{
16
        pool = id_pool_new_init(__pfn(end - start));
17
}
18
 
19
void *vaddr_new(struct id_pool *pool, int npages)
20
{
21
        unsigned int shm_vpfn;
22
 
23
        if ((int)(shm_vpfn = ids_new_contiguous(pool, npages)) < 0)
24
                return 0;
25
 
26
        return (void *)__pfn_to_addr(shm_vpfn + cont_mem_regions.shmem->start);
27
}
28
 
29
int vaddr_del(struct id_pool *pool, void *vaddr, int npages)
30
{
31
        unsigned long idpfn = __pfn(page_align(vaddr) -
32
                                    __pfn_to_addr(cont_mem_regions.shmem->start));
33
 
34
        if (ids_del_contiguous(pool, idpfn, npages) < 0) {
35
                printf("%s: Invalid address range returned to "
36
                       "virtual address pool.\n", __FUNCTION__);
37
                return -1;
38
        }
39
        return 0;
40
}
41
 

powered by: WebSVN 2.1.0

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