flashreadstatus.c 1.6 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: flashreadstatus.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"
#endif

/* READ STATUS */
void	osFlashReadStatus(u8 *flash_status)
{
#ifdef BBPLAYER
  if (__osBbFlashSize)
    *flash_status = 0;
  else
    *flash_status = 0xff;
#else
  u32 status;
  
  /* Read Status Register */

  /* コマンドコンビネーションバグの(3)を回避するためのダミーコマンド */
  /* ステータス2度読みで回避			       			*/

  /* 1回目 */
  /* Set Read Status */
  osEPiWriteIo(&__osFlashHandler,(__osFlashHandler.baseAddress|0x10000),0xd2000000);
  /* Read Status Register */
  osEPiReadIo(&__osFlashHandler,__osFlashHandler.baseAddress, &status);

  /* 2回目 */
  /* Set Read Status */
  osEPiWriteIo(&__osFlashHandler,(__osFlashHandler.baseAddress|0x10000),0xd2000000);
  /* Read Status Register */
  osEPiReadIo(&__osFlashHandler,__osFlashHandler.baseAddress, &status);

  *flash_status =  (u8)(status & 0xff);
  
  return;  
#endif
}