]>
git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyCmos.c
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 This program and the accompanying materials
9 are licensed and made available under the terms and conditions
10 of the BSD License which accompanies this distribution. The
11 full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include "LegacyBiosInterface.h"
22 Read CMOS register through index/data port.
24 @param[in] Index The index of the CMOS register to read.
26 @return The data value from the CMOS register specified by Index.
30 LegacyReadStandardCmos (
34 IoWrite8 (PORT_70
, Index
);
35 return IoRead8 (PORT_71
);
39 Write CMOS register through index/data port.
41 @param[in] Index The index of the CMOS register to write.
42 @param[in] Value The value of CMOS register to write.
44 @return The value written to the CMOS register specified by Index.
48 LegacyWriteStandardCmos (
53 IoWrite8 (PORT_70
, Index
);
54 return IoWrite8 (PORT_71
, Value
);
58 Calculate the new standard CMOS checksum and write it.
60 @param Private Legacy BIOS Instance data
62 @retval EFI_SUCCESS Calculate 16-bit checksum successfully
66 LegacyCalculateWriteStandardCmosChecksum (
73 for (Checksum
= 0, Register
= 0x10; Register
< 0x2e; Register
++) {
74 Checksum
= (UINT16
)(Checksum
+ LegacyReadStandardCmos (Register
));
76 LegacyWriteStandardCmos (CMOS_2E
, (UINT8
)(Checksum
>> 8));
77 LegacyWriteStandardCmos (CMOS_2F
, (UINT8
)(Checksum
& 0xff));
83 Fill in the standard CMOS stuff before Legacy16 load
85 @param Private Legacy BIOS Instance data
87 @retval EFI_SUCCESS It should always work.
92 IN LEGACY_BIOS_INSTANCE
*Private
98 // Clear all errors except RTC lost power
100 LegacyWriteStandardCmos (CMOS_0E
, (UINT8
)(LegacyReadStandardCmos (CMOS_0E
) & BIT7
));
103 // Update CMOS locations 15,16,17,18,30,31 and 32
104 // CMOS 16,15 = 640Kb = 0x280
105 // CMOS 18,17 = 31,30 = 15Mb max in 1Kb increments =0x3C00 max
108 LegacyWriteStandardCmos (CMOS_15
, 0x80);
109 LegacyWriteStandardCmos (CMOS_16
, 0x02);
111 Size
= 15 * SIZE_1MB
;
112 if (Private
->IntThunk
->EfiToLegacy16InitTable
.OsMemoryAbove1Mb
< (15 * SIZE_1MB
)) {
113 Size
= Private
->IntThunk
->EfiToLegacy16InitTable
.OsMemoryAbove1Mb
>> 10;
116 LegacyWriteStandardCmos (CMOS_17
, (UINT8
)(Size
& 0xFF));
117 LegacyWriteStandardCmos (CMOS_30
, (UINT8
)(Size
& 0xFF));
118 LegacyWriteStandardCmos (CMOS_18
, (UINT8
)(Size
>> 8));
119 LegacyWriteStandardCmos (CMOS_31
, (UINT8
)(Size
>> 8));
121 LegacyCalculateWriteStandardCmosChecksum ();