flashwritebuffer.c 1.41 KB
/*---------------------------------------------------------------------
        Copyright (C) 1998 Nintendo.
        
        File            flash.c
        Coded    by     Atushi Watanabe. Dec  1, 1998.
        Modified by     Atushi Watanabe. Apr 4, 2000.
        Comments        1M Flash ROM access functions(Ver.7.6)
   
 	$Id: flashwritebuffer.c,v 1.2 2003/03/26 02:00:13 blythe Exp $
   ---------------------------------------------------------------------*/
/**************************************************************************
 *
 *  $Revision: 1.2 $
 *  $Date: 2003/03/26 02:00:13 $
 *  $Source: 
 *
 **************************************************************************/

#include	<ultra64.h>
#include        "osint_flash.h"
#ifdef BBPLAYER
#include	"bbint.h"
u8 __osBbFlashBuffer[128];
#endif

s32	osFlashWriteBuffer(OSIoMesg *mb, s32 priority, void *dramAddr, OSMesgQueue *mq)
{
#ifdef BBPLAYER
  if (__osBbFlashSize) {
    bcopy(dramAddr, __osBbFlashBuffer, 128);
    return osSendMesg(mq, (OSMesg)0, OS_MESG_NOBLOCK);
  } else
    return -1;
#else
  s32 ret;

  /* Set Read Buffer(Buffer Access Mode) */
  osEPiWriteIo(&__osFlashHandler,(__osFlashHandler.baseAddress|0x10000),0xb4000000);
	
  /* Read Buffer */
  mb->hdr.pri  =  priority;
  mb->hdr.retQueue  =  mq;
  mb->dramAddr  =  dramAddr;
  mb->devAddr  =  0;
  mb->size  = 128;
  ret = osEPiStartDma(&__osFlashHandler, mb, OS_WRITE);
  return ret;
#endif
}