/*****************************************************************************

 @(#) sl_s508.h,v SS7preBetaRelease(0.8) 2002/04/02 08:21:00

 -----------------------------------------------------------------------------

 Copyright (c) 2001-2002  OpenSS7 Corporation <http://www.openss7.com>
 Copyright (c) 1997-2000  Brian F. G. Bidulock <bidulock@dallas.net>

 All Rights Reserved.

 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation; either version 2 of the License, or (at your option) any later
 version.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 details.

 You should have received a copy of the GNU General Public License along with
 this program; if not, write to the Free Software Foundation, Inc., 675 Mass
 Ave, Cambridge, MA 02139, USA.

 -----------------------------------------------------------------------------

 U.S. GOVERNMENT RESTRICTED RIGHTS.  If you are licensing this Software on
 behalf of the U.S. Government ("Government"), the following provisions apply
 to you.  If the Software is supplied by the Department of Defense ("DoD"), it
 is classified as "Commercial Computer Software" under paragraph 252.227-7014
 of the DoD Supplement to the Federal Acquisition Regulations ("DFARS") (or any
 successor regulations) and the Government is acquiring only the license rights
 granted herein (the license rights customarily provided to non-Government
 users).  If the Software is supplied to any unit or agency of the Government
 other than DoD, it is classified as "Restricted Computer Software" and the
 Government's rights in the Software are defined in paragraph 52.227-19 of the
 Federal Acquisition Regulations ("FAR") (or any success regulations) or, in
 the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR
 (or any successor regulations).

 -----------------------------------------------------------------------------

 Commercial licensing and support of this software is available from OpenSS7
 Corporation at a fee.  See http://www.openss7.com/

 -----------------------------------------------------------------------------

 Last Modified 2002/04/02 08:21:00 by brian

 *****************************************************************************/

#ifndef __S514_H__
#define __S514_H__

#ident "@(#) sl_s508.h,v SS7preBetaRelease(0.8) 2002/04/02 08:21:00"

/*
 *  Global commands
 */
#define READ_GLOBAL_EXCEPTION_CONDITION     0x01
#define SET_GLOBAL_CONFIGURATION            0x02
#define READ_GLOBAL_CONFIGURATION           0x03
#define READ_GLOBAL_STATISTICS              0x04
#define FLUSH_GLOBAL_STATISTICS             0x05
#define SET_MODEM_STATUS                    0x06
#define READ_MODEM_STATUS                   0x07
#define READ_COMMS_ERROR_STATS              0x08
#define FLUSH_COMMS_ERROR_STATS             0x09
#define SET_TRACE_CONFIGURATION             0x0a
#define READ_TRACE_CONFIGURATION            0x0b
#define READ_TRACE_STATISTICS               0x0c
#define FLUSH_TRACE_STATISTICS              0x0d

/*
 *  SS7 L2 Commands
 */
#define READ_SS7_CODE_VERSION               0x20
#define L2_READ_EXCEPTION_CONDITION         0x21
#define L2_SET_CONFIGURATION                0x22
#define L2_READ_CONFIGURATION               0x23
#define L2_READ_LINK_STATUS                 0x24
#define L2_READ_OPERATIONAL_STATS           0x25
#define L2_FLUSH_OPERATIONAL_STATS          0x26
#define L2_READ_HISTORY_TABLE               0x27
#define L2_FLUSH_HISTORY_TABLE              0x28
#define L2_SET_INTERRUPT_TRIGGERS           0x30
#define L2_READ_INTERRUPT_TRIGGERS          0x31
#define L2_POWER_ON                         0x40
#define L2_EMERGENCY                        0x41
#define L2_EMERGENCY_CEASES                 0x42
#define L2_START                            0x43
#define L2_STOP                             0x44
#define L2_RESUME                           0x45
#define L2_RETRIEVE_BSNT                    0x46
#define L2_RETRIEVAL_REQ_AND_FSNC           0x47
#define L2_CLEAR_BUFFERS                    0x48
#define L2_CLEAR_RTB                        0x49
#define L2_LOCAL_PROCESSOR_OUTAGE           0x4a
#define L2_CONTINUE                         0x4b
#define L2_CONGESTION_CONTROL               0x4c

/*
 *  READ_GLOBAL_EXCEPTION_CONDITION
 */
#define NO_GLOBAL_EXCEP_COND_TO_REPORT
#define EXCEP_MODEM_STATUS_CHANGE
#define EXCEP_TRC_DISABLED
#define EXCEP_APP_IRQ_TIMEOUT
#define EXCEP_FT1_INS_ALARM_COND
#define EXCEP_ASY_BREAK_RECEIVED
    /*
     *  EXCEP_MODEM_STATUS_CHANGE
     */
#   define MODEM_STATUS_DCD_CHANGED 0x04
#   define MODEM_STATUS_DCD_SETTING 0x08
#   define MODEM_STATUS_CTS_CHANGED 0x10
#   define MODEM_STATUS_CTS_SETTING 0x20

