summaryrefslogtreecommitdiff
path: root/Board/EM/IdeBusBoard/IdeBusBoard.c
blob: b21bc57213205bbd6d23e1b0eeee585b4155ef0f (plain)
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************

//*************************************************************************
// $Header: /Alaska/BIN/Core/Modules/IdeBus/IdeBusBoard.c 2     9/27/11 2:50a Rajeshms $
//
// $Revision: 2 $
//
// $Date: 9/27/11 2:50a $
//*************************************************************************
// Revision History
// ----------------
// $Log: /Alaska/BIN/Core/Modules/IdeBus/IdeBusBoard.c $
// 
// 2     9/27/11 2:50a Rajeshms
// [TAG]  		EIP69295
// [Category]  	Improvement
// [Description]  	The Timeout values used by IDE and AHCI drivers are
// made as SDL tokens, so that the timeout values can be varied.
// [Files]  		IdeBusBoard.c, CORE_DXE.sdl, AhciSmm.h, AhciBus.h, IDESMM.h,
// Ata.c, Atapi.c, IdeBus.c, IdeBus.h, IdeBusMaster.c, IdeBusBoard.h
// 
// 1     8/25/10 5:37a Rameshr
// New Feature: EIP 37748
// Description: Move all the IDEBus Source driver SDL token into IdeBus
// Bin Driver.
// FilesModified: Ata.c, Atapi.c, idebus.c, IdeBus.h,
// IdebuscomponentName.c, IdeBusmaster.c IdeBusSrc.mak IdebusSrc.sdl
// IdeHpa.c, IdePowerManagement.c
// 
//    
//
//*************************************************************************
//<AMI_FHDR_START>
//
// Name: IdeBusBoard.c
//
// Description: Installs PlatformIdeProtocol Interface and Initializes it.
//  
//<AMI_FHDR_END>
//*************************************************************************

#include <AmiDxeLib.h>
#include <EFI.h>
#include <Dxe.h>
#include <Token.h>
#include <Protocol\IdeBusBoard.h>

#include <Protocol\PciIo.h>
#include <Protocol\PIDEController.h>
#include <Protocol\IdeControllerInit.h>
#include <Protocol\ComponentName.h>

EFI_GUID PlatformIdeProtocolGuid = PLATFORM_IDE_PROTOCOL_GUID;

