ppb_msq.h revision 39134
138061Smsmith/*- 238061Smsmith * Copyright (c) 1998 Nicolas Souchu 338061Smsmith * All rights reserved. 438061Smsmith * 538061Smsmith * Redistribution and use in source and binary forms, with or without 638061Smsmith * modification, are permitted provided that the following conditions 738061Smsmith * are met: 838061Smsmith * 1. Redistributions of source code must retain the above copyright 938061Smsmith * notice, this list of conditions and the following disclaimer. 1038061Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1138061Smsmith * notice, this list of conditions and the following disclaimer in the 1238061Smsmith * documentation and/or other materials provided with the distribution. 1338061Smsmith * 1438061Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1538061Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1638061Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1738061Smsmith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1838061Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1938061Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2038061Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2138061Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2238061Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2338061Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2438061Smsmith * SUCH DAMAGE. 2538061Smsmith * 2639134Snsouch * $Id: ppb_msq.h,v 1.1.2.7 1998/06/20 19:03:47 son Exp $ 2738061Smsmith * 2838061Smsmith */ 2938061Smsmith#ifndef __PPB_MSQ_H 3038061Smsmith#define __PPB_MSQ_H 3138061Smsmith 3238061Smsmith/* 3338061Smsmith * Basic definitions 3438061Smsmith */ 3538061Smsmith 3638061Smsmith/* microsequence parameter descriptor */ 3738061Smsmith#define MS_INS_MASK 0x00ff /* mask to retrieve the instruction position */ 3838061Smsmith#define MS_ARG_MASK 0x0f00 /* mask to retrieve the argument number */ 3938061Smsmith#define MS_TYP_MASK 0xf000 /* mask to retrieve the type of the param */ 4038061Smsmith 4138061Smsmith/* offset of each mask (see above) */ 4238061Smsmith#define MS_INS_OFFSET 0 4338061Smsmith#define MS_ARG_OFFSET 8 4438061Smsmith#define MS_TYP_OFFSET 12 4538061Smsmith 4638061Smsmith/* list of parameter types */ 4738061Smsmith#define MS_TYP_INT 0x0 /* integer */ 4838061Smsmith#define MS_TYP_CHA 0x1 /* character */ 4938061Smsmith#define MS_TYP_PTR 0x2 /* void pointer */ 5038061Smsmith#define MS_TYP_FUN 0x3 /* function pointer */ 5138061Smsmith 5238061Smsmith#define MS_PARAM(ins,arg,typ) \ 5338061Smsmith (((ins<<MS_INS_OFFSET) & MS_INS_MASK) | \ 5438061Smsmith ((arg<<MS_ARG_OFFSET) & MS_ARG_MASK) | \ 5538061Smsmith ((typ<<MS_TYP_OFFSET) & MS_TYP_MASK)) 5638061Smsmith 5738061Smsmith#define MS_INS(param) ((param & MS_INS_MASK) >> MS_INS_OFFSET) 5838061Smsmith#define MS_ARG(param) ((param & MS_ARG_MASK) >> MS_ARG_OFFSET) 5938061Smsmith#define MS_TYP(param) ((param & MS_TYP_MASK) >> MS_TYP_OFFSET) 6038061Smsmith 6138061Smsmith/* microsequence opcodes - do not change! */ 6238061Smsmith#define MS_OP_GET 0 /* get <ptr>, <len> */ 6338061Smsmith#define MS_OP_PUT 1 /* put <ptr>, <len> */ 6438061Smsmith 6538061Smsmith#define MS_OP_RFETCH 2 /* rfetch <reg>, <mask>, <ptr> */ 6638061Smsmith#define MS_OP_RSET 3 /* rset <reg>, <mask>, <mask> */ 6738061Smsmith#define MS_OP_RASSERT 4 /* rassert <reg>, <mask> */ 6838061Smsmith#define MS_OP_DELAY 5 /* delay <val> */ 6938061Smsmith#define MS_OP_SET 6 /* set <val> */ 7038061Smsmith#define MS_OP_DBRA 7 /* dbra <offset> */ 7138061Smsmith#define MS_OP_BRSET 8 /* brset <mask>, <offset> */ 7238061Smsmith#define MS_OP_BRCLEAR 9 /* brclear <mask>, <offset> */ 7338061Smsmith#define MS_OP_RET 10 /* ret <retcode> */ 7438061Smsmith#define MS_OP_C_CALL 11 /* c_call <function>, <parameter> */ 7538061Smsmith#define MS_OP_PTR 12 /* ptr <pointer> */ 7639134Snsouch#define MS_OP_ADELAY 13 /* adelay <val> */ 7739134Snsouch#define MS_OP_BRSTAT 14 /* brstat <mask>, <mask>, <offset> */ 7838061Smsmith#define MS_OP_SUBRET 15 /* subret <code> */ 7938061Smsmith#define MS_OP_CALL 16 /* call <microsequence> */ 8038061Smsmith#define MS_OP_RASSERT_P 17 /* rassert_p <iter>, <reg> */ 8138061Smsmith#define MS_OP_RFETCH_P 18 /* rfetch_p <iter>, <reg>, <mask> */ 8238061Smsmith#define MS_OP_TRIG 19 /* trigger <reg>, <len>, <array> */ 8338061Smsmith 8438061Smsmith/* common masks */ 8538061Smsmith#define MS_CLEAR_ALL 0x0 8638061Smsmith#define MS_ASSERT_NONE 0x0 8738061Smsmith#define MS_ASSERT_ALL 0xff 8838061Smsmith#define MS_FETCH_ALL 0xff 8938061Smsmith 9038061Smsmith/* undefined parameter value */ 9139134Snsouch#define MS_NULL 0 9239134Snsouch#define MS_UNKNOWN MS_NULL 9338061Smsmith 9439134Snsouch/* predifined parameters */ 9539134Snsouch#define MS_ACCUM -1 /* use accum previously set by MS_OP_SET */ 9639134Snsouch 9738061Smsmith/* these are register numbers according to our PC-like parallel port model */ 9838061Smsmith#define MS_REG_DTR 0x0 9938061Smsmith#define MS_REG_STR 0x1 10038061Smsmith#define MS_REG_CTR 0x2 10138061Smsmith#define MS_REG_EPP 0x4 10238061Smsmith 10338061Smsmith/* 10438061Smsmith * Microsequence macro abstraction level 10538061Smsmith */ 10638061Smsmith 10738061Smsmith/* register operations */ 10838061Smsmith#define MS_RSET(reg,assert,clear) { MS_OP_RSET, { reg, assert, clear} } 10938061Smsmith#define MS_RASSERT(reg,byte) { MS_OP_RASSERT, { reg, byte } } 11038061Smsmith#define MS_RCLR(reg,clear) { MS_OP_RSET, { reg, MS_ASSERT_NONE, clear } } 11138061Smsmith 11238061Smsmith#define MS_RFETCH(reg,mask,ptr) { MS_OP_RFETCH, { reg, mask, ptr } } 11338061Smsmith 11438061Smsmith/* trigger the port with array[char, delay,...] */ 11538061Smsmith#define MS_TRIG(reg,len,array) { MS_OP_TRIG, { reg, len, array } } 11638061Smsmith 11738061Smsmith/* assert/fetch from/to ptr */ 11838061Smsmith#define MS_RASSERT_P(n,reg) { MS_OP_RASSERT_P, { n, reg } } 11938061Smsmith#define MS_RFETCH_P(n,reg,mask) { MS_OP_RFETCH_P, { n, reg, mask } } 12038061Smsmith 12138061Smsmith/* ptr manipulation */ 12238061Smsmith#define MS_PTR(ptr) { MS_OP_PTR, { ptr } } 12338061Smsmith 12438061Smsmith#define MS_DASS(byte) MS_RASSERT(MS_REG_DTR,byte) 12538061Smsmith#define MS_SASS(byte) MS_RASSERT(MS_REG_STR,byte) 12638061Smsmith#define MS_CASS(byte) MS_RASSERT(MS_REG_CTR,byte) 12738061Smsmith 12839134Snsouch#define MS_SET(accum) { MS_OP_SET, { accum } } 12938061Smsmith#define MS_BRSET(mask,offset) { MS_OP_BRSET, { mask, offset } } 13038061Smsmith#define MS_DBRA(offset) { MS_OP_DBRA, { offset } } 13139134Snsouch#define MS_BRCLEAR(mask,offset) { MS_OP_BRCLEAR, { mask, offset } } 13239134Snsouch#define MS_BRSTAT(mask_set,mask_clr,offset) \ 13339134Snsouch { MS_OP_BRSTAT, { mask_set, mask_clr, offset } } 13438061Smsmith 13538061Smsmith/* C function or submicrosequence call */ 13638061Smsmith#define MS_C_CALL(function,parameter) \ 13738061Smsmith { MS_OP_C_CALL, { function, parameter } } 13838061Smsmith#define MS_CALL(microseq) { MS_OP_CALL, { microseq } } 13938061Smsmith 14038061Smsmith/* mode dependent read/write operations 14138061Smsmith * ppb_MS_xxx_init() call required otherwise default is 14238061Smsmith * IEEE1284 operating mode */ 14338061Smsmith#define MS_PUT(ptr,len) { MS_OP_PUT, { ptr, len } } 14438061Smsmith#define MS_GET(ptr,len) { MS_OP_GET, { ptr, len } } 14538061Smsmith 14638061Smsmith/* delay in microseconds */ 14739134Snsouch#define MS_DELAY(udelay) { MS_OP_DELAY, { udelay } } 14838061Smsmith 14939134Snsouch/* asynchroneous delay in ms */ 15039134Snsouch#define MS_ADELAY(mdelay) { MS_OP_ADELAY, { mdelay } } 15139134Snsouch 15238061Smsmith/* return from submicrosequence execution or microseqence execution */ 15338061Smsmith#define MS_SUBRET(code) { MS_OP_SUBRET, { code } } 15438061Smsmith#define MS_RET(code) { MS_OP_RET, { code } } 15538061Smsmith 15638061Smsmith/* 15738061Smsmith * Function abstraction level 15838061Smsmith */ 15938061Smsmith 16038061Smsmith#define ppb_MS_GET_init(dev,body) ppb_MS_init(dev, body, MS_OP_GET) 16138061Smsmith 16238061Smsmith#define ppb_MS_PUT_init(dev,body) ppb_MS_init(dev, body, MS_OP_PUT) 16338061Smsmith 16438061Smsmithextern int ppb_MS_init( 16538061Smsmith struct ppb_device *, /* ppbus device */ 16638061Smsmith struct ppb_microseq *, /* loop msq to assign */ 16738061Smsmith int opcode /* MS_OP_GET, MS_OP_PUT */ 16838061Smsmith ); 16938061Smsmith 17038061Smsmithextern int ppb_MS_init_msq( 17138061Smsmith struct ppb_microseq *, 17238061Smsmith int, /* number of parameters */ 17338061Smsmith ... /* descriptor, value, ... */ 17438061Smsmith ); 17538061Smsmith 17638061Smsmithextern int ppb_MS_exec( 17738061Smsmith struct ppb_device *, /* ppbus device */ 17838061Smsmith int, /* microseq opcode */ 17938061Smsmith union ppb_insarg, /* param1 */ 18038061Smsmith union ppb_insarg, /* param2 */ 18138061Smsmith union ppb_insarg, /* param3 */ 18238061Smsmith int * /* returned value */ 18338061Smsmith ); 18438061Smsmith 18538061Smsmithextern int ppb_MS_loop( 18638061Smsmith struct ppb_device *, /* ppbus device */ 18738061Smsmith struct ppb_microseq *, /* prologue msq of loop */ 18838061Smsmith struct ppb_microseq *, /* body msq of loop */ 18938061Smsmith struct ppb_microseq *, /* epilogue msq of loop */ 19038061Smsmith int, /* number of iter */ 19138061Smsmith int * /* returned value */ 19238061Smsmith ); 19338061Smsmith 19438061Smsmithextern int ppb_MS_microseq( 19538061Smsmith struct ppb_device *, /* ppbus device */ 19638061Smsmith struct ppb_microseq *, /* msq to execute */ 19738061Smsmith int * /* returned value */ 19838061Smsmith ); 19938061Smsmith 20038061Smsmith#endif 201