]>
git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Csm/LegacyBiosDxe/LegacyCmos.c
de25e06184a42ccf3949003bed857cde7af30122
2 This code fills in standard CMOS values and updates the standard CMOS
3 checksum. The Legacy16 code or LegacyBiosPlatform.c is responsible for
4 non-standard CMOS locations and non-standard checksums.
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include "LegacyBiosInterface.h"
15 Read CMOS register through index/data port.
17 @param[in] Index The index of the CMOS register to read.
19 @return The data value from the CMOS register specified by Index.
23 LegacyReadStandardCmos (
27 IoWrite8 (PORT_70
, Index
);
28 return IoRead8 (PORT_71
);
32 Write CMOS register through index/data port.
34 @param[in] Index The index of the CMOS register to write.
35 @param[in] Value The value of CMOS register to write.
37 @return The value written to the CMOS register specified by Index.
41 LegacyWriteStandardCmos (
46 IoWrite8 (PORT_70
, Index
);
47 return IoWrite8 (PORT_71
, Value
);
51 Calculate the new standard CMOS checksum and write it.
53 @param Private Legacy BIOS Instance data
55 @retval EFI_SUCCESS Calculate 16-bit checksum successfully
59 LegacyCalculateWriteStandardCmosChecksum (
66 for (Checksum
= 0, Register
= 0x10; Register
< 0x2e; Register
++) {
67 Checksum
= (UINT16
)(Checksum
+ LegacyReadStandardCmos (Register
));
69 LegacyWriteStandardCmos (CMOS_2E
, (UINT8
)(Checksum
>> 8));
70 LegacyWriteStandardCmos (CMOS_2F
, (UINT8
)(Checksum
& 0xff));
76 Fill in the standard CMOS stuff before Legacy16 load
78 @param Private Legacy BIOS Instance data
80 @retval EFI_SUCCESS It should always work.
85 IN LEGACY_BIOS_INSTANCE
*Private
91 // Clear all errors except RTC lost power
93 LegacyWriteStandardCmos (CMOS_0E
, (UINT8
)(LegacyReadStandardCmos (CMOS_0E
) & BIT7
));
96 // Update CMOS locations 15,16,17,18,30,31 and 32
97 // CMOS 16,15 = 640Kb = 0x280
98 // CMOS 18,17 = 31,30 = 15Mb max in 1Kb increments =0x3C00 max
101 LegacyWriteStandardCmos (CMOS_15
, 0x80);
102 LegacyWriteStandardCmos (CMOS_16
, 0x02);
104 Size
= 15 * SIZE_1MB
;
105 if (Private
->IntThunk
->EfiToLegacy16InitTable
.OsMemoryAbove1Mb
< (15 * SIZE_1MB
)) {
106 Size
= Private
->IntThunk
->EfiToLegacy16InitTable
.OsMemoryAbove1Mb
>> 10;
109 LegacyWriteStandardCmos (CMOS_17
, (UINT8
)(Size
& 0xFF));
110 LegacyWriteStandardCmos (CMOS_30
, (UINT8
)(Size
& 0xFF));
111 LegacyWriteStandardCmos (CMOS_18
, (UINT8
)(Size
>> 8));
112 LegacyWriteStandardCmos (CMOS_31
, (UINT8
)(Size
>> 8));
114 LegacyCalculateWriteStandardCmosChecksum ();