*
* @license
*
- * See MaRTE OS license
+ * -----------------------------------------------------------------------
+ * Copyright (C) 2006 - 2008 FRESCOR consortium partners:
+ *
+ * Universidad de Cantabria, SPAIN
+ * University of York, UK
+ * Scuola Superiore Sant'Anna, ITALY
+ * Kaiserslautern University, GERMANY
+ * Univ. Politécnica Valencia, SPAIN
+ * Czech Technical University in Prague, CZECH REPUBLIC
+ * ENEA SWEDEN
+ * Thales Communication S.A. FRANCE
+ * Visual Tools S.A. SPAIN
+ * Rapita Systems Ltd UK
+ * Evidence ITALY
+ *
+ * See http://www.frescor.org for a link to partners' websites
+ *
+ * FRESCOR project (FP6/2005/IST/5-034026) is funded
+ * in part by the European Union Sixth Framework Programme
+ * The European Union is not liable of any use that may be
+ * made of this code.
+ *
+ * This file is part of FRESCAN
+ *
+ * FRESCAN is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * FRESCAN is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * distributed with FRESCAN; see file COPYING. If not, write to the
+ * Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * As a special exception, including FRESCAN header files in a file,
+ * instantiating FRESCAN generics or templates, or linking other files
+ * with FRESCAN objects to produce an executable application, does not
+ * by itself cause the resulting executable application to be covered
+ * by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be
+ * covered by the GNU Public License.
+ * -----------------------------------------------------------------------
*
*/
-#ifndef _MARTE_FRESCAN_PACKETS_H_
-#define _MARTE_FRESCAN_PACKETS_H_
+#ifndef _FRESCAN_PACKETS_H_
+#define _FRESCAN_PACKETS_H_
-#include <time.h> // struct timespec
-#include <stdint.h> // uint8_t ...
-#include "frescan.h" // frescan_flags_t
-#include <misc/linux_list.h> // struct list_head
-#include <drivers/can.h> // can_frame_t
-
-/**
- * frescan_packet_t - a frescan packet
- *
- * This structure is very important and it is used to store a FRESCAN packet.
- * As we support fragmentation, a FRESCAN packet can be composed of several
- * CAN frames. This 'frescan_packet_t' structure is used in two main cases:
- *
- * 1.- When we are sending data. In this case, the buffer pointers store the
- * real data we want to sent and we use a 'buffer_read_pointer' to know
- * how many bytes of the buffer we already sent. In 'frame', we store the
- * last sent frame (with the corresponding CAN id fields). We will have
- * to update the fragmentation fields as long as we send more packets.
- * The 'fifo_list' is used to chained frescan packets of the same priority
- * or that belong to the same sporadic server. Finally, 'flags', specify
- * if we are sending ASYNC or SYNC. If we are sending SYNC the buffer
- * pointers are pointing to the buffer sent by the user (zero copying),
- * while if we use ASYNC, a copy of the data is done to the buffer.
- *
- * 2.- When we are receiving data, we only use 'frame' and 'fifo_list' fields.
- * The IRQ handler of the chip allocates a CAN frame and calls to our hook.
- * We store the pointer to that frame in 'frame' and we make a chain with
- * frames of the same message (using the fragmentation fields). When we
- * have all of them, we move the packet list to the corresponding
- * receiving channel to wait for the user to perform a receive operation
- * when we will copy the data and free both the packets and the frames.
- *
- * @flags: to know if the packet is to be sent SYNC or ASYNC, FP or SERVER...
- * @frame: pointer to the last sent frame or the received frame
- * @fifo_list: list to put several packets together
- * @msg_list: list to put packets of the same message together
- * @buffer_head: pointer to first byte of the buffer that is going to be sent
- * @buffer_read_pointer: pointer to the part of the buffer being read
- * @buffer_pending_bytes: bytes waiting to be sent
- * @timestamp: time when the packet was enqueued (activation time)
- * @pool_pos: position in the packets pool to know how to free it
- *
- * NOTE: the buffers could also be used on the receiving part to support
- * sequential reads, instead of reading the whole message at once.
- *
- */
-
-typedef struct {
- frescan_flags_t flags;
- struct can_frame_t *frame;
- struct list_head fifo_list;
- struct list_head msg_list;
- uint8_t *buffer_head; // only for sending packets
- uint8_t *buffer_read_pointer; // only for sending packets
- uint32_t buffer_pending_bytes; // only for sending packets
- struct timespec timestamp;
- int pool_pos;
-} frescan_packet_t;
-
-#define FRESCAN_MX_PACKETS 100
-
-/**
- * frescan_packets_init
- *
- * Initializes a pool of packets that will be managed internally
- */
+#include "frescan_types.h"
extern int frescan_packets_init();
-
-/**
- * frescan_packets_alloc
- *
- * Allocates a frame from the pool of packets. On error it returns NULL
- */
-
extern frescan_packet_t *frescan_packets_alloc();
-
-/**
- * frescan_packets_free
- *
- * Frees a frame and returns it to the pool of packets.
- */
-
extern int frescan_packets_free(frescan_packet_t *packet);
-#endif // _MARTE_FRESCAN_PACKETS_H_
+#endif // _FRESCAN_PACKETS_H_