/*
 * interrupt.c
 *
 * Author: Tomi Ollila <too@cs.hut.fi>
 *
 * Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
 *		      All rights reserved.
 *
 * Created: Tue Oct 19 21:27:16 1993 too
 * Last modified: Mon Nov 15 23:21:26 1993 too
 *
 * $Id: interrupt.c,v 1.1 1993/11/17 11:47:44 too Exp $
 *
 * HISTORY
 * $Log: interrupt.c,v $
 * Revision 1.1  1993/11/17  11:47:44  too
 * Initial revision
 *
 * Revision 1.1  1993/11/17  11:47:44  too
 * Initial revision
 *
 * Revision 1.1  1993/10/24  12:50:39  too
 * Initial revision
 *
 */

#include <exec/types.h>
#include <exec/lists.h>
#include <exec/ports.h>
#include <exec/execbase.h>

#include "global.h"

#include <sys/types.h>

#include "applport.h"

#include "dirindex.h"

#define RFI ->

#if __GNUC__

#define RAF2(funname, type1, arg1, reg1, type2, arg2, reg2) \
  funname(VOID)			    \
{				    \
  register type1 reg1 __asm(#reg1); \
  type1 arg1 = reg1; 		    \
  register type2 reg2 __asm(#reg2); \
  type2 arg2 = reg2;

#elif __SASC
#include <proto/exec.h>
#define RAF2(funname,type1, arg1, reg1,type2, arg2, reg2) \
 __asm funname(register __##reg1 type1 arg1,	\
	       register __##reg2 type2 arg2)	\
{

#else
  #error foo
#endif /* __GNUC__ */

/*
 * interrupt handler...
 */
void RAF2(intCode,
	  struct ExecBase *,	SysBase,	a6,
	  struct ApplPort *,	port,		a1)
#if 0
{
#endif

#if __GNUC__
  register struct ApplShared * AS __asm("a5") = port->ap_AS;
#else
  struct ApplShared * AS = port->ap_AS;
#endif  
  int pos = applcbpos;

  directIndex(struct ApplPort *, applcbbuf, pos) = port;
  
  pos += sizeof (struct ApplPort *);
  pos &= 0x3f * sizeof (struct ApplPort *);
  applcbpos = pos;
#if __GNUC__
  {
    register struct Task * a1 __asm("a1") = me;
    register ULONG d0 __asm("d0") = applportflag;
    __asm __volatile ("jmp a6@(-0x144)"			/* Signal() */
		      : /* no output */
		      : /*"r" (a6),*/ "r" (a1), "r" (d0)
		      : "a0","a1","d0","d1", "memory");
  }
#else
    Signal(me, applportflag);
#endif
}