/*
 *  SET_GLOBAL_CONFIGURATION
 *  READ_GLOBAL_CONFIGURATION
 */
#define MAX_APP_IRQ_TIMEOUT_VALUE 600000
typedef struct {
    int     adapter_config_options;
    int     app_IRQ_timeout;
    int     adapter_operating_frequency;
} GLOBAL_CONFIGURATION_STRUCT;

#define OK
#define LGTH_GLOBAL_CFG_DATA_INVALID
#define IRQ_TIMEOUT_INVALID
#define ADAPTER_OPERATING_FREQ_INVALID

/*
 *  READ_GLOBAL_STATISTICS
 */
typedef struct {
    int     app_IRQ_timeout_count;
    int     FT1_INS_alarm_count;
} GLOBAL_STATS_STRUCT;

/*
 *  SET_MODEM_STATUS
 *  READ_MODEM_STATUS
 */
#define MODEM_STATUS_DTR_SETTING 0x01
#define MODEM_STATUS_RTS_SETTING 0x02
//#define MODEM_STATUS_DCD_SETTING 0x08
//#define MODEM_STATUS_CTS_SETTING 0x20

/*
 *  READ_COMMS_ERROR_STATS
 */
typedef struct {
    int     CRC_err_count;
    int     Rx_abort_count;
    int     Rx_dis_pri_bfrs_full_count;
} COMMS_ERROR_STATS_STRUCT;

/*
 *  SET_TRACE_CONFIGURATION
 *  READ_TRACE_CONFIGURATION
 */
#define MIN_TRC_DEAC_TMR_VAL
#define MAX_TRC_DEAC_TMR_VAL
typedef struct {
    char    trace_config;
#   define TRACE_ACTIVE
#   define TRACE_DELAY_MODE
#   define TRACE_FISU
#   define TRACE_LSSU
#   define TRACE_MSU
    int     trace_deactivation_timer;
    void*   ptr_trace_stat_el_cfg_struct;
} LINE_TRACE_CONFIG_STRUCT;

#define LGTH_TRC_CFG_DATA_INVALID
#define TRACE_CONFIG_INVALID
#define TRC_DEAC_TMR_INVALID

/*
 *  READ_TRACE_STATISTICS
 */
typedef struct {
    int     frames_traced_count;
    int     trc_frames_not_recorded_count;
    int     trc_disabled_internally_count;
} LINE_TRACE_STATS_STRUCT;

/*
 *  L2_READ_EXCEPTION_CONDITION
 */
#define NO_L2_EXCEP_COND_TO_REPORT
#define L2_EXCEP_IN_SERVICE
#define L2_EXCEP_OUT_OF_SERVICE
#define L2_EXCEP_REMOTE_PROC_OUTAGE
#define L2_EXCEP_REPORT_PROC_RECOVERED
#define L2_EXCEP_RTB_CLEARED
#define L2_EXCEP_RB_CLEARED
#define L2_EXCEP_BSNT
#define L2_EXCEP_RETRIEVAL_COMPLETE
#define L2_EXCEP_CONG_INBOUND
#define L2_EXCEP_CONG_INBOUND_CEASED
#define L2_EXCEP_CONG_OUTBOUND
#define L2_EXCEP_CONG_OUTBOUND_CEASED

/*
 *  L2_SET_CONFIGURATION
 */

typedef struct {
} SHARED_MEMORY_INFO_STRUCT;

typedef struct {
    int     baud_rate;
#           define MAX_BAUD_RATE
    int     line_config_options;
#           define  DONT_RAISE_DTR_RTS_ON_EN_COMMS
#           define  DONT_REPORT_CHG_IN_MODEM_STATUS
    int     modem_status_timer;
#           define  MIN_PERMITTED_MODEM_TIMER
#           define  MAX_PERMITTED_MODEM_TIMER
    int     L2_API_options;
    int     L2_protocol_options;
#           define  LSSU_TWO_BYTE_SF
#           define  AUTO_START_WHEN_OUT_OF_SERVICE
#           define  MANUAL_RESUME_AFTER_REM_PROC_OUT
#           define  ENABLE_INTERNAL_RX_FLOW_CTRL
#           define  ENABLE_INTERNAL_TX_FLOW_CTRL
#           define  PREVENTIVE_CYCLIC_RETRANS
    int     L2_protocol_specification;
    int     L2_stats_history_option;
    int     T1_timer;
    int     T2_timer;
    int     T3_timer;
    int     T4_timer;
    int     T5_timer;
    int     T6_timer;
    int     T7_timer;
    int     T8_timer;
    int     emergency_proving_period;
    int     normal_proving_period;
    SHARED_MEMORY_INFO_STRUCT       *ptr_shared_mem_info_struct;
    L2_TX_STATUS_EL_CFG_STRUCT      *ptr_L2_Tx_stat_el_cfg_struct;
    L2_RX_STATUS_EL_CFG_STRUCT      *ptr_L2_Rx_stat_el_cfg_struct;
} L2_CONFIGURATION_STRUCT;