PLATFORM_IDE_PROTOCOL PlatformIdeProtocol= {

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    Revision
//
// Description:	Variable contains the Revision of PLATFORM_IDE_PROTOCOL.
//
// Notes: UINT8
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
PLATFORM_IDE_PROTOCOL_REVISION,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    MasterSlaveEnumeration
//
// Description:	Variable to replace MASTER_SLAVE_ENUMERATION token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
#ifdef MASTER_SLAVE_ENUMERATION
    MASTER_SLAVE_ENUMERATION
#else
    0
#endif
    ,
//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    IdeBusMasterSupport
//
// Description:	Variable to replace IDEBUSMASTER_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef IDEBUSMASTER_SUPPORT
    IDEBUSMASTER_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    AtapiBusMasterSupport
//
// Description:	Variable to replace ATAPI_BUSMASTER_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
 
#ifdef ATAPI_BUSMASTER_SUPPORT
    ATAPI_BUSMASTER_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    AcousticManagementSupport
//
// Description:	Variable to replace ACOUSTIC_MANAGEMENT_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef ACOUSTIC_MANAGEMENT_SUPPORT
    ACOUSTIC_MANAGEMENT_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    IdePowerManagementSupport
//
// Description:	Variable to replace IDE_POWER_MANAGEMENT_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef IDE_POWER_MANAGEMENT_SUPPORT
    IDE_POWER_MANAGEMENT_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    StandbyTimeout
//
// Description:	Variable to replace STANDBY_TIMEOUT token.
//
// Notes: INT16
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef STANDBY_TIMEOUT
    STANDBY_TIMEOUT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    AdvPowerManagementSupport
//
// Description:	Variable to replace ADVANCED_POWER_MANAGEMENT_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
 
#ifdef ADVANCED_POWER_MANAGEMENT_SUPPORT
    ADVANCED_POWER_MANAGEMENT_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    AdvPowerManagementLevel
//
// Description:	Variable to replace ADVANCED_POWER_MANAGEMENT_LEVEL token.
//
// Notes: UINT8
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
 
#ifdef ADVANCED_POWER_MANAGEMENT_LEVEL
    ADVANCED_POWER_MANAGEMENT_LEVEL
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    PowerupInStandbySupport
//
// Description:	Variable to replace POWERUP_IN_STANDBY_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef POWERUP_IN_STANDBY_SUPPORT
    POWERUP_IN_STANDBY_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    PowerupInStandbyMode
//
// Description:	Variable to replace POWERUP_IN_STANDBY_MODE token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef POWERUP_IN_STANDBY_MODE
    POWERUP_IN_STANDBY_MODE
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    IdePwrManagementInterfaceSupport
//
// Description:	Variable to replace IDE_POWER_MANAGEMENT_INTERFACE_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef IDE_POWER_MANAGEMENT_INTERFACE_SUPPORT
    IDE_POWER_MANAGEMENT_INTERFACE_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    HostProtectedAreaSupport
//
// Description:	Variable to replace HOST_PROTECTED_AREA_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef HOST_PROTECTED_AREA_SUPPORT
    HOST_PROTECTED_AREA_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    IdeHPSupport
//
// Description:	Variable to replace IDE_HP_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
 
#ifdef IDE_HP_SUPPORT
    IDE_HP_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    EfiIdeProtocol
//
// Description:	Variable to replace EFI_IDE_PROTOCOL token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef EFI_IDE_PROTOCOL
    EFI_IDE_PROTOCOL
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    AhciCompatibleMode
//
// Description:	Variable to replace AHCI_COMPATIBLE_MODE token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
 
#ifdef AHCI_COMPATIBLE_MODE
    AHCI_COMPATIBLE_MODE
#else
    0
#endif
    ,
//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    SBIdeSupport
//
// Description:	Variable to replace SBIDE_SUPPORT token.
//
// Notes: const BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
 
#ifdef SBIDE_SUPPORT
    SBIDE_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    HddPowerLossInS3
//
// Description:	Variable to replace HDD_POWER_LOSS_IN_S3 token.
//
// Notes: const BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>
 
#ifdef HDD_POWER_LOSS_IN_S3
    HDD_POWER_LOSS_IN_S3
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    DiPMSupport
//
// Description:	Variable to replace DiPM_SUPPORT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef DiPM_SUPPORT
    DiPM_SUPPORT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    DisableSoftSetPrev
//
// Description:	Variable to replace DISABLE_SOFT_SET_PREV token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef DISABLE_SOFT_SET_PREV
    DISABLE_SOFT_SET_PREV
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    ForceHddPasswordPrompt
//
// Description:	Variable to replace FORCE_HDD_PASSWORD_PROMPT token.
//
// Notes: BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef FORCE_HDD_PASSWORD_PROMPT
    FORCE_HDD_PASSWORD_PROMPT
#else
    0
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    gIdeControllerProtocolGuid
//
// Description:	Variable contains Ide Controller Protocol GUID.
//
// Notes: const EFI_GUID
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#if defined EFI_IDE_PROTOCOL && EFI_IDE_PROTOCOL == 1
    EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID
#else
    IDE_CONTROLLER_PROTOCOL_GUID
#endif
   ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    gComponentNameProtocolGuid
//
// Description:	Variable contains Component Name Protocol GUID.
//
// Notes: const EFI_GUID
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef EFI_COMPONENT_NAME2_PROTOCOL_GUID
    EFI_COMPONENT_NAME2_PROTOCOL_GUID
#else
    EFI_COMPONENT_NAME_PROTOCOL_GUID
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    S3BusyClearTimeout
//
// Description:	Variable to replace S3_BUSY_CLEAR_TIMEOUT token.
//
// Notes: const EFI_GUID
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef S3_BUSY_CLEAR_TIMEOUT
    S3_BUSY_CLEAR_TIMEOUT
#else
    10000
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    DmaAtaCompleteCommandTimeout
//
// Description:	Variable to replace DMA_ATA_COMMAND_COMPLETE_TIMEOUT token.
//
// Notes: const EFI_GUID
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef DMA_ATA_COMMAND_COMPLETE_TIMEOUT
    DMA_ATA_COMMAND_COMPLETE_TIMEOUT
#else
    5000
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    DmaAtaPiCompleteCommandTimeout
//
// Description:	Variable to replace DMA_ATAPI_COMMAND_COMPLETE_TIMEOUT token.
//
// Notes: const EFI_GUID
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef DMA_ATAPI_COMMAND_COMPLETE_TIMEOUT
    DMA_ATAPI_COMMAND_COMPLETE_TIMEOUT
#else
    16000
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    AtaPiResetCommandTimeout
//
// Description:	Variable to replace ATAPI_RESET_COMMAND_TIMEOUT token.
//
// Notes: const EFI_GUID
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef ATAPI_RESET_COMMAND_TIMEOUT
    ATAPI_RESET_COMMAND_TIMEOUT
#else
    5000
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    AtaPiBusyClearTimeout
//
// Description:	Variable to replace ATAPI_BUSY_CLEAR_TIMEOUT token.
//
// Notes: const EFI_GUID
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef ATAPI_BUSY_CLEAR_TIMEOUT
    ATAPI_BUSY_CLEAR_TIMEOUT
#else
    16000
#endif
    ,

//<AMI_SHDR_START>
//----------------------------------------------------------------------------
// Name:    PoweonBusyClearTimeout
//
// Description:	Variable to replace DMA_ATA_COMMAND_COMPLETE_TIMEOUT token.
//
// Notes: const EFI_GUID
//
//----------------------------------------------------------------------------
//<AMI_SHDR_END>

#ifdef POWERON_BUSY_CLEAR_TIMEOUT
    POWERON_BUSY_CLEAR_TIMEOUT
#else
    10000
#endif
};

