#ifndef __PPB_MSQ_H
#define __PPB_MSQ_H
#define MS_INS_MASK 0x00ff
#define MS_ARG_MASK 0x0f00
#define MS_TYP_MASK 0xf000
#define MS_INS_OFFSET 0
#define MS_ARG_OFFSET 8
#define MS_TYP_OFFSET 12
#define MS_TYP_INT 0x0
#define MS_TYP_CHA 0x1
#define MS_TYP_PTR 0x2
#define MS_TYP_FUN 0x3
#define MS_PARAM(ins,arg,typ) \
(((ins<<MS_INS_OFFSET) & MS_INS_MASK) | \
((arg<<MS_ARG_OFFSET) & MS_ARG_MASK) | \
((typ<<MS_TYP_OFFSET) & MS_TYP_MASK))
#define MS_INS(param) ((param & MS_INS_MASK) >> MS_INS_OFFSET)
#define MS_ARG(param) ((param & MS_ARG_MASK) >> MS_ARG_OFFSET)
#define MS_TYP(param) ((param & MS_TYP_MASK) >> MS_TYP_OFFSET)
#define MS_OP_GET 0
#define MS_OP_PUT 1
#define MS_OP_RFETCH 2
#define MS_OP_RSET 3
#define MS_OP_RASSERT 4
#define MS_OP_DELAY 5
#define MS_OP_SET 6
#define MS_OP_DBRA 7
#define MS_OP_BRSET 8
#define MS_OP_BRCLEAR 9
#define MS_OP_RET 10
#define MS_OP_C_CALL 11
#define MS_OP_PTR 12
#define MS_OP_ADELAY 13
#define MS_OP_BRSTAT 14
#define MS_OP_SUBRET 15
#define MS_OP_CALL 16
#define MS_OP_RASSERT_P 17
#define MS_OP_RFETCH_P 18
#define MS_OP_TRIG 19
#define MS_CLEAR_ALL 0x0
#define MS_ASSERT_NONE 0x0
#define MS_ASSERT_ALL 0xff
#define MS_FETCH_ALL 0xff
#define MS_NULL 0
#define MS_UNKNOWN MS_NULL
#define MS_ACCUM -1
#define MS_REG_DTR 0x0
#define MS_REG_STR 0x1
#define MS_REG_CTR 0x2
#define MS_REG_EPP_A 0x3
#define MS_REG_EPP_D 0x4
#define MS_RSET(reg,assert,clear) { MS_OP_RSET, {{ (reg) }, { (assert) }, { (clear) }}}
#define MS_RASSERT(reg,byte) { MS_OP_RASSERT, { { (reg) }, { (byte) }}}
#define MS_RCLR(reg,clear) { MS_OP_RSET, {{ (reg) }, { MS_ASSERT_NONE }, { (clear) }}}
#define MS_RFETCH(reg,mask,ptr) { MS_OP_RFETCH, {{ (reg) }, { (mask) }, { (ptr) }}}
#define MS_TRIG(reg,len,array) { MS_OP_TRIG, {{ (reg) }, { (len) }, { (array) }}}
#define MS_RASSERT_P(n,reg) { MS_OP_RASSERT_P, {{ (n) }, { (reg) }}}
#define MS_RFETCH_P(n,reg,mask) { MS_OP_RFETCH_P, {{ (n) }, { (reg) }, { (mask) }}}
#define MS_PTR(ptr) { MS_OP_PTR, {{ (ptr) }}}
#define MS_DASS(byte) MS_RASSERT(MS_REG_DTR,byte)
#define MS_SASS(byte) MS_RASSERT(MS_REG_STR,byte)
#define MS_CASS(byte) MS_RASSERT(MS_REG_CTR,byte)
#define MS_SET(accum) { MS_OP_SET, {{ (accum) }}}
#define MS_BRSET(mask,offset) { MS_OP_BRSET, {{ (mask) }, { (offset) }}}
#define MS_DBRA(offset) { MS_OP_DBRA, {{ (offset) }}}
#define MS_BRCLEAR(mask,offset) { MS_OP_BRCLEAR, {{ (mask) }, { (offset) }}}
#define MS_BRSTAT(mask_set,mask_clr,offset) \
{ MS_OP_BRSTAT, {{ mask_set }, { mask_clr }, { (offset) }}}
#define MS_C_CALL(function,parameter) \
{ MS_OP_C_CALL, {{ (function) }, { (parameter) }}}
#define MS_CALL(microseq) { MS_OP_CALL, {{ (microseq) }}}
#define MS_PUT(ptr,len) { MS_OP_PUT, {{ (ptr) }, { (len) }}}
#define MS_GET(ptr,len) { MS_OP_GET, {{ (ptr) }, { (len) }}}
#define MS_DELAY(udelay) { MS_OP_DELAY, {{ (udelay) }}}
#define MS_ADELAY(mdelay) { MS_OP_ADELAY, {{ (mdelay) }}}
#define MS_SUBRET(code) { MS_OP_SUBRET, {{ (code) }}}
#define MS_RET(code) { MS_OP_RET, {{ (code) }}}
#define ppb_MS_GET_init(bus,dev,body) ppb_MS_init(bus, dev, body, MS_OP_GET)
#define ppb_MS_PUT_init(bus,dev,body) ppb_MS_init(bus, dev, body, MS_OP_PUT)
extern int ppb_MS_init(
device_t,
device_t,
struct ppb_microseq *,
int opcode
);
extern int ppb_MS_init_msq(
struct ppb_microseq *,
int,
...
);
extern int ppb_MS_exec(
device_t,
device_t,
int,
union ppb_insarg,
union ppb_insarg,
union ppb_insarg,
int *
);
extern int ppb_MS_loop(
device_t,
device_t,
struct ppb_microseq *,
struct ppb_microseq *,
struct ppb_microseq *,
int,
int *
);
extern int ppb_MS_microseq(
device_t,
device_t,
struct ppb_microseq *,
int *
);
#endif