mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 19:03:15 +01:00
Fixed various errors with ipc message passing.
Previously we had changed the method of setting the ipc tag from l4_ipc() call argument to being passed as a message register. - This change was not reflected in l4_ipc() signature as it still had a 3rd argument, even though ignored. - l4_set_sender and _set_tag had their arguments wrong way around. - Previously 5 mrs were passed onto utcb instead of 6, relying on the fact that l4_ipc tag argument was being passed in r3 directly, this wasnt true anymore with new convention, but wasn't catered for. TODO: - MM0 shouldn't really allocate tids itself, but use ones supplied by C0. - Sender tid shouldn't really passed by the sender task, but rather by C0. Otherwise security can be easily breached by user tasks pretending to be other tasks. This would also save us a message register.
This commit is contained in:
@@ -71,7 +71,7 @@ void handle_fs_requests(void)
|
||||
|
||||
void main(void)
|
||||
{
|
||||
printf("\n\n%s: Started.\n", __TASKNAME__);
|
||||
printf("\n\n%s: Started with tid: %d\n", __TASKNAME__, self_tid());
|
||||
|
||||
initialise();
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ typedef int (*__l4_getid_t)(struct task_ids *ids);
|
||||
extern __l4_getid_t __l4_getpid;
|
||||
int l4_getid(struct task_ids *ids);
|
||||
|
||||
typedef int (*__l4_ipc_t)(l4id_t to, l4id_t from, u32 tag);
|
||||
typedef int (*__l4_ipc_t)(l4id_t to, l4id_t from);
|
||||
extern __l4_ipc_t __l4_ipc;
|
||||
int l4_ipc(l4id_t to, l4id_t from, u32 tag);
|
||||
int l4_ipc(l4id_t to, l4id_t from);
|
||||
|
||||
typedef int (*__l4_kread_t)(u32 rd, void *addr);
|
||||
extern __l4_kread_t __l4_kread;
|
||||
|
||||
@@ -39,7 +39,7 @@ static inline l4id_t l4_get_sender(void)
|
||||
|
||||
static inline void l4_set_sender(l4id_t id)
|
||||
{
|
||||
write_mr(MR_SENDER, (unsigned int)id);
|
||||
write_mr((unsigned int)id, MR_SENDER);
|
||||
}
|
||||
|
||||
static inline unsigned int l4_get_tag(void)
|
||||
@@ -49,7 +49,7 @@ static inline unsigned int l4_get_tag(void)
|
||||
|
||||
static inline void l4_set_tag(unsigned int tag)
|
||||
{
|
||||
write_mr(MR_TAG, tag);
|
||||
write_mr(tag, MR_TAG);
|
||||
}
|
||||
|
||||
static inline l4id_t self_tid(void)
|
||||
@@ -64,7 +64,8 @@ static inline int l4_send(l4id_t to, unsigned int tag)
|
||||
{
|
||||
l4_set_tag(tag);
|
||||
l4_set_sender(self_tid());
|
||||
return l4_ipc(to, L4_NILTHREAD, 0);
|
||||
|
||||
return l4_ipc(to, L4_NILTHREAD);
|
||||
}
|
||||
|
||||
static inline int l4_sendrecv(l4id_t to, l4id_t from, unsigned int tag)
|
||||
@@ -72,12 +73,12 @@ static inline int l4_sendrecv(l4id_t to, l4id_t from, unsigned int tag)
|
||||
BUG_ON(to == L4_NILTHREAD || from == L4_NILTHREAD);
|
||||
l4_set_tag(tag);
|
||||
l4_set_sender(self_tid());
|
||||
return l4_ipc(to, from, 0);
|
||||
return l4_ipc(to, from);
|
||||
}
|
||||
|
||||
static inline int l4_receive(l4id_t from)
|
||||
{
|
||||
return l4_ipc(L4_NILTHREAD, from, 0);
|
||||
return l4_ipc(L4_NILTHREAD, from);
|
||||
}
|
||||
|
||||
/* Servers:
|
||||
|
||||
@@ -43,12 +43,12 @@ END_PROC(l4_kread)
|
||||
|
||||
/*
|
||||
* Inter-process communication. Loads message registers as arguments before the call,
|
||||
* and stores them as results after the call. @r0 = to, @r1 = from, @r2 = tag.
|
||||
* and stores them as results after the call. @r0 = to, @r1 = from.
|
||||
*/
|
||||
BEGIN_PROC(l4_ipc)
|
||||
stmfd sp!, {r4-r8,lr} @ Save context.
|
||||
utcb_address r12 @ Get utcb address.
|
||||
ldmib r12!, {r3-r8} @ Load 5 Message registers from utcb. MR1-MR5
|
||||
ldmia r12!, {r3-r8} @ Load 6 Message registers from utcb. MR1-MR5
|
||||
ldr r12, =__l4_ipc
|
||||
mov lr, pc
|
||||
ldr pc, [r12]
|
||||
|
||||
@@ -105,7 +105,11 @@ void handle_requests(void)
|
||||
}
|
||||
default:
|
||||
printf("%s: Unrecognised ipc tag (%d) "
|
||||
"received. Ignoring.\n", __TASKNAME__, tag);
|
||||
"received from (%d). Full mr reading: "
|
||||
"%u, %u, %u, %u, %u, %u. Ignoring.\n",
|
||||
__TASKNAME__, tag, sender, read_mr(0),
|
||||
read_mr(1), read_mr(2), read_mr(3), read_mr(4),
|
||||
read_mr(5));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,15 @@
|
||||
void wait_pager(l4id_t partner)
|
||||
{
|
||||
printf("%s: Syncing with pager.\n", __TASKNAME__);
|
||||
for (int i = 0; i < 6; i++)
|
||||
write_mr(i, i);
|
||||
l4_send(partner, L4_IPC_TAG_WAIT);
|
||||
printf("Pager synced with us.\n");
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
printf("\n%s: Started.\n", __TASKNAME__);
|
||||
printf("\n%s: Started with tid %d.\n", __TASKNAME__, self_tid());
|
||||
/* Sync with pager */
|
||||
while (1)
|
||||
wait_pager(0);
|
||||
|
||||
Reference in New Issue
Block a user