mirror of
https://github.com/drasko/codezero.git
synced 2026-01-11 18:33:16 +01:00
Fixed minor issues on capability list sharing.
This commit is contained in:
@@ -36,7 +36,7 @@ cap_strings = { 'ipc' : \
|
||||
\t\t\t[${idx}] = {
|
||||
\t\t\t\t.target = ${cid},
|
||||
\t\t\t\t.type = CAP_TYPE_IRQCTRL | ${target_rtype},
|
||||
\t\t\t\t.access = CAP_IRQCTRL_REGISTER
|
||||
\t\t\t\t.access = CAP_IRQCTRL_REGISTER | CAP_IRQCTRL_WAIT
|
||||
\t\t\t\t | CAP_CHANGEABLE | CAP_REPLICABLE
|
||||
\t\t\t\t | CAP_TRANSFERABLE,
|
||||
\t\t\t\t.start = 0, .end = 0, .size = 0,
|
||||
@@ -146,7 +146,8 @@ cap_strings = { 'ipc' : \
|
||||
\t\t\t\t.target = ${cid},
|
||||
\t\t\t\t.type = CAP_TYPE_MAP_PHYSMEM | CAP_RTYPE_CONTAINER,
|
||||
\t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE | CAP_MAP_EXEC |
|
||||
\t\t\t\t\tCAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP,
|
||||
\t\t\t\t\tCAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP |
|
||||
\t\t\t\t\tCAP_IRQCTRL_REGISTER,
|
||||
\t\t\t\t.start = __pfn(PLATFORM_${devname}_BASE),
|
||||
\t\t\t\t.end = __pfn(PLATFORM_${devname}_BASE + PLATFORM_${devname}_SIZE),
|
||||
\t\t\t\t.size = 1,
|
||||
|
||||
@@ -512,6 +512,10 @@ CONT%(cn)d_CAP_CAPCTRL_USE 'Enable this Capability'
|
||||
CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container'
|
||||
CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space'
|
||||
|
||||
CONT%(cn)d_CAP_IRQCTRL_USE 'Enable this Capability'
|
||||
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container'
|
||||
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space'
|
||||
|
||||
CONT%(cn)d_CAP_UMUTEX_USE 'Enable this Capability'
|
||||
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container'
|
||||
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space'
|
||||
@@ -539,6 +543,7 @@ cont%(cn)d_cap_tctrl 'Container %(cn)d Thread Control Capability'
|
||||
cont%(cn)d_cap_exregs 'Container %(cn)d Exchange Registers Capability'
|
||||
cont%(cn)d_cap_ipc 'Container %(cn)d IPC Capability'
|
||||
cont%(cn)d_cap_capctrl 'Container %(cn)d Capability Control Capability'
|
||||
cont%(cn)d_cap_irqctrl 'Container %(cn)d IRQ Control Capability'
|
||||
cont%(cn)d_cap_umutex 'Container %(cn)d Userspace Mutex Control Capability'
|
||||
cont%(cn)d_cap_custom0 'Container %(cn)d Custom Capability 0 Parameters'
|
||||
cont%(cn)d_cap_custom1 'Container %(cn)d Custom Capability 1 Parameters'
|
||||
@@ -589,6 +594,10 @@ when CONT%(cn)d_CAP_CAPCTRL_USE == n
|
||||
suppress CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER
|
||||
CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE
|
||||
|
||||
when CONT%(cn)d_CAP_IRQCTRL_USE == n
|
||||
suppress CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER
|
||||
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE
|
||||
|
||||
when CONT%(cn)d_CAP_UMUTEX_USE == n
|
||||
suppress CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER
|
||||
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE
|
||||
@@ -615,6 +624,10 @@ choicegroup CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER
|
||||
CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE
|
||||
default CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER from y
|
||||
|
||||
choicegroup CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER
|
||||
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE
|
||||
default CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER from y
|
||||
|
||||
choicegroup CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER
|
||||
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE
|
||||
default CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER from y
|
||||
@@ -623,6 +636,7 @@ default CONT%(cn)d_CAP_TCTRL_USE from y
|
||||
default CONT%(cn)d_CAP_EXREGS_USE from y
|
||||
default CONT%(cn)d_CAP_IPC_USE from y
|
||||
default CONT%(cn)d_CAP_CAPCTRL_USE from y
|
||||
default CONT%(cn)d_CAP_IRQCTRL_USE from y
|
||||
default CONT%(cn)d_CAP_UMUTEX_USE from y
|
||||
|
||||
default CONT%(cn)d_CAP_IPC_TARGET from 0
|
||||
@@ -648,6 +662,11 @@ menu cont%(cn)d_cap_umutex
|
||||
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER
|
||||
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE
|
||||
|
||||
menu cont%(cn)d_cap_irqctrl
|
||||
CONT%(cn)d_CAP_IRQCTRL_USE
|
||||
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER
|
||||
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE
|
||||
|
||||
menu cont%(cn)d_cap_ipc
|
||||
CONT%(cn)d_CAP_IPC_USE
|
||||
CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER
|
||||
@@ -687,6 +706,7 @@ menu cont%(cn)d_capability_list
|
||||
cont%(cn)d_cap_ipc
|
||||
cont%(cn)d_cap_capctrl
|
||||
cont%(cn)d_cap_umutex
|
||||
cont%(cn)d_cap_irqctrl
|
||||
cont%(cn)d_cap_custom0
|
||||
cont%(cn)d_cap_custom1
|
||||
cont%(cn)d_cap_custom2
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
/* Capability printing generic routines */
|
||||
|
||||
#include <l4lib/capability/cap_print.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void cap_dev_print(struct capability *cap)
|
||||
{
|
||||
@@ -58,8 +59,12 @@ void cap_print(struct capability *cap)
|
||||
case CAP_TYPE_QUANTITY:
|
||||
printf("Capability type:\t\t%s\n", "Quantitative");
|
||||
break;
|
||||
case CAP_TYPE_CAP:
|
||||
printf("Capability type:\t\t%s\n", "Capability Control");
|
||||
break;
|
||||
default:
|
||||
printf("Capability type:\t\t%s\n", "Unknown");
|
||||
printf("Capability type:\t\t%s, cap_type=0x%x\n",
|
||||
"Unknown", cap_type(cap));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -92,7 +97,8 @@ void cap_print(struct capability *cap)
|
||||
printf("Capability resource type:\t%s\n", "Capability Pool");
|
||||
break;
|
||||
default:
|
||||
printf("Capability resource type:\t%s\n", "Unknown");
|
||||
printf("Capability resource type:\t%s, id=0x%x\n", "Unknown",
|
||||
cap_rtype(cap));
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
@@ -47,9 +47,9 @@ Shares a single capability or list of capabilities with a collection entity such
|
||||
.B CAP_SHARE_SINGLE
|
||||
is specified in
|
||||
.IR "flag",
|
||||
a single capability is shared. Currently no method has been defined for sharing a larger entity than a single capability at a time, i.e. a list of capabilities. To achieve this, a
|
||||
.B CAP_SHARE_ALL
|
||||
flag is planned for a future release.
|
||||
a single capability is shared.
|
||||
.BR "CAP_SHARE_ALL_CONTAINER " "makes the caller thread share all of its thread-level and address space-level capability lists with its container. The caller must also be the owner of all of the capabilities, in case of the address space.
|
||||
.BR "CAP_SHARE_ALL_SPACE " "makes the caller thread share all of its thread-level capabilities with its address space."
|
||||
|
||||
The sharing must be made with a thread collection entity that contains the capability owner. For example, a capability possessed by a thread may be shared with the thread's address space, or the thread's container. However it is not possible to share a capability in one container with another container. See
|
||||
.B CAP_CONTROL_REPLICATE
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
#define CAP_CONTROL_DEDUCE 0x00000006
|
||||
#define CAP_CONTROL_DESTROY 0x00000007
|
||||
|
||||
#define CAP_SHARE_MASK 0x00000003
|
||||
#define CAP_SHARE_MASK 0x0000000F
|
||||
#define CAP_SHARE_SINGLE 0x00000001
|
||||
#define CAP_SHARE_ALL_CONTAINER 0x00000002
|
||||
#define CAP_SHARE_ALL_SPACE 0x00000003
|
||||
|
||||
#define CAP_GRANT_MASK 0x0000000F
|
||||
#define CAP_GRANT_SINGLE 0x00000001
|
||||
|
||||
@@ -104,12 +104,17 @@
|
||||
|
||||
/*
|
||||
* IRQ Control capability
|
||||
*
|
||||
*/
|
||||
#define CAP_IRQCTRL_WAIT (1 << 8)
|
||||
|
||||
/*
|
||||
* This is a common one and it applies to both
|
||||
* CAP_TYPE_IRQCTRL and CAP_TYPE_MAP_PHYSMEM
|
||||
*/
|
||||
#define CAP_IRQCTRL_REGISTER (1 << 7)
|
||||
|
||||
|
||||
|
||||
/* Ipc capability */
|
||||
#define CAP_IPC_SEND (1 << 0)
|
||||
#define CAP_IPC_RECV (1 << 1)
|
||||
|
||||
@@ -55,7 +55,12 @@ static inline void cap_list_remove(struct capability *cap,
|
||||
static inline struct capability *
|
||||
cap_list_detach(struct cap_list *clist)
|
||||
{
|
||||
struct link *list = list_detach(&clist->caps);
|
||||
struct link *list;
|
||||
|
||||
if (!clist->ncaps)
|
||||
return 0;
|
||||
|
||||
list = list_detach(&clist->caps);
|
||||
clist->ncaps = 0;
|
||||
return link_to_struct(list, struct capability, list);
|
||||
}
|
||||
@@ -75,6 +80,9 @@ static inline void cap_list_attach(struct capability *cap,
|
||||
static inline void cap_list_move(struct cap_list *to,
|
||||
struct cap_list *from)
|
||||
{
|
||||
if (!from->ncaps)
|
||||
return;
|
||||
|
||||
struct capability *cap_head = cap_list_detach(from);
|
||||
cap_list_attach(cap_head, to);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ do { \
|
||||
(wqh)->sleepers++; \
|
||||
list_insert_tail(&wq.task_list, \
|
||||
&(wqh)->task_list); \
|
||||
/* printk("(%d) waiting...\n", current->tid); */\
|
||||
printk("(%d) waiting...\n", current->tid); \
|
||||
sched_prepare_sleep(); \
|
||||
spin_unlock_irq(&(wqh)->slock, irqsave); \
|
||||
schedule(); \
|
||||
|
||||
@@ -69,24 +69,43 @@ int cap_share_single(struct capability *user)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Shares the whole list */
|
||||
int cap_share_all(void)
|
||||
/*
|
||||
* Shares the whole capability list.
|
||||
*
|
||||
* FIXME: Make sure each and every capability has its
|
||||
* share right set!
|
||||
*/
|
||||
int cap_share_all(unsigned int flags)
|
||||
{
|
||||
cap_list_move(&curcont->cap_list,
|
||||
¤t->space->cap_list);
|
||||
if (flags == CAP_SHARE_ALL_CONTAINER) {
|
||||
|
||||
/* Move all private caps to container */
|
||||
cap_list_move(&curcont->cap_list,
|
||||
¤t->cap_list);
|
||||
|
||||
/*
|
||||
* Move all space caps to container, also.
|
||||
*
|
||||
* FIXME: Make sure all space capabilities
|
||||
* are owned by the sharer!!!
|
||||
*/
|
||||
cap_list_move(&curcont->cap_list,
|
||||
¤t->space->cap_list);
|
||||
} else if (flags == CAP_SHARE_ALL_SPACE) {
|
||||
|
||||
/* Move all private caps to space */
|
||||
cap_list_move(¤t->space->cap_list,
|
||||
¤t->cap_list);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int cap_share(struct capability *cap, unsigned int flags)
|
||||
{
|
||||
if (flags & CAP_SHARE_SINGLE)
|
||||
cap_share_single(cap);
|
||||
if (flags == CAP_SHARE_SINGLE)
|
||||
return cap_share_single(cap);
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
return cap_share_all(flags);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -665,6 +684,9 @@ int sys_capability_control(unsigned int req, unsigned int flags, void *userbuf)
|
||||
return err;
|
||||
break;
|
||||
case CAP_CONTROL_SHARE:
|
||||
if (flags == CAP_SHARE_ALL_CONTAINER ||
|
||||
flags == CAP_SHARE_ALL_SPACE)
|
||||
break;
|
||||
case CAP_CONTROL_GRANT:
|
||||
case CAP_CONTROL_SPLIT:
|
||||
case CAP_CONTROL_REPLICATE:
|
||||
|
||||
Reference in New Issue
Block a user