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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
//**********************************************************************
//**********************************************************************
//** **
//** (C)Copyright 1985-2012, American Megatrends, Inc. **
//** **
//** All Rights Reserved. **
//** **
//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
//** **
//** Phone: (770)-246-8600 **
//** **
//**********************************************************************
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartCommonLib/RapidStartCommonLib.h 2 11/20/12 2:46a Bensonlai $
//
// $Revision: 2 $
//
// $Date: 11/20/12 2:46a $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/Intel Fast Flash Standby/iRST_SharkBay/RapidStartWrapper/RapidStartCommonLib/RapidStartCommonLib.h $
//
// 2 11/20/12 2:46a Bensonlai
// [TAG] EIP107013
// [Category] Improvement
// [Description] Update Shark Bay Rapid Start Reference Code Version
// 0.8.0.0
// [Files] RapidStartCommonLib.sdl
// RapidStartCommonLib.mak
// RapidStartCommonLib.c
// RapidStartCommonLib.h
// RapidStartCommonLib.inf
// RapidStartCommonLib.cif
//
// 1 10/15/12 4:40a Bensonlai
// [TAG] None
// [Category] Improvement
// [Description] [Category] Improvement
// [Severity] Important
// [Description] Rename all IFFS sting to Rapid Start.
// [Files] Board\EM\RapidStartWrapper\*.*, ReferenceCode\RapidStart\*.*
// [Files] RapidStartCommonLib.cif
// RapidStartCommonLib.sdl
// RapidStartCommonLib.mak
// RapidStartCommonLib.c
// RapidStartCommonLib.h
// RapidStartCommonLib.inf
//
//**********************************************************************
//<AMI_FHDR_START>
//
// Name: RapidStartCommonLib.h
//
// Description: Defines and prototypes for the library module.
//
//<AMI_FHDR_END>
//**********************************************************************
#ifndef _RAPID_START_LIB_H_
#define _RAPID_START_LIB_H_
#include <RapidStartConfig.h>
#include <RapidStartData.h>
/**
Read specific RTC/CMOS RAM
@param[in] Location Point to RTC/CMOS RAM offset for read
@retval The data of specific location in RTC/CMOS RAM.
**/
UINT8
RtcRead (
IN UINT8 Location
);
/**
Write specific RTC/CMOS RAM
@param[in] Location Point to RTC/CMOS RAM offset for write
@param[in] Value The data that will be written to RTC/CMOS RAM
**/
VOID
RtcWrite (
IN UINT8 Location,
IN UINT8 Value
);
/**
Read word from specific RTC/CMOS RAM
@param[in] Location Point to RTC/CMOS RAM offset for read
@retval The data of specific location in RTC/CMOS RAM.
**/
UINT16
RtcRead16 (
IN UINT8 Location
);
/**
Write word to specific RTC/CMOS RAM
@param[in] Location Point to RTC/CMOS RAM offset for write
@param[in] Value The data that will be written to RTC/CMOS RAM
**/
VOID
RtcWrite16 (
IN UINT8 Location,
IN UINT16 Value
);
/**
Initialize RTC Timer
**/
VOID
RtcInit (
VOID
);
/**
Get current RTC time
@param[out] tm RTC time structure including Second, Minute and Hour.
@retval EFI_SUCCESS Operation successfully and RTC_TIME structure contained current time.
**/
EFI_STATUS
RtcGetTime (
OUT RTC_TIME *tm
);
/**
Check if RTC Alarm has been enabled.
@retval TRUE RTC Alarm is enabled
@retval FALSE RTC Alarm is not enabled
**/
BOOLEAN
RtcIsAlarmEnabled (
VOID
);
/**
Get current RTC Alarm time.
@param[out] tm A structure which will be updated with current RTC Alarm time
@retval EFI_NOT_STARTED RTC Alarm has not been enabled yet.
@retval EFI_SUCCESS RTC Alarm enabled and RTC_TIME structure contain current Alarm time setting.
**/
EFI_STATUS
RtcGetAlarm (
OUT RTC_TIME *tm
);
/**
Set RTC Alarm with specific time
@param[in] tm A time interval structure which will be used to setup an RTC Alarm
@retval EFI_SUCCESS RTC Alarm has been enabled with specific time interval
**/
EFI_STATUS
RtcSetAlarm (
IN RTC_TIME *tm
);
/**
Enable or disable critical battery wakeup event.
This function enables/disables critical battery wakeup event on KSC controller.
This KSC specific command will not be sent if KSC not present. Porting is
required to match platform design.
@param[in] Enabled - Enable or disable Critical Battery wakeup event.
**/
VOID
RapidStartInitializeCriticalBatteryWakeupEvent (
IN BOOLEAN Enabled
);
/**
Check if current wakeup is because of critical low battery.
This function checks if current S3 resume caused by critical battery wakeup
event. This KSC specific command will not be sent if KSC not present. Porting is
required to match platform design.
@retval TRUE - Current wakeup source is critical low battery event.
@retval FALSE - The wakeup source is not critical low battery event.
**/
BOOLEAN
RapidStartCheckCriticalBatteryWakeupEvent (
VOID
);
/**
Clear all wakeup status.
This function clears all wakeup status bits on KSC controller. This KSC specific
command will not be sent if KSC not present. Porting is required to match
platform design.
**/
VOID
RapidStartClearAllKscWakeStatus (
VOID
);
#ifdef RAPID_START_WHOLE_MEMORY_CHECK
/**
Log CRC32 mismatched address and length
This is optional OEM hook function. It can be used to log any CRC32 mismatched memory chunk if needed.
@param[in] MismatchedBaseAddress - Memory address caused mismatched CRC32
@param[in] MismatchedDataSize - memory length for calculating CRC32
@retval EFI_SUCCESS Process successfully
**/
EFI_STATUS
LogCrc32MismatchedAddress (
UINTN MismatchedBaseAddress,
UINT32 MismatchedDataSize
);
/**
Log or compare CRC32 value for specific memory range. Each 16MB block will have one CRC32 value.
This function checks the memory integrity between Rapid Start Entry and Resume.
It calculates CRC32 for each memory chunk during Rapid Start Entry, and when
Rapid Start Resume it compares each memory chunk CRC32 value with previously
saved value to see if any mismatch found. Basically the debug mode BIOS can
display all information regarding mismatched memory address. In non-debug mode
BIOS, the mismatched memory address and size can be logged if needed. Refer to
section "Porting recommendation" for more information.
@param[in] IsComparingCrc32 - FALSE to save CRC32 value into buffer. TRUE to compare CRC32 value with pre-saved value in buffer.
@param[in] BaseAddress - Base memory address for logging or checking CRC32
@param[in] EndAddress - End memory address for logging or checking CRC32
@param[in] RapidStartData - A data buffer stored RapidStart internal non-volatile information.
**/
VOID
SaveOrCompareCrc32 (
IN BOOLEAN IsComparingCrc32,
IN UINTN BaseAddress,
IN UINTN EndAddress,
IN RAPID_START_PERSISTENT_DATA *RapidStartData
);
#endif
/**
Gets RapidStart non-volatile flag.
Bit0 (RAPID_START_FLAG_ENTRY_DONE):
- Rapid Start Entry flow has completed successfully.
- Next boot will perform Rapid Start Resume.
Bit1 (RAPID_START_FLAG_STORE_CHANGE):
- Rapid Start Store change detected in Rapid Start Resume flow.
- Rapid Start Resume should be aborted.
This function will get Rapid Start non-volatile flag which controls overall
Rapid Start transition behavior. If Rapid Start Entry already performed in last
boot (Rapid Start Flag bit1 was set) the Rapid Start Exit transition can be
executed in current boot. After got the Rapid Start Entry state it is
recommended to clear this flag (Rapid Start Flag bit1) after drive lock password
has been retrieved and scrubbed from non-volatile memory (if drive-lock feature
enabled). There are several ways to store Rapid Start Flag and it is platform
specific. It must be stored in non-volatile memory and one of the methods is to
use CMOS RAM.
@param[out] Value - RapidStart non-volatile flag
@retval EFI_SUCCESS - Return the RapidStart flag in Value argument.
**/
EFI_STATUS
RapidStartGetFlag (
OUT UINT8 *Value
);
/**
Sets RapidStart non-volatile flag.
Bit0 (RAPID_START_FLAG_ENTRY_DONE):
- Rapid Start Entry flow has completed successfully.
- Next boot will perform Rapid Start Resume.
Bit1 (RAPID_START_FLAG_STORE_CHANGE):
- Rapid Start Store change detected in Rapid Start Resume flow.
- Rapid Start Resume should be aborted.
This function will set Rapid Start non-volatile flag which controls overall
Rapid Start transition behavior. In end of Rapid Start Entry it will set bit0 to
indicate next boot may perform Rapid Start Resume. It will also be used to clear
Rapid Start Flag when required information has been retrieved.
@param[in] Value - RapidStart flag state
@retval EFI_SUCCESS - Flag is set.
**/
EFI_STATUS
RapidStartSetFlag (
IN UINT8 Value
);
/**
Retrieves non-volatile RapidStart settings.
@param[out] Value - RapidStart non-volatile settings
@retval EFI_SUCCESS
**/
EFI_STATUS
RapidStartGetConfig (
OUT UINT8 *Value
);
/**
Sets non-volatile RapidStart settings.
@param[in] Value - RapidStart non-volatile settings
@retval EFI_SUCCESS
**/
EFI_STATUS
RapidStartSetConfig (
IN UINT8 Value
);
/**
This callback is executed at the end of RapidStart Entry events initialization. (Inside sleep SMI handler)
This function will be called in the end of sleep SMI handler which initializes
Rapid Start Entry trigger events (RTC alarm timer or critical battery wakeup
threshold). It can be used to log the status of initialization like Entry
cancellation or Entry aborted due to a sooner wakeup timer has be initialized by
OS/application. In these cases Rapid Start trigger events will not be
initialized and system will directly enter standard S3 state.
This function can be used to log any error status of initializing Rapid Start
Entry trigger events in sleep SMI handler and then inform users for why Rapid
Start Entry not happened.
@param[in] TransitionStatus - Status of initialization for RapidStart Entry events.
**/
VOID
AfterInitializingEntryEvent (
IN EFI_STATUS TransitionStatus
);
/**
Check whether RapidStart Resume.
@retval TRUE - Rapid Start Entry flow has completed successfully
**/
BOOLEAN
RapidStartResumeCheck (
VOID
);
#endif
//**********************************************************************
//**********************************************************************
//** **
//** (C)Copyright 1985-2012, American Megatrends, Inc. **
//** **
//** All Rights Reserved. **
//** **
//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
//** **
//** Phone: (770)-246-8600 **
//** **
//**********************************************************************
//**********************************************************************
|