|
NAMEmicroseq —
ppbus microsequencer developer's guide
SYNOPSIS#include <sys/types.h>
#include <dev/ppbus/ppbconf.h>
#include <dev/ppbus/ppb_msq.h>
DESCRIPTIONSee ppbus(4) for ppbus description and general info about the microsequencer.The purpose of this document is to encourage developers to use the microsequencer mechanism in order to have:
Before using microsequences, you are encouraged to look at ppc(4) microsequencer implementation and an example of how using it in ppi(4). PPBUS register modelBackgroundThe parallel port model chosen for ppbus is the PC parallel port model. Thus, any register described later has the same semantic than its counterpart in a PC parallel port. For more info about ISA/ECP programming, get the Microsoft standard referenced as "Extended Capabilities Port Protocol and ISA interface Standard". Registers described later are standard parallel port registers.Mask macros are defined in the standard ppbus include files for each valid bit of parallel port registers. Data registerIn compatible or nibble mode, writing to this register will drive data to the parallel port data lines. In any other mode, drivers may be tri-stated by setting the direction bit (PCD) in the control register. Reads to this register return the value on the data lines.Device status registerThis read-only register reflects the inputs on the parallel port interface.
Others are reserved and return undefined result when read. Device control registerThis register directly controls several output signals as well as enabling some functions.
MICROINSTRUCTIONSDescriptionMicroinstructions are either parallel port accesses, program iterations, submicrosequence or C calls. The parallel port must be considered as the logical model described in ppbus(4).Available microinstructions are: #define MS_OP_GET 0 /* get <ptr>, <len> */ #define MS_OP_PUT 1 /* put <ptr>, <len> */ #define MS_OP_RFETCH 2 /* rfetch <reg>, <mask>, <ptr> */ #define MS_OP_RSET 3 /* rset <reg>, <mask>, <mask> */ #define MS_OP_RASSERT 4 /* rassert <reg>, <mask> */ #define MS_OP_DELAY 5 /* delay <val> */ #define MS_OP_SET 6 /* set <val> */ #define MS_OP_DBRA 7 /* dbra <offset> */ #define MS_OP_BRSET 8 /* brset <mask>, <offset> */ #define MS_OP_BRCLEAR 9 /* brclear <mask>, <offset> */ #define MS_OP_RET 10 /* ret <retcode> */ #define MS_OP_C_CALL 11 /* c_call <function>, <parameter> */ #define MS_OP_PTR 12 /* ptr <pointer> */ #define MS_OP_ADELAY 13 /* adelay <val> */ #define MS_OP_BRSTAT 14 /* brstat <mask>, <mask>, <offset> */ #define MS_OP_SUBRET 15 /* subret <code> */ #define MS_OP_CALL 16 /* call <microsequence> */ #define MS_OP_RASSERT_P 17 /* rassert_p <iter>, <reg> */ #define MS_OP_RFETCH_P 18 /* rfetch_p <iter>, <reg>, <mask> */ #define MS_OP_TRIG 19 /* trigger <reg>, <len>, <array> */ Execution contextThe execution context of microinstructions is:
This data is modified by some of the microinstructions, not all. MS_OP_GET and MS_OP_PUTare microinstructions used to do either predefined standard IEEE1284-1994 transfers or programmed non-standard io.MS_OP_RFETCH - Register FETCHis used to retrieve the current value of a parallel port register, apply a mask and save it in a buffer.Parameters:
Predefined macro: MS_RFETCH(reg,mask,ptr) MS_OP_RSET - Register SETis used to assert/clear some bits of a particular parallel port register, two masks are applied.Parameters:
Predefined macro: MS_RSET(reg,assert,clear) MS_OP_RASSERT - Register ASSERTis used to assert all bits of a particular parallel port register.Parameters:
Predefined macro: MS_RASSERT(reg,byte) MS_OP_DELAY - microsecond DELAYis used to delay the execution of the microsequence.Parameter:
Predefined macro: MS_DELAY(delay) MS_OP_SET - SET internal branch registeris used to set the value of the internal branch register.Parameter:
Predefined macro: MS_SET(accum) MS_OP_DBRA - Do BRAnchis used to branch if internal branch register decremented by one result value is positive.Parameter:
Predefined macro: MS_DBRA(offset) MS_OP_BRSET - BRanch on SETis used to branch if some of the status register bits of the parallel port are set.Parameter:
Predefined macro: MS_BRSET(mask,offset) MS_OP_BRCLEAR - BRanch on CLEARis used to branch if some of the status register bits of the parallel port are cleared.Parameter:
Predefined macro: MS_BRCLEAR(mask,offset) MS_OP_RET - RETurnis used to return from a microsequence. This instruction is mandatory. This is the only way for the microsequencer to detect the end of the microsequence. The return code is returned in the integer pointed by the (int *) parameter of the ppb_MS_microseq().Parameter:
Predefined macro: MS_RET(code) MS_OP_C_CALL - C function CALLis used to call C functions from microsequence execution. This may be useful when a non-standard i/o is performed to retrieve a data character from the parallel port.Parameter:
The C function shall be declared as a int(*)(void *p, char *ptr). The ptr parameter is the current position in the buffer currently scanned. Predefined macro: MS_C_CALL(func,param) MS_OP_PTR - initialize internal PTRis used to initialize the internal pointer to the currently scanned buffer. This pointer is passed to any C call (see above).Parameter:
Predefined macro: MS_PTR(ptr) MS_OP_ADELAY - do an Asynchronous DELAYis used to make a tsleep() during microsequence execution. The tsleep is executed at PPBPRI level.Parameter:
Predefined macro: MS_ADELAY(delay) MS_OP_BRSTAT - BRanch on STATeis used to branch on status register state condition.Parameter:
Predefined macro: MS_BRSTAT(asserted_bits,clear_bits,offset) MS_OP_SUBRET - SUBmicrosequence RETurnis used to return from the submicrosequence call. This action is mandatory before a RET call. Some microinstructions (PUT, GET) may not be callable within a submicrosequence.No parameter. Predefined macro: MS_SUBRET() MS_OP_CALL - submicrosequence CALLis used to call a submicrosequence. A submicrosequence is a microsequence with a SUBRET call. Parameter:
Predefined macro: MS_CALL(microseq) MS_OP_RASSERT_P - Register ASSERT from internal PTRis used to assert a register with data currently pointed by the internal PTR pointer. Parameter:
Predefined macro: MS_RASSERT_P(iter,reg) MS_OP_RFETCH_P - Register FETCH to internal PTRis used to fetch data from a register. Data is stored in the buffer currently pointed by the internal PTR pointer. Parameter:
Predefined macro: MS_RFETCH_P(iter,reg,mask) MS_OP_TRIG - TRIG registeris used to trigger the parallel port. This microinstruction is intended to provide a very efficient control of the parallel port. Triggering a register is writing data, wait a while, write data, wait a while... This allows to write magic sequences to the port. Parameter:
Predefined macro: MS_TRIG(reg,len,array) MICROSEQUENCESC structuresunion ppb_insarg { int i; char c; void *p; int (* f)(void *, char *); }; struct ppb_microseq { int opcode; /* microins. opcode */ union ppb_insarg arg[PPB_MS_MAXARGS]; /* arguments */ }; Using microsequencesTo instantiate a microsequence, just declare an array of ppb_microseq structures and initialize it as needed. You may either use predefined macros or code directly your microinstructions according to the ppb_microseq definition. For example,struct ppb_microseq select_microseq[] = { /* parameter list */ #define SELECT_TARGET MS_PARAM(0, 1, MS_TYP_INT) #define SELECT_INITIATOR MS_PARAM(3, 1, MS_TYP_INT) /* send the select command to the drive */ MS_DASS(MS_UNKNOWN), MS_CASS(H_nAUTO | H_nSELIN | H_INIT | H_STROBE), MS_CASS( H_AUTO | H_nSELIN | H_INIT | H_STROBE), MS_DASS(MS_UNKNOWN), MS_CASS( H_AUTO | H_nSELIN | H_nINIT | H_STROBE), /* now, wait until the drive is ready */ MS_SET(VP0_SELTMO), /* loop: */ MS_BRSET(H_ACK, 2 /* ready */), MS_DBRA(-2 /* loop */), /* error: */ MS_RET(1), /* ready: */ MS_RET(0) }; Here, some parameters are undefined and must be filled before executing the microsequence. In order to initialize each microsequence, one should use the ppb_MS_init_msq() function like this: ppb_MS_init_msq(select_microseq, 2, SELECT_TARGET, 1 << target, SELECT_INITIATOR, 1 << initiator); and then execute the microsequence. The microsequencerThe microsequencer is executed either at ppbus or adapter level (see ppbus(4) for info about ppbus system layers). Most of the microsequencer is executed at ppc level to avoid ppbus to adapter function call overhead. But some actions like deciding whereas the transfer is IEEE1284-1994 compliant are executed at ppbus layer.SEE ALSOppbus(4), ppc(4), ppi(4)HISTORYThemicroseq manual page first appeared in
FreeBSD 3.0.
AUTHORSThis manual page was written by Nicolas Souchu.BUGSOnly one level of submicrosequences is allowed.When triggering the port, maximum delay allowed is 255 us.
Visit the GSP FreeBSD Man Page Interface. |