1 /** @file
2   This code fills in BDA (0x400) and EBDA (pointed to by 0x4xx)
3   information. There is support for doing initializeation before
4   Legacy16 is loaded and before a legacy boot is attempted.
5 
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
7 
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9 
10 **/
11 
12 #include "LegacyBiosInterface.h"
13 
14 /**
15   Fill in the standard BDA and EBDA stuff before Legacy16 load
16 
17   @param  Private     Legacy BIOS Instance data
18 
19   @retval EFI_SUCCESS It should always work.
20 
21 **/
22 EFI_STATUS
LegacyBiosInitBda(IN LEGACY_BIOS_INSTANCE * Private)23 LegacyBiosInitBda (
24   IN  LEGACY_BIOS_INSTANCE    *Private
25   )
26 {
27   BDA_STRUC *Bda;
28   UINT8     *Ebda;
29 
30   Bda   = (BDA_STRUC *) ((UINTN) 0x400);
31   Ebda  = (UINT8 *) ((UINTN) 0x9fc00);
32 
33   ACCESS_PAGE0_CODE (
34     ZeroMem (Bda, 0x100);
35     //
36     // 640k-1k for EBDA
37     //
38     Bda->MemSize        = 0x27f;
39     Bda->KeyHead        = 0x1e;
40     Bda->KeyTail        = 0x1e;
41     Bda->FloppyData     = 0x00;
42     Bda->FloppyTimeout  = 0xff;
43 
44     Bda->KeyStart       = 0x001E;
45     Bda->KeyEnd         = 0x003E;
46     Bda->KeyboardStatus = 0x10;
47     Bda->Ebda           = 0x9fc0;
48 
49     //
50     // Move LPT time out here and zero out LPT4 since some SCSI OPROMS
51     // use this as scratch pad (LPT4 is Reserved)
52     //
53     Bda->Lpt1_2Timeout  = 0x1414;
54     Bda->Lpt3_4Timeout  = 0x1400;
55 
56   );
57 
58   ZeroMem (Ebda, 0x400);
59   *Ebda = 0x01;
60 
61   return EFI_SUCCESS;
62 }
63