]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFsp2Pkg/Include/FspEas/FspApi.h
5e47f475db5bf034d49deddf9919db5de9e5b546
[mirror_edk2.git] / IntelFsp2Pkg / Include / FspEas / FspApi.h
1 /** @file
2 Intel FSP API definition from Intel Firmware Support Package External
3 Architecture Specification v2.0 - v2.2
4
5 Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _FSP_API_H_
11 #define _FSP_API_H_
12
13 #include <Pi/PiStatusCode.h>
14 #include <Base.h>
15
16 ///
17 /// FSP Reset Status code
18 /// These are defined in FSP EAS v2.4 section 13.2.2 - OEM Status Code
19 /// @{
20
21 #define ENCODE_RESET_REQUEST(ResetType) \
22 ((EFI_STATUS)((MAX_BIT >> 1) | (ResetType)))
23 #define FSP_STATUS_RESET_REQUIRED_COLD ENCODE_RESET_REQUEST(1)
24 #define FSP_STATUS_RESET_REQUIRED_WARM ENCODE_RESET_REQUEST(2)
25 #define FSP_STATUS_RESET_REQUIRED_3 ENCODE_RESET_REQUEST(3)
26 #define FSP_STATUS_RESET_REQUIRED_4 ENCODE_RESET_REQUEST(4)
27 #define FSP_STATUS_RESET_REQUIRED_5 ENCODE_RESET_REQUEST(5)
28 #define FSP_STATUS_RESET_REQUIRED_6 ENCODE_RESET_REQUEST(6)
29 #define FSP_STATUS_RESET_REQUIRED_7 ENCODE_RESET_REQUEST(7)
30 #define FSP_STATUS_RESET_REQUIRED_8 ENCODE_RESET_REQUEST(8)
31 #define FSP_STATUS_VARIABLE_REQUEST ENCODE_RESET_REQUEST(10)
32 /// @}
33
34 ///
35 /// FSP Event related definition.
36 ///
37 #define FSP_EVENT_CODE 0xF5000000
38 #define FSP_POST_CODE (FSP_EVENT_CODE | 0x00F80000)
39
40 /*
41 FSP may optionally include the capability of generating events messages to aid in the debugging of firmware issues.
42 These events fall under three catagories: Error, Progress, and Debug. The event reporting mechanism follows the
43 status code services described in section 6 and 7 of the PI Specification v1.7 Volume 3.
44
45 @param[in] Type Indicates the type of event being reported.
46 See MdePkg/Include/Pi/PiStatusCode.h for the definition of EFI_STATUS_CODE_TYPE.
47 @param[in] Value Describes the current status of a hardware or software entity.
48 This includes information about the class and subclass that is used to classify the entity as well as an operation.
49 For progress events, the operation is the current activity. For error events, it is the exception.
50 For debug events, it is not defined at this time.
51 See MdePkg/Include/Pi/PiStatusCode.h for the definition of EFI_STATUS_CODE_VALUE.
52 @param[in] Instance The enumeration of a hardware or software entity within the system.
53 A system may contain multiple entities that match a class/subclass pairing. The instance differentiates between them.
54 An instance of 0 indicates that instance information is unavailable, not meaningful, or not relevant.
55 Valid instance numbers start with 1.
56 @param[in] *CallerId This parameter can be used to identify the sub-module within the FSP generating the event.
57 This parameter may be NULL.
58 @param[in] *Data This optional parameter may be used to pass additional data. The contents can have event-specific data.
59 For example, the FSP provides a EFI_STATUS_CODE_STRING_DATA instance to this parameter when sending debug messages.
60 This parameter is NULL when no additional data is provided.
61
62 @retval EFI_SUCCESS The event was handled successfully.
63 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
64 @retval EFI_DEVICE_ERROR The event handler failed.
65 */
66 typedef
67 EFI_STATUS
68 (EFIAPI *FSP_EVENT_HANDLER)(
69 IN EFI_STATUS_CODE_TYPE Type,
70 IN EFI_STATUS_CODE_VALUE Value,
71 IN UINT32 Instance,
72 IN OPTIONAL EFI_GUID *CallerId,
73 IN OPTIONAL EFI_STATUS_CODE_DATA *Data
74 );
75
76 /*
77 Handler for FSP-T debug log messages, provided by the bootloader.
78
79 @param[in] DebugMessage A pointer to the debug message to be written to the log.
80 @param[in] MessageLength Number of bytes to written to the debug log.
81
82 @retval UINT32 The return value indicates the number of bytes actually written to
83 the debug log. If the return value is less than MessageLength,
84 an error occurred.
85 */
86 typedef
87 UINT32
88 (EFIAPI *FSP_DEBUG_HANDLER)(
89 IN CHAR8 *DebugMessage,
90 IN UINT32 MessageLength
91 );
92
93 #pragma pack(1)
94 ///
95 /// FSP_UPD_HEADER Configuration.
96 ///
97 typedef struct {
98 ///
99 /// UPD Region Signature. This signature will be
100 /// "XXXXXX_T" for FSP-T
101 /// "XXXXXX_M" for FSP-M
102 /// "XXXXXX_S" for FSP-S
103 /// Where XXXXXX is an unique signature
104 ///
105 UINT64 Signature;
106 ///
107 /// Revision of the Data structure.
108 /// For FSP spec 2.0/2.1 value is 1.
109 /// For FSP spec 2.2 value is 2.
110 ///
111 UINT8 Revision;
112 UINT8 Reserved[23];
113 } FSP_UPD_HEADER;
114
115 ///
116 /// FSPT_ARCH_UPD Configuration.
117 ///
118 typedef struct {
119 ///
120 /// Revision of the structure is 1 for this version of the specification.
121 ///
122 UINT8 Revision;
123 UINT8 Reserved[3];
124 ///
125 /// Length of the structure in bytes. The current value for this field is 32.
126 ///
127 UINT32 Length;
128 ///
129 /// FspDebugHandler Optional debug handler for the bootloader to receive debug messages
130 /// occurring during FSP execution.
131 ///
132 FSP_DEBUG_HANDLER FspDebugHandler;
133 UINT8 Reserved1[20];
134 } FSPT_ARCH_UPD;
135
136 ///
137 /// FSPT_ARCH2_UPD Configuration.
138 ///
139 typedef struct {
140 ///
141 /// Revision of the structure is 2 for this version of the specification.
142 ///
143 UINT8 Revision;
144 UINT8 Reserved[3];
145 ///
146 /// Length of the structure in bytes. The current value for this field is 32.
147 ///
148 UINT32 Length;
149 ///
150 /// FspDebugHandler Optional debug handler for the bootloader to receive debug messages
151 /// occurring during FSP execution.
152 ///
153 EFI_PHYSICAL_ADDRESS FspDebugHandler;
154 UINT8 Reserved1[16];
155 } FSPT_ARCH2_UPD;
156
157 ///
158 /// FSPM_ARCH_UPD Configuration.
159 ///
160 typedef struct {
161 ///
162 /// Revision of the structure. For FSP v2.0 value is 1.
163 ///
164 UINT8 Revision;
165 UINT8 Reserved[3];
166 ///
167 /// Pointer to the non-volatile storage (NVS) data buffer.
168 /// If it is NULL it indicates the NVS data is not available.
169 ///
170 VOID *NvsBufferPtr;
171 ///
172 /// Pointer to the temporary stack base address to be
173 /// consumed inside FspMemoryInit() API.
174 ///
175 VOID *StackBase;
176 ///
177 /// Temporary stack size to be consumed inside
178 /// FspMemoryInit() API.
179 ///
180 UINT32 StackSize;
181 ///
182 /// Size of memory to be reserved by FSP below "top
183 /// of low usable memory" for bootloader usage.
184 ///
185 UINT32 BootLoaderTolumSize;
186 ///
187 /// Current boot mode.
188 ///
189 UINT32 BootMode;
190 ///
191 /// Optional event handler for the bootloader to be informed of events occurring during FSP execution.
192 /// This value is only valid if Revision is >= 2.
193 ///
194 FSP_EVENT_HANDLER *FspEventHandler;
195 UINT8 Reserved1[4];
196 } FSPM_ARCH_UPD;
197
198 ///
199 /// FSPM_ARCH2_UPD Configuration.
200 ///
201 typedef struct {
202 ///
203 /// Revision of the structure is 3 for this version of the specification.
204 ///
205 UINT8 Revision;
206 UINT8 Reserved[3];
207 ///
208 /// Length of the structure in bytes. The current value for this field is 64.
209 ///
210 UINT32 Length;
211 ///
212 /// Pointer to the temporary stack base address to be
213 /// consumed inside FspMemoryInit() API.
214 ///
215 EFI_PHYSICAL_ADDRESS StackBase;
216 ///
217 /// Temporary stack size to be consumed inside
218 /// FspMemoryInit() API.
219 ///
220 UINT64 StackSize;
221 ///
222 /// Size of memory to be reserved by FSP below "top
223 /// of low usable memory" for bootloader usage.
224 ///
225 UINT32 BootLoaderTolumSize;
226 ///
227 /// Current boot mode.
228 ///
229 UINT32 BootMode;
230 ///
231 /// Optional event handler for the bootloader to be informed of events occurring during FSP execution.
232 /// This value is only valid if Revision is >= 2.
233 ///
234 EFI_PHYSICAL_ADDRESS FspEventHandler;
235 UINT8 Reserved1[24];
236 } FSPM_ARCH2_UPD;
237
238 ///
239 /// FSPS_ARCH_UPD Configuration.
240 ///
241 typedef struct {
242 ///
243 /// Revision of the structure is 1 for this version of the specification.
244 ///
245 UINT8 Revision;
246 UINT8 Reserved[3];
247 ///
248 /// Length of the structure in bytes. The current value for this field is 32.
249 ///
250 UINT32 Length;
251 ///
252 /// FspEventHandler Optional event handler for the bootloader to be informed of events
253 /// occurring during FSP execution.
254 ///
255 FSP_EVENT_HANDLER FspEventHandler;
256 ///
257 /// A FSP binary may optionally implement multi-phase silicon initialization,
258 /// This is only supported if the FspMultiPhaseSiInitEntryOffset field in FSP_INFO_HEADER
259 /// is non-zero.
260 /// To enable multi-phase silicon initialization, the bootloader must set
261 /// EnableMultiPhaseSiliconInit to a non-zero value.
262 ///
263 UINT8 EnableMultiPhaseSiliconInit;
264 UINT8 Reserved1[19];
265 } FSPS_ARCH_UPD;
266
267 ///
268 /// FSPS_ARCH2_UPD Configuration.
269 ///
270 typedef struct {
271 ///
272 /// Revision of the structure is 2 for this version of the specification.
273 ///
274 UINT8 Revision;
275 UINT8 Reserved[3];
276 ///
277 /// Length of the structure in bytes. The current value for this field is 32.
278 ///
279 UINT32 Length;
280 ///
281 /// FspEventHandler Optional event handler for the bootloader to be informed of events
282 /// occurring during FSP execution.
283 ///
284 EFI_PHYSICAL_ADDRESS FspEventHandler;
285 UINT8 Reserved1[16];
286 } FSPS_ARCH2_UPD;
287
288 ///
289 /// FSPT_UPD_COMMON Configuration.
290 ///
291 typedef struct {
292 ///
293 /// FSP_UPD_HEADER Configuration.
294 ///
295 FSP_UPD_HEADER FspUpdHeader;
296 } FSPT_UPD_COMMON;
297
298 ///
299 /// FSPT_UPD_COMMON Configuration for FSP spec. 2.2 and above.
300 ///
301 typedef struct {
302 ///
303 /// FSP_UPD_HEADER Configuration.
304 ///
305 FSP_UPD_HEADER FspUpdHeader;
306
307 ///
308 /// FSPT_ARCH_UPD Configuration.
309 ///
310 FSPT_ARCH_UPD FsptArchUpd;
311 } FSPT_UPD_COMMON_FSP22;
312
313 ///
314 /// FSPT_UPD_COMMON Configuration for FSP spec. 2.4 and above.
315 ///
316 typedef struct {
317 ///
318 /// FSP_UPD_HEADER Configuration.
319 ///
320 FSP_UPD_HEADER FspUpdHeader;
321
322 ///
323 /// FSPT_ARCH2_UPD Configuration.
324 ///
325 FSPT_ARCH2_UPD FsptArchUpd;
326 } FSPT_UPD_COMMON_FSP24;
327
328 ///
329 /// FSPM_UPD_COMMON Configuration.
330 ///
331 typedef struct {
332 ///
333 /// FSP_UPD_HEADER Configuration.
334 ///
335 FSP_UPD_HEADER FspUpdHeader;
336 ///
337 /// FSPM_ARCH_UPD Configuration.
338 ///
339 FSPM_ARCH_UPD FspmArchUpd;
340 } FSPM_UPD_COMMON;
341
342 ///
343 /// FSPM_UPD_COMMON Configuration for FSP spec. 2.4 and above.
344 ///
345 typedef struct {
346 ///
347 /// FSP_UPD_HEADER Configuration.
348 ///
349 FSP_UPD_HEADER FspUpdHeader;
350 ///
351 /// FSPM_ARCH2_UPD Configuration.
352 ///
353 FSPM_ARCH2_UPD FspmArchUpd;
354 } FSPM_UPD_COMMON_FSP24;
355
356 ///
357 /// FSPS_UPD_COMMON Configuration.
358 ///
359 typedef struct {
360 ///
361 /// FSP_UPD_HEADER Configuration.
362 ///
363 FSP_UPD_HEADER FspUpdHeader;
364 } FSPS_UPD_COMMON;
365
366 ///
367 /// FSPS_UPD_COMMON Configuration for FSP spec. 2.2 and above.
368 ///
369 typedef struct {
370 ///
371 /// FSP_UPD_HEADER Configuration.
372 ///
373 FSP_UPD_HEADER FspUpdHeader;
374
375 ///
376 /// FSPS_ARCH_UPD Configuration.
377 ///
378 FSPS_ARCH_UPD FspsArchUpd;
379 } FSPS_UPD_COMMON_FSP22;
380
381 ///
382 /// FSPS_UPD_COMMON Configuration for FSP spec. 2.4 and above.
383 ///
384 typedef struct {
385 ///
386 /// FSP_UPD_HEADER Configuration.
387 ///
388 FSP_UPD_HEADER FspUpdHeader;
389
390 ///
391 /// FSPS_ARCH2_UPD Configuration.
392 ///
393 FSPS_ARCH2_UPD FspsArchUpd;
394 } FSPS_UPD_COMMON_FSP24;
395
396 ///
397 /// Enumeration of FSP_INIT_PHASE for NOTIFY_PHASE.
398 ///
399 typedef enum {
400 ///
401 /// This stage is notified when the bootloader completes the
402 /// PCI enumeration and the resource allocation for the
403 /// PCI devices is complete.
404 ///
405 EnumInitPhaseAfterPciEnumeration = 0x20,
406 ///
407 /// This stage is notified just before the bootloader hand-off
408 /// to the OS loader.
409 ///
410 EnumInitPhaseReadyToBoot = 0x40,
411 ///
412 /// This stage is notified just before the firmware/Preboot
413 /// environment transfers management of all system resources
414 /// to the OS or next level execution environment.
415 ///
416 EnumInitPhaseEndOfFirmware = 0xF0
417 } FSP_INIT_PHASE;
418
419 ///
420 /// Definition of NOTIFY_PHASE_PARAMS.
421 ///
422 typedef struct {
423 ///
424 /// Notification phase used for NotifyPhase API
425 ///
426 FSP_INIT_PHASE Phase;
427 } NOTIFY_PHASE_PARAMS;
428
429 ///
430 /// Action definition for FspMultiPhaseSiInit API
431 ///
432 typedef enum {
433 EnumMultiPhaseGetNumberOfPhases = 0x0,
434 EnumMultiPhaseExecutePhase = 0x1
435 } FSP_MULTI_PHASE_ACTION;
436
437 ///
438 /// Data structure returned by FSP when bootloader calling
439 /// FspMultiPhaseSiInit API with action 0 (EnumMultiPhaseGetNumberOfPhases)
440 ///
441 typedef struct {
442 UINT32 NumberOfPhases;
443 UINT32 PhasesExecuted;
444 } FSP_MULTI_PHASE_GET_NUMBER_OF_PHASES_PARAMS;
445
446 ///
447 /// FspMultiPhaseSiInit function parameter.
448 ///
449 /// For action 0 (EnumMultiPhaseGetNumberOfPhases):
450 /// - PhaseIndex must be 0.
451 /// - MultiPhaseParamPtr should point to an instance of FSP_MULTI_PHASE_GET_NUMBER_OF_PHASES_PARAMS.
452 ///
453 /// For action 1 (EnumMultiPhaseExecutePhase):
454 /// - PhaseIndex will be the phase that will be executed by FSP.
455 /// - MultiPhaseParamPtr shall be NULL.
456 ///
457 typedef struct {
458 IN FSP_MULTI_PHASE_ACTION MultiPhaseAction;
459 IN UINT32 PhaseIndex;
460 IN OUT VOID *MultiPhaseParamPtr;
461 } FSP_MULTI_PHASE_PARAMS;
462
463 #pragma pack()
464
465 /**
466 This FSP API is called soon after coming out of reset and before memory and stack is
467 available. This FSP API will load the microcode update, enable code caching for the
468 region specified by the boot loader and also setup a temporary stack to be used until
469 main memory is initialized.
470
471 A hardcoded stack can be set up with the following values, and the "esp" register
472 initialized to point to this hardcoded stack.
473 1. The return address where the FSP will return control after setting up a temporary
474 stack.
475 2. A pointer to the input parameter structure
476
477 However, since the stack is in ROM and not writeable, this FSP API cannot be called
478 using the "call" instruction, but needs to be jumped to.
479
480 @param[in] FsptUpdDataPtr Pointer to the FSPT_UPD data structure.
481
482 @retval EFI_SUCCESS Temporary RAM was initialized successfully.
483 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
484 @retval EFI_UNSUPPORTED The FSP calling conditions were not met.
485 @retval EFI_DEVICE_ERROR Temp RAM initialization failed.
486
487 If this function is successful, the FSP initializes the ECX and EDX registers to point to
488 a temporary but writeable memory range available to the boot loader and returns with
489 FSP_SUCCESS in register EAX. Register ECX points to the start of this temporary
490 memory range and EDX points to the end of the range. Boot loader is free to use the
491 whole range described. Typically the boot loader can reload the ESP register to point
492 to the end of this returned range so that it can be used as a standard stack.
493 **/
494 typedef
495 EFI_STATUS
496 (EFIAPI *FSP_TEMP_RAM_INIT)(
497 IN VOID *FsptUpdDataPtr
498 );
499
500 /**
501 This FSP API is used to notify the FSP about the different phases in the boot process.
502 This allows the FSP to take appropriate actions as needed during different initialization
503 phases. The phases will be platform dependent and will be documented with the FSP
504 release. The current FSP supports two notify phases:
505 Post PCI enumeration
506 Ready To Boot
507
508 @param[in] NotifyPhaseParamPtr Address pointer to the NOTIFY_PHASE_PRAMS
509
510 @retval EFI_SUCCESS The notification was handled successfully.
511 @retval EFI_UNSUPPORTED The notification was not called in the proper order.
512 @retval EFI_INVALID_PARAMETER The notification code is invalid.
513 **/
514 typedef
515 EFI_STATUS
516 (EFIAPI *FSP_NOTIFY_PHASE)(
517 IN NOTIFY_PHASE_PARAMS *NotifyPhaseParamPtr
518 );
519
520 /**
521 This FSP API is called after TempRamInit and initializes the memory.
522 This FSP API accepts a pointer to a data structure that will be platform dependent
523 and defined for each FSP binary. This will be documented in Integration guide with
524 each FSP release.
525 After FspMemInit completes its execution, it passes the pointer to the HobList and
526 returns to the boot loader from where it was called. BootLoader is responsible to
527 migrate its stack and data to Memory.
528 FspMemoryInit, TempRamExit and FspSiliconInit APIs provide an alternate method to
529 complete the silicon initialization and provides bootloader an opportunity to get
530 control after system memory is available and before the temporary RAM is torn down.
531
532 @param[in] FspmUpdDataPtr Pointer to the FSPM_UPD data structure.
533 @param[out] HobListPtr Pointer to receive the address of the HOB list.
534
535 @retval EFI_SUCCESS FSP execution environment was initialized successfully.
536 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
537 @retval EFI_UNSUPPORTED The FSP calling conditions were not met.
538 @retval EFI_DEVICE_ERROR FSP initialization failed.
539 @retval EFI_OUT_OF_RESOURCES Stack range requested by FSP is not met.
540 @retval FSP_STATUS_RESET_REQUIREDx A reset is reuired. These status codes will not be returned during S3.
541 **/
542 typedef
543 EFI_STATUS
544 (EFIAPI *FSP_MEMORY_INIT)(
545 IN VOID *FspmUpdDataPtr,
546 OUT VOID **HobListPtr
547 );
548
549 /**
550 This FSP API is called after FspMemoryInit API. This FSP API tears down the temporary
551 memory setup by TempRamInit API. This FSP API accepts a pointer to a data structure
552 that will be platform dependent and defined for each FSP binary. This will be
553 documented in Integration Guide.
554 FspMemoryInit, TempRamExit and FspSiliconInit APIs provide an alternate method to
555 complete the silicon initialization and provides bootloader an opportunity to get
556 control after system memory is available and before the temporary RAM is torn down.
557
558 @param[in] TempRamExitParamPtr Pointer to the Temp Ram Exit parameters structure.
559 This structure is normally defined in the Integration Guide.
560 And if it is not defined in the Integration Guide, pass NULL.
561
562 @retval EFI_SUCCESS FSP execution environment was initialized successfully.
563 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
564 @retval EFI_UNSUPPORTED The FSP calling conditions were not met.
565 @retval EFI_DEVICE_ERROR FSP initialization failed.
566 **/
567 typedef
568 EFI_STATUS
569 (EFIAPI *FSP_TEMP_RAM_EXIT)(
570 IN VOID *TempRamExitParamPtr
571 );
572
573 /**
574 This FSP API is called after TempRamExit API.
575 FspMemoryInit, TempRamExit and FspSiliconInit APIs provide an alternate method to complete the
576 silicon initialization.
577
578 @param[in] FspsUpdDataPtr Pointer to the FSPS_UPD data structure.
579 If NULL, FSP will use the default parameters.
580
581 @retval EFI_SUCCESS FSP execution environment was initialized successfully.
582 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
583 @retval EFI_UNSUPPORTED The FSP calling conditions were not met.
584 @retval EFI_DEVICE_ERROR FSP initialization failed.
585 @retval FSP_STATUS_RESET_REQUIREDx A reset is required. These status codes will not be returned during S3.
586 **/
587 typedef
588 EFI_STATUS
589 (EFIAPI *FSP_SILICON_INIT)(
590 IN VOID *FspsUpdDataPtr
591 );
592
593 /**
594 This FSP API is expected to be called after FspSiliconInit but before FspNotifyPhase.
595 This FSP API provides multi-phase silicon initialization; which brings greater modularity
596 beyond the existing FspSiliconInit() API. Increased modularity is achieved by adding an
597 extra API to FSP-S. This allows the bootloader to add board specific initialization steps
598 throughout the SiliconInit flow as needed.
599
600 @param[in,out] FSP_MULTI_PHASE_PARAMS For action - EnumMultiPhaseGetNumberOfPhases:
601 FSP_MULTI_PHASE_PARAMS->MultiPhaseParamPtr will contain
602 how many phases supported by FSP.
603 For action - EnumMultiPhaseExecutePhase:
604 FSP_MULTI_PHASE_PARAMS->MultiPhaseParamPtr shall be NULL.
605 @retval EFI_SUCCESS FSP execution environment was initialized successfully.
606 @retval EFI_INVALID_PARAMETER Input parameters are invalid.
607 @retval EFI_UNSUPPORTED The FSP calling conditions were not met.
608 @retval EFI_DEVICE_ERROR FSP initialization failed.
609 @retval FSP_STATUS_RESET_REQUIREDx A reset is required. These status codes will not be returned during S3.
610 **/
611 typedef
612 EFI_STATUS
613 (EFIAPI *FSP_MULTI_PHASE_SI_INIT)(
614 IN FSP_MULTI_PHASE_PARAMS *MultiPhaseSiInitParamPtr
615 );
616
617 #endif