diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
old mode 100755
new mode 100644
index bdfaa4751..27abf3878
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -2008,10 +2008,10 @@ DEFINE GCC_X64_RC_FLAGS = -I binary -O elf64-x86-64 -B i386 --re
DEFINE GCC_ARM_RC_FLAGS = -I binary -O elf32-littlearm -B arm --rename-section .data=.hii
DEFINE GCC_AARCH64_RC_FLAGS = -I binary -O elf64-littleaarch64 -B aarch64 --rename-section .data=.hii
-DEFINE GCC48_ALL_CC_FLAGS = -g -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
+DEFINE GCC48_ALL_CC_FLAGS = -g -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -Wno-unused-const-variable -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
DEFINE GCC48_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x20
-DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables -Wno-address
-DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64 -fno-stack-protector -Wno-unused-but-set-variable "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address
+DEFINE GCC48_IA32_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables -Wno-address -Os -flto
+DEFINE GCC48_X64_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) -m64 -fno-stack-protector -Wno-unused-but-set-variable -mabi=ms "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address -Os -flto
DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
DEFINE GCC48_IA32_X64_DLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
DEFINE GCC48_IA32_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(GCC_DLINK2_FLAGS_COMMON)
diff --git a/PcAtChipsetPkg/8254TimerDxe/8254Timer.inf b/PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
index 67493d13f..40af7fccc 100644
--- a/PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
+++ b/PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
@@ -1,14 +1,8 @@
## @file
# 8254 timer driver that provides Timer Arch protocol.
#
-# Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
diff --git a/PcAtChipsetPkg/8254TimerDxe/Timer.c b/PcAtChipsetPkg/8254TimerDxe/Timer.c
index 2cd888a12..1cf948b6f 100644
--- a/PcAtChipsetPkg/8254TimerDxe/Timer.c
+++ b/PcAtChipsetPkg/8254TimerDxe/Timer.c
@@ -1,14 +1,8 @@
/** @file
Timer Architectural Protocol as defined in the DXE CIS
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/PcAtChipsetPkg/8254TimerDxe/Timer.h b/PcAtChipsetPkg/8254TimerDxe/Timer.h
index b2c8afb60..4c4b720d5 100644
--- a/PcAtChipsetPkg/8254TimerDxe/Timer.h
+++ b/PcAtChipsetPkg/8254TimerDxe/Timer.h
@@ -1,14 +1,8 @@
/** @file
Private data structures
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef _TIMER_H_
diff --git a/PcAtChipsetPkg/8254TimerDxe/Timer.uni b/PcAtChipsetPkg/8254TimerDxe/Timer.uni
index 15b690132..7f3d35f4e 100644
--- a/PcAtChipsetPkg/8254TimerDxe/Timer.uni
+++ b/PcAtChipsetPkg/8254TimerDxe/Timer.uni
@@ -3,15 +3,9 @@
//
// 8254 timer driver that provides Timer Arch protocol.
//
-// Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.
+// Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
diff --git a/PcAtChipsetPkg/8254TimerDxe/TimerExtra.uni b/PcAtChipsetPkg/8254TimerDxe/TimerExtra.uni
index 3f20889dd..14ea2bf73 100644
--- a/PcAtChipsetPkg/8254TimerDxe/TimerExtra.uni
+++ b/PcAtChipsetPkg/8254TimerDxe/TimerExtra.uni
@@ -1,15 +1,9 @@
// /** @file
// Timer Localized Strings and Content
//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c
index 7d8265dbd..d77e07276 100644
--- a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c
+++ b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.c
@@ -1,14 +1,8 @@
/** @file
This contains the installation function for the driver.
-Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h
index 0d4c1e822..a874e11fb 100644
--- a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h
+++ b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.h
@@ -2,13 +2,7 @@
Driver implementing the Tiano Legacy 8259 Protocol
Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
index 4187c5152..f961955c8 100644
--- a/PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
+++ b/PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
@@ -1,14 +1,8 @@
## @file
# 8259 Interrupt Controller driver that provides Legacy 8259 protocol.
#
-# Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -29,7 +23,7 @@
CloverPkg.dec
MdePkg/MdePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
- PcAtChipsetPkg/PcAtChipsetPkg.dec
+# PcAtChipsetPkg/PcAtChipsetPkg.dec
[LibraryClasses]
UefiBootServicesTableLib
diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/Legacy8259.uni b/PcAtChipsetPkg/8259InterruptControllerDxe/Legacy8259.uni
index a29daac10..d03529241 100644
--- a/PcAtChipsetPkg/8259InterruptControllerDxe/Legacy8259.uni
+++ b/PcAtChipsetPkg/8259InterruptControllerDxe/Legacy8259.uni
@@ -3,15 +3,9 @@
//
// 8259 Interrupt Controller driver that provides Legacy 8259 protocol.
//
-// Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.
+// Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
diff --git a/PcAtChipsetPkg/8259InterruptControllerDxe/Legacy8259Extra.uni b/PcAtChipsetPkg/8259InterruptControllerDxe/Legacy8259Extra.uni
index f3c6c7259..0097ed14d 100644
--- a/PcAtChipsetPkg/8259InterruptControllerDxe/Legacy8259Extra.uni
+++ b/PcAtChipsetPkg/8259InterruptControllerDxe/Legacy8259Extra.uni
@@ -1,15 +1,9 @@
// /** @file
// Legacy8259 Localized Strings and Content
//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
diff --git a/PcAtChipsetPkg/IsaAcpiDxe/ComponentName.c b/PcAtChipsetPkg/IsaAcpiDxe/ComponentName.c
index 0d634ea61..af75acbaa 100644
--- a/PcAtChipsetPkg/IsaAcpiDxe/ComponentName.c
+++ b/PcAtChipsetPkg/IsaAcpiDxe/ComponentName.c
@@ -1,14 +1,8 @@
/** @file
UEFI Component Name(2) protocol implementation for IsaAcpi driver.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "PcatIsaAcpi.h"
diff --git a/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.c b/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.c
index c1f5e90d0..05a72ee39 100644
--- a/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.c
+++ b/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.c
@@ -2,13 +2,7 @@
ISA ACPI Protocol Implementation
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "PcatIsaAcpi.h"
diff --git a/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf b/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf
index ef710b3cf..cf8493e2c 100644
--- a/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf
+++ b/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.inf
@@ -2,13 +2,7 @@
# IsaAcpi driver to install EFI_ISA_ACPI_PROTOCOL.
#
# Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
##
@@ -24,9 +18,10 @@
ENTRY_POINT = PcatIsaAcpiDriverEntryPoint
[Packages]
+ CloverPkg.dec
MdePkg/MdePkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
- PcAtChipsetPkg/PcAtChipsetPkg.dec
+# PcAtChipsetPkg/PcAtChipsetPkg.dec
[LibraryClasses]
UefiDriverEntryPoint
diff --git a/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.uni b/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.uni
index 45b021a0a..526a9791d 100644
--- a/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.uni
+++ b/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpi.uni
@@ -3,15 +3,9 @@
//
// PCAT ISA ACPI driver for a Generic PC Platform.
//
-// Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.
+// Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
diff --git a/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpiExtra.uni b/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpiExtra.uni
index ed1e07966..4727621d9 100644
--- a/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpiExtra.uni
+++ b/PcAtChipsetPkg/IsaAcpiDxe/IsaAcpiExtra.uni
@@ -1,15 +1,9 @@
// /** @file
// IsaAcpi Localized Strings and Content
//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
//
-// This program and the accompanying materials
-// are licensed and made available under the terms and conditions of the BSD License
-// which accompanies this distribution. The full text of the license may be found at
-// http://opensource.org/licenses/bsd-license.php
-//
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
index c7ea55900..84aa7e322 100644
--- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
+++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
@@ -1,14 +1,8 @@
/** @file
EFI PCAT ISA ACPI Driver for a Generic PC Platform
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h
index d48c5882d..be9af621e 100644
--- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h
+++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h
@@ -1,14 +1,8 @@
/** @file
EFI PCAT ISA ACPI Driver for a Generic PC Platform
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
index 8b68b0f19..d08ad0e22 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
@@ -66,8 +66,8 @@ RtcRead (
IN UINT8 Address
)
{
- IoWrite8 (PcdGet8 (PcdRtcIndexRegister), (UINT8) (Address | (UINT8) (IoRead8 (PcdGet8 (PcdRtcIndexRegister)) & 0x80)));
- return IoRead8 (PcdGet8 (PcdRtcTargetRegister));
+ IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, (UINT8) (Address | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));
+ return IoRead8 (PCAT_RTC_DATA_REGISTER);
}
/**
@@ -84,8 +84,8 @@ RtcWrite (
IN UINT8 Data
)
{
- IoWrite8 (PcdGet8 (PcdRtcIndexRegister), (UINT8) (Address | (UINT8) (IoRead8 (PcdGet8 (PcdRtcIndexRegister)) & 0x80)));
- IoWrite8 (PcdGet8 (PcdRtcTargetRegister), Data);
+ IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, (UINT8) (Address | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));
+ IoWrite8 (PCAT_RTC_DATA_REGISTER, Data);
}
/**
@@ -124,7 +124,7 @@ PcRtcInit (
// Make sure Division Chain is properly configured,
// or RTC clock won't "tick" -- time won't increment
//
- RegisterA.Data = FixedPcdGet8 (PcdInitialValueRtcRegisterA);
+ RegisterA.Data = RTC_INIT_REGISTER_A;
RtcWrite (RTC_ADDRESS_REGISTER_A, RegisterA.Data);
//
@@ -139,8 +139,16 @@ PcRtcInit (
//
// Clear RTC register D
+ //patch by nms42
+ // Modification of "read only" bit Vrt considered harmful.
+ // Peculiar RTC implementations have VRT bit writable.
+ // Writing 0 to Vrt bit produce a bunch of hardware
+ // events.
//
- RegisterD.Data = FixedPcdGet8 (PcdInitialValueRtcRegisterD);
+// RegisterD.Data = RTC_INIT_REGISTER_D;
+ RegisterD.Data = RtcRead(RTC_ADDRESS_REGISTER_D) | RTC_INIT_REGISTER_D;
+// RegisterD.Bits.Reserved = RTC_INIT_REGISTER_D;
+
RtcWrite (RTC_ADDRESS_REGISTER_D, RegisterD.Data);
//
@@ -172,7 +180,7 @@ PcRtcInit (
// Set RTC configuration after get original time
// The value of bit AIE should be reserved.
//
- RegisterB.Data = FixedPcdGet8 (PcdInitialValueRtcRegisterB) | (RegisterB.Data & BIT5);
+ RegisterB.Data = RTC_INIT_REGISTER_B | (RegisterB.Data & BIT5);
RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
//
@@ -210,13 +218,6 @@ PcRtcInit (
Status = RtcTimeFieldsValid (&Time);
}
if (EFI_ERROR (Status)) {
- //
- // Report Status Code to indicate that the RTC has bad date and time
- //
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- (EFI_SOFTWARE_DXE_RT_DRIVER | EFI_SW_EC_BAD_DATE_TIME)
- );
Time.Second = RTC_INIT_SECOND;
Time.Minute = RTC_INIT_MINUTE;
Time.Hour = RTC_INIT_HOUR;
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
index 038482d04..9e45625c2 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.h
@@ -41,6 +41,9 @@ typedef struct {
extern PC_RTC_MODULE_GLOBALS mModuleGlobal;
+#define PCAT_RTC_ADDRESS_REGISTER 0x70
+#define PCAT_RTC_DATA_REGISTER 0x71
+
//
// Dallas DS12C887 Real Time Clock
//
@@ -68,6 +71,17 @@ extern PC_RTC_MODULE_GLOBALS mModuleGlobal;
#define RTC_INIT_DAY 1
#define RTC_INIT_MONTH 1
+//
+// Register initial values
+//
+#define RTC_INIT_REGISTER_A 0x26
+#define RTC_INIT_REGISTER_B 0x02
+#ifdef AMD_SUPPORT
+#define RTC_INIT_REGISTER_D 0x80
+#else
+#define RTC_INIT_REGISTER_D 0x0
+#endif
+
#pragma pack(1)
//
// Register A
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
index dca3b8d9f..a53d1b1c2 100644
--- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
+++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtcEntry.c
@@ -133,6 +133,9 @@ InitializePcRtc (
Status = PcRtcInit (&mModuleGlobal);
ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
@@ -143,6 +146,9 @@ InitializePcRtc (
&Event
);
ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
@@ -153,6 +159,9 @@ InitializePcRtc (
&Event
);
ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
gRT->GetTime = PcRtcEfiGetTime;
gRT->SetTime = PcRtcEfiSetTime;