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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
/*++
Copyright (c) 1993 Digital Equipment Corporation
Module Name:
xxnvram.c
Abstract:
This module implements the device-specific routines necessary to
Read and Write the Non Volatile RAM containing the system environment
variables. The routines implemented here are:
HalpReadNVRamBuffer() - copy data from NVRAM into memory
HalpWriteNVRamBuffer() - write memory data to NVRAM
HalpCopyNVRamBuffer() - move data within the NVRAM
Author:
Steve Brooks 5-Oct 93
Revision History:
--*/
#include "halp.h"
#include "cmos8k.h"
#include "arccodes.h"
//
// Local function prototypes.
//
ARC_STATUS
HalpReadNVRamBuffer (
OUT PCHAR DataPtr,
IN PCHAR NvRamPtr,
IN ULONG Length
);
ARC_STATUS
HalpWriteNVRamBuffer (
IN PCHAR NvRamPtr,
IN PCHAR DataPtr,
IN ULONG Length
);
ARC_STATUS
HalpCopyNVRamBuffer (
IN PCHAR NvDestPtr,
IN PCHAR NvSrcPtr,
IN ULONG Length
);
#ifdef AXP_FIRMWARE
#pragma alloc_text(DISTEXT, HalpReadNVRamBuffer )
#pragma alloc_text(DISTEXT, HalpWriteNVRamBuffer )
#pragma alloc_text(DISTEXT, HalpCopyNVRamBuffer )
#endif
//
//
//
ARC_STATUS HalpReadNVRamBuffer (
OUT PCHAR DataPtr,
IN PCHAR NvRamPtr,
IN ULONG Length )
/*++
Routine Description:
This routine Reads data from the NVRam into main memory
Arguments:
DataPtr - Pointer to memory location to receive data
NvRamPtr - Pointer (qva) to NVRam location to read data from
Length - Number of bytes of data to transfer
Return Value:
ESUCCESS if the operation succeeds.
--*/
{
ULONG PageSelect, ByteSelect;
PageSelect = (NvRamPtr - (PUCHAR)HalpCMOSRamBase) >> CONFIG_RAM_PAGE_SHIFT;
ByteSelect = (NvRamPtr - (PUCHAR)HalpCMOSRamBase) & CONFIG_RAM_BYTE_MASK;
WRITE_CONFIG_RAM_PAGE_SELECT(PageSelect);
while ( Length -- )
{
*DataPtr++ = READ_CONFIG_RAM_DATA(NvRamPtr);
NvRamPtr ++;
ByteSelect = (ByteSelect + 1) & CONFIG_RAM_BYTE_MASK;
if (ByteSelect == 0)
{
PageSelect++;
WRITE_CONFIG_RAM_PAGE_SELECT(PageSelect);
}
}
return(ESUCCESS);
}
//
//
//
ARC_STATUS HalpWriteNVRamBuffer (
IN PCHAR NvRamPtr,
IN PCHAR DataPtr,
IN ULONG Length )
/*++
Routine Description:
This routine Writes data from memory into the NVRam
Arguments:
NvRamPtr - Pointer (qva) to NVRam location to write data into
DataPtr - Pointer to memory location of data to be written
Length - Number of bytes of data to transfer
Return Value:
ESUCCESS if the operation succeeds.
--*/
{
ULONG PageSelect, ByteSelect;
PageSelect = (NvRamPtr - (PUCHAR)HalpCMOSRamBase) >> CONFIG_RAM_PAGE_SHIFT;
ByteSelect = (NvRamPtr - (PUCHAR)HalpCMOSRamBase) & CONFIG_RAM_BYTE_MASK;
WRITE_CONFIG_RAM_PAGE_SELECT(PageSelect);
while ( Length -- )
{
WRITE_CONFIG_RAM_DATA(NvRamPtr, *DataPtr);
NvRamPtr ++;
DataPtr ++;
ByteSelect = (ByteSelect + 1) & CONFIG_RAM_BYTE_MASK;
if (ByteSelect == 0)
{
PageSelect++;
WRITE_CONFIG_RAM_PAGE_SELECT(PageSelect);
}
}
return(ESUCCESS);
}
//
//
//
ARC_STATUS HalpCopyNVRamBuffer (
IN PCHAR NvDestPtr,
IN PCHAR NvSrcPtr,
IN ULONG Length )
/*++
Routine Description:
This routine copies data between two locations within the NVRam. It is
the callers responsibility to assure that the destination region does not
overlap the src region i.e. if the regions overlap, NvSrcPtr > NvDestPtr.
Arguments:
NvDestPtr - Pointer (qva) to NVRam location to write data into
NvSrcPtr - Pointer (qva) to NVRam location of data to copy
Length - Number of bytes of data to transfer
Return Value:
ESUCCESS if the operation succeeds.
--*/
{
ULONG PageSelect0, ByteSelect0; // Src Pointer Page & offset
ULONG PageSelect1, ByteSelect1; // Dest Pointer Page & offset
PageSelect0 = (NvSrcPtr - (PUCHAR)HalpCMOSRamBase) >> CONFIG_RAM_PAGE_SHIFT;
ByteSelect0 = (NvSrcPtr - (PUCHAR)HalpCMOSRamBase) & CONFIG_RAM_BYTE_MASK;
PageSelect1 = (NvDestPtr-(PUCHAR)HalpCMOSRamBase) >> CONFIG_RAM_PAGE_SHIFT;
ByteSelect1 = (NvDestPtr - (PUCHAR)HalpCMOSRamBase) & CONFIG_RAM_BYTE_MASK;
WRITE_CONFIG_RAM_PAGE_SELECT(PageSelect0);
while ( Length -- )
{
UCHAR AChar;
//
// Check the Page select for the src pointer, and write the
// select register if necessary:
//
if (ByteSelect0 == 0)
{
PageSelect0++;
}
if ( PageSelect0 != PageSelect1 )
{
WRITE_CONFIG_RAM_PAGE_SELECT(PageSelect0);
}
AChar = READ_CONFIG_RAM_DATA(NvSrcPtr);
ByteSelect0 = (ByteSelect0 + 1) & CONFIG_RAM_BYTE_MASK;
//
// Check the page select for the dest pointer, and write
// the select register if necessary:
//
if (ByteSelect1 == 0)
{
PageSelect1++;
}
if ( PageSelect1 != PageSelect0 )
{
WRITE_CONFIG_RAM_PAGE_SELECT(PageSelect1);
}
WRITE_CONFIG_RAM_DATA(NvDestPtr, AChar);
ByteSelect1 = (ByteSelect1 + 1) & CONFIG_RAM_BYTE_MASK;
NvSrcPtr ++;
NvDestPtr ++;
}
return(ESUCCESS);
}
|