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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [libl4/] [include/] [l4lib/] [lib/] [cap.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Capability-related management.
3
 *
4
 * Copyright (C) 2009 Bahadir Balban
5
 */
6
#ifndef __LIBL4_CAPABILITY_H__
7
#define __LIBL4_CAPABILITY_H__
8
 
9
#include <l4lib/types.h>
10
#include <l4/lib/list.h>
11
#include <l4/api/capability.h>
12
#include <l4/generic/cap-types.h>
13
 
14
void cap_dev_print(struct capability *cap);
15
void cap_print(struct capability *cap);
16
void cap_array_print(int total_caps, struct capability *caparray);
17
 
18
/*
19
 * Definitions for lists of capabilities
20
 */
21
struct cap_list {
22
        int ncaps;
23
        struct link caps;
24
};
25
 
26
static inline void cap_list_init(struct cap_list *clist)
27
{
28
        clist->ncaps = 0;
29
        link_init(&clist->caps);
30
}
31
 
32
static inline void cap_list_insert(struct capability *cap,
33
                                   struct cap_list *clist)
34
{
35
        list_insert(&cap->list, &clist->caps);
36
        clist->ncaps++;
37
}
38
 
39
/* Detach a whole list of capabilities from list head */
40
static inline struct capability *
41
cap_list_detach(struct cap_list *clist)
42
{
43
        struct link *list = list_detach(&clist->caps);
44
        clist->ncaps = 0;
45
        return link_to_struct(list, struct capability, list);
46
}
47
 
48
/* Attach a whole list of capabilities to list head */
49
static inline void cap_list_attach(struct capability *cap,
50
                                   struct cap_list *clist)
51
{
52
        /* Attach as if cap is the list and clist is the element */
53
        list_insert(&clist->caps, &cap->list);
54
 
55
        /* Count the number of caps attached */
56
        list_foreach_struct(cap, &clist->caps, list)
57
                clist->ncaps++;
58
}
59
 
60
static inline void cap_list_move(struct cap_list *to,
61
                                 struct cap_list *from)
62
{
63
        struct capability *cap_head = cap_list_detach(from);
64
        cap_list_attach(cap_head, to);
65
}
66
 
67
/*
68
 * Definitions for reading from the library capability array
69
 */
70
void __l4_capability_init(void);
71
struct capability *cap_get_by_type(unsigned int cap_type);
72
struct capability *cap_get_physmem(unsigned int cap_type);
73
 
74
 
75
#endif /* __LIBL4_CAPABILITY_H__ */

powered by: WebSVN 2.1.0

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