+++ /dev/null
-/** @file\r
- This code fills in standard CMOS values and updates the standard CMOS\r
- checksum. The Legacy16 code or LegacyBiosPlatform.c is responsible for\r
- non-standard CMOS locations and non-standard checksums.\r
-\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
-\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "LegacyBiosInterface.h"\r
-\r
-/**\r
- Read CMOS register through index/data port.\r
-\r
- @param[in] Index The index of the CMOS register to read.\r
-\r
- @return The data value from the CMOS register specified by Index.\r
-\r
-**/\r
-UINT8\r
-LegacyReadStandardCmos (\r
- IN UINT8 Index\r
- )\r
-{\r
- IoWrite8 (PORT_70, Index);\r
- return IoRead8 (PORT_71);\r
-}\r
-\r
-/**\r
- Write CMOS register through index/data port.\r
-\r
- @param[in] Index The index of the CMOS register to write.\r
- @param[in] Value The value of CMOS register to write.\r
-\r
- @return The value written to the CMOS register specified by Index.\r
-\r
-**/\r
-UINT8\r
-LegacyWriteStandardCmos (\r
- IN UINT8 Index,\r
- IN UINT8 Value\r
- )\r
-{\r
- IoWrite8 (PORT_70, Index);\r
- return IoWrite8 (PORT_71, Value);\r
-}\r
-\r
-/**\r
- Calculate the new standard CMOS checksum and write it.\r
-\r
- @param Private Legacy BIOS Instance data\r
-\r
- @retval EFI_SUCCESS Calculate 16-bit checksum successfully\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyCalculateWriteStandardCmosChecksum (\r
- VOID\r
- )\r
-{\r
- UINT8 Register;\r
- UINT16 Checksum;\r
-\r
- for (Checksum = 0, Register = 0x10; Register < 0x2e; Register++) {\r
- Checksum = (UINT16)(Checksum + LegacyReadStandardCmos (Register));\r
- }\r
- LegacyWriteStandardCmos (CMOS_2E, (UINT8)(Checksum >> 8));\r
- LegacyWriteStandardCmos (CMOS_2F, (UINT8)(Checksum & 0xff));\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Fill in the standard CMOS stuff before Legacy16 load\r
-\r
- @param Private Legacy BIOS Instance data\r
-\r
- @retval EFI_SUCCESS It should always work.\r
-\r
-**/\r
-EFI_STATUS\r
-LegacyBiosInitCmos (\r
- IN LEGACY_BIOS_INSTANCE *Private\r
- )\r
-{\r
- UINT32 Size;\r
-\r
- //\r
- // Clear all errors except RTC lost power\r
- //\r
- LegacyWriteStandardCmos (CMOS_0E, (UINT8)(LegacyReadStandardCmos (CMOS_0E) & BIT7));\r
-\r
- //\r
- // Update CMOS locations 15,16,17,18,30,31 and 32\r
- // CMOS 16,15 = 640Kb = 0x280\r
- // CMOS 18,17 = 31,30 = 15Mb max in 1Kb increments =0x3C00 max\r
- // CMOS 32 = 0x20\r
- //\r
- LegacyWriteStandardCmos (CMOS_15, 0x80);\r
- LegacyWriteStandardCmos (CMOS_16, 0x02);\r
-\r
- Size = 15 * SIZE_1MB;\r
- if (Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb < (15 * SIZE_1MB)) {\r
- Size = Private->IntThunk->EfiToLegacy16InitTable.OsMemoryAbove1Mb >> 10;\r
- }\r
-\r
- LegacyWriteStandardCmos (CMOS_17, (UINT8)(Size & 0xFF));\r
- LegacyWriteStandardCmos (CMOS_30, (UINT8)(Size & 0xFF));\r
- LegacyWriteStandardCmos (CMOS_18, (UINT8)(Size >> 8));\r
- LegacyWriteStandardCmos (CMOS_31, (UINT8)(Size >> 8));\r
-\r
- LegacyCalculateWriteStandardCmosChecksum ();\r
-\r
- return EFI_SUCCESS;\r
-}\r