Merge branch 'master' into mailbox_integration

This commit is contained in:
Simon Pickartz 2011-07-01 12:08:01 +02:00
commit c7b73fcb8e
13 changed files with 61 additions and 233 deletions

View file

@ -39,22 +39,17 @@ typedef struct {
extern bootinfo_t* bootinfo;
typedef struct {
uint8_t type;
uint8_t tag;
uint32_t length;
} icc_header_t;
/*
#define ICC_TYPE_IP (1 << 0)
#define ICC_TYPE_SVM (1 << 1)
#define ICC_TYPE_PINGREQUEST (1 << 2)
#define ICC_TYPE_PINGRESPONSE (1 << 3)
*/
int icc_init(void);
int icc_ping(int ue);
void icc_check(void);
void icc_mail_check(void);
int icc_halt(void);
int icc_send_irq(int ue);
void icc_mail_check(void);
int icc_mail_ping(void);
#endif

View file

@ -34,6 +34,8 @@
// [2010-12-09] added cancel functions for non-blocking send/recv requests
// by Carsten Clauss
//
// [2011-06-29] added the support of using IPIs
// by Simon Pickartz, Stefan Lankes
#include <metalsvm/stdlib.h>
#include <metalsvm/string.h>
@ -42,27 +44,7 @@
#include <asm/iRCCE_lib.h>
#include <asm/SCC_API.h>
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;
}
#include <asm/icc.h>
static int iRCCE_push_send_request(iRCCE_SEND_REQUEST *request) {
@ -264,7 +246,7 @@ int iRCCE_isend(
0, privbuf, dest );
NOP8;
NOP8;
send_irq( dest );
icc_send_irq( dest );
return iRCCE_SUCCESS;
}
// we need an extra isend-call
@ -273,7 +255,7 @@ int iRCCE_isend(
0, NULL, dest );
NOP8;
NOP8;
send_irq( dest );
icc_send_irq( dest );
return iRCCE_isend_general( privbuf, send_size,
dest, request );
}

View file

@ -1,31 +1,30 @@
//******************************************************************************
// Mailbox system.
//******************************************************************************
//
// Author: Rob F. Van der Wijngaart
// Intel Corporation
// Date: 008/30/2010
//
//******************************************************************************
//
// Copyright 2010 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// [2011-05-08] implemented mailbox send/recv routines
// by Simon Pickartz, Chair for Operating Systems,
// RWTH Aachen University
//
/*
* Copyright 2011 Simon Pickartz, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of MetalSVM.
*/
/*
* Mailbox system
*
* [2011-05-08] implemented mailbox send/recv routines
* by Simon Pickartz, Chair for Operating Systems,
* RWTH Aachen University
*/
#include <metalsvm/stdlib.h>
#include <metalsvm/string.h>

View file

@ -160,14 +160,14 @@ int icc_init(void)
SetConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1), tmp);
// set interrupt handler (INTR/LINT0)
//irq_install_handler(124, intr_handler);
irq_install_handler(124, intr_handler);
kputs("Now, the SCC is initialized!\n");
return 0;
}
static inline int icc_send_irq(int ue)
int icc_send_irq(int ue)
{
int tmp, x, y, z, addr;
@ -196,60 +196,24 @@ int icc_halt(void)
// iRCCE is not thread save => disable interrupts
flags = irq_nested_disable();
if (do_send)
if (do_send) {
do_send = (iRCCE_isend_push() == iRCCE_PENDING);
icc_check();
iRCCE_irecv_push();
}
icc_mail_check();
irq_nested_enable(flags);
} while(do_send);
iRCCE_finalize();
HALT;
return 0;
}
static volatile uint64_t ping_start = 0;
static icc_header_t ping_request = {ICC_TYPE_PINGREQUEST, 0, 0};
static icc_header_t ping_response = {ICC_TYPE_PINGRESPONSE, 0, 0};
int icc_ping(int ue)
{
uint32_t flags;
if (BUILTIN_EXPECT(ue == my_ue, 0))
return -EINVAL;
if (BUILTIN_EXPECT((ue < 0) || (ue >= num_ues), 0))
return -EINVAL;
while(ping_start) {
NOP8;
}
ping_start = rdtsc();
// iRCCE is not thread save => disable interrupts
flags = irq_nested_disable();
iRCCE_isend((char*) &ping_request, sizeof(icc_header_t), ue, NULL);
// wait some time
NOP8;
// wake up receiver
icc_send_irq(ue);
irq_nested_enable(flags);
return 0;
}
#define MAIL_MSG_SIZE 20
int icc_mail_ping( void )
{
{
uint32_t flags;
uint64_t timer;
int remote_rank = (my_ue+1)%2;
@ -288,78 +252,9 @@ int icc_mail_ping( void )
kprintf( "Response didn't arrive!\n" );
}
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);
switch(header->type)
{
case ICC_TYPE_PINGREQUEST: {
iRCCE_isend((char*) &ping_response, sizeof(icc_header_t), recv_ue, NULL);
// wait some time
NOP8;
// wake up remote core
icc_send_irq(recv_ue);
}
break;
case ICC_TYPE_PINGRESPONSE:
kprintf("Receive ping response. Ticks: %d\n", rdtsc()-ping_start);
ping_start = 0;
break;
default:
kprintf("Receive unknown ICC message (%d)\n", header->type);
}
}
/*
* By entering this function, interrupts are already disables
* => No race by using the static variables
*/
void icc_check(void)
{
static icc_header_t header[MAX_SCC_CORES];
static iRCCE_RECV_REQUEST request[MAX_SCC_CORES];
static int8_t first_call = 1;
int i, ret;
if (first_call) {
first_call = 0;
for(i=0; i<num_ues; i++) {
if (i == my_ue)
continue;
iRCCE_irecv((char*) (header+i), sizeof(icc_header_t), i, request+i);
}
}
// pushes the progress of non-blocking communication requests
iRCCE_irecv_push();
for(i=0; i<num_ues; i++) {
if (i == my_ue)
continue;
ret = iRCCE_irecv_test(request+i, NULL);
if (ret == iRCCE_SUCCESS) {
interpret_header(header+i, i);
iRCCE_irecv((char*) (header+i), sizeof(icc_header_t), i, request+i);
}
}
// pushes the progress of non-blocking communication requests
iRCCE_isend_push();
}
void icc_mail_check(void)
@ -383,8 +278,7 @@ void icc_mail_check(void)
}
iRCCE_mail_release( &header );
}
}
}
#endif