//<AMI_PHDR_START>
//---------------------------------------------------------------------------
//
// Procedure:	IdeBusBoardEntryPoint
//
// Description:	Installs PlatformIdeProtocol Interface
//
// Input:
//  IN EFI_HANDLE        ImageHandle,
//  IN EFI_SYSTEM_TABLE  *SystemTable
//
// Output:
//  EFI_STATUS
//
// Modified:
//
// Referrals: InitAmiLib, InstallProtocolInterface
//
// Notes:
//  Here is the control flow of this function:
//  1. Initialize Ami Lib.
//  2. Install PlatformIdeProtocol.
//  3. Return EFI_SUCCESS.
//---------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS
IdeBusBoardEntryPoint (
IN EFI_HANDLE     ImageHandle,
IN EFI_SYSTEM_TABLE   *SystemTable )
{
    EFI_STATUS Status;
    InitAmiLib(ImageHandle,SystemTable);
    Status = pBS->InstallProtocolInterface(\
                    &ImageHandle,\
                    &PlatformIdeProtocolGuid,\
                    EFI_NATIVE_INTERFACE,\
                    &PlatformIdeProtocol\
                        );
    return Status;
}

#ifndef EFI_COMPONENT_NAME2_PROTOCOL_GUID //old Core Support
//*************************************************************************
//<AMI_PHDR_START>
//
// Name: LanguageCodesEqual
//
// Description:	
//  BOOLEAN LanguageCodesEqual(CONST CHAR8* LangCode1, CONST CHAR8* LangCode2) 
// compares two language codes and returns TRUE if they are equal.
//
// Input:
//  CONST CHAR8* LangCode1 - first language code
//  CONST CHAR8* LangCode2 - second language code
//
// Output:
//  BOOLEAN TRUE - the language codes are equal
//          FALSE - the language codes are not equal
//
//<AMI_PHDR_END>
//*************************************************************************
BOOLEAN LanguageCodesEqual(
    CONST CHAR8* LangCode1, CONST CHAR8* LangCode2
){
    return    LangCode1[0]==LangCode2[0] 
           && LangCode1[1]==LangCode2[1]
           && LangCode1[2]==LangCode2[2];
}
#endif 
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************