From f6fed124b697be109c678110bddb03105a0ef747 Mon Sep 17 00:00:00 2001 From: Simon Pickartz Date: Thu, 9 Jun 2011 04:23:17 -0700 Subject: [PATCH] use interrupts+anylength_call now --- arch/x86/kernel/irq.c | 5 ++-- arch/x86/scc/iRCCE_isend.c | 28 ++++++++++++++++++++++ arch/x86/scc/iRCCE_mailbox.c | 1 - arch/x86/scc/icc.c | 46 ++++++++++++++++++++---------------- kernel/mailbox.c | 7 +----- kernel/main.c | 4 +--- 6 files changed, 57 insertions(+), 34 deletions(-) diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 017491fb..413c2932 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -235,10 +235,9 @@ void irq_handler(struct state *s) void (*handler) (struct state * s); // at first, we check our work queues - if( s->int_no == 124 ) { - kprintf( "Got remote interrupt!\n" ); +// 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/iRCCE_isend.c b/arch/x86/scc/iRCCE_isend.c index 15c4e242..51cde3eb 100644 --- a/arch/x86/scc/iRCCE_isend.c +++ b/arch/x86/scc/iRCCE_isend.c @@ -41,6 +41,28 @@ #ifdef CONFIG_ROCKCREEK #include +#include +static int send_irq(int ue) { + int tmp, x, y, z, addr; + + z = Z_PID(RC_COREID[ue]); + x = X_PID(RC_COREID[ue]); + y = Y_PID(RC_COREID[ue]); + addr = CRB_ADDR(x,y) + (z==0 ? GLCFG0 : GLCFG1); + + // send interrupt to ue + do { + NOP1; + tmp=ReadConfigReg(addr); + } while(tmp & 2); + tmp |= 2; + SetConfigReg(addr, tmp); + + return 0; + + +} + static int iRCCE_push_send_request(iRCCE_SEND_REQUEST *request) { @@ -240,12 +262,18 @@ int iRCCE_isend( iRCCE_mail_send( send_size, iRCCE_ANYLENGTH_PIGGYBACK, 0, privbuf, dest ); + NOP8; + NOP8; + send_irq( dest ); return iRCCE_SUCCESS; } // we need an extra isend-call else { iRCCE_mail_send( send_size, iRCCE_ANYLENGTH, 0, NULL, dest ); + NOP8; + NOP8; + send_irq( dest ); return iRCCE_isend_general( privbuf, send_size, dest, request ); } diff --git a/arch/x86/scc/iRCCE_mailbox.c b/arch/x86/scc/iRCCE_mailbox.c index 901799c2..e23bceb1 100644 --- a/arch/x86/scc/iRCCE_mailbox.c +++ b/arch/x86/scc/iRCCE_mailbox.c @@ -187,7 +187,6 @@ int iRCCE_mail_recv( int iRCCE_mail_release( iRCCE_MAIL_HEADER** header ) { - // put header in garbage collection if( (iRCCE_mail_garbage.first == NULL) && (iRCCE_mail_garbage.last == NULL ) ) { diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index 16e7cc73..77282567 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -232,30 +232,32 @@ int icc_ping(int ue) return 0; } +#define MAIL_MSG_SIZE 20 + int icc_mail_ping( void ) { - kprintf( "Hello from mail_ping ... \n" ); uint32_t flags; uint64_t timer; int remote_rank = (my_ue+1)%2; + char send_buffer[MAIL_MSG_SIZE]; + int length = MAIL_MSG_SIZE; + if( my_ue ) { return 0; } - + + kprintf( "Hello from mail_ping ... \n" ); + // disable interrupts flags = irq_nested_disable(); // 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 ); + // start anylength send + iRCCE_isend( send_buffer, -length, remote_rank, NULL ); // wait for response iRCCE_MAIL_HEADER* mail; @@ -349,25 +351,27 @@ void icc_check(void) void icc_mail_check(void) { - iRCCE_MAIL_HEADER* header; - int res, count = 0; - -// if( !my_ue ) return; - - kprintf( "Hello from icc_mail_check() \n" ); + iRCCE_MAIL_HEADER* header = NULL; + int res; + char* recv_buffer; // empty mailbox and interpret headers - do { - res = iRCCE_mail_recv( &header ); + while( (res = iRCCE_mail_recv( &header )) == iRCCE_SUCCESS ) { if( header->tag == 1 ) { - kprintf( "Received mail_ping request ...\n" ); iRCCE_mail_send( 0, 2, 0, NULL, header->source ); } - count++; - iRCCE_mail_release( &header ); - } while( res == iRCCE_SUCCESS ); + else if( header->tag == iRCCE_ANYLENGTH ) { + recv_buffer = (char*)kmalloc( header->size ); + iRCCE_irecv( recv_buffer, header->size, header->source, NULL ); + iRCCE_mail_send( 0, 2, 0, NULL, header->source ); + } + else if( header->tag == iRCCE_ANYLENGTH_PIGGYBACK ) { + iRCCE_mail_send( 0, 2, 0, NULL, header->source ); + } + + iRCCE_mail_release( &header ); + } - kprintf( "received %d headers!\n", count ); } #endif diff --git a/kernel/mailbox.c b/kernel/mailbox.c index e20e9e36..c790f984 100644 --- a/kernel/mailbox.c +++ b/kernel/mailbox.c @@ -28,19 +28,14 @@ #include int STDCALL mail_ping(void* arg) { - - kprintf( "### Hello from mail_ping\n" ); - icc_mail_ping(); - kprintf( "### mail_ping finished\n" ); return 0; } int mailbox_test_init(void) { - char* argv[] = {"/bin/mailbox", NULL}; - create_kernel_task(NULL, mail_ping, argv); + create_kernel_task(NULL, mail_ping, NULL); return 0; } diff --git a/kernel/main.c b/kernel/main.c index f2fcf076..91e3c1ea 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -113,12 +113,10 @@ int main(void) sleep(5); list_root(); // test_init(); - kprintf( "starting mailbox ...\n " ); mailbox_test_init(); per_core(current_task)->status = TASK_IDLE; reschedule(); - - + while(1); while(1) { #ifdef CONFIG_ROCKCREEK icc_halt();