View file

@ -143,7 +143,6 @@ static inline void check_workqueues(void)
uint32_t flags = irq_nested_disable();
#ifdef CONFIG_ROCKCREEK
// icc_check();
icc_mail_check();
#endif

View file

@ -1,4 +1,4 @@
C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c mailbox.c
C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c
MODULE := kernel
include $(TOPDIR)/Makefile.inc

View file

@ -116,7 +116,7 @@ int STDCALL network_task(void* arg)
// start echo and ping server
echo_init();
//ping_init();
ping_init();
while(!done) {
#ifdef CONFIG_PCI

View file

@ -1,42 +0,0 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of MetalSVM.
*/
#include <metalsvm/stddef.h>
#include <metalsvm/stdio.h>
#include <metalsvm/time.h>
#include <metalsvm/tasks.h>
#include <metalsvm/semaphore.h>
#include <metalsvm/mailbox.h>
#include <metalsvm/syscall.h>
#ifdef CONFIG_ROCKCREEK
#include <asm/icc.h>
int STDCALL mail_ping(void* arg) {
icc_mail_ping();
return 0;
}
int mailbox_test_init(void)
{
create_kernel_task(NULL, mail_ping, NULL);
return 0;
}
#endif

View file

@ -35,7 +35,7 @@
#endif
extern int test_init(void);
extern int mailbox_test_init(void);
/*
* Note that linker symbols are not variables, they have no memory allocated for
* maintaining a value, rather their address is their value.
@ -112,11 +112,10 @@ int main(void)
sleep(5);
list_root();
// test_init();
mailbox_test_init();
test_init();
per_core(current_task)->status = TASK_IDLE;
reschedule();
while(1);
while(1) {
#ifdef CONFIG_ROCKCREEK
icc_halt();

View file

@ -53,10 +53,6 @@
#include <lwip/timers.h>
#include <lwip/inet_chksum.h>
#if LWIP_SOCKET
#define PING_USE_SOCKETS 1
#endif
#if PING_USE_SOCKETS
#include <lwip/sockets.h>
#include <lwip/inet.h>

View file

@ -87,13 +87,13 @@ static int STDCALL foo(void* arg)
}
#ifdef CONFIG_ROCKCREEK
static int STDCALL ping(void* arg)
{
int STDCALL mail_ping(void* arg) {
int i;
for(i=0; i<20; i++) {
icc_ping(1);
HALT;
icc_mail_ping();
//icc_halt();
udelay(500000);
}
return 0;
@ -127,11 +127,15 @@ int test_init(void)
sem_init(&consuming, 0);
mailbox_int32_init(&mbox);
#ifdef CONFIG_LWIP
ping_send_now();
#endif
create_kernel_task(NULL, foo, "Hello from foo1\n");
//create_kernel_task(NULL, join_test, NULL);
//create_kernel_task(NULL, producer, NULL);
//create_kernel_task(NULL, consumer, NULL);
//create_kernel_task(NULL, ping, NULL);
//create_kernel_task(NULL, mail_ping, NULL);
//create_user_task(NULL, "/bin/hello", argv);
create_user_task(NULL, "/bin/tests", argv);
//create_user_task(NULL, "/bin/jacobi", argv);

View file

@ -141,6 +141,7 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
err = sem_trywait(&sem->sem);
if (err != -1)
return err;
udelay(1000);
timeout--;
}
return SYS_ARCH_TIMEOUT;
@ -167,6 +168,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t * mbox, void **msg, u32_t timeout)
{
if (!mailbox_ptr_tryfetch(&mbox->mailbox,msg))
return 0;
udelay(1000);
timeout--;
}

View file

@ -95,6 +95,6 @@
#define IP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define NETIF_DEBUG LWIP_DBG_ON
#define TIMERS_DEBUG LWIP_DBG_ON
#define TIMERS_DEBUG LWIP_DBG_OFF
#endif