diff --git a/arch/x86/include/asm/icc.h b/arch/x86/include/asm/icc.h index f08bd07c..b02be40e 100644 --- a/arch/x86/include/asm/icc.h +++ b/arch/x86/include/asm/icc.h @@ -53,6 +53,7 @@ typedef struct { int icc_init(void); int icc_ping(int ue); void icc_check(void); +void icc_mail_check(void); int icc_halt(void); int icc_mail_ping(void); diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 3c4b621f..9e8ca5e8 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -235,7 +235,7 @@ void irq_handler(struct state *s) void (*handler) (struct state * s); // at first, we check our work queues - check_workqueues(); + if( s->int_no == 124 ) check_workqueues(); /* * Find out if we have a custom handler to run for this diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index bf4c5180..49cc0734 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -235,36 +235,50 @@ int icc_ping(int ue) int icc_mail_ping( void ) { uint32_t flags; + uint64_t timer; int remote_rank = (my_ue+1)%2; - - kprintf( "#### Hello from icc_mail_ping\n" ); + + if( my_ue ) { + return 0; + } + // iRCCE is not thread save => disable interrupts flags = irq_nested_disable(); - - // start timer - uint64_t timer = rdtsc(); - - // send mail - iRCCE_mail_send( 0, my_ue, 0, NULL, remote_rank ); - // wait for mail from remote rank + // start timer + timer = rdtsc(); + + iRCCE_mail_send( 0, 1, 0, NULL, remote_rank ); + kprintf( "Sent pingrequest to %d ...\n", remote_rank ); + + + // wake up receiver + icc_send_irq( remote_rank ); + + // wait for response iRCCE_MAIL_HEADER* mail; do { iRCCE_mail_recv( &mail ); } while( !mail ); - timer = rdtsc() - timer; - - kprintf( "Received mail in %d ticks!\n", timer ); + // stop timer + timer = rdtsc() - timer; + + if( mail->tag == 2 ) { + kprintf( "Response received in %d ticks!\n", timer ); + } + else { + kprintf( "Response didn't arrive!\n" ); + } + + - // show content - iRCCE_mailbox_print_header( mail ); - irq_nested_enable(flags); - + return 0; } + static void interpret_header(icc_header_t* header, int recv_ue) { //kprintf("Got ICC message %d from %d\n", header->type, recv_ue); @@ -331,4 +345,24 @@ void icc_check(void) iRCCE_isend_push(); } +void icc_mail_check(void) +{ + if( !my_ue ) return ; + + iRCCE_MAIL_HEADER* header; + int res; + + kprintf( "Hello from icc_mail_check() \n" ); + // empty mailbox and interpret headers + do { + res = iRCCE_mail_recv( &header ); + if( header->tag == 1 ) { + kprintf( "Received mail_ping request ...\n" ); + iRCCE_mail_send( 0, 2, 0, NULL, header->source ); + } + + iRCCE_mail_release( &header ); + } while( res == iRCCE_SUCCESS ); +} + #endif diff --git a/include/metalsvm/tasks.h b/include/metalsvm/tasks.h index 5329fc61..b8822dfa 100644 --- a/include/metalsvm/tasks.h +++ b/include/metalsvm/tasks.h @@ -143,7 +143,8 @@ static inline void check_workqueues(void) uint32_t flags = irq_nested_disable(); #ifdef CONFIG_ROCKCREEK - icc_check(); +// icc_check(); + icc_mail_check(); #endif irq_nested_enable(flags); diff --git a/kernel/mailbox.c b/kernel/mailbox.c index 8b7a8b78..e20e9e36 100644 --- a/kernel/mailbox.c +++ b/kernel/mailbox.c @@ -40,7 +40,6 @@ int STDCALL mail_ping(void* arg) { int mailbox_test_init(void) { char* argv[] = {"/bin/mailbox", NULL}; - kprintf( "### Hello from mailbox_test_init\n" ); create_kernel_task(NULL, mail_ping, argv); return 0; diff --git a/kernel/main.c b/kernel/main.c index 9519dafc..4238ea72 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -114,11 +114,12 @@ int main(void) sleep(5); list_root(); - //test_init(); +// test_init(); mailbox_test_init(); per_core(current_task)->status = TASK_IDLE; reschedule(); + while(1) { #ifdef CONFIG_ROCKCREEK icc_halt();