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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [include/] [l4/] [generic/] [capability.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
/*
2
 * Codezero Capability Definitions
3
 *
4
 * Copyright (C) 2009 Bahadir Balban
5
 */
6
#ifndef __GENERIC_CAPABILITY_H__
7
#define __GENERIC_CAPABILITY_H__
8
 
9
#include <l4/api/exregs.h>
10
#include <l4/api/capability.h>
11
 
12
/*
13
 * Some resources that capabilities possess don't
14
 * have unique ids or need ids at all.
15
 *
16
 * E.g. a threadpool does not need a resource id.
17
 * A virtual memory capability does not require
18
 * a resource id, its capid is sufficient.
19
 */
20
#define CAP_RESID_NONE          -1
21
 
22
 
23
struct cap_list {
24
        int ktcb_refs;
25
        int ncaps;
26
        struct link caps;
27
};
28
 
29
void capability_init(struct capability *cap);
30
struct capability *capability_create(void);
31
struct capability *boot_capability_create(void);
32
 
33
 
34
static inline void cap_list_init(struct cap_list *clist)
35
{
36
        clist->ncaps = 0;
37
        link_init(&clist->caps);
38
}
39
 
40
static inline void cap_list_insert(struct capability *cap,
41
                                   struct cap_list *clist)
42
{
43
        list_insert(&cap->list, &clist->caps);
44
        clist->ncaps++;
45
}
46
 
47
static inline void cap_list_remove(struct capability *cap,
48
                                   struct cap_list *clist)
49
{
50
        list_remove(&cap->list);
51
        clist->ncaps--;
52
}
53
 
54
/* Detach a whole list of capabilities from list head */
55
static inline struct capability *
56
cap_list_detach(struct cap_list *clist)
57
{
58
        struct link *list;
59
 
60
        if (!clist->ncaps)
61
                return 0;
62
 
63
        list = list_detach(&clist->caps);
64
        clist->ncaps = 0;
65
        return link_to_struct(list, struct capability, list);
66
}
67
 
68
/* Attach a whole list of capabilities to list head */
69
static inline void cap_list_attach(struct capability *cap,
70
                                   struct cap_list *clist)
71
{
72
        /* Attach as if cap is the list and clist is the element */
73
        list_insert(&clist->caps, &cap->list);
74
 
75
        /* Count the number of caps attached */
76
        list_foreach_struct(cap, &clist->caps, list)
77
                clist->ncaps++;
78
}
79
 
80
static inline void cap_list_move(struct cap_list *to,
81
                                 struct cap_list *from)
82
{
83
        if (!from->ncaps)
84
                return;
85
 
86
        struct capability *cap_head = cap_list_detach(from);
87
        cap_list_attach(cap_head, to);
88
}
89
 
90
/* Have to have these as tcb.h includes this file */
91
struct ktcb;
92
struct task_ids;
93
 
94
/* Capability checking for quantitative capabilities */
95
int capability_consume(struct capability *cap, int quantity);
96
int capability_free(struct capability *cap, int quantity);
97
struct capability *capability_find_by_rtype(struct ktcb *task,
98
                                            unsigned int rtype);
99
int cap_count(struct ktcb *task);
100
struct capability *cap_list_find_by_rtype(struct cap_list *clist,
101
                                          unsigned int rtype);
102
struct capability *cap_find_by_capid(l4id_t capid, struct cap_list **clist);
103
 
104
/* Capability checking on system calls */
105
int cap_map_check(struct ktcb *task, unsigned long phys, unsigned long virt,
106
                  unsigned long npages, unsigned int flags);
107
int cap_unmap_check(struct ktcb *task, unsigned long virt,
108
                    unsigned long npages);
109
int cap_thread_check(struct ktcb *task, unsigned int flags,
110
                     struct task_ids *ids);
111
int cap_exregs_check(struct ktcb *task, struct exregs_data *exregs);
112
int cap_ipc_check(l4id_t to, l4id_t from,
113
                  unsigned int flags, unsigned int ipc_type);
114
int cap_cap_check(struct ktcb *task, unsigned int req, unsigned int flags);
115
int cap_mutex_check(unsigned long mutex_address, int mutex_op);
116
 
117
int cap_irq_check(struct ktcb *registrant, unsigned int req,
118
                  unsigned int flags, l4id_t irq);
119
int cap_cache_check(unsigned long start, unsigned long end,
120
                    unsigned int flags);
121
 
122
#endif /* __GENERIC_CAPABILITY_H__ */

powered by: WebSVN 2.1.0

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