hi all, does the interrupt number of interrupt thread correspond to IRQ number? So thread-id for IRQ2 is 0x00008001?
I just want to make interrupt handler. So if you can also give a example I would appreciate it. Thank
ok so far i have code like this:
void IRH(void) { printf("the interrupt occur\n"); }
int main () { L4_ThreadId_t handler_thread, IRQ_thread, mylocal, me; L4_Word_t root_utcb, new_utcb, sp, ip, root_threadNo; void* kip; char stack[1024]; L4_Msg_t msg;
kip = L4_kernelInterface(); me = L4_MyGlobalId(); mylocal = L4_MyLocalId(); root_threadNo = L4_ThreadNo(me); root_utcb = *(L4_Word_t*)&mylocal; root_utcb &= ~(L4_UtcbAreaSize(kip)-1); new_utcb = root_utcb + (L4_UtcbSize(kip) * ((root_threadNo+1) - L4_ThreadIdUserBase(kip)));
handler_thread = L4_GlobalId(root_threadNo+1, 1); IRQ_thread = L4_GlobalId(1,1);
ip = (L4_Word_t)IRH; sp = (L4_Word_t)&stack[1025];
L4_ThreadControl(handler_thread, me, me, me, (void*) new_utcb);
L4_Clear(&msg); L4_Append(&msg, ip); L4_Append(&msg, sp); L4_Load(&msg); L4_Send(handler_thread);
L4_AssociateInterrupt(IRQ_thread, handler_thread);
while(1) { }
return 0; }
the intent is when i press a key on keyboard the interrupt is suppose to occur but text "the interrupt occur" do not display. I run tests so I know the threads working (interrupt and handler). but this does not work. Why is this so?
On Mon May 02, 2011 at 20:40:57 +0000, Jason Phillips wrote:
ok so far i have code like this:
void IRH(void) { printf("the interrupt occur\n"); }
int main () { L4_ThreadId_t handler_thread, IRQ_thread, mylocal, me; L4_Word_t root_utcb, new_utcb, sp, ip, root_threadNo; void* kip; char stack[1024]; L4_Msg_t msg;
kip = L4_kernelInterface(); me = L4_MyGlobalId(); mylocal = L4_MyLocalId(); root_threadNo = L4_ThreadNo(me); root_utcb = *(L4_Word_t*)&mylocal; root_utcb &= ~(L4_UtcbAreaSize(kip)-1); new_utcb = root_utcb + (L4_UtcbSize(kip) * ((root_threadNo+1) - L4_ThreadIdUserBase(kip)));
handler_thread = L4_GlobalId(root_threadNo+1, 1); IRQ_thread = L4_GlobalId(1,1);
ip = (L4_Word_t)IRH; sp = (L4_Word_t)&stack[1025];
L4_ThreadControl(handler_thread, me, me, me, (void*) new_utcb);
L4_Clear(&msg); L4_Append(&msg, ip); L4_Append(&msg, sp); L4_Load(&msg); L4_Send(handler_thread);
L4_AssociateInterrupt(IRQ_thread, handler_thread);
the intent is when i press a key on keyboard the interrupt is suppose to occur but text "the interrupt occur" do not display. I run tests so I know the threads working (interrupt and handler). but this does not work. Why is this so?
Just an idea, I'm not seeing an IPC operation on the IRQ_thread. Is that missing?
Adam
I not if i suppose to have one, I assuming the l4 kernel take care of it for me since it is a interrupt, because interrupt thread is kernel property. should there be a IPC to the interrupt thread?
On Wed May 04, 2011 at 01:35:00 +0000, Jason Phillips wrote:
I not if i suppose to have one, I assuming the l4 kernel take care of it for me since it is a interrupt, because interrupt thread is kernel property. should there be a IPC to the interrupt thread?
Yes. Your handler thread immediately exits. You need to have a loop in there (or in the while in the main function, you do not necessarily need a thread for your example).
Adam
this code give:
#include <l4/kip.h> #include <l4/thread.h> #include <l4/schedule.h> #include <l4/ipc.h> #include <l4io.h> #include <l4/sigma0.h>
L4_ThreadId_t INT_THREAD;
void IRH1(void) { while(1) { L4_Msg_t msg; printf("the interrupt is raise\n"); L4_Clear(&msg); L4_Append(&msg,(L4_Word_t)0); L4_Load(&msg); L4_Send(INT_THREAD, L4_TimePeriod(2000000)); printf("result: [%d]\n", (int)L4_ErrorCode()); } }
int main() { L4_Word_t sp, ip, utcb_b, utcb_n; L4_ThreadId_t me, h1, mylocal; void* kip; char stack[1024]; L4_Msg_t msg; kip = L4_KernelInterface(); me = L4_MyGlobalId(); mylocal = L4_MyLocalId(); h1 = L4_GlobalId(L4_ThreadNo(me)+1, 2); utcb_b = *(L4_Word_t*)&mylocal; utcb_b &= ~(L4_UtcbAreaSize(kip) -1); utcb_n = utcb_b + (L4_UtcbSize(kip) * (L4_ThreadNo(h1) - L4_ThreadIdUserBase(kip))); sp = (L4_Word_t)&stack[1025]; ip = (L4_Word_t)IRH1; INT_THREAD = L4_GlobalId(1,1); L4_ThreadControl(h1, me, me, me, (void*)utcb_n); L4_Clear(&msg); L4_Append(&msg, ip); L4_Append(&msg, sp); L4_Load(&msg); L4_Send(h1, L4_TimePeriod(3000000)); printf("error code [%d]\n", (int)L4_ErrorCode()); L4_AssociateInterrupt(INT_THREAD,h1); while(1) { L4_Wait(L4_TimePeriod(3000000), &INT_THREAD); } return 0; }
give me a endless loop where a error code of 1 arise first then it loop endless with a error code of 2, this happen when keyboard is not press. Just to be clear by error code i mean the 'e' field of register. And if use 'sleep' instead wait it do not work when keyboard is press. as well how do i know if the interrupt is calling thread? I try if statement to compare the label to -1 but it it is not a legal compare because label is unsigned. how do i know?
Is there document or example that show how to handle hardware interrupt I use to guide me on this?
can someone please show how to register a interrupt in pistachio. I using a pentium4 cpu
l4-hackers@os.inf.tu-dresden.de