*
* @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_DATA_H_
#define _MARTE_FRESCAN_DATA_H_
-#include <stdint.h> // uint32_t
-#include <semaphore.h> // sem_t
-#include <time.h> // struct timespec, timer_t
-#include "fosa_threads_and_signals.h" // fosa_thread_id_t
-
-#include <misc/linux_list.h> // struct list_head
-#include <misc/freelist.h> // freelist_t
-
-#include "frescan.h" // frescan_node_t, _prio_t, _budget_t
+#include "frescan_types.h" // frescan_node_t, _prio_t, _budget_t
#include "frescan_config.h" // FRESCAN_MLOCK_T, FRESCAN_MX_XXX
-#include "frescan_packets.h" // frescan_packet_t
-#include "frescan_servers_replenishments.h" // frescan_repl_op_t
-
-/**
- * frescan_repl_op_t - a replenishment operation
- *
- * @when: when the replenishment operation is programmed at
- * @amount: number of frames to add to the current_budget
- * @repl_list: to chain the replenishments for a certain sporadic server
- * @pool_pos: to know how to free it from the replenishment pool
- */
-
-typedef struct {
- struct timespec when;
- frescan_budget_t amount;
- struct list_head repl_list;
- int pool_pos;
-} frescan_repl_op_t;
-
-/**
- * frescan_server_params_t - server parameters
- *
- * @budget: the budget in CAN 8-byte frames
- * @period: the replenishment period for the server
- * @prio: the priority for the server TODO: this should be a return value
- */
-
-typedef struct {
- frescan_budget_t budget;
- struct timespec period;
- frescan_prio_t prio;
-} frescan_server_params_t;
-
-/**
- * frescan_server_data_t - server data
- *
- * @params: the fixed parameters (budget, period and priority)
- * @current_budget: the current available capacity
- * @current_priority: the current priority (0=background)
- * @repl_list: the list of pending replenishment operations
- * @repl_timer: the timer for the replenishments associated to this server
- * NOTE: we could use a single timer for all but for now this is simpler
- * @packet_list: the packets enqueued on this server
- */
-
-typedef struct {
- frescan_server_params_t params;
- frescan_network_t net;
- frescan_ss_t id;
- frescan_budget_t current_budget;
- frescan_prio_t current_priority;
- frescan_budget_t pending_packets;
- frescan_repl_op_t replenishments;
- timer_t repl_timer;
- frescan_packet_t packet_list;
- struct list_head servers_list;
-} frescan_server_data_t;
-
-/**
- * the_servers_pool - pool of servers structure
- */
-
-extern frescan_server_data_t the_servers_pool[FRESCAN_MX_NETWORKS][FRESCAN_MX_IDS];
-extern freelist_t the_servers_pool_freelist[FRESCAN_MX_NETWORKS];
-extern frescan_server_data_t the_active_servers[FRESCAN_MX_NETWORKS];
-
-/**
- * frescan_contract_t
- */
-typedef struct {
- frescan_budget_t max_budget;
- struct timespec min_period;
- frescan_budget_t min_budget;
- struct timespec max_period;
- frescan_prio_t prio;
-} frescan_contract_t;
-
-/**
- * frescan_prio_queue_t - priority queue
- *
- * FRESCAN priority queues are implemented as an array of one 'fifo_queue' for
- * each priority. Where the 'fifo_queues' are implemented using the
- * 'struct list_head fifo_list;' field of each packet structure (Linux lists).
- *
- * So far mutual exclusion is achieved by disabling interrupts and
- * synchronization is done using a semaphore. This is because the queues
- * are accesed concurrently from user threads and the IRQ handler.
- *
- * @fifo_queues: an array of packets for each priority where each packet
- * is just the head of a fifo_list. The array is allocated
- * from the heap, using malloc, at initialization with range
- * 0..max_prio-1
- * @max_prio: defines the number of priorities as (0 .. max_prio - 1)
- * @sem: semaphore used for synchronization
- */
-
-typedef struct {
- frescan_packet_t *fifo_queues;
- uint32_t max_prio;
- sem_t sem;
-} frescan_prio_queue_t;
-
-/**
- * frescan_queues_t - the set of FRESCAN queues for each instance of a protocol
- *
- * @tx_fp_queue: priority queue for the fixed priority packets
- * @rx_channel_queues: a priority queue for each receiving channel
- *
- * TODO: add here the sporadic server queues...
- */
-
-typedef struct {
- frescan_prio_queue_t *tx_fp_queue;
- frescan_prio_queue_t **rx_channel_queues;
- uint32_t num_rx_channels;
-} frescan_queues_t;
-
-/**
- * frescan_network_data_t - data for each network instance
- *
- * @local_node: the local node id for that network. The implementation does not
- * support several interfaces for the same network.
- * @fd: file descriptor associated to /dev/canXX
- * @queues: the queues of this network instance
- * @last_packet: pointer to the last packet from which a frame was inserted
- * in the chip and its transmission is not complete.
- * @last_packet_prio: prio of the packet in the buffer
- * @id_queues: queues to store received packets while the whole message is
- * not complete (fragmentation). (id = 0 .. FRESCAN_MX_IDS - 1)
- * @id_fp_queues: the same as id_queues but for fp messages, which have
- * id=FRESCAN_MX_IDS and are distinguised through their
- * priorities.
- *
- * the implementation can handle several FRESCAN networks at the same time
- * in the same node, so we need a place to store its internal data. The data
- * is allocated as an array where the index is the MINOR number (which also
- * identifies the /dev/canx device for that network)
- */
-
-typedef struct {
- FRESCAN_MLOCK_T lock;
- frescan_node_t local_node;
- int fd;
- fosa_thread_id_t repl_thread_id;
- fosa_thread_id_t neg_thread_id;
- frescan_queues_t queues;
- frescan_packet_t *last_packet;
- frescan_prio_t last_packet_prio;
- frescan_packet_t *id_queues[FRESCAN_MX_IDS]; // TODO: alloc at init
- frescan_packet_t *id_fp_queues[FRESCAN_MX_PRIOS]; // TODO: alloc at init
-} frescan_network_data_t;
-
-extern frescan_network_data_t the_networks[FRESCAN_MX_NETWORKS];
-
-/**
- * frescan_data_init() - init the data global variables
- *
- */
+extern frescan_network_data_t frescan_data[FRESCAN_MX_NETWORKS];
extern int frescan_data_init(int fd, frescan_init_params_t *params);
-
-
#endif // _MARTE_FRESCAN_DATA_H_