Commit d14473a3 authored by julien.delange's avatar julien.delange
Browse files

implementation of the 1553 that works !



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@646 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 3178bb11
......@@ -15,15 +15,52 @@
#include <drivers/po_hi_driver_rasta_1553_brmlib.h>
void __po_hi_c_driver_1553_rasta_poller (void);
void __po_hi_c_driver_1553_rasta_terminal_poller (void);
/*
* __po_hi_c_driver_1553_rasta_terminal_poller is the function that should
* be executed on a receiver node to wait for incoming data and put in
* the middleware queue. It must be called by a periodic thread.
*/
void __po_hi_c_driver_1553_rasta_init_terminal (__po_hi_device_id id);
/*
* __po_hi_c_driver_1553_rasta_init_terminal initializes the board
* and sets it in the TERMINAL mode.
*/
void __po_hi_c_driver_1553_rasta_init_controller (__po_hi_device_id id);
/*
* __po_hi_c_driver_1553_rasta_init_terminal initializes the board
* and sets it in the CONTROLLER mode.
*/
void __po_hi_c_driver_1553_rasta_init (__po_hi_device_id id);
int __po_hi_c_driver_1553_rasta_sender_controller (const __po_hi_task_id task_id, const __po_hi_port_t port);
/*
* This function is used on a CONTROLLER to send a message to another node. It
* can't be used when the device is acting as a MONITOR or a TERMINAL.
*/
int __po_hi_c_driver_1553_rasta_sender (const __po_hi_task_id task_id, const __po_hi_port_t port);
int __po_hi_c_driver_1553_rasta_sender_terminal (const __po_hi_task_id task_id, const __po_hi_port_t port);
/*
* This function is used on a TERMINAL to send a message to another node. It
* can't be used when the device is acting as a MONITOR or a CONTROLLER;
*/
void __po_hi_c_driver_1553_rasta_controller ();
/*
* This function is a main loop that is supposed to control all TERMINAL nodes :
* tell them when to send or receive data. However, its content should be
* configured through the generated code. At this moment, its content
* is more a stub taken from GAISLER example. We have to discuss with TASTE
* folks to decide how to implement the communication policy deployed on
* the controller from the AADL models.
*/
int __po_hi_c_driver_1553_rasta_proccess_list (__po_hi_c_driver_rasta_1553_brm_t chan, struct bc_msg *list, int test);
/*
* Function called by the controller to proccess a list of commands.
* A command is a message that indicate if a node can send/receive data.
*/
#endif
......
......@@ -38,6 +38,9 @@ CFLAGS=-Wall $(USER_CFLAGS) $(TARGET_CFLAGS)
CPPFLAGS=$(CFLAGS) $(USER_CPPFLAGS)
LDFLAGS=$(TARGET_LDFLAGS) $(USER_LDFLAGS)
ifdef USE_GPROF
CFLAGS+=-D__PO_HI_USE_GPROF -pg
endif
ifeq ($(ENABLE_DYNAMIC_CONFIGURATION),1)
CFLAGS+=-D__PO_HI_USE_DYNAMIC_CONFIGURATION
......
......@@ -50,7 +50,6 @@ endef
ifdef USE_GPROF
TARGET_LDFLAGS+=-Wl,--wrap,Clock_isr -pg
TARGET_CFLAGS+=-D__PO_HI_USE_GPROF -pg
EXTERNAL_OBJECTS+=po_hi_gprof_rtems_leon.o
target-objects:
......
......@@ -6,3 +6,4 @@ LD = ld
target-clean:
target-objects:
......@@ -41,7 +41,7 @@
__po_hi_c_driver_rasta_1553_brm_t po_hi_c_driver_1553_rasta_fd;
void __po_hi_c_driver_1553_rasta_poller (void)
void __po_hi_c_driver_1553_rasta_terminal_poller (void)
{
int ret;
int msglen;
......@@ -63,6 +63,8 @@ void __po_hi_c_driver_1553_rasta_poller (void)
return;
}
__DEBUGMSG ("[RASTA 1553] Poller received %d messages\n",ret);
if ( msgs[0].desc >= 32 )
{
__DEBUGMSG ("[RASTA 1553] Received message desc >= 32\n");
......@@ -81,6 +83,19 @@ void __po_hi_c_driver_1553_rasta_poller (void)
msglen = (msgs[0].miw >> 11) & 0x1f;
memcpy (&msg, msgs[0].data, __PO_HI_MESSAGES_MAX_SIZE);
{
#include <stdio.h>
printf("received (length=%d): 0x", msglen);
int i;
uint32_t* toto = (uint32_t*) &msg;
for (i = 0 ; i < __PO_HI_MESSAGES_MAX_SIZE ; i++)
{
printf("%x", toto[i]);
}
printf("\n");
}
__po_hi_unmarshall_request (&request, &msg);
......@@ -89,9 +104,10 @@ void __po_hi_c_driver_1553_rasta_poller (void)
__po_hi_main_deliver (&request);
}
int __po_hi_c_driver_1553_rasta_sender (const __po_hi_task_id task_id, const __po_hi_port_t port)
int __po_hi_c_driver_1553_rasta_sender_terminal (const __po_hi_task_id task_id, const __po_hi_port_t port)
{
int ts;
int ret;
struct rt_msg msgs[__PO_HI_NEED_DRIVER_1553_RASTA_MSG_CNT];
__po_hi_local_port_t local_port;
......@@ -114,13 +130,17 @@ int __po_hi_c_driver_1553_rasta_sender (const __po_hi_task_id task_id, const __p
memcpy (msgs[0].data, &msg, __PO_HI_MESSAGES_MAX_SIZE);
msgs[0].desc = 32;
msgs[0].miw = 0;
msgs[0].miw |= (__PO_HI_MESSAGES_MAX_SIZE / 8) << 11;
msgs[0].desc = 2;
__po_hi_c_driver_1553_rasta_brmlib_set_block (po_hi_c_driver_1553_rasta_fd, 1, 0);
if ( __po_hi_c_driver_1553_rasta_brmlib_rt_send (po_hi_c_driver_1553_rasta_fd, msgs) != 1 )
ret = __po_hi_c_driver_1553_rasta_brmlib_rt_send (po_hi_c_driver_1553_rasta_fd, msgs);
if (ret != 1)
{
printf("[RASTA 1553] Error when sending data\n");
printf("[RASTA 1553] Error when sending data, return code=%d\n", ret);
return;
}
__DEBUGMSG ("[RASTA 1553] Message sent: 0x");
......@@ -135,6 +155,67 @@ int __po_hi_c_driver_1553_rasta_sender (const __po_hi_task_id task_id, const __p
}
int __po_hi_c_driver_1553_rasta_sender_controller (const __po_hi_task_id task_id, const __po_hi_port_t port)
{
struct bc_msg msgs[2];
msgs[0].rtaddr[0] = 2;
msgs[0].subaddr[0] = 1;
msgs[0].wc = __PO_HI_MESSAGES_MAX_SIZE / 8;
msgs[0].ctrl = 0;
// msgs[0].ctrl |= BC_TR;
msgs[0].ctrl |= BC_BUSA;
msgs[1].ctrl |= BC_EOL; /* end of list */
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_msg_t msg;
__po_hi_port_t destination_port;
local_port = __po_hi_get_local_port_from_global_port (port);
request = __po_hi_gqueue_get_most_recent_value (task_id, local_port);
destination_port = __po_hi_gqueue_get_destination (task_id, local_port, 0);
__po_hi_msg_reallocate (&msg);
request->port = destination_port;
__po_hi_marshall_request (request, &msg);
memcpy (msgs[0].data, &msg, __PO_HI_MESSAGES_MAX_SIZE);
/*
{
#include <stdio.h>
printf("sent : 0x");
int i;
uint32_t* toto = (uint32_t*) &msg;
for (i = 0 ; i < __PO_HI_MESSAGES_MAX_SIZE ; i++)
{
printf("%x", toto[i]);
}
printf("\n");
}
*/
__po_hi_c_driver_1553_rasta_brmlib_set_block (po_hi_c_driver_1553_rasta_fd, 1, 0);
if ( __po_hi_c_driver_1553_rasta_proccess_list(po_hi_c_driver_1553_rasta_fd,msgs,0) )
{
__DEBUGMSG("[RASTA 1553] CANNOT PROCESS LIST\n");
return 0;
}
return 1;
}
int __po_hi_c_driver_1553_rasta_proccess_list (__po_hi_c_driver_rasta_1553_brm_t chan, struct bc_msg *list, int test)
{
int j,ret;
......@@ -261,12 +342,12 @@ void __po_hi_c_driver_1553_rasta_controller ()
}
/* print the data that was received */
/*
j=1;
while( !(result_list[j-1].ctrl & BC_EOL) )
{
// __DEBUGMSG("[RASTA 1553] Response to message %d: (len: %d, tsw1: %x, tsw2: %x)\n ",j,result_list[j-1].wc,result_list[j-1].tsw[0],result_list[j-1].tsw[1]);
/* print data */
/* for (k = 0; k < result_list[j-1].wc; k++)
__DEBUGMSG("[RASTA 1553] Response to message %d: (len: %d, tsw1: %x, tsw2: %x)\n ",j,result_list[j-1].wc,result_list[j-1].tsw[0],result_list[j-1].tsw[1]);
for (k = 0; k < result_list[j-1].wc; k++)
{
if ( isalnum(result_list[j-1].data[k]) )
{
......@@ -278,9 +359,10 @@ void __po_hi_c_driver_1553_rasta_controller ()
}
}
__DEBUGMSG("\n");
*/
j++;
}
*/
}
......@@ -288,6 +370,8 @@ void __po_hi_c_driver_1553_rasta_controller ()
void __po_hi_c_driver_1553_rasta_init_terminal (__po_hi_device_id id)
{
int ret;
__DEBUGMSG ("[RASTA 1553] Init\n");
init_pci();
__DEBUGMSG ("[RASTA 1553] Initializing RASTA (rasta_register()) ...\n");
......@@ -307,12 +391,29 @@ void __po_hi_c_driver_1553_rasta_init_terminal (__po_hi_device_id id)
return;
}
__po_hi_c_driver_1553_rasta_brmlib_set_mode (po_hi_c_driver_1553_rasta_fd,BRM_MODE_RT);
ret = __po_hi_c_driver_1553_rasta_brmlib_set_mode (po_hi_c_driver_1553_rasta_fd,BRM_MODE_RT);
if (ret != 0)
{
__DEBUGMSG ("Error setting address, return=%d\n", ret);
return;
}
ret = __po_hi_c_driver_1553_rasta_brmlib_set_rt_addr (po_hi_c_driver_1553_rasta_fd, 2);
if (ret != 0)
{
__DEBUGMSG ("Error setting address, return=%d\n", ret);
return;
}
return;
}
void __po_hi_c_driver_1553_rasta_init_controller (__po_hi_device_id id)
{
int ret;
__DEBUGMSG ("[RASTA 1553] Init\n");
init_pci();
__DEBUGMSG ("[RASTA 1553] Initializing RASTA (rasta_register()) ...\n");
......@@ -333,8 +434,15 @@ void __po_hi_c_driver_1553_rasta_init_controller (__po_hi_device_id id)
}
/* Set BC mode */
__DEBUGMSG("[RASTA 1553] Task1: Setting BC mode\n");
__po_hi_c_driver_1553_rasta_brmlib_set_mode (po_hi_c_driver_1553_rasta_fd,BRM_MODE_BC);
__DEBUGMSG("[RASTA 1553] Setting BC mode\n");
ret = __po_hi_c_driver_1553_rasta_brmlib_set_mode (po_hi_c_driver_1553_rasta_fd,BRM_MODE_BC);
if (ret != 0)
{
__DEBUGMSG ("Error setting BC mode, return=%d\n", ret);
}
}
......
......@@ -151,6 +151,7 @@ int __po_hi_c_driver_1553_rasta_brmlib_recv_multiple(__po_hi_c_driver_rasta_1553
if ( msglen == 0 )
{
__DEBUGMSG("[RASTA 1553 BRMLIB] zero length, errno: %d, returned: %d\n",errno,ret);
return 0;
}
......
/**
* \file gmon.c
* \brief This file implements the gprof stub on the LEON2/3 over RTEMS.
*
* The file implements the mcoung function responsible for recording the
* call-graph table.
* It also implements the functionality of the profil() function (see man(2)
* profil) by replacing the clock isr and wrapping the real Clock_isr() RTEMS
* function.
*
* \author Aitor Viana Sanchez (avs), Aitor.Viana.Sanchez@esa.int
*
* \internal
* Created: 05/17/2010
* Revision: $Id: gmon.c 1.4 05/17/2010 avs Exp $
* Compiler: gcc/g++
* Company: European Space Agency (ESA-ESTEC)
* Copyright: Copyright (c) 2010, Aitor Viana Sanchez
*
* This source code is released for free distribution under the terms of the
* GNU General Public License as published by the Free Software Foundation.
* =====================================================================================
*/
/*-
* Copyright (c) 1991, 1998 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. [rescinded 22 July 1999]
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifdef __PO_HI_USE_GPROF
static char sccsid[] = "@(#)gmon.c 1.0 (E.S.A) 10/05/2010";
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <rtems.h>
#include <bsp.h>
#define CONFIG_OS_PROFILE_OVER_SERIAL 1
#define SERIAL_VERBOSE_MODE 1
......@@ -236,7 +171,70 @@ struct rawarc_order {
#define ROUNDDOWN(x,y) (((x)/(y))*(y))
#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))
/**
* \file gmon.c
* \brief This file implements the gprof stub on the LEON2/3 over RTEMS.
*
* The file implements the mcoung function responsible for recording the
* call-graph table.
* It also implements the functionality of the profil() function (see man(2)
* profil) by replacing the clock isr and wrapping the real Clock_isr() RTEMS
* function.
*
* \author Aitor Viana Sanchez (avs), Aitor.Viana.Sanchez@esa.int
*
* \internal
* Created: 05/17/2010
* Revision: $Id: gmon.c 1.4 05/17/2010 avs Exp $
* Compiler: gcc/g++
* Company: European Space Agency (ESA-ESTEC)
* Copyright: Copyright (c) 2010, Aitor Viana Sanchez
*
* This source code is released for free distribution under the terms of the
* GNU General Public License as published by the Free Software Foundation.
* =====================================================================================
*/
/*-
* Copyright (c) 1991, 1998 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. [rescinded 22 July 1999]
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
static char sccsid[] = "@(#)gmon.c 1.0 (E.S.A) 10/05/2010";
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <rtems.h>
#include <bsp.h>
void _mcount() __attribute__((weak, alias("mcount")));
......@@ -273,7 +271,6 @@ static char *s_profil = 0;
static void moncontrol( int mode );
static rtems_isr profile_clock_isr(rtems_vector_number vector);
static rtems_isr Clock_isr(rtems_vector_number vector);
static void moncontrol( int mode )
{
......@@ -558,6 +555,8 @@ static rtems_isr profile_clock_isr(rtems_vector_number vector)
}
#if (CONFIG_OS_PROFILE_OVER_SERIAL == 1)
#include <sys/types.h>
......@@ -588,7 +587,7 @@ static int serialFD = -1;
int initialize_serial()
{
struct termios oldtio, newtio;
serialFD = open( "/dev/apburasta0" , O_RDWR | O_NOCTTY);
serialFD = open( "/dev/apbuart" , O_RDWR | O_NOCTTY);
if( serialFD < 0 )
{
#if(SERIAL_VERBOSE_MODE == 1)
......
......@@ -111,6 +111,10 @@ void __po_hi_wait_end_of_instrumentation ()
__po_hi_time_t now;
__po_hi_get_time (&now);
__po_hi_delay_until (__po_hi_add_times (now, __po_hi_seconds (10)));
__DEBUGMSG ("Call exit()\n");
exit (1);
__DEBUGMSG ("exit() called\n");
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment