Changeset 48bcf49 in mainline for kernel/generic/include/cap/cap.h
- Timestamp:
- 2017-09-28T22:08:15Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6636fb19
- Parents:
- dd20cbb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cap/cap.h
rdd20cbb r48bcf49 37 37 38 38 #include <typedefs.h> 39 #include <ipc/ipc.h>40 39 #include <adt/list.h> 41 40 #include <synch/mutex.h> 41 #include <atomic.h> 42 42 43 43 #define MAX_CAPS 64 44 44 45 typedef int cap_handle_t; 46 45 47 typedef enum { 46 CAP_TYPE_INVALID, 47 CAP_TYPE_ALLOCATED, 48 CAP_TYPE_PHONE, 49 CAP_TYPE_IRQ, 50 CAP_TYPE_MAX 51 } cap_type_t; 48 CAP_STATE_FREE, 49 CAP_STATE_ALLOCATED, 50 CAP_STATE_PUBLISHED 51 } cap_state_t; 52 53 typedef enum { 54 KOBJECT_TYPE_PHONE, 55 KOBJECT_TYPE_IRQ, 56 KOBJECT_TYPE_MAX 57 } kobject_type_t; 58 59 struct task; 60 struct phone; 61 struct irq; 62 63 struct kobject; 64 typedef struct kobject_ops { 65 bool (*reclaim)(struct kobject *); 66 void (*destroy)(void *); 67 } kobject_ops_t; 68 69 typedef struct kobject { 70 kobject_type_t type; 71 atomic_t refcnt; 72 73 kobject_ops_t *ops; 74 75 union { 76 void *raw; 77 struct phone *phone; 78 struct irq *irq; 79 }; 80 } kobject_t; 52 81 53 82 typedef struct cap { 54 cap_type_t type; 55 int handle; 83 cap_state_t state; 56 84 57 bool (* can_reclaim)(struct cap *);85 cap_handle_t handle; 58 86 59 /* Link to the task's capabilities of the same type. */87 /* Link to the task's capabilities of the same kobject type. */ 60 88 link_t link; 61 89 62 90 /* The underlying kernel object. */ 63 void*kobject;91 kobject_t *kobject; 64 92 } cap_t; 65 93 … … 67 95 mutex_t lock; 68 96 69 list_t type_list[ CAP_TYPE_MAX];97 list_t type_list[KOBJECT_TYPE_MAX]; 70 98 71 99 cap_t *caps; 72 100 } cap_info_t; 73 101 74 struct task;75 76 102 extern void caps_task_alloc(struct task *); 77 103 extern void caps_task_free(struct task *); 78 104 extern void caps_task_init(struct task *); 79 extern bool caps_apply_to_ type(struct task *, cap_type_t,105 extern bool caps_apply_to_kobject_type(struct task *, kobject_type_t, 80 106 bool (*)(cap_t *, void *), void *); 81 extern void caps_lock(struct task *);82 extern void caps_unlock(struct task *);83 107 84 extern void cap_initialize(cap_t *, int); 85 extern cap_t *cap_get(struct task *, int, cap_type_t); 86 extern int cap_alloc(struct task *); 87 extern void cap_publish(struct task *, int, cap_type_t, void *); 88 extern cap_t *cap_unpublish(struct task *, int, cap_type_t); 89 extern void cap_free(struct task *, int); 108 extern void cap_initialize(cap_t *, cap_handle_t); 109 extern cap_handle_t cap_alloc(struct task *); 110 extern void cap_publish(struct task *, cap_handle_t, kobject_t *); 111 extern kobject_t *cap_unpublish(struct task *, cap_handle_t, kobject_type_t); 112 extern void cap_free(struct task *, cap_handle_t); 113 114 extern void kobject_initialize(kobject_t *, kobject_type_t, void *, 115 kobject_ops_t *); 116 extern kobject_t *kobject_get(struct task *, cap_handle_t, kobject_type_t); 117 extern void kobject_put(kobject_t *); 90 118 91 119 #endif
Note:
See TracChangeset
for help on using the changeset viewer.