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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [mm0/] [include/] [vfs.h] - Blame information for rev 7

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

Line No. Rev Author Line
1 2 drasko
#ifndef __VFS_H__
2
#define __VFS_H__
3
 
4
#include <fs.h>
5
#include <malloc/malloc.h>
6
#include <l4/lib/list.h>
7
#include <memfs/memfs.h>
8
#include <l4/macros.h>
9
#include <stdio.h>
10
#include <task.h>
11
#include <path.h>
12
 
13
/* Top nibble of vnum indicates filesystem index */
14
#define VFS_FSIDX_MASK          0xF0000000
15
#define VFS_FSIDX_SHIFT         28
16
#define VFS_FSIDX_SIZE          16
17
 
18
extern struct link vnode_cache;
19
extern struct link dentry_cache;
20
extern struct id_pool *vfs_fsidx_pool;
21
 
22
/*
23
 * This is a temporary origacement for page cache support provided by mm0.
24
 * Normally mm0 tracks all vnode pages, but this is used to track pages in
25
 * directory vnodes, which are normally never mapped by tasks.
26
 */
27
static inline void *vfs_alloc_dirpage(struct vnode *v)
28
{
29
        /*
30
         * Urgh, we allocate from the block cache of memfs to store generic vfs directory
31
         * pages. This is currently the quickest we can allocate page-aligned memory.
32
         */
33
        return memfs_alloc_block(v->sb->fs_super);
34
}
35
 
36
static inline void vfs_free_dirpage(struct vnode *v, void *block)
37
{
38
        memfs_free_block(v->sb->fs_super, block);
39
}
40
 
41
static inline struct dentry *vfs_alloc_dentry(void)
42
{
43
        struct dentry *d = kzalloc(sizeof(struct dentry));
44
 
45
        link_init(&d->child);
46
        link_init(&d->children);
47
        link_init(&d->vref);
48
        link_init(&d->cache_list);
49
 
50
        return d;
51
}
52
 
53
static inline void vfs_free_dentry(struct dentry *d)
54
{
55
        return kfree(d);
56
}
57
 
58
static inline struct vnode *vfs_alloc_vnode(void)
59
{
60
        struct vnode *v = kzalloc(sizeof(struct vnode));
61
 
62
        link_init(&v->dentries);
63
        link_init(&v->cache_list);
64
 
65
        return v;
66
}
67
 
68
static inline void vfs_free_vnode(struct vnode *v)
69
{
70
        BUG(); /* Are the dentries freed ??? */
71
        list_remove(&v->cache_list);
72
        kfree(v);
73
}
74
 
75
static inline struct superblock *vfs_alloc_superblock(void)
76
{
77
        struct superblock *sb = kmalloc(sizeof(struct superblock));
78
        int fsidx = id_new(vfs_fsidx_pool);
79
 
80
        sb->fsidx = fsidx << VFS_FSIDX_SHIFT;
81
        link_init(&sb->list);
82
 
83
        return sb;
84
}
85
 
86
struct vfs_mountpoint {
87
        struct superblock *sb;  /* The superblock of mounted filesystem */
88
        struct vnode *pivot;    /* The dentry upon which we mount */
89
};
90
 
91
extern struct vfs_mountpoint vfs_root;
92
 
93
int vfs_mount_root(struct superblock *sb);
94
struct vnode *generic_vnode_lookup(struct vnode *thisnode, struct pathdata *p,
95
                                   const char *component);
96
struct vnode *vfs_vnode_lookup_bypath(struct pathdata *p);
97
struct vnode *vfs_vnode_lookup_byvnum(struct superblock *sb, unsigned long vnum);
98
 
99
int vfs_init(void);
100
 
101
#endif /* __VFS_H__ */

powered by: WebSVN 2.1.0

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