/*
** amiga.lib for vbcc-PowerOpen/WarpOS
**
** CreateExtIO(), CreateStdIO(), DeleteExtIO(), DeleteStdIO()
**
** V0.3 30-May-98 phx
**      FreeVecVec() in DeleteExtIO() should have been "FreeVecPPC()".
** V0.2 19-Apr-98 phx
**      replaced <clib/powerpc/powerpc_protos.h> by <clib/powerpc_protos.h>
**      AllocVecPPC() returns APTR, so a cast is needed
** V0.1 15-Mar-98 phx
**      created
*/

#include <exec/io.h>
#include <exec/memory.h>
#include <clib/alib_protos.h>
#include <proto/exec.h>
#include <clib/powerpc_protos.h>


struct IORequest *CreateExtIO(struct MsgPort *port,long iosize)
{
  struct IORequest *ioreq=NULL;

  if (port && (ioreq = (struct IORequest *)
               AllocVecPPC(iosize,MEMF_CLEAR|MEMF_PUBLIC,0)))
  {
    ioreq->io_Message.mn_Node.ln_Type=NT_MESSAGE;
    ioreq->io_Message.mn_ReplyPort=port;
    ioreq->io_Message.mn_Length=iosize;
  }
  return ioreq;
}

struct IOStdReq *CreateStdIO(struct MsgPort *port)
{
  return (struct IOStdReq *)CreateExtIO(port,sizeof(struct IOStdReq));
}

void DeleteExtIO(struct IORequest *ioreq)
{
  int i;

  i=-1;
  ioreq->io_Message.mn_Node.ln_Type=i;
  ioreq->io_Device=(struct Device *)i;
  ioreq->io_Unit=(struct Unit *)i;
  FreeVecPPC((APTR)ioreq);
}

void DeleteStdIO(struct IOStdReq *io)
{
  int i;struct IORequest *ioreq=(struct IORequest *)io;

  i=-1;
  ioreq->io_Message.mn_Node.ln_Type=i;
  ioreq->io_Device=(struct Device *)i;
  ioreq->io_Unit=(struct Unit *)i;
  FreeVecPPC((APTR)ioreq);
}