#define L2_STOP_BEFORE_CFG
#define LGTH_L2_CFG_DATA_INVALID
#define INVALID_L2_CFG_DATA

/*
 *  L2_READ_LINK_STATUS
 */
typedef struct {
    int     L2_link_status;
    int     no_Rx_MSUs_avail_forL3;
    int     receiver_status;
} L2_LINK_STATUS_STRUCT;

/*
 *  L2_READ_OPERATIONAL_STATS
 */
typedef struct {
    int     MSU_Tx_throughput;
    int     no_hs_for_MSU_Tx_thruput_comp;
    int     MSU_Rx_throughput;
} L2_OPERATIONAL_STATS_STRUCT;

/*
 *  L2_READ_HISTORY_TABLE
 */
typedef struct {
} L2_HISTORY_STRUCT;

/*
 *  SET_SS7_INTERRUPT_TRIGGERS
 *  READ_SS7_INTERRUPT_TRIGGERS
 */
typedef struct {
    int     L2_interrupt_triggers;
#           define RX_APP_INT_PEND                  0x01
#           define TX_APP_INT_PEND                  0x02
#           define COMMAND_COMPLETE_APP_INT_PEND    0x04
#           define TIMER_APP_INT_PEND               0x08
#           define GLOBAL_EXCEP_COND_APP_INT_PEND   0x10
#           define L2_EXCEP_COND_APP_INT_PEND       0x20
#           define RESERVED_APP_INT_PEND            0x40
#           define TRACE_DATA_AVAIL_APP_IND_PEND    0x80
    int     IRQ;
    int     interrupt_timer;
#           define MAX_L2_INTERRUPT_TIMER   60000
    int     misc_interrupt_bits;
} L2_INT_TRIGGERS_STRUCT;

#define LGTH_INT_TRIGGERS_DATA_INVALID
#define INVALID_IRQ_SELECTED
#define IRQ_TMR_VALUE_INVALID

/*
 *  L2_POWER_ON
 */
#define L2_CFG_BEFORE_POWER_ON
#define L2_INVALID_STATE_FOR_COMMAND
#define L2_INVALID_PROTOCOL_FOR_COMMAND

/*
 *  L2_CONGESTION_CONTROL
 */
#define L2_NO_CONGESTION
#define L2_CONGESTION_ACCEPT
#define L2_CONGESTION_DISCARD

typedef struct {
    int     L2_status;
    int     L2_excep_conditions;
} L2_INFORMATION_STRUCT;

typedef struct {
    int     global_status;
    int     global_exception_condition;
    int     code_name;
    int     code_version;
} GLOBAL_INFORMATION_STRUCT;

typedef struct {
    uchar_t interrupt_type;
    uchar_t interrupt_permission;
} INTERRUPT_INFORMATION_STRUCT;

typedef struct {
    GLOBAL_INFORMATION_STRUCT       global_info_struct;
    L2_INFORMATION_STRUCT           L2_info_struct;
    RES_INFORMATION_STRUCT          res0_info_struct;
    RES_INFORMATION_STRUCT          res1_info_struct;
    INTERRUPT_INFORMATION_STRUCT    interrupt_info_struct;
    FT1_INFORMATION_STRUCT          FT1_info_struct;
} SHARED_MEMORY_INFO_STRUCT;

typedef struct {
    int     number_Tx_status_elements;
    int     base_addr_Tx_status_elements;
    int     next_Tx_Status_element_to_use;
} L2_TX_STATUS_EL_CFG_STRUCT;

typedef struct {
    int     number_Rx_status_elements;
    int     base_addr_Rx_status_elements;
    int     next_Rx_Status_element_to_use;
} L2_RX_STATUS_EL_CFG_STRUCT;

typedef struct {
    int     number_trace_status_elements;
    int     base_addr_trace_status_elements;
    int     next_trace_element_to_use;
    int     base_addr_trace_buffer;
    int     end_addr_trace_buffer;
} TRACE_STATUS_EL_CFG_STRUCT;

typedef struct {
    int     opp_flag;
    int     frame_length;
    int     sio;
    int     reserved_1;
    int     reserved_2;
    int     ptr_data_bfr;
} L2_MSU_TX_STATUS_EL_STRUCT;

typedef struct {
    int     opp_flag;
    int     frame_length;
    int     sio;
    ushort_t    time_stamp;
    int     reserved_1;
    int     reserved_2;
    int     ptr_data_bfr;
} L2_MSU_RX_STATUS_EL_STRUCT;

typedef struct {
    int     opp_flag;
    int     trace_length;
    int     trace_type;
    ushort_t    time_stamp;
    int     ptr_data_bfr;
} TRACE_STATUS_ELEMENT_STRUCT;


#endif  /* __S514_H__ */

