summaryrefslogtreecommitdiff
path: root/OvmfPkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/Library')
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.S19
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.asm21
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/Linux.c52
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h11
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.S67
-rw-r--r--OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.asm69
-rw-r--r--OvmfPkg/Library/PlatformBdsLib/QemuKernel.c7
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.S22
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.asm26
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c51
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.S19
-rw-r--r--OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.asm22
-rw-r--r--OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c8
-rw-r--r--OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf2
14 files changed, 370 insertions, 26 deletions
diff --git a/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.S b/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.S
index b8cd4ca5..f7440f74 100644
--- a/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.S
+++ b/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.S
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -13,6 +13,7 @@
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(JumpToKernel)
+ASM_GLOBAL ASM_PFX(JumpToUefiKernel)
#------------------------------------------------------------------------------
# VOID
@@ -27,3 +28,19 @@ ASM_PFX(JumpToKernel):
calll 0x4(%esp)
ret
+#------------------------------------------------------------------------------
+# VOID
+# EFIAPI
+# JumpToUefiKernel (
+# EFI_HANDLE ImageHandle,
+# EFI_SYSTEM_TABLE *SystemTable,
+# VOID *KernelBootParams,
+# VOID *KernelStart
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(JumpToUefiKernel):
+ movl 0xc(%esp), %eax
+ movl 0x264(%eax), %eax
+ addl 0x10(%esp), %eax
+ jmp %eax
+
diff --git a/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.asm b/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.asm
index a8f3965f..21d0c4e7 100644
--- a/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.asm
+++ b/OvmfPkg/Library/LoadLinuxLib/Ia32/JumpToKernel.asm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
;
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
@@ -32,4 +32,23 @@ JumpToKernel PROC
JumpToKernel ENDP
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; JumpToUefiKernel (
+; EFI_HANDLE ImageHandle,
+; EFI_SYSTEM_TABLE *SystemTable,
+; VOID *KernelBootParams,
+; VOID *KernelStart
+; );
+;------------------------------------------------------------------------------
+JumpToUefiKernel PROC
+
+ mov eax, [esp + 12]
+ mov eax, [eax + 264h]
+ add eax, [esp + 16]
+ jmp eax
+
+JumpToUefiKernel ENDP
+
END
diff --git a/OvmfPkg/Library/LoadLinuxLib/Linux.c b/OvmfPkg/Library/LoadLinuxLib/Linux.c
index 96c985bc..c714225e 100644
--- a/OvmfPkg/Library/LoadLinuxLib/Linux.c
+++ b/OvmfPkg/Library/LoadLinuxLib/Linux.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -60,7 +60,8 @@ LoadLinuxCheckKernelSetup (
if ((Bp->hdr.signature != 0xAA55) || // Check boot sector signature
(Bp->hdr.header != SETUP_HDR) ||
- (Bp->hdr.version < 0x205) // We only support relocatable kernels
+ (Bp->hdr.version < 0x205) || // We only support relocatable kernels
+ (!Bp->hdr.relocatable_kernel)
) {
return EFI_UNSUPPORTED;
} else {
@@ -118,6 +119,34 @@ LoadLinuxAllocateKernelSetupPages (
}
}
+EFI_STATUS
+EFIAPI
+LoadLinuxInitializeKernelSetup (
+ IN VOID *KernelSetup
+ )
+{
+ EFI_STATUS Status;
+ UINTN SetupEnd;
+ struct boot_params *Bp;
+
+ Status = BasicKernelSetupCheck (KernelSetup);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Bp = (struct boot_params*) KernelSetup;
+
+ SetupEnd = 0x202 + (Bp->hdr.jump & 0xff);
+
+ //
+ // Clear all but the setup_header
+ //
+ ZeroMem (KernelSetup, 0x1f1);
+ ZeroMem (((UINT8 *)KernelSetup) + SetupEnd, 4096 - SetupEnd);
+ DEBUG ((EFI_D_INFO, "Cleared kernel setup 0-0x1f1, 0x%x-0x1000\n", SetupEnd));
+
+ return EFI_SUCCESS;
+}
VOID*
EFIAPI
@@ -575,14 +604,11 @@ SetupGraphics (
STATIC
EFI_STATUS
SetupLinuxBootParams (
- IN VOID *Kernel,
IN OUT struct boot_params *Bp
)
{
SetupGraphics (Bp);
- Bp->hdr.code32_start = (UINT32)(UINTN) Kernel;
-
SetupLinuxMemmap (Bp);
return EFI_SUCCESS;
@@ -606,7 +632,7 @@ LoadLinux (
Bp = (struct boot_params *) KernelSetup;
- if (Bp->hdr.version < 0x205) {
+ if (Bp->hdr.version < 0x205 || !Bp->hdr.relocatable_kernel) {
//
// We only support relocatable kernels
//
@@ -615,7 +641,19 @@ LoadLinux (
InitLinuxDescriptorTables ();
- SetupLinuxBootParams (Kernel, (struct boot_params*) KernelSetup);
+ Bp->hdr.code32_start = (UINT32)(UINTN) Kernel;
+ if (Bp->hdr.version >= 0x20c && Bp->hdr.handover_offset &&
+ (Bp->hdr.load_flags & (sizeof (UINTN) == 4 ? BIT2 : BIT3))) {
+ DEBUG ((EFI_D_INFO, "Jumping to kernel EFI handover point at ofs %x\n", Bp->hdr.handover_offset));
+
+ DisableInterrupts ();
+ JumpToUefiKernel ((VOID*) gImageHandle, (VOID*) gST, KernelSetup, Kernel);
+ }
+
+ //
+ // Old kernels without EFI handover protocol
+ //
+ SetupLinuxBootParams (KernelSetup);
DEBUG ((EFI_D_INFO, "Jumping to kernel\n"));
DisableInterrupts ();
diff --git a/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h b/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h
index f8697972..045cbf9b 100644
--- a/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h
+++ b/OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.h
@@ -1,7 +1,7 @@
/** @file
Boot UEFI Linux.
- Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -37,6 +37,15 @@ JumpToKernel (
);
VOID
+EFIAPI
+JumpToUefiKernel (
+ EFI_HANDLE ImageHandle,
+ EFI_SYSTEM_TABLE *SystemTable,
+ VOID *KernelBootParams,
+ VOID *KernelStart
+ );
+
+VOID
InitLinuxDescriptorTables (
VOID
);
diff --git a/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.S b/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.S
index 9ae755b0..056e3c01 100644
--- a/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.S
+++ b/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.S
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -13,6 +13,7 @@
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(JumpToKernel)
+ASM_GLOBAL ASM_PFX(JumpToUefiKernel)
#------------------------------------------------------------------------------
# VOID
@@ -23,8 +24,68 @@ ASM_GLOBAL ASM_PFX(JumpToKernel)
# );
#------------------------------------------------------------------------------
ASM_PFX(JumpToKernel):
+
+ // Set up for executing kernel. BP in %esi, entry point on the stack
+ // (64-bit when the 'ret' will use it as 32-bit, but we're little-endian)
+ movq %rdx, %rsi
+ pushq %rcx
+
+ // Jump into the compatibility mode CS
+ pushq $0x10
+ leaq 1f(%rip), %rax
+ pushq %rax
+ .byte 0x48, 0xcb // retfq
+
+1: // Now in compatibility mode
+.code32
+ movl $0x18, %eax
+ movl %eax, %ds
+ movl %eax, %es
+ movl %eax, %fs
+ movl %eax, %gs
+ movl %eax, %ss
+
+ // Disable paging
+ movl %cr0, %eax
+ btcl $31, %eax
+ movl %eax, %cr0
+
+ // Disable long mode in EFER
+ movl $0x0c0000080, %ecx
+ rdmsr
+ btcl $8, %eax
+ wrmsr
+
+ // Disable PAE
+ movl %cr4, %eax
+ btcl $5, %eax
+ movl %eax, %cr4
+
+ // Zero registers and 'return' to kernel
+ xorl %ebp, %ebp
+ xorl %edi, %edi
+ xorl %ebx, %ebx
+ ret
+.code64
+
+#------------------------------------------------------------------------------
+# VOID
+# EFIAPI
+# JumpToUefiKernel (
+# EFI_HANDLE ImageHandle, // rcx
+# EFI_SYSTEM_TABLE *SystemTable, // rdx
+# VOID *KernelBootParams, // r8
+# VOID *KernelStart // r9
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(JumpToUefiKernel):
+ movq %rcx, %rdi
movq %rdx, %rsi
- addq $0x200, %rcx
- callq %rcx
+ movq %r8, %rdx
+ xor %rax, %rax
+ movl 0x264(%r8), %eax
+ addq %rax, %r9
+ addq $0x200, %r9
+ callq %r9
ret
diff --git a/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.asm b/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.asm
index ed53321c..fc07eab6 100644
--- a/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.asm
+++ b/OvmfPkg/Library/LoadLinuxLib/X64/JumpToKernel.asm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
;
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
@@ -24,11 +24,72 @@
;------------------------------------------------------------------------------
JumpToKernel PROC
+ ; Set up for executing kernel. BP in %esi, entry point on the stack
+ ; (64-bit when the 'ret' will use it as 32-bit, but we're little-endian)
+ mov rsi, rdx
+ push rcx
+
+ ; Jump into the compatibility mode CS
+ push 10h
+ lea rax, @F
+ push rax
+ DB 048h, 0cbh ; retfq
+
+@@:
+ ; Now in compatibility mode.
+
+ DB 0b8h, 018h, 000h, 000h, 000h ; movl $0x18, %eax
+ DB 08eh, 0d8h ; movl %eax, %ds
+ DB 08eh, 0c0h ; movl %eax, %es
+ DB 08eh, 0e0h ; movl %eax, %fs
+ DB 08eh, 0e8h ; movl %eax, %gs
+ DB 08eh, 0d0h ; movl %eax, %ss
+
+ ; Disable paging
+ DB 00fh, 020h, 0c0h ; movl %cr0, %eax
+ DB 00fh, 0bah, 0f8h, 01fh ; btcl $31, %eax
+ DB 00fh, 022h, 0c0h ; movl %eax, %cr0
+
+ ; Disable long mode in EFER
+ DB 0b9h, 080h, 000h, 000h, 0c0h ; movl $0x0c0000080, %ecx
+ DB 00fh, 032h ; rdmsr
+ DB 00fh, 0bah, 0f8h, 008h ; btcl $8, %eax
+ DB 00fh, 030h ; wrmsr
+
+ ; Disable PAE
+ DB 00fh, 020h, 0e0h ; movl %cr4, %eax
+ DB 00fh, 0bah, 0f8h, 005h ; btcl $5, %eax
+ DB 00fh, 022h, 0e0h ; movl %eax, %cr4
+
+ DB 031h, 0edh ; xor %ebp, %ebp
+ DB 031h, 0ffh ; xor %edi, %edi
+ DB 031h, 0dbh ; xor %ebx, %ebx
+ DB 0c3h ; ret
+
+JumpToKernel ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; JumpToUefiKernel (
+; EFI_HANDLE ImageHandle, // rcx
+; EFI_SYSTEM_TABLE *SystemTable, // rdx
+; VOID *KernelBootParams // r8
+; VOID *KernelStart, // r9
+; );
+;------------------------------------------------------------------------------
+JumpToUefiKernel PROC
+
+ mov rdi, rcx
mov rsi, rdx
- add rcx, 200h
- call rcx
+ mov rdx, r8
+ xor rax, rax
+ mov eax, [r8 + 264h]
+ add r9, rax
+ add r9, 200h
+ call r9
ret
-JumpToKernel ENDP
+JumpToUefiKernel ENDP
END
diff --git a/OvmfPkg/Library/PlatformBdsLib/QemuKernel.c b/OvmfPkg/Library/PlatformBdsLib/QemuKernel.c
index fa8bcbc9..47ebed9f 100644
--- a/OvmfPkg/Library/PlatformBdsLib/QemuKernel.c
+++ b/OvmfPkg/Library/PlatformBdsLib/QemuKernel.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
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
@@ -78,6 +78,11 @@ TryRunningQemuKernel (
goto FreeAndReturn;
}
+ Status = LoadLinuxInitializeKernelSetup (SetupBuf);
+ if (EFI_ERROR (Status)) {
+ goto FreeAndReturn;
+ }
+
KernelInitialSize = LoadLinuxGetKernelSize (SetupBuf, KernelSize);
if (KernelInitialSize == 0) {
Status = EFI_UNSUPPORTED;
diff --git a/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.S b/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.S
index a32b2c60..c2735d2c 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.S
+++ b/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.S
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
# 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
@@ -30,3 +30,23 @@ rep insb
popl %edi
ret
+
+#------------------------------------------------------------------------------
+# VOID
+# EFIAPI
+# IoWriteFifo8 (
+# IN UINTN Port,
+# IN UINTN Size,
+# IN VOID *Buffer
+# );
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(IoWriteFifo8)
+ASM_PFX(IoWriteFifo8):
+ movw 4(%esp), %dx
+ movl 8(%esp), %ecx
+ pushl %esi
+ movl 16(%esp), %esi
+rep outsb
+ popl %esi
+ ret
+
diff --git a/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.asm b/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.asm
index e46af81e..f7d65c49 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.asm
+++ b/OvmfPkg/Library/QemuFwCfgLib/Ia32/IoLibExAsm.asm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
; 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
@@ -29,12 +29,34 @@ IoReadFifo8 PROC
mov dx, [esp + 4]
mov ecx, [esp + 8]
push edi
- mov edx, [esp + 16]
+ mov edi, [esp + 16]
rep insb
pop edi
ret
IoReadFifo8 ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; IoWriteFifo8 (
+; IN UINTN Port,
+; IN UINTN Size,
+; IN VOID *Buffer
+; );
+;------------------------------------------------------------------------------
+IoWriteFifo8 PROC
+
+ mov dx, [esp + 4]
+ mov ecx, [esp + 8]
+ push esi
+ mov esi, [esp + 16]
+rep outsb
+ pop esi
+ ret
+
+IoWriteFifo8 ENDP
+
END
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
index 8caab42e..7e5ea00b 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -50,6 +50,32 @@ IoReadFifo8 (
OUT VOID *Buffer
);
+/**
+ Writes an 8-bit I/O port fifo from a block of memory.
+
+ Writes the 8-bit I/O fifo port specified by Port.
+
+ The port is written Count times, and the data are obtained
+ from the provided Buffer.
+
+ This function must guarantee that all I/O read and write operations are
+ serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to read.
+ @param Count The number of times to read I/O port.
+ @param Buffer The buffer to store the read data into.
+
+**/
+VOID
+EFIAPI
+IoWriteFifo8 (
+ IN UINTN Port,
+ IN UINTN Count,
+ OUT VOID *Buffer
+ );
+
/**
Returns a boolean indicating if the firmware configuration interface
@@ -132,6 +158,29 @@ QemuFwCfgReadBytes (
}
}
+/**
+ Write firmware configuration bytes from a buffer
+
+ If called multiple times, then the data written will
+ continue at the offset of the firmware configuration
+ item where the previous write ended.
+
+ @param[in] Size - Size in bytes to write
+ @param[in] Buffer - Buffer to read data from
+
+**/
+VOID
+EFIAPI
+QemuFwCfgWriteBytes (
+ IN UINTN Size,
+ IN VOID *Buffer
+ )
+{
+ if (mQemuFwCfgSupported) {
+ IoWriteFifo8 (0x511, Size, Buffer);
+ }
+}
+
/**
Reads a UINT8 firmware configuration value
diff --git a/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.S b/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.S
index b1125ed7..69167b70 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.S
+++ b/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.S
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#
-# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
# 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
@@ -28,3 +28,20 @@ rep insb
mov %r8, %rdi # restore rdi
ret
+#------------------------------------------------------------------------------
+# VOID
+# EFIAPI
+# IoWriteFifo8 (
+# IN UINTN Port, // rcx
+# IN UINTN Size, // rdx
+# IN VOID *Buffer // r8
+# );
+#------------------------------------------------------------------------------
+ASM_GLOBAL ASM_PFX(IoWriteFifo8)
+ASM_PFX(IoWriteFifo8):
+ xchg %rcx, %rdx
+ xchg %r8, %rsi # rdi: buffer address; r8: save rsi
+rep outsb
+ mov %r8, %rsi # restore rsi
+ ret
+
diff --git a/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.asm b/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.asm
index c60ad2c5..47ac158f 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.asm
+++ b/OvmfPkg/Library/QemuFwCfgLib/X64/IoLibExAsm.asm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
; 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
@@ -32,5 +32,25 @@ rep insb
IoReadFifo8 ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; IoWriteFifo8 (
+; IN UINTN Port, // rcx
+; IN UINTN Size, // rdx
+; IN VOID *Buffer // r8
+; );
+;------------------------------------------------------------------------------
+IoWriteFifo8 PROC
+
+ xchg rcx, rdx
+ xchg rsi, r8 ; rdi: buffer address; r8: save rdi
+rep outsb
+ mov rsi, r8 ; restore rdi
+ ret
+
+IoWriteFifo8 ENDP
+
END
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
index 52406add..d075fbef 100644
--- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -17,6 +17,7 @@
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
+#include <Library/TimerLib.h>
VOID
AcpiPmControl (
@@ -45,7 +46,11 @@ ResetCold (
VOID
)
{
- IoWrite8 (0x64, 0xfe);
+ IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST
+ MicroSecondDelay (50);
+
+ IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller
+ CpuDeadLoop ();
}
/**
@@ -62,6 +67,7 @@ ResetWarm (
)
{
IoWrite8 (0x64, 0xfe);
+ CpuDeadLoop ();
}
/**
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
index 0694b4dd..c4d8ce54 100644
--- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
+++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
@@ -35,4 +35,4 @@
[LibraryClasses]
DebugLib
IoLib
-
+ TimerLib