flashinit.c
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*---------------------------------------------------------------------
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: flashinit.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"
u32 __osFlashID[4];
OSIoMesg __osFlashMsg;
OSMesgQueue __osFlashMessageQ;
OSPiHandle __osFlashHandler;
OSMesg __osFlashMsgBuf;
u32 __osFlashVersion;
OSPiHandle *
osFlashInit(void)
{
#ifndef BBPLAYER
u32 flash_type,flash_maker;
#endif
osCreateMesgQueue(&__osFlashMessageQ, &__osFlashMsgBuf, 1);
if (__osFlashHandler.baseAddress == PHYS_TO_K1(FLASH_START_ADDR))
return(&__osFlashHandler);
/* Fill basic information */
__osFlashHandler.type = DEVICE_TYPE_FLASH;
__osFlashHandler.baseAddress = PHYS_TO_K1(FLASH_START_ADDR);
/* Get Domain parameters */
__osFlashHandler.latency = (u8)FLASH_LATENCY;
__osFlashHandler.pulse = (u8)FLASH_PULSE;
__osFlashHandler.pageSize = (u8)FLASH_PAGE_SIZE;
__osFlashHandler.relDuration = (u8)FLASH_REL_DURATION;
__osFlashHandler.domain = PI_DOMAIN2;
/* Fill speed and transferInfo to zero */
__osFlashHandler.speed = 0;
bzero((void *)&(__osFlashHandler.transferInfo),
sizeof(__osFlashHandler.transferInfo));
/* Put the __osFlashHandler onto PiTable*/
osEPiLinkHandle(&__osFlashHandler);
#ifndef BBPLAYER
/* get flash ID */
osFlashReadId(&flash_type, &flash_maker);
if ((flash_maker == 0x00c2001e)||(flash_maker == 0x00c20001)
||(flash_maker == 0x00c20000))
__osFlashVersion = OLD_FLASH;
else
#endif
__osFlashVersion = NEW_FLASH;
return(&__osFlashHandler);
} /* FlashInit */