sectorread.c 1.02 KB

#include <ultra64.h>

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

extern 	s32	__leoActive;

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

  /*
   * Fill up command block
   */
  cmdBlock->header.command = LEO_COMMAND_READ_SECTOR;
  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 the read is from system blocks, enable
   * "No Defect" flag.
   */
  if (LBA < 0)
    cmdBlock->header.control	|= LEO_CONTROL_ND;

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