I am experimenting with l4 pistachio and i seem to be running into some rather
weird problems.
1) when i attempt to create a thread, my thread creation code does seem to work
if it is in "main()" however if i move the code into another function an call
that function from main, the code works. What happens is that if I attempt to
create a thread from "main" when i call "L4_ThreadControl()" the function
returns an error value (which is found to be '6'), which indicates that the the
UTCB location is invalid. However, the latter does not happen when the exact
same thread creation code is in a different function. Now this does not bother
me that much, as long as i can still successfully create threads, but, i am a
bit curious as to why this happens.
2) the piece of code that i use to create threads (derived from the l4test app),
obtains the utcb location of new thread looks like this:
L4_Word_t root_utcb = *(*L4_Word_t)&root_local_id;
root_utcb &= ~(L4_UtcbAreaSize(kip) - 1);
L4_Word_t new_utcb = root_utcb + (L4_UtcbSize(kip) * (L4_ThreadNo(new_tid) -
L4_ThreadNo(root_tid)));
Now this piece of code works, but, i do not understand why the second line is
needed if the local thread id is already equal to the utcb location. Why is this
needed?
3) I cannot seem to receive interrupt IPCs. I have seen no code built on
pistachio that handle interrupts thus far, so my code looks like this:
L4_Thread_t irq;
//simple handler function that simply acknowledges the interrupt ipc
void handler_func(void)
{
printf("the handler has been called\n");
L4_Msg_t msg;
L4_MsgTag_t tag;
L4_Clear(&msg);
L4_Load(&msg);
tag = L4_Send(irq, L4_TimePeriod(1000000));
if(L4_IpcFailed(tag))
/*prints out the error. ">>1" is used to remove propagation bit
printf("the ipc failed with error [%d]", (int)L4_ErrorCode()>>1);
}
int main()
{
... //initialization, etc
irq = L4_GlobalId(1,1); //in hopes of getting the keyboard interrupt
L4_AssociateInterrupt(irq, handler); //the handler thread is setup ealier
L4_Sleep(L4_Never); //so that the code doesn't exit
}
this piece of code prints out:
the handler has been called
the ipc failed with error [1]
Which base on the v4 reference manual mean "timeout, from is defined in this
case". Also if i "sleep" for less than L4_Never the kernel crashes and reports
that there is an invalid opcode. Where am i going wrong?