#ifndef ce_rx_inc_rx_h #define ce_rx_inc_rx_h /* Cesar project {{{ * * Copyright (C) 2009 Spidcom * * <<>> * * }}} */ /** * \file ce/rx/inc/rx.h * \brief Channel Estimation in Receive mode (private part). * \ingroup ce_rx * * This header provide the private declaration of the CE in RX. */ #include "mac/common/tonemap.h" #include "mac/common/store.h" #include "lib/mbox.h" #include "lib/slab.h" /* In order to include this header without eCos support, let's only include * and define eCos variable when we are building for an eCos target. */ #if defined (ECOS) && ECOS # include # include #endif #include "ce/rx/cp/cp.h" #include "ce/rx/bitloading/inc/initial.h" #include "ce/rx/bitloading/inc/bitloading.h" #include "common/defs/priority.h" #include "ce/rx/inc/trace.h" /** * Thread name of the CE in RX. */ #define CE_RX_THREAD_NAME "CE_RX" /** * Statistics of the CE in RX. */ typedef struct ce_rx_stat_t { /** * How many times we have re-sent (not just send) the tone map because TX * is not using it. */ uint resend_tm; } ce_rx_stat_t; struct ce_rx_t { /** * Pointer to the MAC store context. */ mac_store_t *mac_store; /** * Pointer to the MAC config context. */ mac_config_t *mac_config; #if defined (ECOS) && ECOS /** * Flag to know if the CE in RX thread has something to do. * Basically, the CE in RX thread sleep until another thread tell it to do * something (process measurements, stop, ...). */ cyg_flag_t work_flag; /** * Stack used bu the thread. */ u8 thread_stack[CE_RX_THREAD_STACK_SIZE]; /** * ECos thread handler. */ cyg_handle_t thread_handler; /** * The CE in RX ECos thread. */ cyg_thread thread; #endif /** * Stop the CE in RX. */ bool stop_flag; /** * List of released tone maps. */ tonemap_release_list_t tonemap_release_list; /** * Mailbox for the measure communication. */ mbox_t measure_mbox; /** * Cache slab allocator for the mailbox nodes. */ slab_cache_t measure_cache; /** * Mailbox for the exchange wih the CP. */ mbox_t cp_mbox; /** * Cache SLAB allocator for the CP mailbox nodes. */ slab_cache_t cp_mbox_cache; /** * The CP context that need to be contacted when we send MME. */ cp_t *cp_ctx; /** * The callback that need to be called when we need to send a MME. */ ce_rx_cp_signal_work_t cp_cb; #if defined (ECOS) && ECOS /** * eCos real-time clock handler (for real-time clock timers/alarms). */ cyg_handle_t real_time_clock_handle; /** * eCos real-time counter (for real-time clock timers/alarms). */ cyg_handle_t real_time_counter; /** * eCos alarm. */ cyg_alarm alarm; /** * eCos alarm handler. */ cyg_handle_t alarm_handler; #endif #if CONFIG_TRACE /** * CE/RX trace buffer, important. */ trace_buffer_t trace; /** * CE/RX trace verbose (less important). */ trace_buffer_t trace_verbose; #endif /** * Tick per RTC, for eCos timer & co. */ u32 tck_per_rtc; /** * Extra tone mask context used to handle faulty carriers. */ tonemask_info_t tonemask; /** * Statistics. */ ce_rx_stat_t stats; /** * Context of the bsu aclf used to retrieve the theoretical beacon * period duration. */ bsu_aclf_t *aclf; }; /** * Function prototype to calls when flag is set. */ typedef void (*ce_rx_process_work_t) (ce_rx_t *); /** * List of supported flags for work supported by the CE in RX. * This list correspond to the position of the flag in the bitfield. */ typedef enum ce_rx_work_flag_t { /** Stop the CE in RX thread. */ CE_RX_WORK_FLAG_QUIT = 0, /** Measurements processing from SAR. */ CE_RX_WORK_FLAG_MEASURE = 1, /** Size of this enum. */ CE_RX_WORK_FLAG_SIZE } ce_rx_work_flag_t; BEGIN_DECLS #if defined (ECOS) && ECOS /** * Main function of the CE RX thread. * \param data the CE RX context. */ void ce_rx_thread (cyg_addrword_t data); #endif /** * Add work for the CE RX thread. * \param ce_rx the context of the CE RX. * \param work the work to add to the CE RX. */ void ce_rx_work_add (ce_rx_t *ce_rx, ce_rx_work_flag_t work); /** * Process quit request from other threads. * \param ce_rx the CE in RX context. */ void ce_rx_process_work_quit (ce_rx_t *ce_rx); /** * Process new measure from the SAR. * \param ce_rx the CE in RX context. */ void ce_rx_process_work_measure (ce_rx_t *ce_rx); #if defined (ECOS) && ECOS /** * Prevent tone maps expiration. * This function is called every one second to go through each STA and check * if we need to send a MME to prevent tone maps expiration. * \param alarm the eCos alarm handler. * \param data the data associated. */ void ce_rx_timer_prevent_tone_map_expiration (cyg_handle_t alarm_handler, cyg_addrword_t data); #endif /** * Initialize statistics of the CE in RX. * \param ce_rx the CE in RX context. */ void ce_rx_stats_init (ce_rx_t *ce_rx); END_DECLS #endif /* ce_rx_inc_rx_h */