
#include "/snd/everything.h"
#include <st/st_proto.h>
#include "par_protos.h"
#include "parstuff.h"
#include <proto/timer.h>
#include <proto/cia.h>
#include <resources/misc.h>
#include <resources/cia.h>


#define MAXRETRIES	5			/* if a packet fails, this is the number of retries */

#define MAXPKTLEN	4096		/* max pkt len at any one time
								 * note that the routines will split up any send
								 * into blocks at most this size, except for the
								 * header packet (including the stdreq) which
								 * must be smaller than this - the smallest maxpktsize
								 * should be 128 bytes */

#define TIMEOUTSECS   0			/* time before a packet times out */
#define TIMEOUTMICROS (100*MAXPKTLEN/3)

/* max microseconds to back away from the port after each send */
#define BACKAWAYMICROS	MIN(TIMEOUTMICROS/4,999999)
#define ERRORBACKAWAYMICROS	MIN(TIMEOUTMICROS*4,999999)


/** INTERRUPT NUMBER ON CIA */
#define CIAINTB		4


/** hash table to hold majic numbers of the packet-messages */

#define HASH_TABLE_SIZE 128			/* must be power of 2, mem used = *2*4 */
#define HASH_FIRST		0
#define HASH_LAST		1
#define HASH_FUNC(a)	(((long)(a)>>6)&(HASH_TABLE_SIZE-1))

#define FIND_MAJIC(a) (FindHashNode(DMARecvHash, a))
#define MAJIC_PLACE(a) (PlaceHashNode(DMARecvHash, a))
#define MAJIC_REMOVE(a) (RemoveHashNode(a))

/** max number of services available - make this as big as need be */
#define MAXSERVICES		64

#define SERVICE_VALID(a) ((a)>=0 && (a) <= MAXSERVICES) 
#define SERVICE_PORT(a) (ServicePort[a])
#define SERVICE_PORT_EXISTS(a) (SERVICE_VALID(a) && SERVICE_PORT(a))

/* structure passed on to the interrupt (see _CIAIntRotuine par.s) */
struct CIRInt
{
	ULONG	sigmask;
	struct	Task *sigtask;
	UBYTE	machine, abort, pad[2];
	struct	Library *ciares;
};

