sysreadwrite.c 1.04 KB

#include <ultra64.h>

#ifndef	_LONGCMD
#include <leo.h>
#else
#include <leosp.h>
#endif

extern 	s32	__leoActive;

s32 LeoSysReadWrite(LEOCmd *cmdBlock, s32 direction,
		    s32 LBA, void *vAddr, u32 nLBAs, OSMesgQueue *mq)
{
  /* 
   * Check for existence of Leo Manager 
   */
  if (!__leoActive) {
    return(-1);
  }

  /*
   * Fill up command block
   */
  if (direction == OS_READ)
    cmdBlock->header.command = LEO_COMMAND_READ;
  else
    cmdBlock->header.command = LEO_COMMAND_WRITE;
  
  cmdBlock->header.reserve1 = 0;

  /*
   * if mq == null, message will not be sent. 
   */
  if (mq != NULL)
    cmdBlock->header.control = LEO_CONTROL_POST;
  else
    cmdBlock->header.control = 0;
  
  cmdBlock->header.reserve3 	= 0;
  cmdBlock->header.post		= mq;
  cmdBlock->data.readwrite.lba 	= LBA;
  cmdBlock->data.readwrite.xfer_blks = nLBAs;
  cmdBlock->data.readwrite.buff_ptr 	= vAddr;

  if (LBA < 0)
    cmdBlock->header.control	|= LEO_CONTROL_ND;

  leoCommand((void *)cmdBlock);
  
  return 0;			/* For now, simply returns 0 */
  
} /* LeoSysReadWrite */