flashreadid.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: flashreadid.c,v 1.3 2003/12/13 02:14:54 wheeler Exp $
   ---------------------------------------------------------------------*/
/**************************************************************************
 *
 *  $Revision: 1.3 $
 *  $Date: 2003/12/13 02:14:54 $
 *  $Source: 
 *
 **************************************************************************/

#include	<ultra64.h>
#include        "osint_flash.h"

/* READ ID */
void	osFlashReadId(u32 *flash_type, u32 *flash_maker)
{
#ifdef BBPLAYER
  *flash_type = __osFlashID[0] = 0x11118001 ;
  *flash_maker = __osFlashID[1] = 0xc20000 ;
#else
  u8	tmp;

  /* Read Status */
  /* コマンドコンビネーションバグの(2)を回避するためのダミーコマンド */
  osFlashReadStatus(&tmp);

  /* Set Read ID */
  osEPiWriteIo(&__osFlashHandler,(__osFlashHandler.baseAddress|0x10000),0xe1000000);
  /* Read ID */
  __osFlashMsg.hdr.pri  =  OS_MESG_PRI_NORMAL;
  __osFlashMsg.hdr.retQueue  =  &__osFlashMessageQ;
  __osFlashMsg.dramAddr  =  &__osFlashID[0];
  __osFlashMsg.devAddr  =  0;
  __osFlashMsg.size  = 0x8;

  osInvalDCache(&__osFlashID[0], 16);
  osEPiStartDma(&__osFlashHandler, &__osFlashMsg, OS_READ);
  (void)osRecvMesg(&__osFlashMessageQ, NULL, OS_MESG_BLOCK);

  *flash_type = __osFlashID[0];
  *flash_maker = __osFlashID[1];
  
  return;
  
#endif
}