cartrominit.c
2.98 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**************************************************************************
* *
* Copyright (C) 1995, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#include "osint.h"
#include "piint.h"
#include "rcp.h"
OSPiHandle __CartRomHandle;
/*
* Name: osCartRomInit
*
* Description:
* Get cartridge rom handler
*
*/
OSPiHandle *
osCartRomInit(void)
{
u32 value = 0;
u32 saveMask;
static first = 1;
register u32 stat;
u32 latency, pulse, pageSize, relDuration;
/* Block to get resource token */
__osPiGetAccess();
/*
* 2回目以降は既に取得した設定値を返す
*/
if (! first)
{
/* Return resource token */
__osPiRelAccess();
return(&__CartRomHandle);
}
first = 0;
__CartRomHandle.type = DEVICE_TYPE_CART;
__CartRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR2);
__CartRomHandle.domain = PI_DOMAIN1;
/* Fill speed and transferInfo to zero */
__CartRomHandle.speed = 0;
bzero(&(__CartRomHandle.transferInfo),
sizeof(__CartRomHandle.transferInfo));
/*
* ロムのアクセススピードを得る。EPI と同様の処理。
*/
stat = IO_READ(PI_STATUS_REG);
while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) {
stat = IO_READ(PI_STATUS_REG);
}
/*
* アクセススピードを変更する前に、現在の値を保存しておく
*/
latency = IO_READ(PI_BSD_DOM1_LAT_REG);
pageSize = IO_READ(PI_BSD_DOM1_PGS_REG);
relDuration = IO_READ(PI_BSD_DOM1_RLS_REG);
pulse = IO_READ(PI_BSD_DOM1_PWD_REG);
/*
* アクセススピード値を読むため、超低速な値に設定。
*/
IO_WRITE(PI_BSD_DOM1_LAT_REG, (u8)0xff);
IO_WRITE(PI_BSD_DOM1_PGS_REG, (u8)0x0);
IO_WRITE(PI_BSD_DOM1_RLS_REG, (u8)0x3);
IO_WRITE(PI_BSD_DOM1_PWD_REG, (u8)0xff);
/*
* 先頭をリード
*/
value = IO_READ((u32)__CartRomHandle.baseAddress);
__CartRomHandle.latency = (u8)(value & 0xff);
__CartRomHandle.pageSize = (u8)((value >> 16) & 0xf);
__CartRomHandle.relDuration = (u8)((value >> 20) & 0xf);
__CartRomHandle.pulse = (u8)((value >> 8) & 0xff);
/*
* PI バスの設定値を、変更前に戻しておく
*/
IO_WRITE(PI_BSD_DOM1_LAT_REG, latency);
IO_WRITE(PI_BSD_DOM1_PGS_REG, pageSize);
IO_WRITE(PI_BSD_DOM1_RLS_REG, relDuration);
IO_WRITE(PI_BSD_DOM1_PWD_REG, pulse);
/*
* cartrominit は PI バスの設定値を変更しない
* よって、__osCurrentHandle の値も変更してはいけない
*/
/*
* Put the CartRomHandle onto PiTable
*/
saveMask = __osDisableInt();
__CartRomHandle.next = __osPiTable;
__osPiTable = &__CartRomHandle;
__osRestoreInt(saveMask);
/* Return resource token */
__osPiRelAccess();
return(&__CartRomHandle);
} /* osCartRomInit */