Commit f24847a6 authored by jdelange's avatar jdelange
Browse files

* po-hi-c/src/drivers/po_hi_driver_usbbrick_spacewire.c

   po-hi-c/src/drivers/po_hi_driver_rasta_serial.c
   po-hi-c/src/drivers/po_hi_driver_sockets.c
   po-hi-c/src/drivers/po_hi_driver_rasta_spacewire.c
   po-hi-c/src/drivers/po_hi_driver_rasta_1553.c
   po-hi-c/src/drivers/po_hi_driver_leon_serial.c
   po-hi-c/src/drivers/po_hi_driver_leon_eth.c
   po-hi-c/src/drivers/po_hi_driver_linux_serial.c
   - Put variables that consume lot of memory on the heap
     instead of thread stack



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@3178 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 5b593ec8
......@@ -103,6 +103,8 @@ struct rtems_bsdnet_config rtems_bsdnet_config = {
{"255.155.255.255" }, /* NTP server(s) */
};
__po_hi_request_t __po_hi_c_driver_eth_leon_poller_received_request;
__po_hi_msg_t __po_hi_c_driver_eth_leon_poller_msg;
void __po_hi_c_driver_eth_leon_poller (const __po_hi_device_id dev_id)
{
......@@ -118,8 +120,6 @@ void __po_hi_c_driver_eth_leon_poller (const __po_hi_device_id dev_id)
struct sockaddr_in sa;
__po_hi_device_id dev;
__po_hi_node_t dev_init;
__po_hi_request_t received_request;
__po_hi_msg_t msg;
int established = 0;
__po_hi_protocol_conf_t* protocol_conf;
......@@ -231,14 +231,14 @@ void __po_hi_c_driver_eth_leon_poller (const __po_hi_device_id dev_id)
rnodes[dev].socket = -1;
continue;
}
protocol_conf->unmarshaller (&received_request, &datareceived, len);
received_request.port = 1;
protocol_conf->unmarshaller (& __po_hi_c_driver_eth_leon_poller_received_request, &datareceived, len);
__po_hi_c_driver_eth_leon_poller_received_request.port = 1;
}
#else
memset (msg.content, '\0', __PO_HI_MESSAGES_MAX_SIZE);
len = recv (rnodes[dev].socket, msg.content, __PO_HI_MESSAGES_MAX_SIZE, MSG_WAITALL);
msg.length = len;
memset (__po_hi_c_driver_eth_leon_poller_msg.content, '\0', __PO_HI_MESSAGES_MAX_SIZE);
len = recv (rnodes[dev].socket, __po_hi_c_driver_eth_leon_poller_msg.content, __PO_HI_MESSAGES_MAX_SIZE, MSG_WAITALL);
__po_hi_c_driver_eth_leon_poller_msg.length = len;
__DEBUGMSG ("[DRIVER ETH] Message received len=%d\n",(int)len);
#ifdef __PO_HI_DEBUG
......@@ -253,15 +253,15 @@ void __po_hi_c_driver_eth_leon_poller (const __po_hi_device_id dev_id)
rnodes[dev].socket = -1;
continue;
}
swap_pointer = (unsigned long*) &msg.content[0];
swap_pointer = (unsigned long*) &__po_hi_c_driver_eth_leon_poller_msg.content[0];
swap_value = *swap_pointer;
*swap_pointer = __po_hi_swap_byte (swap_value);
__po_hi_unmarshall_request (&received_request, &msg);
__po_hi_unmarshall_request (& __po_hi_c_driver_eth_leon_poller_received_request, &__po_hi_c_driver_eth_leon_poller_msg);
#endif
__po_hi_main_deliver (&received_request);
__po_hi_main_deliver (& __po_hi_c_driver_eth_leon_poller_received_request);
}
}
}
......@@ -511,6 +511,8 @@ void __po_hi_c_driver_eth_leon_init (__po_hi_device_id id)
#if defined (__PO_HI_NEED_DRIVER_ETH_LEON)
__po_hi_msg_t __po_hi_c_driver_eth_leon_sender_msg;
int __po_hi_c_driver_eth_leon_sender (__po_hi_task_id task, __po_hi_port_t port)
{
int len;
......@@ -525,7 +527,6 @@ int __po_hi_c_driver_eth_leon_sender (__po_hi_task_id task, __po_hi_port_t port
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_port_t destination_port;
__po_hi_msg_t msg;
__po_hi_protocol_t protocol_id;
__po_hi_protocol_conf_t* protocol_conf;
......@@ -609,17 +610,17 @@ int __po_hi_c_driver_eth_leon_sender (__po_hi_task_id task, __po_hi_port_t port
default:
{
request->port = destination_port;
__po_hi_msg_reallocate (&msg);
__po_hi_marshall_request (request, &msg);
__po_hi_msg_reallocate (&__po_hi_c_driver_eth_leon_sender_msg);
__po_hi_marshall_request (request, &__po_hi_c_driver_eth_leon_sender_msg);
#ifdef __PO_HI_DEBUG
__po_hi_messages_debug (&msg);
__po_hi_messages_debug (&__po_hi_c_driver_eth_leon_sender_msg);
#endif
swap_pointer = (unsigned long*) &msg.content[0];
swap_pointer = (unsigned long*) &__po_hi_c_driver_eth_leon_sender_msg.content[0];
swap_value = *swap_pointer;
*swap_pointer = __po_hi_swap_byte (swap_value);
len = write (nodes[associated_device].socket, &(msg.content), size_to_write);
len = write (nodes[associated_device].socket, &(__po_hi_c_driver_eth_leon_sender_msg.content), size_to_write);
if (len != size_to_write)
{
......
......@@ -41,6 +41,10 @@ int po_hi_c_driver_leon_serial_fd_write;
#if defined (__PO_HI_NEED_DRIVER_SERIAL_LEON) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER)
__po_hi_request_t po_hi_c_driver_leon_serial_request;
__po_hi_msg_t po_hi_c_driver_leon_serial_poller_msg;
void __po_hi_c_driver_serial_leon_poller (const __po_hi_device_id dev_id)
{
int n;
......@@ -49,43 +53,41 @@ void __po_hi_c_driver_serial_leon_poller (const __po_hi_device_id dev_id)
(void) dev_id;
__po_hi_msg_t msg;
__po_hi_request_t request;
__PO_HI_DEBUG_DEBUG ("[LEON SERIAL] Hello, i'm the serial poller , must read %d bytes on %d !\n", __PO_HI_MESSAGES_MAX_SIZE, po_hi_c_driver_leon_serial_fd_read);
__po_hi_msg_reallocate (&msg);
__po_hi_msg_reallocate (&po_hi_c_driver_leon_serial_poller_msg);
tr = 0;
while (tr < __PO_HI_MESSAGES_MAX_SIZE)
{
if (read (po_hi_c_driver_leon_serial_fd_read, &(msg.content[tr]), 1) == 1)
if (read (po_hi_c_driver_leon_serial_fd_read, &(po_hi_c_driver_leon_serial_poller_msg.content[tr]), 1) == 1)
{
tr++;
}
}
msg.length = __PO_HI_MESSAGES_MAX_SIZE;
po_hi_c_driver_leon_serial_poller_msg.length = __PO_HI_MESSAGES_MAX_SIZE;
__PO_HI_DEBUG_DEBUG ("[LEON SERIAL] read() syscall returns in total %d, received: ", tr);
#ifdef __PO_HI_DEBUG_DEBUG
__PO_HI_DEBUG_DEBUG("[LEON SERIAL] Message received: 0x");
for (ts = 0 ; ts < msg.length ; ts++)
for (ts = 0 ; ts < po_hi_c_driver_leon_serial_poller_msg.length ; ts++)
{
__PO_HI_DEBUG_DEBUG ("%x", msg.content[ts]);
__PO_HI_DEBUG_DEBUG ("%x", po_hi_c_driver_leon_serial_poller_msg.content[ts]);
}
__PO_HI_DEBUG_DEBUG ("\n");
#endif
__po_hi_unmarshall_request (&request, &msg);
__po_hi_unmarshall_request (& po_hi_c_driver_leon_serial_request, &po_hi_c_driver_leon_serial_poller_msg);
if (request.port > __PO_HI_NB_PORTS)
if ( po_hi_c_driver_leon_serial_request.port > __PO_HI_NB_PORTS)
{
__PO_HI_DEBUG_WARNING ("[LEON SERIAL] Invalid port number !\n");
return;
}
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Destination port: %d\n", request.port);
__po_hi_main_deliver (&request);
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Destination port: %d\n", po_hi_c_driver_leon_serial_request.port);
__po_hi_main_deliver (& po_hi_c_driver_leon_serial_request);
}
#endif
......@@ -238,14 +240,15 @@ void __po_hi_c_driver_serial_leon_init (__po_hi_device_id id)
#if defined (__PO_HI_NEED_DRIVER_SERIAL_LEON) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_SENDER)
__po_hi_msg_t __po_hi_c_driver_serial_leon_sender_msg;
int __po_hi_c_driver_serial_leon_sender (__po_hi_task_id task_id, __po_hi_port_t port)
{
int n;
int ts;
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_msg_t msg;
__po_hi_port_t destination_port;
__po_hi_request_t* request;
__po_hi_port_t destination_port;
local_port = __po_hi_get_local_port_from_global_port (port);
......@@ -253,20 +256,20 @@ int __po_hi_c_driver_serial_leon_sender (__po_hi_task_id task_id, __po_hi_port_
destination_port = __po_hi_gqueue_get_destination (task_id, local_port, 0);
__po_hi_msg_reallocate (&msg);
__po_hi_msg_reallocate (&__po_hi_c_driver_serial_leon_sender_msg);
request->port = destination_port;
__po_hi_marshall_request (request, &msg);
__po_hi_marshall_request (request, &__po_hi_c_driver_serial_leon_sender_msg);
n = write (po_hi_c_driver_leon_serial_fd_write, &(msg.content[0]), __PO_HI_MESSAGES_MAX_SIZE);
n = write (po_hi_c_driver_leon_serial_fd_write, &(__po_hi_c_driver_serial_leon_sender_msg.content[0]), __PO_HI_MESSAGES_MAX_SIZE);
#ifdef __PO_HI_DEBUG_INFO
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Message sent: 0x");
for (ts = 0 ; ts < __PO_HI_MESSAGES_MAX_SIZE ; ts++)
{
__PO_HI_DEBUG_INFO ("%x", msg.content[ts]);
__PO_HI_DEBUG_INFO ("%x", __po_hi_c_driver_serial_leon_sender_msg.content[ts]);
}
__PO_HI_DEBUG_INFO ("\n");
#endif
......
......@@ -44,6 +44,8 @@ uint32_t po_hi_c_driver_serial_sending_wait;
#if defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER)
__po_hi_request_t __po_hi_c_driver_serial_linux_request;
__po_hi_msg_t __po_hi_c_driver_serial_linux_poller_msg;
void __po_hi_c_driver_serial_linux_poller (const __po_hi_device_id dev_id)
{
(void) dev_id;
......@@ -53,16 +55,14 @@ void __po_hi_c_driver_serial_linux_poller (const __po_hi_device_id dev_id)
unsigned long* swap_pointer;
unsigned long swap_value;
__po_hi_msg_t msg;
__po_hi_request_t request;
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Hello, i'm the serial poller , must read %d bytes!\n", __PO_HI_MESSAGES_MAX_SIZE);
__po_hi_msg_reallocate (&msg);
__po_hi_msg_reallocate (&__po_hi_c_driver_serial_linux_poller_msg);
n = 0;
while (n < __PO_HI_MESSAGES_MAX_SIZE)
{
if (read (po_hi_c_driver_serial_fd_read, &(msg.content[n]), 1) != 1)
if (read (po_hi_c_driver_serial_fd_read, &(__po_hi_c_driver_serial_linux_poller_msg.content[n]), 1) != 1)
{
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Cannot read on socket !\n");
return;
......@@ -86,41 +86,31 @@ void __po_hi_c_driver_serial_linux_poller (const __po_hi_device_id dev_id)
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] read() returns %d\n", n);
/*
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Message: 0x");
for (ts = 0 ; ts < __PO_HI_MESSAGES_MAX_SIZE ; ts++)
{
__PO_HI_DEBUG_DEBUG ("%x", msg.content[ts]);
}
*/
__PO_HI_DEBUG_DEBUG ("\n");
swap_pointer = (unsigned long*) &msg.content[0];
swap_pointer = (unsigned long*) &__po_hi_c_driver_serial_linux_poller_msg.content[0];
swap_value = *swap_pointer;
*swap_pointer = __po_hi_swap_byte (swap_value);
msg.length = n;
__po_hi_c_driver_serial_linux_poller_msg.length = n;
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Message after swapped port: 0x");
for (ts = 0 ; ts < msg.length ; ts++)
for (ts = 0 ; ts < __po_hi_c_driver_serial_linux_poller_msg.length ; ts++)
{
__PO_HI_DEBUG_DEBUG ("%x", msg.content[ts]);
__PO_HI_DEBUG_DEBUG ("%x", __po_hi_c_driver_serial_linux_poller_msg.content[ts]);
}
__PO_HI_DEBUG_DEBUG ("\n");
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Received: %s\n", msg.content);
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Received: %s\n", __po_hi_c_driver_serial_linux_poller_msg.content);
__po_hi_unmarshall_request (&request, &msg);
__po_hi_unmarshall_request (&__po_hi_c_driver_serial_linux_request, &__po_hi_c_driver_serial_linux_poller_msg);
if (request.port > __PO_HI_NB_PORTS)
if (__po_hi_c_driver_serial_linux_request.port > __PO_HI_NB_PORTS)
{
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Invalid port number !\n");
return;
}
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Destination port: %d\n", request.port);
__po_hi_main_deliver (&request);
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] Destination port: %d\n", __po_hi_c_driver_serial_linux_request.port);
__po_hi_main_deliver (&__po_hi_c_driver_serial_linux_request);
}
#endif
......@@ -313,16 +303,17 @@ void __po_hi_c_driver_serial_linux_init (__po_hi_device_id id)
#if defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_SENDER)
__po_hi_msg_t __po_hi_c_driver_serial_linux_sender_msg;
int __po_hi_c_driver_serial_linux_sender (__po_hi_task_id task_id, __po_hi_port_t port)
{
int n;
int ts;
unsigned long* swap_pointer;
unsigned long swap_value;
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_msg_t msg;
__po_hi_port_t destination_port;
int n;
int ts;
unsigned long* swap_pointer;
unsigned long swap_value;
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_port_t destination_port;
local_port = __po_hi_get_local_port_from_global_port (port);
......@@ -336,14 +327,14 @@ int __po_hi_c_driver_serial_linux_sender (__po_hi_task_id task_id, __po_hi_port
destination_port = __po_hi_gqueue_get_destination (task_id, local_port, 0);
__po_hi_msg_reallocate (&msg);
__po_hi_msg_reallocate (&__po_hi_c_driver_serial_linux_sender_msg);
request->port = destination_port;
__po_hi_marshall_request (request, &msg);
__po_hi_marshall_request (request, &__po_hi_c_driver_serial_linux_sender_msg);
/* Swap only the port (first 32 bytes) */
swap_pointer = (unsigned long*) &msg.content[0];
swap_pointer = (unsigned long*) &__po_hi_c_driver_serial_linux_sender_msg.content[0];
swap_value = *swap_pointer;
*swap_pointer = __po_hi_swap_byte (swap_value);
......@@ -352,21 +343,21 @@ int __po_hi_c_driver_serial_linux_sender (__po_hi_task_id task_id, __po_hi_port
printf("Wait %u between two sends\n", po_hi_c_driver_serial_sending_wait);
for (n = 0 ; n < __PO_HI_MESSAGES_MAX_SIZE ; n++)
{
write (po_hi_c_driver_serial_fd_write, &(msg.content[n]), 1);
write (po_hi_c_driver_serial_fd_write, &(__po_hi_c_driver_serial_linux_sender_msg.content[n]), 1);
usleep (po_hi_c_driver_serial_sending_wait);
}
}
else
{
n = write (po_hi_c_driver_serial_fd_write, &msg, __PO_HI_MESSAGES_MAX_SIZE);
n = write (po_hi_c_driver_serial_fd_write, &__po_hi_c_driver_serial_linux_sender_msg, __PO_HI_MESSAGES_MAX_SIZE);
}
__PO_HI_DEBUG_DEBUG ("[LINUX SERIAL] write() returns %d, message sent: 0x", n);
for (ts = 0 ; ts < __PO_HI_MESSAGES_MAX_SIZE ; ts++)
{
__PO_HI_DEBUG_DEBUG ("%x", msg.content[ts]);
__PO_HI_DEBUG_DEBUG ("%x", __po_hi_c_driver_serial_linux_sender_msg.content[ts]);
}
__PO_HI_DEBUG_DEBUG ("\n");
......
......@@ -39,17 +39,15 @@
#define __PO_HI_NEED_DRIVER_1553_RASTA_MSG_CNT 4
__po_hi_c_driver_rasta_1553_brm_t po_hi_c_driver_1553_rasta_fd;
__po_hi_c_driver_rasta_1553_brm_t po_hi_c_driver_1553_rasta_fd;
__po_hi_request_t po_hi_c_driver_1553_rasta_request;
__po_hi_msg_t __po_hi_c_driver_1553_rasta_terminal_poller_msg;
void __po_hi_c_driver_1553_rasta_terminal_poller (void)
{
int ret;
int msglen;
__po_hi_msg_t msg;
__po_hi_request_t request;
struct rt_msg msgs[__PO_HI_NEED_DRIVER_1553_RASTA_MSG_CNT];
int ret;
int msglen;
struct rt_msg msgs[__PO_HI_NEED_DRIVER_1553_RASTA_MSG_CNT];
__DEBUGMSG ("[RASTA 1553] Hello, i'm the poller !\n");
......@@ -82,12 +80,12 @@ void __po_hi_c_driver_1553_rasta_terminal_poller (void)
msglen = (msgs[0].miw >> 11) & 0x1f;
memcpy (&msg, msgs[0].data, __PO_HI_MESSAGES_MAX_SIZE);
memcpy (&__po_hi_c_driver_1553_rasta_terminal_poller_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;
uint32_t* toto = (uint32_t*) &__po_hi_c_driver_1553_rasta_terminal_poller_msg;
for (i = 0 ; i < __PO_HI_MESSAGES_MAX_SIZE ; i++)
{
printf("%x", toto[i]);
......@@ -97,13 +95,15 @@ void __po_hi_c_driver_1553_rasta_terminal_poller (void)
}
__po_hi_unmarshall_request (&request, &msg);
__po_hi_unmarshall_request (&po_hi_c_driver_1553_rasta_request, &__po_hi_c_driver_1553_rasta_terminal_poller_msg);
__DEBUGMSG ("[RASTA 1553] Destination port: %d\n", request.port);
__DEBUGMSG ("[RASTA 1553] Destination port: %d\n", po_hi_c_driver_1553_rasta_request.port);
__po_hi_main_deliver (&request);
__po_hi_main_deliver (&po_hi_c_driver_1553_rasta_request);
}
__po_hi_msg_t __po_hi_c_driver_1553_rasta_sender_terminal_msg;
int __po_hi_c_driver_1553_rasta_sender_terminal (const __po_hi_task_id task_id, const __po_hi_port_t port)
{
int ts;
......@@ -112,7 +112,6 @@ int __po_hi_c_driver_1553_rasta_sender_terminal (const __po_hi_task_id task_id,
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_msg_t msg;
__po_hi_port_t destination_port;
......@@ -122,13 +121,13 @@ int __po_hi_c_driver_1553_rasta_sender_terminal (const __po_hi_task_id task_id,
destination_port = __po_hi_gqueue_get_destination (task_id, local_port, 0);
__po_hi_msg_reallocate (&msg);
__po_hi_msg_reallocate (&__po_hi_c_driver_1553_rasta_sender_terminal_msg);
request->port = destination_port;
__po_hi_marshall_request (request, &msg);
__po_hi_marshall_request (request, &__po_hi_c_driver_1553_rasta_sender_terminal_msg);
memcpy (msgs[0].data, &msg, __PO_HI_MESSAGES_MAX_SIZE);
memcpy (msgs[0].data, &__po_hi_c_driver_1553_rasta_sender_terminal_msg, __PO_HI_MESSAGES_MAX_SIZE);
msgs[0].miw = 0;
msgs[0].miw |= (__PO_HI_MESSAGES_MAX_SIZE / 8) << 11;
......@@ -147,7 +146,7 @@ int __po_hi_c_driver_1553_rasta_sender_terminal (const __po_hi_task_id task_id,
for (ts = 0 ; ts < __PO_HI_MESSAGES_MAX_SIZE ; ts++)
{
__DEBUGMSG ("%x", msg.content[ts]);
__DEBUGMSG ("%x", __po_hi_c_driver_1553_rasta_sender_terminal_msg.content[ts]);
}
__DEBUGMSG ("\n");
......@@ -155,6 +154,7 @@ int __po_hi_c_driver_1553_rasta_sender_terminal (const __po_hi_task_id task_id,
}
__po_hi_msg_t __po_hi_c_driver_1553_rasta_sender_controller_msg;
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];
......@@ -170,7 +170,6 @@ int __po_hi_c_driver_1553_rasta_sender_controller (const __po_hi_task_id task_id
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_msg_t msg;
__po_hi_port_t destination_port;
......@@ -180,13 +179,13 @@ int __po_hi_c_driver_1553_rasta_sender_controller (const __po_hi_task_id task_id
destination_port = __po_hi_gqueue_get_destination (task_id, local_port, 0);
__po_hi_msg_reallocate (&msg);
__po_hi_msg_reallocate (&__po_hi_c_driver_1553_rasta_sender_controller_msg);
request->port = destination_port;
__po_hi_marshall_request (request, &msg);
__po_hi_marshall_request (request, &__po_hi_c_driver_1553_rasta_sender_controller_msg);
memcpy (msgs[0].data, &msg, __PO_HI_MESSAGES_MAX_SIZE);
memcpy (msgs[0].data, &__po_hi_c_driver_1553_rasta_sender_controller_msg, __PO_HI_MESSAGES_MAX_SIZE);
/*
{
......
......@@ -53,6 +53,8 @@
int po_hi_c_driver_rasta_serial_fd_read[__PO_HI_NB_DEVICES];
int po_hi_c_driver_rasta_serial_fd_write[__PO_HI_NB_DEVICES];
__po_hi_request_t __po_hi_c_driver_serial_rasta_request;
__po_hi_msg_t __po_hi_c_driver_serial_rasta_poller_msg;
/*!
* \fn void __po_hi_c_driver_serial_rasta_poller (const __po_hi_device_id dev_id)
......@@ -70,12 +72,10 @@ void __po_hi_c_driver_serial_rasta_poller (const __po_hi_device_id dev_id)
int n;
int ts;
uint8_t* ptr;
__po_hi_request_t request;
__po_hi_msg_t msg;
ts = __PO_HI_MESSAGES_MAX_SIZE;
ptr = &(msg.content[0]);
__po_hi_msg_reallocate (&msg);
ptr = &(__po_hi_c_driver_serial_rasta_poller_msg.content[0]);
__po_hi_msg_reallocate (&__po_hi_c_driver_serial_rasta_poller_msg);
while (ts > 0)
{
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Poller waits for incoming message (%d bytes are required)!\n", ts);
......@@ -94,16 +94,16 @@ void __po_hi_c_driver_serial_rasta_poller (const __po_hi_device_id dev_id)
}
}
msg.length = __PO_HI_MESSAGES_MAX_SIZE;
__po_hi_c_driver_serial_rasta_poller_msg.length = __PO_HI_MESSAGES_MAX_SIZE;
__po_hi_unmarshall_request (&request,
&msg);
__po_hi_unmarshall_request (&__po_hi_c_driver_serial_rasta_request,
&__po_hi_c_driver_serial_rasta_poller_msg);
if (request.port > __PO_HI_NB_PORTS)
if (__po_hi_c_driver_serial_rasta_request.port > __PO_HI_NB_PORTS)
{
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Invalid port number (%d), will not deliver", request.port);
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Invalid port number (%d), will not deliver", __po_hi_c_driver_serial_rasta_request.port);
}
__po_hi_main_deliver (&request);
__po_hi_main_deliver (&__po_hi_c_driver_serial_rasta_request);
}
extern amba_confarea_type* __po_hi_driver_rasta_common_get_bus ();
......@@ -216,6 +216,9 @@ void __po_hi_c_driver_serial_rasta_init (__po_hi_device_id id)
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Initialization complete !\n");
}
__po_hi_msg_t __po_hi_c_driver_serial_rasta_sender_msg;
/*!
* \fn int __po_hi_c_driver_serial_rasta_sender (const __po_hi_task_id task_id, const __po_hi_port_t port)
* \brief Function related to the RASTA serial driver - sender function.
......@@ -236,7 +239,6 @@ int __po_hi_c_driver_serial_rasta_sender (const __po_hi_task_id task_id, const _
int ts;
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_msg_t msg;
__po_hi_port_t destination_port;
__po_hi_device_id dev_id;
......@@ -260,14 +262,14 @@ int __po_hi_c_driver_serial_rasta_sender (const __po_hi_task_id task_id, const _
destination_port = __po_hi_gqueue_get_destination (task_id, local_port, 0);
__po_hi_msg_reallocate (&msg);
__po_hi_msg_reallocate (&__po_hi_c_driver_serial_rasta_sender_msg);
request->port = destination_port;
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Destination port= %d, send through device %d (fd=%d)\n", destination_port, dev_id, po_hi_c_driver_rasta_serial_fd_write[dev_id]);
__po_hi_marshall_request (request, &msg);
__po_hi_marshall_request (request, &__po_hi_c_driver_serial_rasta_sender_msg);
n = write (po_hi_c_driver_rasta_serial_fd_write[dev_id], &msg, __PO_HI_MESSAGES_MAX_SIZE);
n = write (po_hi_c_driver_rasta_serial_fd_write[dev_id], &__po_hi_c_driver_serial_rasta_sender_msg, __PO_HI_MESSAGES_MAX_SIZE);
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] write() returns %d\n", n);
......
......@@ -45,8 +45,9 @@
#define __PO_HI_DRIVER_SPACEWIRE_RASTA_DEVICE "/dev/grspwrasta0"
int po_hi_c_driver_rasta_spacewire_fd[__PO_HI_NB_DEVICES];
__po_hi_request_t __po_hi_c_driver_spacewire_rasta_request;
__po_hi_msg_t __po_hi_c_driver_spacewire_rasta_poller_msg;
int po_hi_c_driver_rasta_spacewire_fd[__PO_HI_NB_DEVICES];
void __po_hi_c_driver_spacewire_rasta_poller (const __po_hi_device_id dev_id)
{
......@@ -54,15 +55,13 @@ void __po_hi_c_driver_spacewire_rasta_poller (const __po_hi_device_id dev_id)
int j;
int ts;
__po_hi_msg_t msg;
__po_hi_request_t request;
__PO_HI_DEBUG_DEBUG ("[RASTA SPACEWIRE] Hello, i'm the spacewire poller !\n");
__po_hi_msg_reallocate (&msg);
__po_hi_msg_reallocate (&__po_hi_c_driver_spacewire_rasta_poller_msg);
len = read (po_hi_c_driver_rasta_spacewire_fd[dev_id],
&msg.content[0],
&__po_hi_c_driver_spacewire_rasta_poller_msg.content[0],
__PO_HI_MESSAGES_MAX_SIZE);
__PO_HI_DEBUG_DEBUG ("[RASTA SPACEWIRE] Poller received a message, len=%d\n", len);
......@@ -76,16 +75,16 @@ void __po_hi_c_driver_spacewire_rasta_poller (const __po_hi_device_id dev_id)
__PO_HI_DEBUG_DEBUG ("Message content: |0x");
for (ts = 0 ; ts < __PO_HI_MESSAGES_MAX_SIZE ; ts++)
{
__PO_HI_DEBUG_DEBUG ("%x", msg.content[ts]);
__PO_HI_DEBUG_DEBUG ("%x", __po_hi_c_driver_spacewire_rasta_poller_msg.content[ts]);
}
__PO_HI_DEBUG_DEBUG ("|\n");
msg.length = __PO_HI_MESSAGES_MAX_SIZE;
__po_hi_unmarshall_request (&request, &msg);
__po_hi_c_driver_spacewire_rasta_poller_msg.length = __PO_HI_MESSAGES_MAX_SIZE;
__po_hi_unmarshall_request (&__po_hi_c_driver_spacewire_rasta_request, &__po_hi_c_driver_spacewire_rasta_poller_msg);
__PO_HI_DEBUG_DEBUG ("[RASTA SPACEWIRE] Destination port: %d\n", request.port);
__po_hi_main_deliver (&request);
__PO_HI_DEBUG_DEBUG ("[RASTA SPACEWIRE] Destination port: %d\n", __po_hi_c_driver_spacewire_rasta_request.port);
__po_hi_main_deliver (&__po_hi_c_driver_spacewire_rasta_request);
}
}
......@@ -150,13 +149,15 @@ void __po_hi_c_driver_spacewire_rasta_init (__po_hi_device_id id)
perror ("spw start");
}
__po_hi_msg_t __po_hi_c_driver_spacewire_rasta_sender_msg;
int __po_hi_c_driver_spacewire_rasta_sender (const __po_hi_task_id task_id, const __po_hi_port_t port)
{
int len = -1;
int i;