summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/plcdrv
diff options
context:
space:
mode:
authorCyril Jourdan2011-12-09 14:52:11 +0100
committerNicolas Schodet2012-02-10 15:33:49 +0100
commit89328e8cc096f8c9f340a3eb8910d06748a3e572 (patch)
treebc38232bc82f639a80b917d739740b3d9608c03e /cleopatre/devkit/plcdrv
parentc0199c330baadc6a8089a1db26b3ec7f76734b2b (diff)
cleo/devkit/plcdrv: remove gidel and move arm dir content to plcdrv, refs #848
Diffstat (limited to 'cleopatre/devkit/plcdrv')
-rw-r--r--cleopatre/devkit/plcdrv/.gitignore (renamed from cleopatre/devkit/plcdrv/arm/.gitignore)0
-rw-r--r--cleopatre/devkit/plcdrv/Makefile (renamed from cleopatre/devkit/plcdrv/arm/Makefile)4
-rw-r--r--cleopatre/devkit/plcdrv/Module (renamed from cleopatre/devkit/plcdrv/arm/Module)0
-rw-r--r--cleopatre/devkit/plcdrv/gidel/Makefile32
-rw-r--r--cleopatre/devkit/plcdrv/gidel/inc/common.h72
-rw-r--r--cleopatre/devkit/plcdrv/gidel/inc/hal.h197
-rw-r--r--cleopatre/devkit/plcdrv/gidel/inc/mailbox.h56
-rw-r--r--cleopatre/devkit/plcdrv/gidel/inc/plc_drv.h43
-rw-r--r--cleopatre/devkit/plcdrv/gidel/inc/processing.h52
-rw-r--r--cleopatre/devkit/plcdrv/gidel/src/hal.cpp869
-rw-r--r--cleopatre/devkit/plcdrv/gidel/src/mailbox.c465
-rw-r--r--cleopatre/devkit/plcdrv/gidel/src/plc_drv.c498
-rw-r--r--cleopatre/devkit/plcdrv/gidel/src/processing.c204
-rw-r--r--cleopatre/devkit/plcdrv/inc/boot_params.h (renamed from cleopatre/devkit/plcdrv/arm/inc/boot_params.h)0
-rw-r--r--cleopatre/devkit/plcdrv/inc/common.h (renamed from cleopatre/devkit/plcdrv/arm/inc/common.h)0
-rw-r--r--cleopatre/devkit/plcdrv/inc/hal.h (renamed from cleopatre/devkit/plcdrv/arm/inc/hal.h)0
-rw-r--r--cleopatre/devkit/plcdrv/inc/linux_drv.h (renamed from cleopatre/devkit/plcdrv/arm/inc/linux_drv.h)0
-rw-r--r--cleopatre/devkit/plcdrv/inc/mailbox.h (renamed from cleopatre/devkit/plcdrv/arm/inc/mailbox.h)0
-rw-r--r--cleopatre/devkit/plcdrv/inc/processing.h (renamed from cleopatre/devkit/plcdrv/arm/inc/processing.h)0
-rw-r--r--cleopatre/devkit/plcdrv/inc/registers.h (renamed from cleopatre/devkit/plcdrv/arm/inc/registers.h)0
-rw-r--r--cleopatre/devkit/plcdrv/src/boot_params.c (renamed from cleopatre/devkit/plcdrv/arm/src/boot_params.c)0
-rw-r--r--cleopatre/devkit/plcdrv/src/hal.c (renamed from cleopatre/devkit/plcdrv/arm/src/hal.c)0
-rw-r--r--cleopatre/devkit/plcdrv/src/linux_drv.c (renamed from cleopatre/devkit/plcdrv/arm/src/linux_drv.c)0
-rw-r--r--cleopatre/devkit/plcdrv/src/mailbox.c (renamed from cleopatre/devkit/plcdrv/arm/src/mailbox.c)0
-rw-r--r--cleopatre/devkit/plcdrv/src/processing.c (renamed from cleopatre/devkit/plcdrv/arm/src/processing.c)0
25 files changed, 2 insertions, 2490 deletions
diff --git a/cleopatre/devkit/plcdrv/arm/.gitignore b/cleopatre/devkit/plcdrv/.gitignore
index 21c5d41f8f..21c5d41f8f 100644
--- a/cleopatre/devkit/plcdrv/arm/.gitignore
+++ b/cleopatre/devkit/plcdrv/.gitignore
diff --git a/cleopatre/devkit/plcdrv/arm/Makefile b/cleopatre/devkit/plcdrv/Makefile
index 1e4286bcb1..60900c5bd7 100644
--- a/cleopatre/devkit/plcdrv/arm/Makefile
+++ b/cleopatre/devkit/plcdrv/Makefile
@@ -1,5 +1,5 @@
-BASEPATH=../../..
-PLCSUBPATH=devkit/plcdrv/arm
+BASEPATH=../..
+PLCSUBPATH=devkit/plcdrv/
PLCPATH=$(BASEPATH)/$(PLCSUBPATH)
KRNPATH=$(BASEPATH)/linux-2.6.25.10-spc300
DEBUG = n
diff --git a/cleopatre/devkit/plcdrv/arm/Module b/cleopatre/devkit/plcdrv/Module
index d644569e21..d644569e21 100644
--- a/cleopatre/devkit/plcdrv/arm/Module
+++ b/cleopatre/devkit/plcdrv/Module
diff --git a/cleopatre/devkit/plcdrv/gidel/Makefile b/cleopatre/devkit/plcdrv/gidel/Makefile
deleted file mode 100644
index a931ff8b50..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-BASE := $(CURDIR)/../../..
-OBJPATH := ./obj
-GIDEL_LIBPATH := $(BASE)/devkit/hal/gidel
-INC_GIDEL_LIBPATH := $(GIDEL_LIBPATH)
-###################################################
-
-# Common stuff
-CC := g++
-CFLAGS := -Wall -g3 -DLINUX -I. -I./inc -I$(INC_GIDEL_LIBPATH)
-LIBS := -L$(GIDEL_LIBPATH) -lgidel -lgidelproc
-export LD_LIBRARY_PATH=\$$LD_LIBRARY_PATH:$(GIDEL_LIBPATH)
-
-# Rules
-all: $(GIDEL_LIBPATH)/libgidel.so
- mkdir -p $(OBJPATH)
- $(MAKE) $(OBJPATH)/plcdrv
-
-$(GIDEL_LIBPATH)/libgidel.so:
- $(MAKE) -C $(GIDEL_LIBPATH)
-
-$(OBJPATH)/plcdrv : $(OBJPATH)/mailbox.o $(OBJPATH)/hal.o $(OBJPATH)/processing.o $(OBJPATH)/plc_drv.o
- $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
-
-$(OBJPATH)/%.o : ./src/%.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(OBJPATH)/%.o : ./src/%.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-clean :
- rm -rf $(OBJPATH)
-
diff --git a/cleopatre/devkit/plcdrv/gidel/inc/common.h b/cleopatre/devkit/plcdrv/gidel/inc/common.h
deleted file mode 100644
index b141843438..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/inc/common.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef common_h
-#define common_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file common.h
- * \brief common includes.
- * \ingroup Cleopatre - Isis
- *
- * include all structure, define and variables used by all layers.
- */
-
-#include <stdint.h>
-
-/** Debug mode */
-#ifdef DEBUG
-#define TRACE printf
-#else
-#define TRACE(...)
-#endif
-
-/** Size of each ethernet frame allocation */
-#define ETH_MAX_SIZE 1522 //WARNING: must be align on 32bits
-
-/** Define Error Code */
-#define SUCCESS 0
-#define NOT_FULL 0
-#define ERROR -1
-#define NEARLY_FULL -2
-#define FULL -3
-#define DROP -4
-
-/** Initialization structure */
-struct init_info {
- char bin[260];
- char rbf[260];
- char tuntap_name[16];
- int nb_data_buf_alloc;
- int nb_mme_buf_alloc;
- int nb_interface_buf_alloc;
- void (*txack_handler)(void);
- int wait_debugger;
- int use_ext_clock;
-};
-
-/** type of buffer */
-enum buffer_type {
- DATA = 0,
- MME = 1,
- INTERFACE = 2,
-};
-
-/**
- * Swap a 32bits value.
- *
- * \param val value to swap.
- * \return the swaped value.
- */
-static inline uint32_t swap32(uint32_t val)
-{
- return (((uint32_t)((val & 0x000000FF) << 24)) |
- ((uint32_t)((val & 0x0000FF00) << 8)) |
- ((uint32_t)((val & 0x00FF0000) >> 8)) |
- ((uint32_t)((val & 0xFF000000) >> 24)));
-}
-
-#endif /* common_h */
diff --git a/cleopatre/devkit/plcdrv/gidel/inc/hal.h b/cleopatre/devkit/plcdrv/gidel/inc/hal.h
deleted file mode 100644
index 7244c03405..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/inc/hal.h
+++ /dev/null
@@ -1,197 +0,0 @@
-#ifndef hal_h
-#define hal_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal.h
- * \brief HAL layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * this layer provide all Hardware Abstraction:
- * registers, Gidel memory, interrupts.
- */
-
-#include "common.h"
-
-#ifdef __UTESTS__
-#include "hard_stub.h"
-#endif
-
-/** Precise which IT arrived */
-enum pending_its {
- NONE = 0,
- A2LA = 1,
- L2AT = 2,
- ALL = 3,
-};
-
-/**
- * Initialize the hal layer.
- *
- * \param init user information.
- * \param irq_handler interrupt handler for L->A.
- */
-void halmbx_init(struct init_info *init, void(*irq_handler)(void*));
-
-/**
- * UnInitialize the hal layer.
- */
-void halmbx_uninit(void);
-
-/**
- * Check if Leon to Arm mailbox queue is empty.
- *
- * \return 0 if the queue is empty.
- */
-int halmbx_L2Amail_not_empty_queue(void);
-
-/**
- * Check Arm to Leon mailbox queue status.
- *
- * \return queue state.
- */
-int halmbx_A2Lmail_status_queue(void);
-
-/**
- * Check Leon to Arm mailbox queue status.
- *
- * \return queue state.
- */
-int halmbx_L2Amail_status_queue(void);
-
-/**
- * Copy message from the Gidel Memory
- * to the PC Memory.
- *
- * \param message pointer to the message.
- * \param size message size in bytes.
- * \return address on the Gidel memory.
- */
-uint32_t halmbx_save_in_pc_memory(uint32_t *message, int size);
-
-/**
- * Free message space in the PC Memory.
- *
- * \param message pointer to the message.
- * \return error code.
- */
-int halmbx_free_in_pc_memory(uint32_t *message);
-
-/**
- * Copy message from the PC Memory
- * to the Gidel Memory.
- *
- * \param message pointer to the message.
- * \param size message size in bytes.
- * \return address on the Gidel memory.
- */
-uint32_t halmbx_save_in_gidel_memory(uint32_t *message, int size);
-
-/**
- * Alloc message space on the Gidel Memory.
- *
- * \return address on the Gidel memory.
- */
-uint32_t halmbx_alloc_in_gidel_memory(void);
-
-/**
- * Free message space in the Gidel Memory.
- *
- * \param message pointer to the message.
- * \return error code.
- */
-int halmbx_free_in_gidel_memory(uint32_t *message);
-
-/**
- * Copy message to the ring buffer.
- *
- * \param message pointer to the message align on 32bits.
- * \param size message size in bytes and align on 32bits.
- * \return error code.
- */
-int halmbx_copy_to_ring (uint32_t *message, int size);
-
-/**
- * Copy message from the ring buffer.
- *
- * \param message pointer to the message align on 32bits.
- * \param size max message size in bytes and align on 32bits.
- * \return error code.
- */
-int halmbx_copy_from_ring (uint32_t *message, int size);
-
-/**
- * Update the ring management for Leon to Arm mailbox (TX).
- *
- * \param size real size of the last proceed message.
- * \return error code.
- */
-int halmbx_A2Lmail_update (int size);
-
-/**
- * Update the ring management for Arm to Leon mailbox (RX).
- *
- * \param size real size of the last proceed message.
- * \return error code.
- */
-int halmbx_L2Amail_update (int size);
-
-/**
- * Enable the Arm to Leon Acknowledge Interrupt.
- */
-void A2La_it_enable(void);
-
-/**
- * Enable the Leon to Arm Trigger Interrupt.
- */
-void L2At_it_enable(void);
-
-/**
- * Disable the Arm to Leon Acknowledge Interrupt.
- */
-void A2La_it_disable(void);
-
-/**
- * Disable the Leon to Arm Trigger Interrupt.
- */
-void L2At_it_disable(void);
-
-/**
- * Set the Arm to Leon Interrupt.
- */
-void set_A2Lt_interrupt(void);
-
-/**
- * Set the Arm to Leon acknowledge Interrupt.
- */
-void set_L2Aa_interrupt(void);
-
-/**
- * Clear the Leon to Arm Interrupt.
- */
-void clr_L2At_interrupt(void);
-
-/**
- * Clear the Leon to Arm acknowledge Interrupt.
- */
-void clr_A2La_interrupt(void);
-
-/**
- * Disable the Leon to Arm Trigger Interrupt.
- *
- * \return waiting its.
- */
-enum pending_its check_its(void);
-
-
-uint32_t hal_ctrl_dsp_ss_read(uint32_t offset);
-int hal_ctrl_dsp_ss_write(uint32_t offset, uint32_t *value);
-uint32_t hal_afredi_memory_read(uint32_t offset);
-int hal_afredi_memory_write(uint32_t offset, uint32_t *value);
-
-#endif /* hal_h */
diff --git a/cleopatre/devkit/plcdrv/gidel/inc/mailbox.h b/cleopatre/devkit/plcdrv/gidel/inc/mailbox.h
deleted file mode 100644
index d48c1d40f1..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/inc/mailbox.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef mailbox_h
-#define mailbox_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file mailbox.h
- * \brief Mailbox layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * this layer provide all mechanisms to manage mailboxes.
- */
-
-#include "common.h"
-
-#define MAX_MSG_SIZE 12 //max size of a mailbox message in bytes
-
-/**
- * Initialize the mailbox layer.
- *
- * \param init user information.
- */
-void mailbox_init(struct init_info *init);
-
-/**
- * UnInitialize the mailbox layer.
- */
-void mailbox_uninit(void);
-
-/**
- * Send a message to the HLE layer.
- *
- * \param pointer the message pointer.
- * \param length the length of the message.
- * \param type type of message.
- * \return error code.
- */
-int mailbox_send(void *pointer, uint32_t length, enum buffer_type type);
-
-/**
- * Receive everything from the HLE layer.
- *
- * \return error code.
- */
-int mailbox_receive(void);
-
-
-#ifdef __UTESTS__
-int mailbox_buffer_add(enum buffer_type type);
-#endif
-
-#endif /* mailbox_h */
diff --git a/cleopatre/devkit/plcdrv/gidel/inc/plc_drv.h b/cleopatre/devkit/plcdrv/gidel/inc/plc_drv.h
deleted file mode 100644
index 8e57e2b112..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/inc/plc_drv.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef plc_drv_h
-#define plc_drv_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file plc_drv.h
- * \brief OS layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * For the Gidel prototype this layer only precise how to receive a packet
- * and what to do when we receive an acknowledge of a previous sending frame.
- */
-
-#include "common.h"
-
-/**
- * Receive a packet.
- *
- * \param pointer the packet pointer.
- * \param length the length of the packet.
- * \return error code.
- */
-int plcdrv_rx(void *pointer, int length);
-
-/**
- * Precedure executed when the frame is really sending to CESAR
- * and only when there are few buffer in the mailbox ring.
- */
-void plcdrv_tx_ack(void);
-
-
-#ifdef __UTESTS__
-int parse_args(struct init_info *init, int argc, char **argv);
-int create_tuntap(struct init_info *init);
-#endif
-
-
-#endif /* plc_drv_h */
diff --git a/cleopatre/devkit/plcdrv/gidel/inc/processing.h b/cleopatre/devkit/plcdrv/gidel/inc/processing.h
deleted file mode 100644
index ee986caca1..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/inc/processing.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef processing_h
-#define processing_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file processing.h
- * \brief Processing layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * this layer is used to check every packet received by CESAR or TUN/TAP
- * and sometime drop it.
- */
-
-#include "common.h"
-
-/**
- * Initialize the processing layer.
- *
- * \param init user information.
- */
-void processing_init(struct init_info *init);
-
-/**
- * UnInitialize the processing layer.
- */
-void processing_uninit(void);
-
-/**
- * Processing procedure for a A->L message.
- *
- * \param pointer packet pointer.
- * \param length length of the packet pointed.
- * \return status queue.
- */
-int processing_send (void *pointer, int length);
-
-/**
- * Processing procedure for a L->A message.
- *
- * \param pointer packet pointer.
- * \param length length of the packet pointed.
- * \param type type of message.
- * \return error code.
- */
-int processing_receive (void *pointer, int length, enum buffer_type type);
-
-#endif /* processing_h */
diff --git a/cleopatre/devkit/plcdrv/gidel/src/hal.cpp b/cleopatre/devkit/plcdrv/gidel/src/hal.cpp
deleted file mode 100644
index d12ddb3c13..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/src/hal.cpp
+++ /dev/null
@@ -1,869 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal.cpp
- * \brief HAL layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * this layer provide all Hardware Abstraction:
- * registers, Gidel memory, interrupts.
- */
-
-#include <fcntl.h>
-#include <vector>
-#include <iostream>
-using namespace std;
-
-#include "hal.h"
-
-#ifndef __UTESTS__
-#include "mailbox.h"
-#include "AHBMemory.h"
-#include "AHBRegister.h"
-#include "Gidel.h"
-#else
-#include "mailbox_stub.h"
-#endif
-
-#ifndef __UTESTS__
-/** Defines for Gidel memory and register */
-#define FPGA_NUM 1
-#define DEFAULT_RBF "/home/spidcom/Maria_proto/projects/Maria_Proto_11/modules/maria_proto/board/hardware/proto_maria_ddr/fpga.rbf"
-#define DEFAULT_BIN "/home/spidcom/cesar-proto/bin/loopback.bin"
-
-#define LEON_BASE_ADDR (0x00000000)
-#define DSU_CONFIG_ADDR (0x90000000)
-#define DSU_UNBREAK_MASK (0xFFFFFD7F)
-
-#define A2L_RING_BASE_ADDR (0x40500000)
-#define A2L_RING_SIZE (0x100)
-#define L2A_RING_BASE_ADDR (A2L_RING_BASE_ADDR + A2L_RING_SIZE)
-#define L2A_RING_SIZE (A2L_RING_SIZE)
-#define A2L_RING_MASK (A2L_RING_SIZE-1)
-#define L2A_RING_MASK (L2A_RING_SIZE-1)
-
-#define MAILBOX_REG_BASE_ADDR (0xB5000000)
-#define A2L_HEAD_ADDR (MAILBOX_REG_BASE_ADDR + 0x14)
-#define A2L_TAIL_ADDR (MAILBOX_REG_BASE_ADDR + 0x10)
-#define L2A_HEAD_ADDR (MAILBOX_REG_BASE_ADDR + 0x1C)
-#define L2A_TAIL_ADDR (MAILBOX_REG_BASE_ADDR + 0x18)
-#define A2L_IT_ADDR (MAILBOX_REG_BASE_ADDR + 0x00)
-#define L2A_IT_ADDR (MAILBOX_REG_BASE_ADDR + 0x08)
-#define L2A_IT_MASK_ADDR (MAILBOX_REG_BASE_ADDR + 0x0C)
-
-#define L2AT_EN_MASK (0x00000001)
-#define L2AA_EN_MASK (0x00000002)
-#define A2LT_MASK (0x00000001)
-#define A2LA_MASK (0x00000002)
-#define L2AT_MASK (0x00000001)
-#define L2AA_MASK (0x00000002)
-
-#define BUFFER_GIDEL_BASE_ADDR (0x40700000)
-#define MAX_GIDEL_BUFFER (0x100)
-
-/** Global variables for Gidel memory and registers*/
-CGidel *m_gidel = NULL;
-AHBMemoryPtr<uint32_t> *A2L_ptr = NULL;
-AHBMemoryPtr<uint32_t> *L2A_ptr = NULL;
-AHBRegister *A2L_head = NULL;
-AHBRegister *A2L_tail = NULL;
-AHBRegister *L2A_head = NULL;
-AHBRegister *L2A_tail = NULL;
-AHBRegister *A2L_it = NULL;
-AHBRegister *L2A_it = NULL;
-AHBRegister *L2A_it_mask = NULL;
-#else
-uint32_t A2L_ring[A2L_RING_SIZE];
-uint32_t L2A_ring[L2A_RING_SIZE];
-uint32_t *val_A2L_ptr = &A2L_ring[0];
-uint32_t *val_L2A_ptr = &L2A_ring[0];
-uint32_t **A2L_ptr = &val_A2L_ptr;
-uint32_t **L2A_ptr = &val_L2A_ptr;
-
-uint32_t val_A2L_head;
-uint32_t val_A2L_tail;
-uint32_t val_L2A_head;
-uint32_t val_L2A_tail;
-uint32_t val_A2L_it;
-uint32_t val_L2A_it;
-uint32_t val_L2A_it_mask;
-uint32_t *A2L_head = &val_A2L_head;
-uint32_t *A2L_tail = &val_A2L_tail;
-uint32_t *L2A_head = &val_L2A_head;
-uint32_t *L2A_tail = &val_L2A_tail;
-uint32_t *A2L_it = &val_A2L_it;
-uint32_t *L2A_it = &val_L2A_it;
-uint32_t *L2A_it_mask = &val_L2A_it_mask;
-
-uint32_t buffer_gidel[MAX_GIDEL_BUFFER][ETH_MAX_SIZE];
-#endif
-
-vector<uint32_t> free_buff_list;
-
-char path[256];
-
-uint32_t hal_ctrl_dsp_ss_read(uint32_t offset)
-{
-#ifndef __UTESTS__
- return m_gidel->m_CtrlDspSs.GetAt(offset);
-#else
- return 0;
-#endif
-}
-
-int hal_ctrl_dsp_ss_write(uint32_t offset, uint32_t *value)
-{
-#ifndef __UTESTS__
- m_gidel->m_CtrlDspSs.SetAt(offset, *value);
- if(*value == m_gidel->m_CtrlDspSs.GetAt(offset))
- {
- return 0;
- }
- else
- {
- *value = m_gidel->m_CtrlDspSs.GetAt(offset);
- return -1;
- }
-#else
- return 0;
-#endif
-}
-
-uint32_t hal_afredi_memory_read(uint32_t offset)
-{
-#ifndef __UTESTS__
- return (m_gidel->m_AfrediMemory.GetAt(offset) & 0x3FF);
-#else
- return 0;
-#endif
-}
-
-int hal_afredi_memory_write(uint32_t offset, uint32_t *value)
-{
-#ifndef __UTESTS__
- m_gidel->m_AfrediMemory.SetAt(offset, (*value & 0x3FF));
- if((*value & 0x3FF) == (m_gidel->m_AfrediMemory.GetAt(offset) & 0x3FF))
- {
- return 0;
- }
- else
- {
- *value = (m_gidel->m_AfrediMemory.GetAt(offset) & 0x3FF);
- return -1;
- }
-#else
- return 0;
-#endif
-}
-
-#ifndef __UTESTS__
-/**
- * Download the Cesar bin into gidel memory.
- */
-static void unactive_dsu_break(CGidel *m_gidel)
-{
- AHBRegister dsu_config(m_gidel, DSU_CONFIG_ADDR);
-
- dsu_config &= (uint32_t)DSU_UNBREAK_MASK;
-}
-
-/**
- * Download the Cesar bin into gidel memory.
- *
- * \param m_gidel gidel object.
- * \param bin_path path to the cesar bin file.
- */
-static int download_leon_bin(CGidel *m_gidel, char *bin_path)
-{
- int fd;
- off_t size;
- uint32_t tmp;
- ssize_t result;
- AHBMemoryPtr<uint32_t> *gidel_memory;
-
- printf("Starting Cesar download...");
- //No path found, don't download the Cesar bin
- if(!strcmp(bin_path,""))
- {
- printf("Not Needed\n");
- return 0;
- }
-
- memset(path, 0, sizeof(path));
-
- //Path found check for default path
- if(!strcmp(bin_path,"OK"))
- {
- strcpy(path, DEFAULT_BIN);
- }
- else
- {
- strncpy(path, bin_path, sizeof(path));
- }
-
- //Open the binary file
- fd = open((const char*)path, O_RDONLY);
- if(fd <= 0)
- {
- printf("ERROR (can't open file %s)\n",path);
- return -1;
- }
-
- //Calculate file size
- lseek(fd, 0, SEEK_SET);
- size = lseek(fd, 0, SEEK_END);
- lseek(fd, 0, SEEK_SET);
-
- gidel_memory = new AHBMemoryPtr<uint32_t>(m_gidel, LEON_BASE_ADDR, size);
-
- //Copy the binary file into the gidel memory
- while((result = read(fd, &tmp, sizeof(uint32_t))) > 0)
- {
- tmp = swap32(tmp);
- **gidel_memory = tmp;
- (*gidel_memory)++;
- }
-
- free(gidel_memory);
- close(fd);
-
- printf("%s\n",result ? "ERROR (during copy)":"OK");
-
- return result;
-}
-#endif
-
-/**
- * Initialize the hal layer.
- *
- * \param init user information.
- * \param irq_handler interrupt handler for L->A.
- */
-void halmbx_init(struct init_info *init, void(*irq_handler)(void*))
-{
-#ifndef __UTESTS__
- if(init == NULL || irq_handler == NULL)
- return;
-
- //Programming the Gidel Platform
- try
- {
- if(!strcmp(init->rbf,""))
- {
- memset(path, 0, sizeof(path));
- strcpy(path, DEFAULT_RBF);
- m_gidel = new CGidel(path, FPGA_NUM, init->use_ext_clock);
- }
- else
- {
- m_gidel = new CGidel(init->rbf, FPGA_NUM, init->use_ext_clock);
- }
- }
- catch(const ProcException& e)
- {
- e.ErrorMsg();
- exit(-1);
- }
- catch(...)
- {
- printf("Unable to Load FPGA under Gidel\n");
- exit(-1);
- }
-
- //Starting AHB
- m_gidel->f_rst_ahb = 0;
-
- //Enable DSP_SS
- m_gidel->f_dspenable = 1;
-
- //Configure AFE
- m_gidel->r_AfrediUseDataRx = 1;
- usleep(100000);
- m_gidel->r_ConfigAfredi = 0x0D41;
- usleep(100000);
- m_gidel->r_SportIn = 0x0000;
- usleep(100000);
- m_gidel->r_SportInstr = 0x0101;
- usleep(100000);
- m_gidel->r_SportIn = 0x0004;
- usleep(100000);
- m_gidel->r_SportInstr = 0x0103;
- usleep(100000);
- m_gidel->r_SportIn = 0x0035;
- usleep(100000);
- m_gidel->r_SportInstr = 0x0104;
- usleep(100000);
- m_gidel->r_SportIn = 0x0000;
- usleep(100000);
- m_gidel->r_SportInstr = 0x0109;
- usleep(100000);
- m_gidel->r_SportIn = 0x0000;
- usleep(100000);
- m_gidel->r_SportInstr = 0x010A;
- usleep(100000);
- m_gidel->r_SportIn = 0x0020;
- usleep(100000);
- m_gidel->r_SportInstr = 0x010B;
- usleep(100000);
- m_gidel->r_SportIn = 0x0043;
- usleep(100000);
- m_gidel->r_SportInstr = 0x010C;
- usleep(100000);
- m_gidel->r_SportIn = 0x0001;
- usleep(100000);
- m_gidel->r_SportInstr = 0x010D;
- usleep(100000);
- m_gidel->r_SportIn = 0x0080;
- usleep(100000);
- m_gidel->r_SportInstr = 0x010E;
- usleep(100000);
- //auto calibration
- m_gidel->r_SportIn = 0x0021;
- usleep(100000);
- m_gidel->r_SportInstr = 0x0107;
- usleep(100000);
-
- //Set interrupt handler (interrupt from LEON)
- m_gidel->SetUserInterruptHandler(irq_handler);
- m_gidel->EnableInterrupt(true);
-
- //Init Free buffer table
- uint32_t base_gidel_buff = BUFFER_GIDEL_BASE_ADDR;
- for(int i=0 ; i<MAX_GIDEL_BUFFER ; i++)
- {
- free_buff_list.push_back(base_gidel_buff);
- base_gidel_buff += ((ETH_MAX_SIZE + sizeof(uint32_t) -1) / sizeof(uint32_t)) * sizeof(uint32_t);
- }
-
- //Declare Mailbox register and memory pointers
- A2L_head = new AHBRegister(m_gidel, A2L_HEAD_ADDR);
- A2L_tail = new AHBRegister(m_gidel, A2L_TAIL_ADDR);
- L2A_head = new AHBRegister(m_gidel, L2A_HEAD_ADDR);
- L2A_tail = new AHBRegister(m_gidel, L2A_TAIL_ADDR);
- A2L_it = new AHBRegister(m_gidel, A2L_IT_ADDR);
- L2A_it = new AHBRegister(m_gidel, L2A_IT_ADDR);
- L2A_it_mask = new AHBRegister(m_gidel, L2A_IT_MASK_ADDR);
- A2L_ptr = new AHBMemoryPtr<uint32_t>(m_gidel, A2L_RING_BASE_ADDR, A2L_RING_SIZE);
- L2A_ptr = new AHBMemoryPtr<uint32_t>(m_gidel, L2A_RING_BASE_ADDR, L2A_RING_SIZE);
-
- //Init mailboxes pointers
- *A2L_tail = A2L_RING_BASE_ADDR;
- *L2A_head = L2A_RING_BASE_ADDR;
-
- //TODO:Download the Leon Code into the Gidel Memory
- download_leon_bin(m_gidel, init->bin);
-
- //Don't wait the debugger
- if(!init->wait_debugger)
- {
- unactive_dsu_break(m_gidel);
- }
-
- //Starting Leon
- m_gidel->f_rst_proc = 0;
-
-#else
- //Init mailboxes pointers
- *A2L_head = A2L_RING_BASE_ADDR;
- *A2L_tail = A2L_RING_BASE_ADDR;
- *L2A_head = L2A_RING_BASE_ADDR;
- *L2A_tail = L2A_RING_BASE_ADDR;
-
- //Init Free buffer table
- uint32_t base_gidel_buff = BUFFER_GIDEL_BASE_ADDR;
- for(int i=0 ; i<MAX_GIDEL_BUFFER ; i++)
- {
- free_buff_list.push_back(base_gidel_buff);
- base_gidel_buff += ETH_MAX_SIZE;
- }
-#endif
-}
-
-/**
- * UnInitialize the hal layer.
- */
-void halmbx_uninit(void)
-{
-#ifndef __UTESTS__
- //Stopping Gidel interrupt mechanism
- m_gidel->EnableInterrupt(false);
-
- //Stopping the Leon
- m_gidel->f_rst_proc = 1;
-
- //Free Mailboxes register and memory pointers
- free(A2L_head);
- free(A2L_tail);
- free(L2A_head);
- free(L2A_tail);
- free(A2L_it);
- free(L2A_it);
- free(L2A_it_mask);
- free(A2L_ptr);
- free(L2A_ptr);
-
- //Stopping AHB
- m_gidel->f_rst_ahb = 1;
-#endif
-}
-
-/**
- * Set the Arm to Leon Interrupt.
- */
-void set_A2Lt_interrupt(void)
-{
- *A2L_it |= A2LT_MASK;
-}
-
-/**
- * Set the Arm to Leon acknowledge Interrupt.
- */
-void set_L2Aa_interrupt(void)
-{
- *A2L_it |= A2LA_MASK;
-}
-
-/**
- * Clear the Leon to Arm Interrupt.
- */
- void clr_L2At_interrupt(void)
-{
- *L2A_it = L2AT_MASK;
-}
-
-/**
- * Clear the Leon to Arm acknowledge Interrupt.
- */
-void clr_A2La_interrupt(void)
-{
- *L2A_it = L2AA_MASK;
-}
-
-/**
- * Enable the Arm to Leon Acknowledge Interrupt.
- */
-void A2La_it_enable(void)
-{
- *L2A_it_mask &= ~L2AA_EN_MASK;
-}
-
-/**
- * Enable the Leon to Arm Trigger Interrupt.
- */
-void L2At_it_enable(void)
-{
- *L2A_it_mask &= ~L2AT_EN_MASK;
-}
-
-/**
- * Disable the Arm to Leon Acknowledge Interrupt.
- */
-void A2La_it_disable(void)
-{
- *L2A_it_mask |= L2AA_EN_MASK;
-}
-
-/**
- * Disable the Leon to Arm Trigger Interrupt.
- */
-void L2At_it_disable(void)
-{
- *L2A_it_mask |= L2AT_EN_MASK;
-}
-
-/**
- * Check if Leon to Arm mailbox queue is empty.
- *
- * \return 0 if the queue is empty.
- */
-int halmbx_L2Amail_not_empty_queue(void)
-{
- int result;
- result = (int)((*L2A_head - *L2A_tail) & L2A_RING_MASK);
- TRACE("Is queue not empty=%x ; ",result);
- TRACE("L2A_head=%x ; L2A_tail=%x\n", (unsigned int)*L2A_head, (unsigned int)*L2A_tail);
- return result;
-}
-
-/**
- * Check Arm to Leon mailbox queue status.
- *
- * \return queue state.
- */
-int halmbx_A2Lmail_status_queue(void)
-{
- uint32_t space;
-
- space = ((*A2L_head - *A2L_tail) & A2L_RING_MASK);
-
- if((space != 0) && (space <= MAX_MSG_SIZE))
- return FULL;
- else
- return NOT_FULL;
-}
-
-/**
- * Check Leon to Arm mailbox queue status.
- *
- * \return queue state.
- */
-int halmbx_L2Amail_status_queue(void)
-{
- uint32_t space;
- space = ((*L2A_head - *L2A_tail) & L2A_RING_MASK);
-
- if((space != 0) && (space <= MAX_MSG_SIZE))
- return FULL;
- else
- return NOT_FULL;
-}
-
-/**
- * Alloc message space on the Gidel Memory.
- *
- * \return address on the Gidel memory.
- */
-uint32_t halmbx_alloc_in_gidel_memory(void)
-{
- //Recover the last free buff in the Gidel memory
- uint32_t gidel_addr = free_buff_list.back();
-
- //Mark as not free
- free_buff_list.pop_back();
-
- return gidel_addr;
-}
-
-/**
- * Free message space in the Gidel Memory.
- *
- * \param message pointer to the message.
- * \param size message size in bytes.
- * \return error code.
- */
-int halmbx_free_in_gidel_memory(uint32_t *message)
-{
- //Store the buffer as free
- free_buff_list.push_back((uint32_t) message);
- return 0;
-}
-
-/**
- * Copy message from the PC Memory
- * to the Gidel Memory.
- *
- * \param message pointer to the message.
- * \param size message size in bytes.
- * \return address on the Gidel memory.
- */
-uint32_t halmbx_save_in_gidel_memory(uint32_t *message, int size)
-{
- uint32_t gidel_addr;
- uint32_t *pc_msg;
- int i;
-
- //Check size
- if(size > ETH_MAX_SIZE || size == 0)
- return 0;
- //Check pointer
- if(message == NULL)
- return 0;
- pc_msg = message;
-
- //Align and convert size for 32bits
- size = (((size + sizeof(uint32_t) -1) / sizeof(uint32_t)) * sizeof(uint32_t)) / sizeof(uint32_t);
-
- //Alloc a buffer in Gidel Memory
- gidel_addr = halmbx_alloc_in_gidel_memory();
- //Check gidel pointer
- if(gidel_addr == 0)
- return 0;
-
-#ifndef __UTESTS__
- //Create a pointer to a free buffer in the Gidel memory
- AHBMemoryPtr<uint32_t> gidel_msg(m_gidel, gidel_addr, size);
-#else
- uint32_t *gidel_msg = (uint32_t*)gidel_addr;
-#endif
-
- //Copy the message into the gidel memory
- for(i=0 ; i<size ; i++)
- {
- *gidel_msg = *pc_msg;
- gidel_msg++;
- pc_msg++;
- }
- return gidel_addr;
-}
-
-/**
- * Copy message from the Gidel Memory
- * to the PC Memory.
- *
- * \param message pointer to the message.
- * \param size message size in bytes.
- * \return address on the PC memory.
- */
-uint32_t halmbx_save_in_pc_memory(uint32_t *message, int size)
-{
- uint32_t *pc_msg;
- uint32_t pc_addr;
- int i;
-
- //Check size
- if(size > ETH_MAX_SIZE || size ==0)
- return 0;
- //Check pointer
- if(message == NULL)
- return 0;
-
- //Align and convert size for 32bits
- size = (((size + sizeof(uint32_t) -1) / sizeof(uint32_t)) * sizeof(uint32_t)) / sizeof(uint32_t);
-
- //Prepare a new msg in the pc memory
- pc_msg = (uint32_t*)malloc(size*sizeof(uint32_t));
- //Check pc pointer
- if(pc_msg == NULL)
- return 0;
- else
- pc_addr = (uint32_t) pc_msg;
-
-#ifndef __UTESTS__
- //Create a pointer to the buffer in the Gidel memory
- AHBMemoryPtr<uint32_t> gidel_msg(m_gidel, (uint32_t)message, size);
-#else
- uint32_t *gidel_msg = (uint32_t*)message;
-#endif
-
- //Copy the message into the pc memory
- for(i=0 ; i<size ; i++)
- {
- *pc_msg = *gidel_msg;
- pc_msg++;
- gidel_msg++;
- }
-
- //Free buffer in the Gidel Memory
- halmbx_free_in_gidel_memory(message);
-
- return pc_addr;
-}
-
-/**
- * free message space in the PC Memory.
- *
- * \param message pointer to the message.
- * \return error code.
- */
-int halmbx_free_in_pc_memory(uint32_t *message)
-{
- if(message == NULL)
- return -1;
-
- free(message);
- return 0;
-}
-
-/**
- * Copy message to the ring buffer.
- *
- * \param message pointer to the message align on 32bits.
- * \param size message size in bytes and align on 32bits.
- * \return error code.
- */
-int halmbx_copy_to_ring (uint32_t *message, int size)
-{
- int i;
- uint32_t tail;
- uint32_t *our_msg;
-
-
- //Check size range and alignment on 32bits
- if(size > ETH_MAX_SIZE || size == 0 || size & 0x3)
- return -1;
- //Check pointer and alignment on 32bits
- if(message == NULL || ((uint32_t)message & 0x3))
- return -1;
- else
- our_msg = message;
-
- //Check space in ring just to be sure
- if(halmbx_A2Lmail_status_queue() == FULL)
- return FULL;
-
- //Convert size for 32bits
- size = (size / sizeof(uint32_t));
-
- //Calculate offset and convert for 32bits
- tail = (*A2L_tail & A2L_RING_MASK);
- tail = (tail / sizeof(uint32_t));
-
-// TRACE("size=%d\n",size);
-// TRACE("A2L_ptr=0x%x + tail=0x%x\n", A2L_ptr->GetAddr(), tail);
- //Copy the message into the mailbox ring
- for(i=0 ; i<size ; i++)
- {
- *(*A2L_ptr + tail) = *our_msg++;
-// TRACE("@0x%x= 0x%x ; ",((A2L_ptr->GetAddr())+tail),(unsigned int)*(*A2L_ptr+tail));
- tail = ((tail+1) & (A2L_RING_MASK / sizeof(uint32_t)));
- }
- TRACE("\nmsg= %x, %x\n",*(our_msg-2), *(our_msg-1));
-#if DEBUG
- our_msg = message;
- //Convert size for 32bits
- size = (size / sizeof(uint32_t));
- //Calculate offset and convert for 32bits
- tail = (*A2L_tail & A2L_RING_MASK);
- tail = (tail / sizeof(uint32_t));
-
- TRACE("size=%d\n",size);
- TRACE("A2L_ptr=0x%x + tail=0x%x\n", A2L_ptr->GetAddr(), tail);
- //Copy the message into the mailbox ring
- for(i=0 ; i<size ; i++)
- {
- TRACE("@0x%x= 0x%x ; ",((A2L_ptr->GetAddr())+tail*4),(unsigned int)*(*A2L_ptr+tail));
- tail = ((tail+1) & (A2L_RING_MASK / sizeof(uint32_t)));
- }
-#endif
- return 0;
-}
-
-/**
- * Copy message from the ring buffer.
- *
- * \param message pointer to the message align on 32bits.
- * \param size max message size in bytes and align on 32bits.
- * \return error code.
- */
-int halmbx_copy_from_ring (uint32_t *message, int size)
-{
- int i;
- uint32_t head;
- uint32_t *our_msg;
-
- //Check size range and alignment on 32bits
- if(size > ETH_MAX_SIZE || size == 0 || size & 0x3)
- return -1;
- //Check pointer and alignment on 32bits
- if(message == NULL || ((uint32_t)message & 0x3))
- return -1;
- else
- our_msg = message;
-
- //Align and convert size for 32bits
- size = (size / sizeof(uint32_t));
-
- //Calculate offset and convert for 32bits
- head = (*L2A_head & L2A_RING_MASK);
- head = (head / sizeof(uint32_t));
-
-// TRACE("Copy : ");
- //Copy the message into the mailbox ring
- for(i=0 ; i<size ; i++)
- {
-// TRACE("*ptr=%x, head=%x ; ", (unsigned int)*(*L2A_ptr + head), head*4);
- *our_msg++ = *(*L2A_ptr + head);
- head = ((head+1) & (L2A_RING_MASK / sizeof(uint32_t)));
- }
-// TRACE("\n");
- return 0;
-}
-
-/**
- * Update the ring management for Arm to Leon mailbox (TX).
- *
- * \param size real size in bytes of the last proceed message.
- * \return error code.
- */
-int halmbx_A2Lmail_update (int size)
-{
- //Check size
- if(size == 0)
- return -1;
-
- //Update the TAIL pointer
- *A2L_tail = ((*A2L_tail + size) & A2L_RING_MASK) + A2L_RING_BASE_ADDR;
-
- //Start interrupt
- set_A2Lt_interrupt();
-
- return 0;
-}
-
-/**
- * Update the ring management for Leon to Arm mailbox (RX).
- *
- * \param size real size in bytes of the last proceed message.
- * \return error code.
- */
-int halmbx_L2Amail_update(int size)
-{
- //Check size
- if(size == 0)
- return -1;
-
- //Update the TAIL pointer
- *L2A_head = ((*L2A_head + size) & L2A_RING_MASK) + L2A_RING_BASE_ADDR;
-
- //Acknowledge the interrupt
- set_L2Aa_interrupt();
-
- return 0;
-}
-
-/**
- * Disable the Leon to Arm Trigger Interrupt.
- *
- * \return waiting its.
- */
-enum pending_its check_its(void)
-{
- int result = 0;
- uint32_t tmp_it = (uint32_t)*L2A_it;
- uint32_t tmp_it_mask = (uint32_t)*L2A_it_mask;
-
- if(tmp_it & L2AA_MASK)
- {
- TRACE("RX IT L2AA ");
- if((tmp_it_mask & L2AA_EN_MASK) == 0)
- {
- result |= 1;
- TRACE("not masked\n");
- }
- else
- {
- TRACE("masked\n");
- }
- }
-
- if(tmp_it & L2AT_MASK)
- {
- TRACE("RX IT L2AT ");
- if((tmp_it_mask & L2AT_EN_MASK) == 0)
- {
- result |= 2;
- TRACE("not masked\n");
- }
- else
- {
- TRACE("masked\n");
- }
- }
-
- if(result<1 || result>3)
- TRACE("RX unkown IT\n");
-
- switch(result)
- {
- case 3: return ALL;
- case 2: return L2AT;
- case 1: return A2LA;
- default: return NONE;
- }
-}
-
diff --git a/cleopatre/devkit/plcdrv/gidel/src/mailbox.c b/cleopatre/devkit/plcdrv/gidel/src/mailbox.c
deleted file mode 100644
index ad137a8135..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/src/mailbox.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file mailbox.c
- * \brief Mailbox layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * this layer provide all mechanisms to manage mailboxes.
- */
-
-#include "common.h"
-#include <stdio.h>
-#include <string.h>
-#ifdef __UTESTS__
-#include "hal_stub.h"
-#include "processing_stub.h"
-#else
-#include "hal.h"
-#include "processing.h"
-#endif
-#include "mailbox.h"
-
-/** Data parameters */
-#define MBX_MSG_TYPE_DATA_TYPE_DATA 0
-#define MBX_MSG_TYPE_DATA_TYPE_MME 1
-typedef struct {
- uint32_t type :8;
- uint32_t length :4;
- uint32_t param_type :1;
- uint32_t param_length :11;
- uint32_t :8;
-} __attribute__ ((__packed__)) mbx_data_hdr_t;
-
-/** Buffer add parameters */
-#define MBX_MSG_TYPE_BUFF_ADD_TYPE_DATA 0
-#define MBX_MSG_TYPE_BUFF_ADD_TYPE_MME 1
-#define MBX_MSG_TYPE_BUFF_ADD_TYPE_INTERFACE 2
-typedef struct {
- uint32_t type :8;
- uint32_t length :4;
- uint32_t param_type :2;
- uint32_t reserved :18;
-} __attribute__ ((__packed__)) mbx_buffer_add_hdr_t;
-
-/** Send done parameters */
-typedef struct {
- uint32_t type :8;
- uint32_t length :4;
- uint32_t reserved :20;
-} __attribute__ ((__packed__)) mbx_send_done_hdr_t;
-
-/** Interface parameters */
-#define MBX_MSG_TYPE_INTERFACE_TYPE_INTERFACE 0
-#define MBX_MSG_TYPE_INTERFACE_TYPE_SNIFFER 1
-#define MBX_MSG_TYPE_INTERFACE_TYPE_FCALL 2
-typedef struct {
- uint32_t type :8;
- uint32_t length :4;
- uint32_t param_type :8;
- uint32_t param_length :11;
- uint32_t reserved :1;
-} __attribute__ ((__packed__)) mbx_interface_hdr_t;
-
-/** Mailbox type */
-#define MBX_MSG_TYPE_DATA 0
-#define MBX_MSG_TYPE_BUFFER_ADD 1
-#define MBX_MSG_TYPE_SEND_DONE 2
-#define MBX_MSG_TYPE_INTERFACE 3
-
-/** Mailbox Header Structure */
-typedef union {
- mbx_data_hdr_t data;
- mbx_buffer_add_hdr_t buffer_add;
- mbx_send_done_hdr_t send_done;
- mbx_interface_hdr_t interface;
-} mbx_hdr_t;
-
-/** Mailbox interface Structure */
-typedef struct {
- uint32_t way :1;
- uint32_t encryption :1;
- uint32_t data_type :3;
- uint32_t reserved :27;
- uint32_t buffer_ptr;
-} __attribute__ ((__packed__)) mbx_interface_t;
-
-/** Mailbox Data Structure */
-typedef union {
- uint32_t buffer_ptr;
- mbx_interface_t interface;
-} __attribute__ ((__packed__)) mbx_data_t;
-
-/** Mailbox Structure */
-typedef struct {
- mbx_hdr_t header;
- mbx_data_t data;
-} __attribute__ ((__packed__)) mbx_t;
-
-
-/** Global variables */
-void (*txack_handler)(void) = 0;
-
-/**
- * Send a message to the HLE layer.
- *
- * \param pointer the data message pointer.
- * \param length the length of the data message.
- * \param type type of message.
- * \return error code.
- */
-int mailbox_send(void *pointer, uint32_t length, enum buffer_type type)
-{
- mbx_t msg;
- uint32_t gidel_pointer;
- int status;
-
- //Check pointer ans length
- if(pointer == NULL || length == 0)
- return -1;
-
- //Check room
- status = halmbx_A2Lmail_status_queue();
- if(status == NEARLY_FULL || status == FULL)
- {
- //the mailbox is nearly full stop upper layers
- //and activate tx_ack interrupt
- A2La_it_enable();
- if(status == FULL)
- return status;
- }
- else
- {
- A2La_it_disable();
- }
-
- TRACE("In the mailbox send\n");
-
- memset(&msg, 0, sizeof(msg));
-
- switch(type)
- {
- case DATA:
- //header construction
- msg.header.data.type = MBX_MSG_TYPE_DATA;
- msg.header.data.length = 1;
- TRACE("SEND data data\n");
- msg.header.data.param_type = MBX_MSG_TYPE_DATA_TYPE_DATA;
- msg.header.data.param_length = length;
- break;
- case MME:
- //header construction
- msg.header.data.type = MBX_MSG_TYPE_DATA;
- msg.header.data.length = 1;
- TRACE("SEND data mme\n");
- msg.header.data.param_type = MBX_MSG_TYPE_DATA_TYPE_MME;
- msg.header.data.param_length = length;
- break;
- case INTERFACE:
- //header construction
- msg.header.interface.type = MBX_MSG_TYPE_INTERFACE;
- msg.header.interface.length = 1;
- TRACE("SEND interface\n");
- msg.header.interface.param_type = MBX_MSG_TYPE_INTERFACE_TYPE_FCALL;
- msg.header.interface.param_length = length;
- break;
- default:
- return -1;
- }
-
- //Copy the frame to send to the HLE into the Gidel Memory
- //because the leon code can only access to Gidel Memory
- gidel_pointer = halmbx_save_in_gidel_memory((uint32_t*)pointer, length);
- if(gidel_pointer == 0) //Do not append
- return FULL;
-
- //data construction
- msg.data.buffer_ptr = gidel_pointer;
-
- //Copy to ring buffer and send to HLE layer
- if(halmbx_copy_to_ring((uint32_t*)&msg, sizeof(mbx_hdr_t) + (msg.header.data.length * sizeof(uint32_t))))
- return -1;
-
- //Update the ring management
- if(halmbx_A2Lmail_update(sizeof(mbx_hdr_t) + (msg.header.data.length * sizeof(uint32_t))))
- return -1;
-
-#ifdef DEBUG
- uint32_t *ptr = (uint32_t*)&msg;
- TRACE("msg(size=%d)=%x, %x, %x\n", msg.header.data.length * sizeof(uint32_t), *ptr, *(ptr+1), *(ptr+2));
-#endif
-
- return 0;
-}
-
-/**
- * Send a new buffer to the HLE layer.
- *
- * \param pointer the buffer pointer.
- * \param type type of message.
- * \return error code.
- */
-#ifdef __UTESTS__
-int mailbox_buffer_add(enum buffer_type type)
-#else
-static int mailbox_buffer_add(enum buffer_type type)
-#endif
-{
- mbx_t msg;
- uint32_t *gidel_pointer;
- int status;
-
- //Check room
- status = halmbx_A2Lmail_status_queue();
- if(status == NEARLY_FULL || status == FULL)
- {
- //The mailbox is nearly full stop upper layers
- //and activate tx_ack interrupt
- A2La_it_enable();
- if(status == FULL)
- return status;
- }
- else
- {
- A2La_it_disable();
- }
-
- //Find a free buffer in Gidel Memory
- gidel_pointer = (uint32_t*)halmbx_alloc_in_gidel_memory();
- if(gidel_pointer == 0) //Do not append
- return FULL;
-
- memset(&msg, 0, sizeof(msg));
-
- //Header construction
- msg.header.buffer_add.type = MBX_MSG_TYPE_BUFFER_ADD;
- msg.header.buffer_add.length = 1;
- switch(type)
- {
- case DATA:
- printf("SEND BUFF ADD data data\n");
- TRACE("SEND BUFF ADD data data\n");
- msg.header.buffer_add.param_type = MBX_MSG_TYPE_BUFF_ADD_TYPE_DATA;
- break;
- case MME:
- printf("SEND BUFF ADD data mme\n");
- TRACE("SEND BUFF ADD data mme\n");
- msg.header.buffer_add.param_type = MBX_MSG_TYPE_BUFF_ADD_TYPE_MME;
- break;
- case INTERFACE:
- printf("SEND BUFF ADD interface\n");
- TRACE("SEND BUFF ADD interface\n");
- msg.header.buffer_add.param_type = MBX_MSG_TYPE_BUFF_ADD_TYPE_INTERFACE;
- break;
- default:
- return -1;
- }
-
- //Data construction
- msg.data.buffer_ptr = (uint32_t)gidel_pointer;
-
- //Copy to ring buffer
- if(halmbx_copy_to_ring((uint32_t*)&msg, sizeof(mbx_hdr_t) + (msg.header.buffer_add.length * sizeof(uint32_t))))
- return -1;
-
- //Update the ring management
- if(halmbx_A2Lmail_update(sizeof(mbx_hdr_t) + (msg.header.buffer_add.length * sizeof(uint32_t))))
- return -1;
-
-#ifdef DEBUG
- uint32_t *ptr = (uint32_t*)&msg;
- TRACE("msg(size=%d)=%x, %x, %x\n", msg.header.buffer_add.length * sizeof(uint32_t), *ptr, *(ptr+1), *(ptr+2));
-#endif
-
- return 0;
-}
-
-/**
- * Receive everything from the HLE layer.
- *
- * \return error code.
- */
-int mailbox_receive(void)
-{
- mbx_t msg;
- uint32_t *pc_pointer;
- int result = 0;
-
- while(halmbx_L2Amail_not_empty_queue())
- {
- //Copy the new message from the ring buffer
- if(halmbx_copy_from_ring((uint32_t*)&msg, sizeof(msg)))
- return -2;
-
- //Update the ring management
- if(halmbx_L2Amail_update(sizeof(mbx_hdr_t) + (msg.header.send_done.length * sizeof(uint32_t))))
- return -3;
-
- //Proceed the message
-#ifdef DEBUG
- uint32_t *ptr = (uint32_t*)&msg;
- TRACE("msg(size=%d)=%x, %x, %x\n", msg.header.send_done.length * sizeof(uint32_t), *ptr, *(ptr+1), *(ptr+2));
-#endif
- switch(msg.header.send_done.type)
- {
- case MBX_MSG_TYPE_SEND_DONE: //Free the Gidel memory allocated with the buffer_add
- TRACE("RECEIVE a send_done\n");
- printf("RECEIVE a send_done\n");
- if(halmbx_free_in_gidel_memory((uint32_t*)msg.data.buffer_ptr))
- result = -4;
- else
- result = 0;
- break;
-
- case MBX_MSG_TYPE_INTERFACE: //Copy the frame receive from the HLE into the PC Memory
- //because the PC driver code can only access to PC Memory
- TRACE("RECEIVE an interface\n");
- pc_pointer = (uint32_t*)halmbx_save_in_pc_memory((uint32_t*)msg.data.buffer_ptr, (int)msg.header.interface.param_length);
- if(pc_pointer == NULL)
- {
- result = -5;
- break;
- }
-
- //Transmit to the upper layers
- if(processing_receive(pc_pointer, msg.header.interface.param_length, INTERFACE))
- {
- result = -6;
- break;
- }
- mailbox_buffer_add(INTERFACE);
-
- //Free the previous buffer allocated in the PC Memory
- halmbx_free_in_pc_memory(pc_pointer);
- result = 0;
- break;
-
- case MBX_MSG_TYPE_DATA: //Copy the frame receive from the HLE into the PC Memory
- //because the PC driver code can only access to PC Memory
- TRACE("RECEIVE a data\n");
- pc_pointer = (uint32_t*)halmbx_save_in_pc_memory((uint32_t*)msg.data.buffer_ptr, (int)msg.header.data.param_length);
- if(pc_pointer == NULL)
- {
- result = -7;
- break;
- }
-
- //Transmit to the upper layers
- if(msg.header.data.param_type == MBX_MSG_TYPE_DATA_TYPE_MME)
- {
- if(processing_receive(pc_pointer, msg.header.data.param_length, MME))
- {
- result = -8;
- break;
- }
- mailbox_buffer_add(MME);
- }
- else
- {
- if(processing_receive(pc_pointer, msg.header.data.param_length, DATA))
- {
- result = -9;
- break;
- }
- mailbox_buffer_add(DATA);
- }
-
- //Free the previous buffer allocated in the PC Memory
- halmbx_free_in_pc_memory(pc_pointer);
- result = 0;
- break;
- default:
- result = -1;
- break;
- }
- if(result)
- break;
- }
- return result;
-}
-
-/**
- * Receive everything from the HLE layer.
- *
- * \param data argument (not used).
- */
-void mailbox_irq (void*data)
-{
- int result;
- switch(check_its())
- {
- case A2LA :
- clr_A2La_interrupt();
- if(txack_handler)
- (*txack_handler)();
- break;
-
- case L2AT :
- clr_L2At_interrupt();
- result = mailbox_receive();
- TRACE("mailbox_receive=%d\n\n",result);
- break;
-
- case ALL :
- clr_A2La_interrupt();
- if(txack_handler)
- (*txack_handler)();
- clr_L2At_interrupt();
- result = mailbox_receive();
- TRACE("mailbox_receive=%d\n\n",result);
- break;
- case NONE :
- default:
- break;
- }
-}
-
-/**
- * Initialize the mailbox layer.
- *
- * \param init user information.
- */
-void mailbox_init(struct init_info *init)
-{
- int i;
-
- //Register TX acknowledge Interrupt handler
- txack_handler = init->txack_handler;
-
- //Init lower layers
- halmbx_init(init, &mailbox_irq);
-
- //Stop all interrupt
- A2La_it_disable();
- L2At_it_disable();
-
- //Unmask sending interrupt
- L2At_it_enable();
-
- //Add to Leon the RX buffers
- for(i=0 ; i < init->nb_data_buf_alloc ; i++)
- mailbox_buffer_add(DATA);
- for(i=0 ; i < init->nb_mme_buf_alloc ; i++)
- mailbox_buffer_add(MME);
- for(i=0 ; i < init->nb_interface_buf_alloc ; i++)
- mailbox_buffer_add(INTERFACE);
-}
-
-/**
- * UnInitialize the mailbox layer.
- */
-void mailbox_uninit(void)
-{
- //Mask all interrupts
- A2La_it_disable();
- L2At_it_disable();
-
- //Uninit lower layers
- halmbx_uninit();
-}
-
diff --git a/cleopatre/devkit/plcdrv/gidel/src/plc_drv.c b/cleopatre/devkit/plcdrv/gidel/src/plc_drv.c
deleted file mode 100644
index 22fee484de..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/src/plc_drv.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file plc_drv.c
- * \brief OS layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * For the Gidel prototype this layer only precise how to receive a packet
- * and what to do when we receive an acknowledge of a previous sending frame.
- */
-
-#define DEBUG
-
-#define DRV_NAME "SPC300_Gidel"
-#define DRV_VERSION "1.1"
-#define DRV_RELDATE "Mar 19, 2009"
-
-#include <stdio.h>
-#include <string.h>
-#include <libgen.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <sys/socket.h>
-#include <linux/if.h>
-#include <linux/if_tun.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <signal.h>
-
-#include "common.h"
-#include "plc_drv.h"
-#ifndef __UTESTS__
-#include "processing.h"
-#include "hal.h"
-#else
-#include "processing_stub.h"
-
-#endif
-
-#ifdef __UTESTS__
-int help_function = 0;
-#endif
-
-#define DEFAULT_NB_DATA_BUFF 13
-#define DEFAULT_NB_INTERFACE_BUFF 2
-#define DEFAULT_NB_MME_BUFF 1
-
-//These identify the driver base version and may not be removed
-static char version[] = DRV_NAME " PLC driver v" DRV_VERSION " (" DRV_RELDATE ")\n";
-
-/** Global variable definition */
-static struct init_info init;
-static uint8_t frame_tx[ETH_MAX_SIZE+1];
-static int tuntap_fd;
-int thread_ending = 0;
-pthread_mutex_t mutex_listener = PTHREAD_MUTEX_INITIALIZER;
-
-/**
- * Help message given to the user when arguments are false.
- */
-static void help(char *file)
-{
-#ifndef __UTESTS__
- printf("Usage: %s [OPTIONS]\nOPTIONS:\n",file);
- printf("--bin [bin file] download the leon bin.\n");
- printf("--rbf <rbf file> path to the fpga file.\n");
- printf("--tun <TUN/TAP name> name of the tun/tap interface.\n");
- printf("--data <number> number of data buffer to allocate for LEON.\n");
- printf("--mme <number> number of mme data buffer to allocate for LEON.\n");
- printf("--grmon Cesar binary doesn't run, it wait debug connexion.\n");
- printf("--extclk Change Gidel clock to external clock.\n");
-#else
- help_function = 1;
-#endif
-}
-
-/**
- * Fill all parameters in our structure.
- *
- * \param argc number of arguments.
- * \param argv pointer to each argument.
- * \return error code.
- */
-#ifndef __UTESTS__
-static
-#endif
-int parse_args(struct init_info *init, int argc, char **argv)
-{
- int i;
- int result = 0;
-
- i = 1;
- while(i<argc)
- {
- if (!strcmp(argv[i],"--help"))
- {
- help(basename(argv[0]));
- result = -1;
- break;
- }
- else if (!strcmp(argv[i],"--bin"))
- {
- if(i+1<argc && strncmp(argv[i+1],"--",2))
- {
- i++;
- strncpy(init->bin, argv[i], sizeof(init->bin));
- }
- else
- {
- strncpy(init->bin, "OK", 3);
- }
- }
- else if (!strcmp(argv[i],"--rbf") && i+1<argc)
- {
- i++;
- strncpy(init->rbf, argv[i], sizeof(init->rbf));
- }
- else if (!strcmp(argv[i],"--tun") && i+1<argc)
- {
- i++;
- strncpy(init->tuntap_name, argv[i], sizeof(init->tuntap_name));
- }
- else if (!strcmp(argv[i],"--data") && i+1<argc)
- {
- i++;
- init->nb_data_buf_alloc = (int)strtoul(argv[i],NULL,0);
- }
- else if (!strcmp(argv[i],"--mme") && i+1<argc)
- {
- i++;
- init->nb_mme_buf_alloc = (int)strtoul(argv[i],NULL,0);
- }
- else if (!strcmp(argv[i],"--grmon"))
- {
- init->wait_debugger = 1;
- }
- else if (!strcmp(argv[i],"--extclk"))
- {
- init->use_ext_clock = 1;
- }
- else
- {
- help(basename(argv[0]));
- result = -1;
- break;
- }
- i++;
- }
- return result;
-}
-
-/**
- * Create TUN/TAP mechanism
- *
- * \param init intitialization structure.
- * \return error code.
- */
-#ifndef __UTESTS__
-static
-#endif
-int create_tuntap(struct init_info *init)
-{
-#ifndef __UTESTS__
- int fd;
- struct ifreq ifr;
- char default_name[] = "tap0";
- int error;
-
- //Open TUN device
- if((fd = open("/dev/net/tun", O_RDWR)) < 0)
- {
- printf("open /dev/net/tun failed");
- return -1;
- }
-
- //Prepare TUN/TAP name
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
- if(strncmp(init->tuntap_name, default_name, sizeof(default_name)) < 0)
- strncpy(init->tuntap_name, default_name, IFNAMSIZ);
-
- strncpy(ifr.ifr_name, init->tuntap_name, IFNAMSIZ);
-
- //Create a TUN/TAP interface
- if((error = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0)
- {
- close(fd);
- if (error == EPERM)
- printf("TUN/TAP creation error.\nYou need to be root to create an network interface.\n");
- else
- printf("TUN/TAP creation error(%d).\n",error);
- return -1;
- }
-
- tuntap_fd = fd;
-
- return 0;
-
-#else
- struct ifreq ifr;
- char default_name[] = "tap0";
-
- memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_flags = IFF_TAP;
- if(strncmp(init->tuntap_name, default_name, sizeof(default_name)) < 0)
- return -1;
- else
- return 0;
-
-#endif
-}
-
-/**
- * Close TUN/TAP mechanism
- *
- * \param fd TUN/TAP file descriptor.
- */
-static inline void close_tuntap(int fd)
-{
- close(fd);
-}
-
-/**
- * Uninit procedure, called when the user type Ctrl+C.
- *
- * \param sig signal catched
- */
-static void catch_sigint(int sig)
-{
- printf("Stopping PLC Driver...\n");
-
- //Stop Mutex and thread
- thread_ending = 1;
- pthread_mutex_unlock(&mutex_listener);
- pthread_mutex_destroy(&mutex_listener);
-
- //Uninit lower layers
- processing_uninit();
-
- //CLose TUN/TAP interface
- close_tuntap(tuntap_fd);
-
- exit(0);
-}
-
-/**
- * Communication with User to read/write in debug memories
- */
-static void* thread_user(void* data)
-{
- char reading[21], cmd[2];
- uint32_t offset, value, res, i;
-
- TRACE("User Communication starting...\n");
- printf("Only 4 commands allowed with this format : cmd %%x %%x\n");
- printf(" rd <offset> <length> --> to read under ctrl_dsp_ss\n");
- printf(" rw <offset> <value> --> to write under ctrl_dsp_ss\n");
- printf(" md <offset> <length> --> to read under Afredi Memory\n");
- printf(" mw <offset> <value> --> to write under Afredi Memory\n");
-
- while(!thread_ending)
- {
- fflush(stdin);
- fgets(reading, sizeof(reading), stdin);
- sscanf(reading,"%c%c %x %x", &cmd[0], &cmd[1], &offset, &value);
-
- if(!strncmp(cmd, "rd", 2))
- {
- if(value > 32)
- value = 32;
- for(i=0;i<value;i++)
- {
- res = hal_ctrl_dsp_ss_read(offset+(i*4));
- printf("%08x %08x\n",offset+(i*4), res);
- }
- }
- else if(!strncmp(cmd, "rw", 2))
- {
- res = hal_ctrl_dsp_ss_write(offset, &value);
- if(res)
- printf("Error during writing, %08x = %08x\n", offset, value);
- }
- else if(!strncmp(cmd, "md", 2))
- {
- if(value > 131072)
- value = 131072;
- for(i=0;i<value;i++)
- {
- res = hal_afredi_memory_read(offset+(i*4));
- printf("%08x %08x\n",offset+(i*4), res);
- }
- }
- else if(!strncmp(cmd, "mw", 2))
- {
- res = hal_afredi_memory_write(offset, &value);
- if(res)
- printf("Error during writing, %08x = %08x\n", offset, value);
- }
- else
- {
- printf("Unknown command\n");
- }
- printf("\n");
- }
- TRACE("User Thread stop\n");
- pthread_exit(NULL);
-}
-
-/**
- * Send a packet, after received it from TUN/TAP.
- */
-static void* thread_listener(void* data)
-{
- int recv_len;
- int status;
-#ifdef DEBUG
- uint32_t *check_frame;
- int i;
-#endif
-
- TRACE("Thread starting...\n");
- while(!thread_ending)
- {
- //Recover the frame from the TUN/TAP interface
- TRACE("Before read\n");
- recv_len = read(tuntap_fd, (void*)frame_tx, ETH_MAX_SIZE);
-#ifdef DEBUG
- check_frame = (uint32_t*)frame_tx;
- TRACE("\n\nSEND a Frame (%d bytes) : \n",recv_len);
- for(i=0;i<((recv_len/4)+1);i++)
- {
- if((i%4 == 0) && i)
- printf("\n");
- printf("%08X ",*(check_frame+i));
- }
- printf("\n");
-#endif
- TRACE("After read\n");
-
- TRACE("Lock Normal\n");
- pthread_mutex_lock(&mutex_listener);
-
- //Send the frame to lower layers
- status = processing_send((void *)frame_tx, recv_len);
- if(status == NEARLY_FULL)
- {
- //There is nearly room in the mailbox ring
- //so stop the tx part (packets from TUN/TAP)
- TRACE("Lock NEARLY_FULL\n");
- pthread_mutex_lock(&mutex_listener);
- }
- else if(status == FULL)
- {
- //There is no room in the mailbox ring
- //so stop the tx part (packets from TUN/TAP)
- //and drop the frame
- TRACE("Lock FULL\n");
- pthread_mutex_lock(&mutex_listener);
- }
-
- TRACE("UnLock Normal\n");
- pthread_mutex_unlock(&mutex_listener);
- }
- TRACE("Thread stop\n");
- pthread_exit(NULL);
-}
-
-/**
- * Receive a packet.
- *
- * \param pointer the packet pointer.
- * \param length the length of the packet.
- * \return error code.
- */
-int plcdrv_rx(void *pointer, int length)
-{
-#ifdef DEBUG
- uint32_t *check_frame;
- int i;
- check_frame = (uint32_t*)pointer;
- printf("RECEIVE a Frame (%d bytes) : \n",length);
- for(i=0;i<((length/4)+1);i++)
- {
- if((i%4 == 0) && i)
- printf("\n");
- printf("%08X ",*(check_frame+i));
- }
- printf("\n");
-#endif
-
- //Send the frame received from lower layers to TUN/TAP interface
- if(write(tuntap_fd, pointer, length) != length)
- return -1;
- else
- return 0;
-}
-
-/**
- * Precedure executed when the frame is really sending to CESAR
- * and only when there are few buffer in the mailbox ring.
- */
-void plcdrv_tx_ack(void)
-{
- //there is room in the mailbox ring now
- //so re-enable emission part
- //(frames coming from the TUN/TAP interface)
- TRACE("UnLock FULL\n");
- pthread_mutex_unlock(&mutex_listener);
-}
-
-/**
- * Main Procedure.
- *
- * \param argc number of arguments.
- * \param argv pointer to each argument.
- * \return error code.
- */
-#if defined __UTESTS__ || defined __HTESTS__
-int plc_drv_main(int argc, const char **argv)
-#else
-int main(int argc, const char **argv)
-#endif
-{
- pthread_t listener;
- pthread_t user;
- pthread_attr_t attribut;
-
- printf("%s",version);
-
- //Set default value in the init structure
- memset(&init, 0, sizeof(init));
- init.nb_data_buf_alloc = DEFAULT_NB_DATA_BUFF;
- init.nb_interface_buf_alloc = DEFAULT_NB_INTERFACE_BUFF;
- init.nb_mme_buf_alloc = DEFAULT_NB_MME_BUFF;
-
- //Recover user parameters and fill the init structure
- if(parse_args(&init, argc, (char **)argv))
- return -1;
-
- //Finish construction of init structure
- init.txack_handler = &plcdrv_tx_ack;
-
- //Remap the Ctrl+C to close the plcdrv
- signal(SIGINT, catch_sigint);
-
- //Create a TUN/TAP interface
- if(create_tuntap(&init))
- return -1;
-
- //Open device tap
-/* if((tuntap_fd = open("/dev/tap0",O_RDWR)) <= 0)
- {
- printf("Error open /dev/tap0 (%d)\n",tuntap_fd);
- return -1;
- }
-*/
- //Initialize the lower layers
- processing_init(&init);
-
- //Create a pthread for eth frames receive from TUN/TAP
- pthread_mutex_init(&mutex_listener, NULL);
- if(pthread_attr_init(&attribut))
- {
- perror("ERROR pthread_attr_init");
- return -1;
- }
- if(pthread_attr_setschedpolicy(&attribut, SCHED_RR))
- {
- perror("ERROR pthread_setschedpolicy");
- return -1;
- }
- if(pthread_create(&listener, &attribut, &thread_listener, NULL))
- {
- perror("ERROR pthread_create Listener");
- return -1;
- }
- if(pthread_create(&user, &attribut, &thread_user, NULL))
- {
- perror("ERROR pthread_create User");
- return -1;
- }
- pthread_attr_destroy(&attribut);
-
- //Wait thread ending and CTRL+C
- pthread_join(listener, 0);
- pthread_join(user, 0);
- while(1);
-
- return 0;
-}
-
diff --git a/cleopatre/devkit/plcdrv/gidel/src/processing.c b/cleopatre/devkit/plcdrv/gidel/src/processing.c
deleted file mode 100644
index 4ff9af3c12..0000000000
--- a/cleopatre/devkit/plcdrv/gidel/src/processing.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file processing.c
- * \brief Processing layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * this layer is used to check every packet received by CESAR or TUN/TAP
- * and sometime drop it.
- */
-
-#define DEBUG 1
-
-#include "common.h"
-#include "processing.h"
-#include <stdio.h>
-#ifndef __UTESTS__
-#include "mailbox.h"
-#include "plc_drv.h"
-#else
-#include "mailbox_stub.h"
-#include "plc_drv_stub.h"
-#endif
-
-#define ETH_SRC_ADDR_OFFSET 0
-#define ETH_SRC_ADDR_SIZE 6
-#define ETH_DST_ADDR_OFFSET ETH_SRC_ADDR_SIZE
-#define ETH_DST_ADDR_SIZE 6
-#define ETH_TYPE_OFFSET ETH_DST_ADDR_OFFSET + ETH_DST_ADDR_SIZE
-#define ETH_TYPE_SIZE 2
-#define ETH_MME_VERSION_OFFSET ETH_TYPE_OFFSET + ETH_TYPE_SIZE
-#define ETH_MME_VERSION_SIZE 1
-#define ETH_MME_TYPE_OFFSET ETH_MME_VERSION_OFFSET + ETH_MME_VERSION_SIZE
-#define ETH_MME_TYPE_SIZE 2
-#define ETH_MME_FMI_OFFSET ETH_MME_TYPE_OFFSET + ETH_MME_TYPE_SIZE
-#define ETH_MME_FMI_SIZE 2
-
-#define ETH_MME_HPAV_TYPE 0x88E1
-#define MME_HPAV_TYPE_FCALL 0xABCD
-#define MME_HPAV_TYPE_SNIFFER 0xA02C
-
-/**
- * Find the Ethernet source Address.
- */
-void get_eth_src_addr(uint8_t* eth_frame, uint8_t source[6])
-{
- uint8_t i;
- for(i=0;i<ETH_SRC_ADDR_SIZE;i++)
- {
- source[ETH_SRC_ADDR_SIZE - 1 - i] = *(eth_frame + i + ETH_SRC_ADDR_OFFSET);
- }
-}
-
-/**
- * Find the Ethernet source Address.
- */
-void get_eth_dst_addr(uint8_t* eth_frame, uint8_t dest[6])
-{
- uint8_t i;
- for(i=0;i<ETH_DST_ADDR_SIZE;i++)
- {
- dest[ETH_DST_ADDR_OFFSET -1 - i] = *(eth_frame + i + ETH_DST_ADDR_OFFSET);
- }
-}
-
-/**
- * Find the Ethernet type.
- */
-uint16_t get_eth_type(uint8_t* eth_frame)
-{
- uint16_t type = 0;
- type = (*(eth_frame + ETH_TYPE_OFFSET) << 8);
- type |= *(eth_frame + ETH_TYPE_OFFSET + 1);
- return type;
-}
-
-/**
- * Find the Ethernet MME version.
- */
-uint8_t get_eth_mme_version(uint8_t* eth_frame)
-{
- return *(eth_frame + ETH_TYPE_OFFSET);
-}
-
-/**
- * Find the Ethernet MME type.
- */
-uint16_t get_eth_mme_type(uint8_t* eth_frame)
-{
- uint16_t type = 0;
- type = (*(eth_frame + ETH_MME_TYPE_OFFSET + 1) << 8);
- type |= *(eth_frame + ETH_MME_TYPE_OFFSET);
- return type;
-}
-
-/**
- * Find the Ethernet MME type.
- */
-uint16_t get_eth_mme_fmi(uint8_t* eth_frame)
-{
- uint16_t fmi = 0;
- fmi = (*(eth_frame + ETH_MME_FMI_OFFSET) << 8);
- fmi |= *(eth_frame + ETH_MME_FMI_OFFSET + 1);
- return fmi;
-}
-
-
-/**
- * Initialize the processing layer.
- *
- * \param init user information.
- */
-void processing_init (struct init_info *init)
-{
- //Init lower layers
- mailbox_init(init);
-}
-
-/**
- * UnInitialize the processing layer.
- */
-void processing_uninit (void)
-{
- //Uninit lower layers
- mailbox_uninit();
-}
-
-/**
- * Processing procedure for a A->L message.
- *
- * \param pointer packet pointer.
- * \param length length of the packet pointed.
- * \return status queue.
- */
-int processing_send (void *pointer, int length)
-{
- int result;
- uint16_t type;
-
- //TODO:if frame not ok drop it (for Gidel : do nothing)
-
- //Check which type of frame is it and send it
- if(get_eth_type((uint8_t*)pointer) == ETH_MME_HPAV_TYPE)
- {
- type = get_eth_mme_type((uint8_t*)pointer);
- if((type == MME_HPAV_TYPE_FCALL) || (type == MME_HPAV_TYPE_SNIFFER))
- {
- TRACE("In the processing_send : INTERFACE\n");
- result = mailbox_send(pointer, length, INTERFACE);
- }
- else
- {
- TRACE("In the processing_send : MME\n");
- result = mailbox_send(pointer, length, MME);
- }
- }
- else
- {
- TRACE("In the processing_send : DATA\n");
- result = mailbox_send(pointer, length, DATA);
- }
- return result;
-}
-
-/**
- * Processing procedure for a L->A message
- *
- * \param pointer packet pointer.
- * \param length length of the packet pointed.
- * \param type type of message.
- * \return error code.
- */
-int processing_receive (void *pointer, int length, enum buffer_type type)
-{
- //TODO:Check which type of frame is it
-
- //TODO:if frame not ok drop it (for Gidel : do nothing)
-
- //TODO:Send the packet to the TX part with processing_send(pointer, length)
-
-
- if(type == INTERFACE)
- {
- TRACE("In the processing_receive : INTERFACE\n");
- }
- else if(type == MME)
- {
- TRACE("In the processing_receive : MME\n");
- }
- else if(type == DATA)
- {
- TRACE("In the processing_receive : DATA\n");
- }
-
-
- //Or Send packet to the upper layers
- return plcdrv_rx(pointer, length);
-}
-
diff --git a/cleopatre/devkit/plcdrv/arm/inc/boot_params.h b/cleopatre/devkit/plcdrv/inc/boot_params.h
index 2d264550d2..2d264550d2 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/boot_params.h
+++ b/cleopatre/devkit/plcdrv/inc/boot_params.h
diff --git a/cleopatre/devkit/plcdrv/arm/inc/common.h b/cleopatre/devkit/plcdrv/inc/common.h
index 1737a6cc83..1737a6cc83 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/common.h
+++ b/cleopatre/devkit/plcdrv/inc/common.h
diff --git a/cleopatre/devkit/plcdrv/arm/inc/hal.h b/cleopatre/devkit/plcdrv/inc/hal.h
index db99ef1479..db99ef1479 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/hal.h
+++ b/cleopatre/devkit/plcdrv/inc/hal.h
diff --git a/cleopatre/devkit/plcdrv/arm/inc/linux_drv.h b/cleopatre/devkit/plcdrv/inc/linux_drv.h
index 71f541a0ad..71f541a0ad 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/linux_drv.h
+++ b/cleopatre/devkit/plcdrv/inc/linux_drv.h
diff --git a/cleopatre/devkit/plcdrv/arm/inc/mailbox.h b/cleopatre/devkit/plcdrv/inc/mailbox.h
index f176eab9a4..f176eab9a4 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/mailbox.h
+++ b/cleopatre/devkit/plcdrv/inc/mailbox.h
diff --git a/cleopatre/devkit/plcdrv/arm/inc/processing.h b/cleopatre/devkit/plcdrv/inc/processing.h
index 64f607d46e..64f607d46e 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/processing.h
+++ b/cleopatre/devkit/plcdrv/inc/processing.h
diff --git a/cleopatre/devkit/plcdrv/arm/inc/registers.h b/cleopatre/devkit/plcdrv/inc/registers.h
index eff1d95c9c..eff1d95c9c 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/registers.h
+++ b/cleopatre/devkit/plcdrv/inc/registers.h
diff --git a/cleopatre/devkit/plcdrv/arm/src/boot_params.c b/cleopatre/devkit/plcdrv/src/boot_params.c
index d33b0e7e87..d33b0e7e87 100644
--- a/cleopatre/devkit/plcdrv/arm/src/boot_params.c
+++ b/cleopatre/devkit/plcdrv/src/boot_params.c
diff --git a/cleopatre/devkit/plcdrv/arm/src/hal.c b/cleopatre/devkit/plcdrv/src/hal.c
index c95818c7a3..c95818c7a3 100644
--- a/cleopatre/devkit/plcdrv/arm/src/hal.c
+++ b/cleopatre/devkit/plcdrv/src/hal.c
diff --git a/cleopatre/devkit/plcdrv/arm/src/linux_drv.c b/cleopatre/devkit/plcdrv/src/linux_drv.c
index d76fa729f0..d76fa729f0 100644
--- a/cleopatre/devkit/plcdrv/arm/src/linux_drv.c
+++ b/cleopatre/devkit/plcdrv/src/linux_drv.c
diff --git a/cleopatre/devkit/plcdrv/arm/src/mailbox.c b/cleopatre/devkit/plcdrv/src/mailbox.c
index 0574d64557..0574d64557 100644
--- a/cleopatre/devkit/plcdrv/arm/src/mailbox.c
+++ b/cleopatre/devkit/plcdrv/src/mailbox.c
diff --git a/cleopatre/devkit/plcdrv/arm/src/processing.c b/cleopatre/devkit/plcdrv/src/processing.c
index fa998fd0b3..fa998fd0b3 100644
--- a/cleopatre/devkit/plcdrv/arm/src/processing.c
+++ b/cleopatre/devkit/plcdrv/src/processing.c