From 8eeb67728cc1db4007233f862c61376a094c9d41 Mon Sep 17 00:00:00 2001 From: tzafrir Date: Tue, 13 May 2008 20:01:23 +0000 Subject: xpp r5723: Includes, among others: * New firmware protocol version: 3.0 . * New numbers for the device types: (e.g. in card_init* scripts) - FXS: 1 (was: 3) - FXO: 2 (was: 4) - BRI: 3 (was: 6 for TE, 7 for NT) - PRI: 4 (was: 9) * Init scripts of FXS and FXO modules are now written in Perl as well (be sure to have File::Basename, e.g: perl-modules in Debian). * calibrate_slics merged into init_card_1_30 . * Module parameter print_dbg replaced with debug . Same meaning. * init_fxo_modes removed: content moved into init_card_2_30, verified at build time. * Code tested with sparse. Most warnings were fixed. * Set ZT_SIG_DACS for the bchans in the PRI and BRI modules to not get ignored by ztscan. * Handle null config_desc we get from some crazy USB controllers. * genzaptelconf: Fix reporting of empty slots in list mode. * xpp_blink can now blink a single analog port. * "slics" has been renamed "chipregs". * Fixed a small typo in fpga_load(8). * Fixed bashism in xpp_fxloader. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@4264 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- xpp/xproto.h | 66 ++++++++++++++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 40 deletions(-) (limited to 'xpp/xproto.h') diff --git a/xpp/xproto.h b/xpp/xproto.h index f68fedf..4691094 100644 --- a/xpp/xproto.h +++ b/xpp/xproto.h @@ -32,15 +32,21 @@ /* * This must match the firmware protocol version */ -#define XPP_PROTOCOL_VERSION 29 +#define XPP_PROTOCOL_VERSION 30 struct xpd_addr { - uint8_t unit:UNIT_BITS; uint8_t subunit:SUBUNIT_BITS; uint8_t reserved:1; + uint8_t unit:UNIT_BITS; uint8_t sync_master:1; } PACKED; +#define MKADDR(p, u, s) do { \ + (p)->unit = (u); \ + (p)->subunit = (s); \ + (p)->sync_master = 0; \ + } while(0) + struct xpacket_header { uint16_t packet_len:10; uint16_t reserved:1; @@ -68,12 +74,11 @@ struct xpacket_header { * 0 - TO_PSTN * 1 - TO_PHONE */ -#define XPD_TYPE_FXS 3 // TO_PHONE -#define XPD_TYPE_FXO 4 // TO_PSTN -#define XPD_TYPE_BRI_TE 6 // TO_PSTN -#define XPD_TYPE_BRI_NT 7 // TO_PHONE -#define XPD_TYPE_PRI 9 // TO_PSTN/TO_PHONE (runtime) -#define XPD_TYPE_NOMODULE 15 +#define XPD_TYPE_FXS 1 // TO_PHONE +#define XPD_TYPE_FXO 2 // TO_PSTN +#define XPD_TYPE_BRI 3 // TO_PSTN/TO_PHONE (from hardware) +#define XPD_TYPE_PRI 4 // TO_PSTN/TO_PHONE (runtime) +#define XPD_TYPE_NOMODULE 7 typedef byte xpd_type_t; @@ -140,14 +145,14 @@ bool valid_xpd_addr(const struct xpd_addr *addr); #define XFRAME_NEW_CMD(frm, p, xbus, card, op, to) \ do { \ - int len = RPACKET_SIZE(card,op); \ + int pack_len = RPACKET_SIZE(card,op); \ \ if(!TRANSPORT_RUNNING(xbus)) \ return -ENODEV; \ frm = ALLOC_SEND_XFRAME(xbus); \ if(!frm) \ return -ENOMEM; \ - (p) = xframe_next_packet(frm, len); \ + (p) = xframe_next_packet(frm, pack_len); \ if(!(p)) \ return -ENOMEM; \ XPACKET_INIT(p, card, op, to, 0, 0); \ @@ -156,38 +161,21 @@ bool valid_xpd_addr(const struct xpd_addr *addr); #endif /*--------------------------- register handling --------------------------------*/ -/* - * After the opcode, there are always: - * * A size (in bytes) of the rest. Only 6 bits are counted: - * - The MSB signifies a multibyte write (to BRI fifo) - * - The MSB-1 signifies end of frame to multibyte writes in BRI. - * A normal register command (not multibyte) than contains: - * * A channel selector byte: - * - ALL_CHANS (currently 31) is a broadcast request to set a - * register for all channels. - * - Smaller numbers (0-30) represent the addressed channel number. - * - The MSB signifies: - * 1 - register [R]ead request - * 0 - register [W]rite request - * * Register number - * * Subregister number -- 0 when there is no subregister - * * Data low - * * Data high -- 0 for single byte registers (direct registers) - * A multibyte register command than contains a sequence of bytes. - */ #define MULTIBYTE_MAX_LEN 5 /* FPGA firmware limitation */ typedef struct reg_cmd { - byte bytes:6; + byte bytes:3; /* Length (for Multibyte) */ byte eoframe:1; /* For BRI -- end of frame */ - byte multibyte:1; /* For BRI -- fifo data */ + byte portnum:3; /* For port specific registers */ + byte is_multibyte:1; union { struct { - byte chipsel:CHAN_BITS; /* chip select */ - byte reserved:1; + byte reserved:4; + byte do_datah:1; byte do_subreg:1; byte read_request:1; + byte all_ports_broadcast:1; byte regnum; byte subreg; byte data_low; @@ -228,7 +216,8 @@ xproto_handler_t xproto_global_handler(byte opcode); (xpd)->xops->name(xbus, xpd, ## __VA_ARGS__ ) struct xops { - xpd_t *(*card_new)(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table, byte subtype, byte revision); + xpd_t *(*card_new)(xbus_t *xbus, int unit, int subunit, + const xproto_table_t *proto_table, byte subtype, int subunits, bool to_phone); int (*card_init)(xbus_t *xbus, xpd_t *xpd); int (*card_remove)(xbus_t *xbus, xpd_t *xpd); int (*card_tick)(xbus_t *xbus, xpd_t *xpd); @@ -243,8 +232,6 @@ struct xops { int (*card_register_reply)(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *reg); int (*XPD_STATE)(xbus_t *xbus, xpd_t *xpd, bool on); - int (*RING)(xbus_t *xbus, xpd_t *xpd, lineno_t chan, bool on); - int (*RELAY_OUT)(xbus_t *xbus, xpd_t *xpd, byte which, bool on); }; struct xproto_entry { @@ -259,6 +246,7 @@ struct xproto_table { xproto_entry_t entries[256]; /* Indexed by opcode */ xops_t xops; xpd_type_t type; + byte ports_per_subunit; const char *name; bool (*packet_is_valid)(xpacket_t *pack); void (*packet_dump)(const char *msg, xpacket_t *pack); @@ -277,8 +265,6 @@ struct xpacket { struct xpacket_header head; union { MEMBER(GLOBAL, NULL_REPLY); - MEMBER(GLOBAL, DESC_REQ); - MEMBER(GLOBAL, DEV_DESC); MEMBER(GLOBAL, PCM_WRITE); MEMBER(GLOBAL, PCM_READ); MEMBER(GLOBAL, SYNC_REPLY); @@ -292,8 +278,8 @@ struct xpacket { /* Last byte is chksum */ } PACKED; -void dump_packet(const char *msg, const xpacket_t *packet, bool print_dbg); -void dump_reg_cmd(const char msg[], const reg_cmd_t *regcmd, bool writing); +void dump_packet(const char *msg, const xpacket_t *packet, bool debug); +void dump_reg_cmd(const char msg[], bool writing, xbus_t *xbus, byte unit, xportno_t port, const reg_cmd_t *regcmd); int xframe_receive(xbus_t *xbus, xframe_t *xframe); void notify_bad_xpd(const char *funcname, xbus_t *xbus, const struct xpd_addr addr, const char *msg); int xproto_register(const xproto_table_t *proto_table); -- cgit v1.2.3