summaryrefslogtreecommitdiff
path: root/kernel/xpp/xproto.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/xpp/xproto.h')
-rw-r--r--kernel/xpp/xproto.h66
1 files changed, 26 insertions, 40 deletions
diff --git a/kernel/xpp/xproto.h b/kernel/xpp/xproto.h
index f68fedf..4691094 100644
--- a/kernel/xpp/xproto.h
+++ b/kernel/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);