/*-
* Copyright (c) 1998 Nicolas Souchu
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* FreeBSD: src/sys/dev/ppbus/ppb_msq.h,v 1.8 2000/01/14 00:17:55 nsouch Exp
*
*/
#ifndef __PPBUS_MSQ_H
#define __PPBUS_MSQ_H
/*
* Basic definitions
*/
/* Microsequence stuff. */
#define PPBUS_MS_MAXLEN 64 /* XXX according to MS_INS_MASK */
#define PPBUS_MS_MAXARGS 3 /* according to MS_ARG_MASK */
/* Maximum number of mode dependent submicrosequences for in/out operations. */
#define PPBUS_MAX_XFER 6
/* Argument in microsequence structure */
union ppbus_insarg {
int i;
void *p;
char *c;
int (* f)(void *, char *);
};
/* Microsequence structure */
struct ppbus_microseq {
int opcode; /* microins. opcode */
union ppbus_insarg arg[PPBUS_MS_MAXARGS]; /* arguments */
};
/* Microseqences used for GET/PUT operations */
struct ppbus_xfer {
struct ppbus_microseq *loop; /* the loop microsequence */
};
/* microsequence parameter descriptor */
#define MS_INS_MASK 0x00ff /* mask to retrieve the instruction position < 256 XXX */
#define MS_ARG_MASK 0x0f00 /* mask to retrieve the argument number */
#define MS_TYP_MASK 0xf000 /* mask to retrieve the type of the param */
/* offset of each mask (see above) */
#define MS_INS_OFFSET 0
#define MS_ARG_OFFSET 8
#define MS_TYP_OFFSET 12
/* list of parameter types */
#define MS_TYP_INT 0x0 /* integer */
#define MS_TYP_CHA 0x1 /* character */
#define MS_TYP_PTR 0x2 /* void pointer */
#define MS_TYP_FUN 0x3 /* function pointer */
/* predifined parameters */
#define MS_ACCUM -1 /* use accum previously set by MS_OP_SET */
/* these are register numbers according to our PC-like parallel port model */
#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
/* Function prototypes */
int ppbus_MS_init(
device_t, /* ppbus bus */
device_t, /* ppbus device */
struct ppbus_microseq *, /* loop msq to assign */
int opcode /* MS_OP_GET, MS_OP_PUT */
);
int ppbus_MS_init_msq(
struct ppbus_microseq *,
int, /* number of parameters */
... /* descriptor, value, ... */
);
int ppbus_MS_exec(
device_t, /* ppbus bus */
device_t, /* ppbus device */
int, /* microseq opcode */
union ppbus_insarg, /* param1 */
union ppbus_insarg, /* param2 */
union ppbus_insarg, /* param3 */
int * /* returned value */
);
int ppbus_MS_loop(
device_t, /* ppbus bus */
device_t, /* ppbus device */
struct ppbus_microseq *, /* prologue msq of loop */
struct ppbus_microseq *, /* body msq of loop */
struct ppbus_microseq *, /* epilogue msq of loop */
int, /* number of iter */
int * /* returned value */
);
int ppbus_MS_microseq(
device_t, /* ppbus bus */
device_t, /* ppbus device */
struct ppbus_microseq *, /* msq to execute */
int * /* returned value */
);