summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/maximus/inc
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/hal/phy/maximus/inc
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/hal/phy/maximus/inc')
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_bridgedma_ctx.h64
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_defs.h37
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_interrupts.h22
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_phy_access.h102
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h233
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_phy_ctx.h282
-rw-r--r--cesar/hal/phy/maximus/inc/maximus_trace.h98
7 files changed, 838 insertions, 0 deletions
diff --git a/cesar/hal/phy/maximus/inc/maximus_bridgedma_ctx.h b/cesar/hal/phy/maximus/inc/maximus_bridgedma_ctx.h
new file mode 100644
index 0000000000..8585a7d106
--- /dev/null
+++ b/cesar/hal/phy/maximus/inc/maximus_bridgedma_ctx.h
@@ -0,0 +1,64 @@
+#ifndef MAXIMUS_BRIDGEDMA_CTX_H_
+#define MAXIMUS_BRIDGEDMA_CTX_H_
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/maximus/inc/maximus_bridgedma_ctx.h
+ * \brief HAL Bridge DMA context for Maximus.
+ * \ingroup hal_phy_maximus
+ */
+
+#include "lib/crc.h"
+#include "hal/phy/bridgedma.h"
+#ifdef ECOS
+#include <cyg/hal/drv_api.h>
+#endif /* ECOS */
+#include "host/station.h"
+
+/** 1 byte is processed into 5ns, so 8 bytes per tick (40ns) */
+#define BRIDGEDMA_BYTE_PER_TICK 8
+/** max additionnal processing time is 10us, so 250 ticks */
+#define BRIDGEDMA_ADD_MAX_TICK 250
+
+#define HPAV_CRC32_GENERATOR 0x04c11db7
+#define HPAV_CRC32_INIT 0xffffffff
+#define HPAV_CRC32_MAGIC 0x2144df1c
+
+typedef enum
+{
+ PB_TO_MACFRAME,
+ MACFRAME_TO_PB
+} bridgedma_copy_dir_t;
+
+struct phy_bridgedma_t
+{
+ phy_bridgedma_status_t status;
+ //phy_bridgedma_ctrl_t control;
+ phy_bridgedma_job_t *job_first;
+ phy_bridgedma_job_t *job_current;
+ phy_bridgedma_job_t *job_last;
+ uint32_t icv_substitution;
+ uint32_t icv_current;
+ crc_t crc_ctx;
+ void *user_data;
+ phy_bridgedma_cb_t bridgedma_cb;
+ phy_deferred_cb_t deferred_cb;
+ station_ctx_t *station;
+ netclock_callback_t netclock_cb;
+#ifdef ECOS
+ cyg_interrupt interrupt;
+ cyg_handle_t interrupt_handle;
+#endif /* ECOS */
+};
+
+#ifndef ECOS
+int _pb_data_add(blk_t **pb_current, unsigned char **pb_data_ptr, unsigned int pb_size,
+ unsigned char *mac_ptr, unsigned int mac_len, bridgedma_copy_dir_t direction);
+#endif /* ECOS */
+
+#endif /*MAXIMUS_BRIDGEDMA_CTX_H_*/
diff --git a/cesar/hal/phy/maximus/inc/maximus_defs.h b/cesar/hal/phy/maximus/inc/maximus_defs.h
new file mode 100644
index 0000000000..a155fac59e
--- /dev/null
+++ b/cesar/hal/phy/maximus/inc/maximus_defs.h
@@ -0,0 +1,37 @@
+#ifndef hal_phy_maximus_inc_maximus_defs_h
+#define hal_phy_maximus_inc_maximus_defs_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/maximus/inc/maximus_defs.h
+ * \brief HAL PHY definitions for Maximus.
+ * \ingroup hal_phy_maximus
+ */
+
+/** Delay to receive the preamble, defined by the hardware, not precise.
+ */
+#define MAXIMUS_PHY_PREAMBLE_RECEPTION_DELAY_TCK (5 * 25) // 5 microseconds * 25 ticks per microsecond
+
+/** Delay to receive the frame control, defined by the hardware, not precise.
+ */
+#define MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK (5 * 25) // 5 microseconds * 25 ticks per microsecond
+
+/** Delay to receive the MPDU payload, defined by the hardware, not precise.
+ * \todo Get a real value from hardware team.
+ */
+#define MAXIMUS_PHY_MPDU_RECEPTION_DELAY_TCK ((5 + 5) * 25) // (5 microseconds + 5 microseconds) * 25 ticks per microsecond
+
+/** Threshold used to determinate if a netclock msg is considered to be programmed in the past.
+ */
+#define MAXIMUS_PHY_DATE_TOLERANCE 0x10000000 // 2^28
+
+/** Init value for random library (u32).
+ */
+#define MAXIMUS_PHY_LIB_RND_SEED 123
+
+#endif /* hal_phy_maximus_inc_maximus_defs_h */
diff --git a/cesar/hal/phy/maximus/inc/maximus_interrupts.h b/cesar/hal/phy/maximus/inc/maximus_interrupts.h
new file mode 100644
index 0000000000..c3881bfa00
--- /dev/null
+++ b/cesar/hal/phy/maximus/inc/maximus_interrupts.h
@@ -0,0 +1,22 @@
+#ifndef MAXIMUS_INTERRUPTS_H_
+#define MAXIMUS_INTERRUPTS_H_
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/maximus/inc/maximus_interrupts.h
+ * \brief HAL interrupt register definition for Maximus.
+ * \ingroup hal_phy_maximus
+ */
+
+#define PHY_HAL_INTERRUPT_PHY 4
+#define PHY_HAL_INTERRUPT_PBDMA 5
+#define PHY_HAL_INTERRUPT_BRIDGEDMA 6
+
+#define PHY_HAL_INTERRUPT_PRIORITY 1 /* is it the right value ? */
+
+#endif /*MAXIMUS_INTERRUPTS_H_*/
diff --git a/cesar/hal/phy/maximus/inc/maximus_phy_access.h b/cesar/hal/phy/maximus/inc/maximus_phy_access.h
new file mode 100644
index 0000000000..30ed00e0e5
--- /dev/null
+++ b/cesar/hal/phy/maximus/inc/maximus_phy_access.h
@@ -0,0 +1,102 @@
+#ifndef hal_phy_maximus_inc_maximus_phy_access_h
+#define hal_phy_maximus_inc_maximus_phy_access_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/maximus/inc/maximus_phy_access.h
+ * \brief HAL Phy access declarations for Maximus.
+ * \ingroup hal_phy_maximus
+ */
+
+/** Delay to detect a Priority Resolution Symbol, not precise. */
+#define MAXIMUS_PHY_PRS_DETECTION_DELAY_TCK (30 * 25) // 30 microseconds * 25 ticks per microsecond
+
+/**
+ * Maximus access backoff start callback called when the corresponding netclock message is received.
+ * \param data pointer to phy_t structure.
+ * set errno to:
+ * - EINVAL if data is null
+ * - EPROTO if medium state is not idle
+ * if 'netclock_schedule()' fails, it sets errno
+ */
+void maximus_phy_access_backoff_cb (void *data);
+
+/**
+ * Maximus access slot count callback called when the corresponding netclock message is received.
+ * \param data pointer to phy_t structure.
+ * set errno to:
+ * - EINVAL if data is null
+ * - EPROTO if medium state is not PRS0, PRS1 or CW
+ * if 'netclock_schedule()' fails, it sets errno
+ */
+void maximus_phy_access_slot_count_cb (void *data);
+
+/**
+ * Maximus access PRS0 callback called when the corresponding netclock message is received,
+ * i.e. when the PRS0 must be sent.
+ * \param data pointer to phy_t structure.
+ * set errno to:
+ * - EINVAL if data is null
+ * if 'sci_send()' fails, it sets errno
+ */
+void maximus_phy_access_prs0_cb (void *data);
+
+/**
+ * Maximus access PRS0 result callback called when the corresponding netclock message is received,
+ * i.e. at the end of the PRS0.
+ * \param data pointer to phy_t structure.
+ * set errno to:
+ * - EINVAL if data is null
+ * if 'netclock_schedule()' fails, it sets errno
+ */
+void maximus_phy_access_prs0_result_cb (void *data);
+
+/**
+ * Maximus access PRS1 callback called when the corresponding netclock message is received,
+ * i.e. when the PRS1 must be sent.
+ * \param data pointer to phy_t structure.
+ * set errno to:
+ * - EINVAL if data is null
+ * if 'sci_send()' or 'netclock_schedule()' fails, it sets errno
+ */
+void maximus_phy_access_prs1_cb (void *data);
+
+/**
+ * Maximus access PRP result callback called when the corresponding netclock message is received,
+ * i.e. at the end of the PRS1.
+ * \param data pointer to phy_t structure.
+ * set errno to:
+ * - EINVAL if data is null
+ */
+void maximus_phy_access_prp_result_cb (void *data);
+
+/**
+ * Maximus access timer program callback called when the corresponding netclock message is received.
+* \param data pointer to phy_t structure.
+ * set errno to:
+ * - EINVAL if data or ctx->control.access_cb are null
+ */
+void maximus_phy_access_timer_cb (void *data);
+
+/**
+ * Cancel the backoff procedure.
+ * \param ctx phy context.
+ * set errno to:
+ * - EINVAL if ctx is null
+ */
+void maximus_phy_access_backoff_cancel (phy_t *ctx);
+
+/**
+ * Reset the slot count.
+ * \param ctx phy context.
+ * set errno to:
+ * - EINVAL if ctx is null
+ */
+void maximus_phy_access_slot_count_reset (phy_t *ctx);
+
+#endif /* hal_phy_maximus_inc_maximus_phy_access_h */
diff --git a/cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h b/cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h
new file mode 100644
index 0000000000..c51bb6e6f5
--- /dev/null
+++ b/cesar/hal/phy/maximus/inc/maximus_phy_ctrl.h
@@ -0,0 +1,233 @@
+#ifndef hal_phy_maximus_inc_maximus_phy_ctrl_h
+#define hal_phy_maximus_inc_maximus_phy_ctrl_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/maximus/inc/maximus_phy_ctrl.h
+ * \brief HAL Phy control declarations for Maximus.
+ * \ingroup hal_phy_maximus
+ */
+
+#include "maximus/common/types/phy_types.h"
+#include "hal/phy/forward.h"
+#include "host/fwd.h"
+
+/**
+ * Fill a blank phy header
+ * \param ctx current phy context
+ * \param msg pointer to sci message to fill header
+ * \param type type of message (PREAMBLE, FC_HYBRID_MODE, FC_AV_ONLY_MODE, PRS, MPDU_PAYLOAD, TONEMASK, TONEMAP, NOISE, RX, ZERO_CROSS)
+ * \param mpdu_format MPDU format of message (BEACON, SOF, SACK, RTS_CTS, SOUND, RSOF)
+ * \param pb_nb number of PBs into message
+ * \param fc_mode Frame Control mode
+ * \param short_ppdu short PPDU
+ * \param mod modulation
+ * \param fecrate FEC rate
+ * \param gil Guard Interval
+ * \param tonemap_index tone map index used for message
+ * \param tx_id transmission ID used for message
+ * \param flags flags of message
+ * \param symbol_nb number of symbols into message
+ * \param iv iv used for message
+ * \param nek nek used for message
+ * \param pb_measurement ber, halfit and crc measured for each PB of message
+ * \param pb_header PB header for each PB of message
+ * \return 0 if ok, -1 if it fails with errno =
+ * - EINVAL if ctx or msg are NULL, or if arguments are out-of-range
+ */
+int
+maximus_phy_fill_hdr(phy_t *ctx,
+ sci_msg_t *msg,
+ uint8_t type,
+ uint8_t mpdu_format,
+ uint8_t pb_nb,
+ uint8_t msg_nb,
+ uint8_t fc_mode,
+ uint8_t short_ppdu,
+ uint8_t mod,
+ uint8_t fecrate,
+ uint8_t gil,
+ uint8_t tonemap_index,
+ uint16_t tx_id,
+ uint16_t flags,
+ uint32_t symbol_nb,
+ uint32_t iv[3],
+ uint32_t nek[4],
+ uint32_t pb_measurement[PHY_PB_MAX_NB],
+ uint32_t pb_header[PHY_PB_MAX_NB]);
+
+/**
+ * Process phy message received by the sci layer.
+ * This function must be registred to SCI layer with SCI_MSG_TYPE_PHY type.
+ * \param msg message to process
+ * \param phy phy current context
+ * \return 0 if ok, -1 if it fails with errno =
+ * - EINVAL if msg or phy are NULL
+ * - EPROTO if msg->hdr.phy is null, or if msg->hdr.phy values are out-of-range or incoherent
+ */
+int maximus_phy_recv (sci_msg_t *msg, void *phy);
+
+/**
+ * Process phy message received by the sci layer, depending on the phy header type.
+ * \param phy phy current context
+ * \param msg message to process
+ * \return 0 if ok, -1 if if it fails with errno =
+ * - EINVAL if ctx, msg, msg->sci_hdr or ctx->control.rx_fc_cb are null
+ * - EPROTO if msg->hdr.phy->type is incorrect, if msg->hdr.phy values are incorrect, incoherent or out-of-range,
+ * if recv MPDU payload but medium state is not RX or RX has not been prepared,
+ * or if chandata is null
+ */
+int maximus_phy_recv_none (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_preamble (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_fc_hybrid_mode (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_fc_av_only_mode (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_prs (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_mpdu_payload (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_tonemask (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_tonemap (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_noise (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_rx (phy_t *ctx, sci_msg_t *msg);
+int maximus_phy_recv_zero_cross (phy_t *ctx, sci_msg_t *msg);
+
+/**
+ * Maximus PHY preamble reception callback called when the corresponding netclock message is received.
+ * \param data pointer to 'maximus_phy_recv_preamble_t' structure,
+ * containing flag PHY_FLAG_WRONG_PREAMBLE of the received preamble message.
+ * set errno to:
+ * - EINVAL if data is null
+ */
+void maximus_phy_recv_preamble_cb (void *data);
+
+/** Maximus structure for Maximus preamble reception callback */
+struct maximus_phy_recv_preamble_t
+{
+ phy_t *ctx;
+ bool wrong_preamble;
+ uint16_t src_tx_id;
+ uint16_t src_station_id;
+};
+typedef struct maximus_phy_recv_preamble_t maximus_phy_recv_preamble_t;
+
+/**
+ * Send a PHY SCI message of type TONEMASK, TONEMAP or RX to Maximus.
+ * \param ctx phy current context
+ * \return 0 if ok, -1 if if it fails with errno =
+ * - EINVAL if ctx is null
+ * if 'sci_send()' fails, it sets errno
+ */
+int maximus_phy_send_tonemask (phy_t *ctx);
+int maximus_phy_send_tonemap (phy_t *ctx);
+int maximus_phy_send_rx (phy_t *ctx);
+
+/**
+ * Cancel the next TX frame request.
+ * \param ctx phy context.
+ * set errno to:
+ * - EINVAL if ctx is null
+ * if 'netclock_unschedule()' fails, it sets errno
+ */
+void maximus_phy_next_tx_frame_cancel (phy_t *ctx);
+
+/**
+ * Cancel the current TX frame request.
+ * \param ctx phy context.
+ * set errno to:
+ * - EINVAL if ctx is null
+ * if 'netclock_unschedule()' fails, it sets errno
+ */
+void maximus_phy_current_tx_frame_cancel (phy_t *ctx);
+
+/**
+ * Cancel the previous RX activate request.
+ * \param ctx phy context.
+ * set errno to:
+ * - EINVAL if ctx is null
+ * if 'netclock_unschedule()' fails, it sets errno
+ */
+void maximus_phy_rx_activate_cancel (phy_t *ctx);
+
+/**
+ * Compute schedule tick.
+ * \param date programmed date
+ * \return schedule tick if ok, -1 if programmed date is considered to be in the past with errno = EINVAL
+ */
+tick_t maximus_phy_schedule_tick (u32 date);
+
+/**
+ * Maximus TX frame first callback called when the corresponding netclock message is received.
+ * \param data pointer to 'maximus_tx_frame_t' structure, containing argument 'want_conf' of 'phy_tx_frame'.
+ * set errno to:
+ * - EINVAL if data, ctx->control.access_conf_cb or ctx->control.deferred_cb are null
+ * - EPROTO if medium state is not idle
+ * if 'netclock_schedule()' fails, it sets errno
+ */
+void maximus_phy_tx_frame_cb (void *data);
+
+/** Maximus structure for Maximus TX frame first callback */
+struct maximus_phy_tx_frame_t
+{
+ phy_t *ctx;
+ bool want_conf;
+};
+typedef struct maximus_phy_tx_frame_t maximus_phy_tx_frame_t;
+
+/**
+ * Maximus TX frame second callback called when the corresponding netclock message is received.
+ * \param data pointer to 'phy_t' structure.
+ * set errno to:
+ * - EINVAL if data is null
+ * - EPROTO if medium state is not tx
+ * if 'sci_send()' or 'netclock_schedule()' fails, it sets errno
+ */
+void maximus_phy_tx_pre_cb (void *data);
+
+/**
+ * Maximus TX frame third callback called when the corresponding netclock message is received.
+ * \param data pointer to 'phy_t' structure.
+ * set errno to:
+ * - EINVAL if data is null
+ * - EPROTO if medium state is not tx
+ * if 'sci_send()' or 'netclock_schedule()' fails, it sets errno
+ */
+void maximus_phy_tx_fc_cb (void *data);
+
+/**
+ * Maximus TX frame fourth callback called when the corresponding netclock message is received.
+ * \param data pointer to 'phy_t' structure.
+ * set errno to:
+ * - EINVAL if data is null
+ * - EPROTO if medium state is not tx
+ * if 'sci_send()' fails, it sets errno
+ */
+void maximus_phy_tx_mpdu_cb (void *data);
+
+/**
+ * Maximus RX activate callback called when the corresponding netclock message is received.
+ * \param data pointer to 'maximus_phy_rx_activate_t' structure, containing argument 'flag' of 'phy_rx_activate'.
+ * set errno to:
+ * - EINVAL if data is null
+ */
+void maximus_phy_rx_activate_cb (void *data);
+
+/** Maximus structure for Maximus RX activate callback */
+struct maximus_phy_rx_activate_t
+{
+ phy_t *ctx;
+ bool pre_detection;
+};
+typedef struct maximus_phy_rx_activate_t maximus_phy_rx_activate_t;
+
+/**
+ * Maximus extra timer program callback called when the corresponding netclock message is received.
+ * \param data pointer to 'phy_t' structure.
+ * set errno to:
+ * - EINVAL if data or ctx->control.extra_timer_cb are null
+ */
+void maximus_phy_extra_timer_cb (void *data);
+
+#endif /* hal_phy_maximus_inc_maximus_phy_ctrl_h */
diff --git a/cesar/hal/phy/maximus/inc/maximus_phy_ctx.h b/cesar/hal/phy/maximus/inc/maximus_phy_ctx.h
new file mode 100644
index 0000000000..df4e5b1ec4
--- /dev/null
+++ b/cesar/hal/phy/maximus/inc/maximus_phy_ctx.h
@@ -0,0 +1,282 @@
+#ifndef hal_phy_maximus_inc_maximus_phy_context_h
+#define hal_phy_maximus_inc_maximus_phy_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/maximus/inc/maximus_phy_context.h
+ * \brief HAL Phy context for Maximus.
+ * \ingroup hal_phy_maximus
+ */
+#include <stdint.h> // for uint32_t type
+#include "hal/phy/access.h"
+#include "hal/phy/bridgedma.h"
+#include "hal/phy/forward.h"
+#include "hal/phy/pbdma.h"
+#include "hal/phy/phy.h"
+#include "mac/common/tonemap.h" // for 'TONEMAP_INDEX_NB'
+#include "host/station.h"
+#include "host/netclock.h"
+#include "hal/phy/maximus/inc/maximus_trace.h"
+#include "lib/rnd.h" // for 'lib_rnd_t'
+#ifdef ECOS
+#include <cyg/hal/drv_api.h>
+#endif /* ECOS */
+
+/** Phy access medium state enum for Maximus */
+enum maximus_phy_medium_state_t
+{
+ MAXIMUS_PHY_MEDIUM_IDLE = 0x00,
+ MAXIMUS_PHY_MEDIUM_PRS0 = 0x01,
+ MAXIMUS_PHY_MEDIUM_PRS1 = 0x02,
+ MAXIMUS_PHY_MEDIUM_CW = 0x03,
+ MAXIMUS_PHY_MEDIUM_WAIT_CONF = 0x04,
+ MAXIMUS_PHY_MEDIUM_BUSY_RX = 0x05,
+ MAXIMUS_PHY_MEDIUM_BUSY_TX = 0x06
+};
+typedef enum maximus_phy_medium_state_t maximus_phy_medium_state_t;
+
+/** Phy RX_FC callback parameter structure for Maximus */
+struct maximus_phy_rx_fc_param_t
+{
+ u32 rx_date;
+ u32 *fc_av;
+};
+typedef struct maximus_phy_rx_fc_param_t maximus_phy_rx_fc_param_t;
+
+/** Phy TX parameters structure for Maximus */
+struct maximus_phy_tx_param_t
+{
+ /** Homeplug 1.0 frame control. */
+ u32 fc_10;
+ /** Tick at which Homeplug 1.0 frame control preparation will be finished. */
+ tick_t fc_10_tick;
+ /** Frame control mode. */
+ phy_fc_mode_t fc_mode;
+ /** True if no data symbols will be sent. */
+ bool short_ppdu;
+ /** Modulation type. */
+ phy_mod_t mod;
+ /** TCC rate. */
+ phy_fecrate_t fecrate;
+ /** PB size. */
+ phy_pb_size_t pb_size;
+ /** Guard interval for third symbol and following symbols. */
+ phy_gil_t gil;
+ /** Tonemap index where tonemap is stored. */
+ uint tonemap_index;
+ /** Number of symbols. */
+ uint symbol_nb;
+ /** Frame control. */
+ u32 fc_av[4];
+ /** Id of netclock message sent by 'phy_tx_frame'. */
+ netclock_id_t tx_frame_netclock_id;
+ /** Callback contexts to insert into callback queue. */
+ netclock_callback_t *tx_frame_netclock_cb;
+ /** Unique ID incremented for each transmission (TONEMAP if used, PREAMBLE, FC, and MPDU). */
+ uint16_t tx_id;
+};
+typedef struct maximus_phy_tx_param_t maximus_phy_tx_param_t;
+
+/** Phy RX parameters structure for Maximus */
+struct maximus_phy_rx_param_t
+{
+ /** Frame control mode. */
+ phy_fc_mode_t fc_mode;
+ /** True if no data symbols will be sent. */
+ bool short_ppdu;
+ /** Modulation type. */
+ phy_mod_t mod;
+ /** TCC rate. */
+ phy_fecrate_t fecrate;
+ /** PB size. */
+ phy_pb_size_t pb_size;
+ /** Guard interval for third symbol and following symbols. */
+ phy_gil_t gil;
+ /** Tonemap index where tonemap is stored. */
+ uint tonemap_index;
+ /** Number of symbols. */
+ uint symbol_nb; // not used for Maximus version 1
+ /** Homeplug 1.0 frame control. */
+ u32 fc_10;
+ /** Frame control. */
+ u32 fc_av[4];
+ /** Id of netclock message sent by 'phy_rx_activate'. */
+ netclock_id_t rx_activate_netclock_id;
+ /** Callback contexts to insert into callback queue. */
+ netclock_callback_t *rx_activate_netclock_cb;
+ /** Id of netclock message sent by 'maximus_phy_recv_preamble'. */
+ netclock_id_t recv_preamble_netclock_id;
+ /** Callback contexts to insert into callback queue. */
+ netclock_callback_t *recv_preamble_netclock_cb;
+ /** Transmission ID of the received frame (PREAMBLE, FC, MPDU, and NOISE if enabled). */
+ uint16_t src_tx_id;
+ /** Station ID of the received frame (PREAMBLE, FC, MPDU, and NOISE if enabled). */
+ uint16_t src_station_id;
+ /** Date of last start of preamble. */
+ u32 preamble_start_date;
+};
+typedef struct maximus_phy_rx_param_t maximus_phy_rx_param_t;
+
+/** Phy access structure for Maximus */
+struct maximus_phy_access_t
+{
+ /** Channel access priority. Priority to assert in next PRP. Can be changed at anytime (by 'phy_access_backoff_update'). */
+ u8 cap_mpdu;
+ /** Current CAP asserted in previous PRP. Can be changed under conditions (by 'phy_access_backoff_update'). */
+ u8 cap_sent;
+ /** Medium CAP decoded in previous PRP. */
+ u8 cap_medium;
+ /** Number of slots measured since end of PRP and before PRE detection. */
+ uint slot_count;
+ /** Possible values are: IDLE, PRS0, PRS1, CW, BUSY. */
+ maximus_phy_medium_state_t medium_state;
+ /** Received PRS0. */
+ bool prs0;
+ /** PRP result. */
+ bool prp_result;
+ /** Id of netclock message sent by 'phy_access_backoff_start',
+ * 'maximus_phy_access_backoff_cb' and 'maximus_phy_access_prs0_cb'. */
+ netclock_id_t backoff_start_netclock_id;
+ /** Callback context to insert into callback queue. */
+ netclock_callback_t *backoff_start_netclock_cb;
+ /** Id of netclock message sent by 'maximus_phy_access_backoff_cb' and 'maximus_phy_access_slot_count_cb'. */
+ netclock_id_t backoff_slot_count_netclock_id;
+ /** Callback context to insert into callback queue. */
+ netclock_callback_t *backoff_slot_count_netclock_cb;
+ /** Id of netclock message sent by 'phy_access_timer_program'. */
+ netclock_id_t timer_program_netclock_id;
+ /** Callback context to insert into callback queue. */
+ netclock_callback_t *timer_program_netclock_cb;
+};
+typedef struct maximus_phy_access_t maximus_phy_access_t;
+
+/** Phy control structure for Maximus */
+struct maximus_phy_ctrl_t
+{
+ /** User data passed to 'extra_timer_cb'. */
+ void *extra_timer_user_data;
+ /** User data passed to any other callback. */
+ void *user_data;
+ /** RX FC event callback. */
+ phy_rx_fc_cb_t rx_fc_cb;
+ /** ACCESS event callback. */
+ phy_access_cb_t access_cb;
+ /** ACCESS CONFIRM event callback. */
+ phy_access_conf_cb_t access_conf_cb;
+ /** PB DMA callback. */
+ phy_pbdma_cb_t pbdma_cb;
+ /** TX FALSE ALARM callback. */
+ phy_tx_false_alarm_cb_t tx_false_alarm_cb;
+ /** Zero cross callback. */
+ phy_zero_cross_cb_t zero_cross_cb;
+ /** DSR callback. */
+ phy_deferred_cb_t deferred_cb;
+ /** Extra timer callback. */
+ phy_extra_timer_cb_t extra_timer_cb;
+ /** Pointer to current PHY callback. */
+ void *current_cb;
+ /** Parameters for rx_fc callback. */
+ maximus_phy_rx_fc_param_t rx_fc_param;
+ /** Abort TX if PRP was lost. */
+ bool stop_tx_on_prp_lost;
+ /** Indicates if a TX has been blocked on a PRE TX false alarm. */
+ bool tx_blocked_on_false_alarm;
+ /** Used to enable or disable PRE detection. */
+ bool pre_detection;
+ /** Used to indicate if the RX has been prepared. */
+ bool rx_prepared;
+ /** Date of last zero-cross. */
+ u32 zero_cross_date;
+ /** Phy RX parameters. */
+ maximus_phy_rx_param_t rx_param;
+ /** Phy TX parameters for next TX request. */
+ maximus_phy_tx_param_t next_tx_param;
+ /** Phy TX parameters for current TX request. */
+ maximus_phy_tx_param_t current_tx_param;
+ /** Id of netclock message sent by 'phy_extra_timer_program'. */
+ netclock_id_t extra_timer_program_netclock_id;
+ /** Callback context to insert into callback queue. */
+ netclock_callback_t *extra_timer_program_netclock_cb;
+ /** Random library context.*/
+ lib_rnd_t *rnd;
+#ifdef ECOS
+ /** phy interrupt descriptor for eCos: relates to rx_fc, access and access_conf and extra_timer events */
+ cyg_interrupt phy_interrupt;
+ /** phy interrupt handle */
+ cyg_handle_t phy_interrupt_handle;
+ /** pbdma interrupt descriptor for eCos: relates to pbdma event */
+ cyg_interrupt pbdma_interrupt;
+ /** pbdma interrupt handle */
+ cyg_handle_t pbdma_interrupt_handle;
+#endif /* ECOS */
+};
+typedef struct maximus_phy_ctrl_t maximus_phy_ctrl_t;
+
+/** PB DMA structure for Maximus */
+struct maximus_pbdma_t
+{
+ /** Current status of pbdma: simulates the pbdma status register. */
+ phy_pbdma_status_t status_word;
+ /** Internal PB counter. */
+ u8 index_current_pb;
+ /** Do not encrypt or decrypt using AES. */
+ bool bypass_aes;
+ /** Three first AES initialisation vector words. */
+ u32 iv[3];
+ /** AES network encryption key. */
+ u32 nek[4];
+ /** Total number of PB. */
+ uint nb_total;
+ /** Number of ready descriptors. */
+ uint nb_ready;
+ /** Number of the PB after which an interrupt is triggered. */
+ uint nb_pb_it;
+ /** Used to indicate that a chandata transfer has been requested (true) or not (false). */
+ bool chandata_transfer;
+ /** First PB descriptor. */
+ phy_pb_t *first_pb;
+ /** Current PB descriptor for Rx. */
+ phy_pb_rx_t *current_pb;
+ /** First transfer descriptor. */
+ phy_chandata_t *first_chandata;
+ /** CRC bitmap registers. */
+ u32 crc_bitmap[8];
+};
+typedef struct maximus_pbdma_t maximus_pbdma_t;
+
+/** Tone Map DMA structure for Maximus */
+struct maximus_tmdma_t
+{
+ /** Number of carriers. */
+ uint carrier_nb;
+ /** Tonemask blocks first descriptor. */
+ u8 *tonemask; // tonemask[(PHY_CARRIER_NB+7)/8] (1 bit per carrier)
+ /** Tonemap blocks first descriptor. */
+ blk_t *tonemap[TONEMAP_INDEX_NB]; // tonemap[(PHY_CARRIER_NB+1)/2] (4 bits per carrier)
+};
+typedef struct maximus_tmdma_t maximus_tmdma_t;
+
+/** Phy context structure for Maximus */
+struct phy_t
+{
+ maximus_phy_access_t access;
+ maximus_phy_ctrl_t control;
+ maximus_pbdma_t pbdma;
+ maximus_tmdma_t tmdma;
+ /** For phy messages. */
+ unsigned char buffer[SCI_MSG_MAX_SIZE];
+ /** Set to true to enable assertions on WARNING messages. */
+ bool warning_assert;
+#if CONFIG_TRACE
+ /** PHY trace. */
+ trace_buffer_t trace;
+#endif /* !CONFIG_TRACE */
+};
+/* Forward declaration in hal/phy/forward.h. */
+
+#endif /* hal_phy_maximus_inc_maximus_phy_context_h */
diff --git a/cesar/hal/phy/maximus/inc/maximus_trace.h b/cesar/hal/phy/maximus/inc/maximus_trace.h
new file mode 100644
index 0000000000..74c9278909
--- /dev/null
+++ b/cesar/hal/phy/maximus/inc/maximus_trace.h
@@ -0,0 +1,98 @@
+#ifndef hal_phy_maximus_inc_trace_h
+#define hal_phy_maximus_inc_trace_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/maximus/inc/trace.h
+ * \brief Define PHY trace events.
+ * \ingroup hal_phy_maximus
+ */
+#include "lib/trace.h"
+
+/** Shortcut for tracing inside Maximus. */
+#define MAXIMUS_PHY_TRACE(id, args...) \
+ TRACE_FAST_SHORT (MAXIMUS_PHY_TRACE_, &ctx->trace, id, ## args)
+
+#if CONFIG_TRACE
+
+enum
+{
+ MAXIMUS_PHY_TRACE_INIT,
+ MAXIMUS_PHY_TRACE_SET_TONEMASK,
+ MAXIMUS_PHY_TRACE_UNINIT,
+ MAXIMUS_PHY_TRACE_RESET,
+ MAXIMUS_PHY_TRACE_CLOCK_SET_NUMERATOR,
+ MAXIMUS_PHY_TRACE_SET_TONEMAP,
+ MAXIMUS_PHY_TRACE_TX_FC10,
+ MAXIMUS_PHY_TRACE_TX_PARAM,
+ MAXIMUS_PHY_TRACE_TX_FRAME,
+ MAXIMUS_PHY_TRACE_RX_PARAM,
+ MAXIMUS_PHY_TRACE_RX_ACTIVATE,
+ MAXIMUS_PHY_TRACE_RX_ACTIVATE_NOW,
+ MAXIMUS_PHY_TRACE_RX_PREPARE,
+ MAXIMUS_PHY_TRACE_EXTRA_TIMER_PROGRAM,
+ MAXIMUS_PHY_TRACE_EXTRA_TIMER_CANCEL,
+ MAXIMUS_PHY_TRACE_ACCESS_CONF_CB,
+ MAXIMUS_PHY_TRACE_RX_FC_CB,
+ MAXIMUS_PHY_TRACE_TX_FALSE_ALARM_CB,
+ MAXIMUS_PHY_TRACE_DEFERRED_CB,
+ MAXIMUS_PHY_TRACE_EXTRA_TIMER_CB,
+
+ MAXIMUS_PHY_TRACE_ACCESS_BACKOFF_START,
+ MAXIMUS_PHY_TRACE_ACCESS_BACKOFF_UPDATE,
+ MAXIMUS_PHY_TRACE_ACCESS_TIMER_PROGRAM,
+ MAXIMUS_PHY_TRACE_ACCESS_TIMER_CANCEL,
+ MAXIMUS_PHY_TRACE_ACCESS_CB,
+
+ MAXIMUS_PHY_TRACE_PBDMA_START,
+ MAXIMUS_PHY_TRACE_PBDMA_UPDATE,
+ MAXIMUS_PHY_TRACE_PBDMA_START_CHANDATA,
+ MAXIMUS_PHY_TRACE_PBDMA_CB,
+
+ MAXIMUS_PHY_TRACE_M_PRP0,
+ MAXIMUS_PHY_TRACE_M_PRP1,
+ MAXIMUS_PHY_TRACE_M_PRP_END,
+ MAXIMUS_PHY_TRACE_M_SLOT,
+ MAXIMUS_PHY_TRACE_M_PRE_DETECT,
+ MAXIMUS_PHY_TRACE_M_FC_DETECT,
+ MAXIMUS_PHY_TRACE_M_RECV_MPDU_PAYLOAD,
+ MAXIMUS_PHY_TRACE_M_RECV_CHANDATA,
+ MAXIMUS_PHY_TRACE_M_TX_FRAME,
+ MAXIMUS_PHY_TRACE_M_TX_PRE,
+ MAXIMUS_PHY_TRACE_M_TX_FC,
+ MAXIMUS_PHY_TRACE_M_TX_SYMBOLS,
+ MAXIMUS_PHY_TRACE_M_TX_MPDU,
+ MAXIMUS_PHY_TRACE_M_RX_ACTIVATE,
+};
+
+BEGIN_DECLS
+
+/**
+ * Initialise trace buffer.
+ * \param ctx phy context
+ */
+void
+maximus_phy_trace_init (phy_t *ctx);
+
+/**
+ * Uninitialise trace buffer.
+ * \param ctx phy context
+ */
+void
+maximus_phy_trace_uninit (phy_t *ctx);
+
+END_DECLS
+
+#else /* !CONFIG_TRACE */
+
+# define maximus_phy_trace_init(ctx) ((void) 0)
+# define maximus_phy_trace_uninit(ctx) ((void) 0)
+
+#endif /* !CONFIG_TRACE */
+
+#endif /* hal_phy_maximus_inc_trace_h */