mirror of
https://github.com/drasko/codezero.git
synced 2026-10-15 00:17:01 +02:00
Removed 2 arguments from l4_capability_control
l4_capability_control works well for almost all system calls using a buffer pointer to the capability that it operates on. Only for sharing/granting of capability lists, it is yet to be decided how to provide a grant target id.
This commit is contained in:
@@ -42,8 +42,7 @@ int l4_ipc(l4id_t to, l4id_t from, u32 flags);
|
|||||||
|
|
||||||
typedef int (*__l4_capability_control_t)(unsigned int req, unsigned int flags, void *buf);
|
typedef int (*__l4_capability_control_t)(unsigned int req, unsigned int flags, void *buf);
|
||||||
extern __l4_capability_control_t __l4_capability_control;
|
extern __l4_capability_control_t __l4_capability_control;
|
||||||
int l4_capability_control(unsigned int req, unsigned int flags,
|
int l4_capability_control(unsigned int req, unsigned int flags, void *buf);
|
||||||
l4id_t capid, l4id_t tid, void *buf);
|
|
||||||
|
|
||||||
typedef int (*__l4_map_t)(void *phys, void *virt,
|
typedef int (*__l4_map_t)(void *phys, void *virt,
|
||||||
u32 npages, u32 flags, l4id_t tid);
|
u32 npages, u32 flags, l4id_t tid);
|
||||||
|
|||||||
@@ -112,16 +112,14 @@ END_PROC(l4_map)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads/manipulates capabilities of a thread, particularly a pager.
|
* Reads/manipulates capabilities of a thread, particularly a pager.
|
||||||
* @r0 = request type, @r1 = request flags,
|
* @r0 = request type, @r1 = request flags, @r2 = Capability buffer pointer
|
||||||
* @r2 = capid, @r3 = target thread id, @r4 = io buffer ptr
|
|
||||||
*/
|
*/
|
||||||
BEGIN_PROC(l4_capability_control)
|
BEGIN_PROC(l4_capability_control)
|
||||||
stmfd sp!, {r4, lr}
|
stmfd sp!, {lr}
|
||||||
ldr r4, [sp, #8] @ FIXME: Is this right?
|
|
||||||
ldr r12, =__l4_capability_control
|
ldr r12, =__l4_capability_control
|
||||||
mov lr, pc @ We must return here to restore r4.
|
mov lr, pc
|
||||||
ldr pc, [r12]
|
ldr pc, [r12]
|
||||||
ldmfd sp!, {r4, pc}
|
ldmfd sp!, {pc} @ Restore original lr and return.
|
||||||
END_PROC(l4_capability_control)
|
END_PROC(l4_capability_control)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -22,6 +22,25 @@ struct cap_list capability_list;
|
|||||||
__initdata static struct capability *caparray;
|
__initdata static struct capability *caparray;
|
||||||
__initdata static int total_caps = 0;
|
__initdata static int total_caps = 0;
|
||||||
|
|
||||||
|
|
||||||
|
void cap_dev_print(struct capability *cap)
|
||||||
|
{
|
||||||
|
switch (cap_devtype(cap)) {
|
||||||
|
case CAP_DEVTYPE_UART:
|
||||||
|
printf("Device type:\t\t\t%s%d\n", "UART", cap_devnum(cap));
|
||||||
|
break;
|
||||||
|
case CAP_DEVTYPE_TIMER:
|
||||||
|
printf("Device type:\t\t\t%s%d\n", "Timer", cap_devnum(cap));
|
||||||
|
break;
|
||||||
|
case CAP_DEVTYPE_CLCD:
|
||||||
|
printf("Device type:\t\t\t%s%d\n", "CLCD", cap_devnum(cap));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("Device Irq:\t\t%d\n", cap->irq);
|
||||||
|
}
|
||||||
|
|
||||||
void cap_print(struct capability *cap)
|
void cap_print(struct capability *cap)
|
||||||
{
|
{
|
||||||
printf("Capability id:\t\t\t%d\n", cap->capid);
|
printf("Capability id:\t\t\t%d\n", cap->capid);
|
||||||
@@ -36,18 +55,25 @@ void cap_print(struct capability *cap)
|
|||||||
printf("Capability type:\t\t%s\n", "Exchange Registers");
|
printf("Capability type:\t\t%s\n", "Exchange Registers");
|
||||||
break;
|
break;
|
||||||
case CAP_TYPE_MAP_PHYSMEM:
|
case CAP_TYPE_MAP_PHYSMEM:
|
||||||
printf("Capability type:\t\t%s\n", "Map/Physmem");
|
if (!cap_is_devmem(cap)) {
|
||||||
|
printf("Capability type:\t\t%s\n", "Map/Physmem");
|
||||||
|
} else {
|
||||||
|
printf("Capability type:\t\t%s\n", "Map/Physmem/Device");
|
||||||
|
cap_dev_print(cap);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CAP_TYPE_MAP_VIRTMEM:
|
case CAP_TYPE_MAP_VIRTMEM:
|
||||||
printf("Capability type:\t\t%s\n", "Map/Virtmem");
|
printf("Capability type:\t\t%s\n", "Map/Virtmem");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_TYPE_IPC:
|
case CAP_TYPE_IPC:
|
||||||
printf("Capability type:\t\t%s\n", "Ipc");
|
printf("Capability type:\t\t%s\n", "Ipc");
|
||||||
break;
|
break;
|
||||||
case CAP_TYPE_UMUTEX:
|
case CAP_TYPE_UMUTEX:
|
||||||
printf("Capability type:\t\t%s\n", "Mutex");
|
printf("Capability type:\t\t%s\n", "Mutex");
|
||||||
break;
|
break;
|
||||||
|
case CAP_TYPE_IRQCTRL:
|
||||||
|
printf("Capability type:\t\t%s\n", "IRQ Control");
|
||||||
|
break;
|
||||||
case CAP_TYPE_QUANTITY:
|
case CAP_TYPE_QUANTITY:
|
||||||
printf("Capability type:\t\t%s\n", "Quantitative");
|
printf("Capability type:\t\t%s\n", "Quantitative");
|
||||||
break;
|
break;
|
||||||
@@ -91,6 +117,18 @@ void cap_print(struct capability *cap)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cap_array_print()
|
||||||
|
{
|
||||||
|
printf("Capabilities\n"
|
||||||
|
"~~~~~~~~~~~~\n");
|
||||||
|
|
||||||
|
for (int i = 0; i < total_caps; i++)
|
||||||
|
cap_print(&caparray[i]);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void cap_list_print(struct cap_list *cap_list)
|
void cap_list_print(struct cap_list *cap_list)
|
||||||
{
|
{
|
||||||
struct capability *cap;
|
struct capability *cap;
|
||||||
@@ -154,7 +192,7 @@ found:
|
|||||||
|
|
||||||
/* Split the mutex capability, passing the difference */
|
/* Split the mutex capability, passing the difference */
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_SPLIT,
|
if ((err = l4_capability_control(CAP_CONTROL_SPLIT,
|
||||||
0, 0, 0, diff_cap)) < 0) {
|
0, diff_cap)) < 0) {
|
||||||
printf("l4_capability_control() replication of "
|
printf("l4_capability_control() replication of "
|
||||||
"ipc capability failed.\n Could not "
|
"ipc capability failed.\n Could not "
|
||||||
"complete CAP_CONTROL_SPLIT request on cap (%d), "
|
"complete CAP_CONTROL_SPLIT request on cap (%d), "
|
||||||
@@ -176,7 +214,7 @@ found:
|
|||||||
* to use this pool of mutexes.
|
* to use this pool of mutexes.
|
||||||
*/
|
*/
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_SHARE, CAP_SHARE_SINGLE,
|
if ((err = l4_capability_control(CAP_CONTROL_SHARE, CAP_SHARE_SINGLE,
|
||||||
0, 0, mutex_cap)) < 0) {
|
mutex_cap)) < 0) {
|
||||||
printf("l4_capability_control() sharing of "
|
printf("l4_capability_control() sharing of "
|
||||||
"capabilities failed.\n Could not "
|
"capabilities failed.\n Could not "
|
||||||
"complete CAP_CONTROL_SHARE request.\n");
|
"complete CAP_CONTROL_SHARE request.\n");
|
||||||
@@ -204,7 +242,7 @@ found2:
|
|||||||
* to use this pool of mutexes.
|
* to use this pool of mutexes.
|
||||||
*/
|
*/
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_SHARE, CAP_SHARE_SINGLE,
|
if ((err = l4_capability_control(CAP_CONTROL_SHARE, CAP_SHARE_SINGLE,
|
||||||
0, 0, mutex_cap)) < 0) {
|
mutex_cap)) < 0) {
|
||||||
printf("l4_capability_control() sharing of "
|
printf("l4_capability_control() sharing of "
|
||||||
"capabilities failed.\n Could not "
|
"capabilities failed.\n Could not "
|
||||||
"complete CAP_CONTROL_SHARE request.\n");
|
"complete CAP_CONTROL_SHARE request.\n");
|
||||||
@@ -258,7 +296,7 @@ found:
|
|||||||
|
|
||||||
/* Replicate the ipc capability, giving original as reference */
|
/* Replicate the ipc capability, giving original as reference */
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_REPLICATE,
|
if ((err = l4_capability_control(CAP_CONTROL_REPLICATE,
|
||||||
0, 0, 0, ipc_cap)) < 0) {
|
0, ipc_cap)) < 0) {
|
||||||
printf("l4_capability_control() replication of "
|
printf("l4_capability_control() replication of "
|
||||||
"ipc capability failed.\n Could not "
|
"ipc capability failed.\n Could not "
|
||||||
"complete CAP_CONTROL_REPLICATE request on cap (%d), "
|
"complete CAP_CONTROL_REPLICATE request on cap (%d), "
|
||||||
@@ -279,7 +317,7 @@ found:
|
|||||||
cap_set_rtype(ipc_cap, CAP_RTYPE_SPACE);
|
cap_set_rtype(ipc_cap, CAP_RTYPE_SPACE);
|
||||||
ipc_cap->resid = ids.spid; /* This space is target resource */
|
ipc_cap->resid = ids.spid; /* This space is target resource */
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_DEDUCE,
|
if ((err = l4_capability_control(CAP_CONTROL_DEDUCE,
|
||||||
0, 0, 0, ipc_cap)) < 0) {
|
0, ipc_cap)) < 0) {
|
||||||
printf("l4_capability_control() deduction of "
|
printf("l4_capability_control() deduction of "
|
||||||
"ipc capability failed.\n Could not "
|
"ipc capability failed.\n Could not "
|
||||||
"complete CAP_CONTROL_DEDUCE request on cap (%d), "
|
"complete CAP_CONTROL_DEDUCE request on cap (%d), "
|
||||||
@@ -295,8 +333,9 @@ found:
|
|||||||
* This effectively enables all threads/spaces in this container
|
* This effectively enables all threads/spaces in this container
|
||||||
* to communicate to us only, and be able to do nothing else.
|
* to communicate to us only, and be able to do nothing else.
|
||||||
*/
|
*/
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_SHARE, CAP_SHARE_SINGLE,
|
if ((err = l4_capability_control(CAP_CONTROL_SHARE,
|
||||||
0, 0, ipc_cap)) < 0) {
|
CAP_SHARE_SINGLE,
|
||||||
|
ipc_cap)) < 0) {
|
||||||
printf("l4_capability_control() sharing of "
|
printf("l4_capability_control() sharing of "
|
||||||
"capabilities failed.\n Could not "
|
"capabilities failed.\n Could not "
|
||||||
"complete CAP_CONTROL_SHARE request.\n");
|
"complete CAP_CONTROL_SHARE request.\n");
|
||||||
@@ -344,7 +383,7 @@ int cap_read_all()
|
|||||||
|
|
||||||
/* Read number of capabilities */
|
/* Read number of capabilities */
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_NCAPS,
|
if ((err = l4_capability_control(CAP_CONTROL_NCAPS,
|
||||||
0, 0, 0, &ncaps)) < 0) {
|
0, &ncaps)) < 0) {
|
||||||
printf("l4_capability_control() reading # of"
|
printf("l4_capability_control() reading # of"
|
||||||
" capabilities failed.\n Could not "
|
" capabilities failed.\n Could not "
|
||||||
"complete CAP_CONTROL_NCAPS request.\n");
|
"complete CAP_CONTROL_NCAPS request.\n");
|
||||||
@@ -357,7 +396,7 @@ int cap_read_all()
|
|||||||
|
|
||||||
/* Read all capabilities */
|
/* Read all capabilities */
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_READ,
|
if ((err = l4_capability_control(CAP_CONTROL_READ,
|
||||||
0, 0, 0, caparray)) < 0) {
|
0, caparray)) < 0) {
|
||||||
printf("l4_capability_control() reading of "
|
printf("l4_capability_control() reading of "
|
||||||
"capabilities failed.\n Could not "
|
"capabilities failed.\n Could not "
|
||||||
"complete CAP_CONTROL_READ_CAPS request.\n");
|
"complete CAP_CONTROL_READ_CAPS request.\n");
|
||||||
@@ -480,7 +519,7 @@ int cap_find_replicate_reduce_grant(struct capability *cap)
|
|||||||
|
|
||||||
/* Replicate capability, giving original as reference */
|
/* Replicate capability, giving original as reference */
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_REPLICATE,
|
if ((err = l4_capability_control(CAP_CONTROL_REPLICATE,
|
||||||
0, 0, 0, &new_cap)) < 0) {
|
0, &new_cap)) < 0) {
|
||||||
printf("l4_capability_control() replication of "
|
printf("l4_capability_control() replication of "
|
||||||
"capability failed.\n Could not complete "
|
"capability failed.\n Could not complete "
|
||||||
"CAP_CONTROL_REPLICATE request on cap (%d), "
|
"CAP_CONTROL_REPLICATE request on cap (%d), "
|
||||||
@@ -515,11 +554,11 @@ int cap_find_replicate_reduce_grant(struct capability *cap)
|
|||||||
|
|
||||||
|
|
||||||
if ((err = l4_capability_control(CAP_CONTROL_DEDUCE,
|
if ((err = l4_capability_control(CAP_CONTROL_DEDUCE,
|
||||||
0, 0, 0, &new_cap)) < 0) {
|
0, &new_cap)) < 0) {
|
||||||
/* Couldn't deduce this one, destroy the replica */
|
/* Couldn't deduce this one, destroy the replica */
|
||||||
if ((err =
|
if ((err =
|
||||||
l4_capability_control(CAP_CONTROL_DESTROY,
|
l4_capability_control(CAP_CONTROL_DESTROY,
|
||||||
0, 0, 0, &new_cap)) < 0) {
|
0, &new_cap)) < 0) {
|
||||||
printf("l4_capability_control() destruction of "
|
printf("l4_capability_control() destruction of "
|
||||||
"capability failed.\n Could not "
|
"capability failed.\n Could not "
|
||||||
"complete CAP_CONTROL_DESTROY request "
|
"complete CAP_CONTROL_DESTROY request "
|
||||||
@@ -549,7 +588,7 @@ success:
|
|||||||
if ((err = l4_capability_control(CAP_CONTROL_GRANT,
|
if ((err = l4_capability_control(CAP_CONTROL_GRANT,
|
||||||
CAP_GRANT_SINGLE |
|
CAP_GRANT_SINGLE |
|
||||||
CAP_GRANT_IMMUTABLE,
|
CAP_GRANT_IMMUTABLE,
|
||||||
0, 0, &new_cap)) < 0) {
|
&new_cap)) < 0) {
|
||||||
printf("l4_capability_control() granting of "
|
printf("l4_capability_control() granting of "
|
||||||
"capability (%d) failed.\n Could not "
|
"capability (%d) failed.\n Could not "
|
||||||
"complete CAP_CONTROL_GRANT request.\n",
|
"complete CAP_CONTROL_GRANT request.\n",
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ int sys_ipc_control(void);
|
|||||||
int sys_map(unsigned long phys, unsigned long virt, unsigned long npages,
|
int sys_map(unsigned long phys, unsigned long virt, unsigned long npages,
|
||||||
unsigned int flags, l4id_t tid);
|
unsigned int flags, l4id_t tid);
|
||||||
int sys_getid(struct task_ids *ids);
|
int sys_getid(struct task_ids *ids);
|
||||||
int sys_capability_control(unsigned int req, unsigned int flags,
|
int sys_capability_control(unsigned int req, unsigned int flags, void *addr);
|
||||||
l4id_t capid, l4id_t target, void *addr);
|
|
||||||
int sys_container_control(unsigned int req, unsigned int flags, void *addr);
|
int sys_container_control(unsigned int req, unsigned int flags, void *addr);
|
||||||
int sys_time(struct timeval *tv, int set);
|
int sys_time(struct timeval *tv, int set);
|
||||||
int sys_mutex_control(unsigned long mutex_address, int mutex_op);
|
int sys_mutex_control(unsigned long mutex_address, int mutex_op);
|
||||||
|
|||||||
+2
-3
@@ -626,10 +626,9 @@ int cap_replicate(struct capability *dupl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read, manipulate capabilities. Currently only capability read support.
|
* Read, manipulate capabilities.
|
||||||
*/
|
*/
|
||||||
int sys_capability_control(unsigned int req, unsigned int flags,
|
int sys_capability_control(unsigned int req, unsigned int flags, void *userbuf)
|
||||||
l4id_t capid, l4id_t target, void *userbuf)
|
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user